Paiagram

Created: September 11, 2025
Last updated: September 22, 2025
Author: Jeremy Gao

How to make timetables (for trains).

This article is a work in progress.

Years ago I watched a video about how Chinese railways are scheduled and organized. The video talked about a tool named "运行图". I don't have an official English translation for it (and I also couldn't find related materials of North American railway companies), so I'll just call it a "timetable diagram" afterwards. Anyways, as an elementary kid who have some weird obsession with transportation [1], the organization displayed in the video absolutely fascinated me.

The storytelling part is done, let's talk about something else.

1. Timetable Diagrams

A timetable diagram is a diagram that describes the position and time of trains on a one-dimensional railway. First invented in Paris in the 19th century, it has been the primary tool for railway schedule planning.

It looks like this:[2]

Figure 1: Beijing-Harbin railway timetable diagram

Each line represents a train. The actual position of the train is usually not exactly the same as the position shown in the diagram, since trains' speeds varies over the journey. The lines are approximations of the actual positions. Despite that, they still remain a powerful tool to prevent collisions, and optimize track usage.

2. A Rust Plugin

I was messing with Typst since last year. It's a handy tool, specifically for typesetting. However, it has the potential to do more than just typesetting. It has these powerful functions:

  • place()
  • curve()
  • box()

And these values:

  • Values of the alignment type, including top, bottom, left, horizon, etc.

These functions and values could build up an elementary drawing library, and that is exactly what I did. I made Paiagram.


  1. This includes automobiles. Don't ask me why. If you think I hate trains you're wrong.

  2. Sorry if it does not work on dark mode – I've tried my best to make it look good on both light and dark modes, but it seems just to be impossible.