The aforementioned Igros Moshe writes: The reality is, that if it is not being done derech teivah vechibah it’s permissible to both stand and sit next to a woman on a train or a bus. Therefore, if there are no other seats available, there is no issur for a man to sit next to a woman.
However, the Shu”t Veya’an Yosef (Yoreh Deah 144, ois 2) discusses, what happens if one is traveling by train and he ends up sitting next to a woman, and there is a small gap in-between the man and woman and there is no concern they will come to touch each other, even via clothing (see Shabbos 13a). Amongst his word he writes: According to chasidus there is an obligation for one to stand up immediately.
In his opinion: If one didn’t jump up, as he was worried about making a chillul Hashem, and one is upset about the situation, then he hasn’t acted against what chasidus requires, וכל לבבות דורש ה' – all hearts should seek out Hashem.
Some Stories
The famous posek, Rav Shlomah Zalman Auerbach, once had a woman sit next to him on the bus he regularly took to Bayit Vagan. He frequently sat right behind the bus driver and people avoided sitting in the second seat out of respect for the great Rabbi. In this instance, the bus driver, noticing the situation, stopped the bus and wanted to request from the woman to sit elsewhere, however Rav Shlomah Zalman caught him before the act and told him to continue driving. A few stops later Rav Shlomah Zalman went off the bus prior to reaching his destination. Upon being question by his students who took interest in this occurrence he explained that on the one hand he did not feel comfortable sitting next to the woman, even though it is permitted from the letter of the law, and on the other hand he did not want to embarrass the woman and possibly cause her to dislike Frum people. He thus decided to get off the bus a few stops later in an inconspicuous manner that will not embarrass her (cited in the sefer HaTorah HaMasameches pg. 289, and Ohel Yaakov).
The sefer Ve’aleihu Loi Yibol (2, pg. 182) brings another story, he writes: A cousin of mine who lives in Shaarei Chesed told me, that he was once sitting next to a rov on a bus, and a woman got on the bus and there was nowhere for her to sit. The rov told my cousin, that either he gives up his seat for the women, or the rov himself will. My cousin relates that he stood up, and the women sat next to the rov, and he remained seated.
In this same footnote he mentions that R’ Shlomah Zalman said it’s important to print in a sefer and publicize that strictly speaking a man is able to sit next to a woman. Sometimes men and women that get on the bus are not so well, and because they think it’s forbidden to sit next to the opposite gender they end up standing and act in a way which is bad for their health, therefore, it’s important for such people to know that strictly speaking they may sit down next to opposite gender.