In a busy railway marshalling station, train and engine traffic management in the receiving/departure yard plays a crucial role in efficient and stable operations. Traditionally, a track assignment problem (TAP) is solved to assign tracks to trains for berthing at a receiving/departure yard. However, the TAP does not encompass shunting operations in the yard (e.g., engine replacement and train disassembly), which can result in additional scheduling challenges for dispatchers and route conflicts between operations. This paper investigates a train and engine routing and scheduling problem (TERSP) in a receiving/departure yard of railway marshalling stations, which involves simultaneously assigning routes and scheduling route-setting start times for both train and shunting operations to be conducted in the yard. By introducing the concepts of task, activity, and pattern, we transform the original problem into assigning pre-generated patterns incorporating both route and route-setting start time alternatives to activities. The transformed problem is formulated into a compact binary integer linear programming model with a linear number of constraints and the objective of minimizing the total time deviation of all involved tasks. An improved technique that relies on listing all maximal (bi)cliques in a constructed graph is designed to effectively model the time coherence and track section occupation constraints. A heuristic that gradually expands the patterns for the identified key activities by adding more start time alternatives is applied to remedy an infeasible model caused by potential route conflicts. In addition, a rolling horizon algorithm that decomposes the original problem into consecutive smaller stages using either a time-rolling or a train-rolling rule is developed to efficiently solve instances. Finally, numerical experiments based on the physical layouts and real timetables of a receiving yard and a departure yard of a large marshalling station in China are conducted to assess the performance and applicability of our proposed approaches. The results demonstrate that our approaches typically find (near-)optimal solutions within several minutes for the investigated instances by simultaneously addressing different classes of yard operations and resources.