a lot of arguments can be avoided if after knowing the problem (gender change) steps are taken to change the same in PRS counter/Chief REsrvation Supervisor or by speaking to IRCTC in case of E tickets. they can do the needful.
its a mistake and rectification steps are absolutely necessary. by rule impersonation is an offence (any matter -genunine/non-genuine) and this position is similar to impersonation. tte allowing the passenger to travel was good for the passenger, as well as the passenger's convincing power to make the TTE understand the genuinity.
whenever...
more... we leave the counter, we should check the details in it so that it can be rectified then and there. In case of E ticket also, if tkts are available, you can cancel and rebook the same or else could have explained the problem to irctc who could have guided you.
arguing with tte is the last thing to be done. he would be right in his actions if he had offloaded the passenger.