The position of the person does not change relative to the other person in the compartment thus, the man is at rest relative to the other passenger. However, when the train is moving, the position of the person is changing relative to the platform. So, the man is in motion relative to the platform.
Therefore, a person sitting in a compartment of a moving train is at rest relative to the other person sitting by his side and is in motion relative to the platform.