@researchfairy @amberage out loud i’d say “last free compartment [ən] the train” which could be either (both?) “in” or “on”
in print i’d probably lean “in” but neither looks ungrammatical to me. depends whether you prefer emphasizing riding “on” or being “in” i guess