24

I know that Deutsche Bahn (German railway) is using (La)TeX to typeset their timetables. Are there any (freely available) packages that help in typesetting timetables? I'd be mostly interested in connection timetables, i.e. something like:

  • take train 123 at 5:45 from SomeStation platform 1 in direction of SomeFarAwayStation

  • [105 min]

  • arrive at ChangeStation platform 3 at 7:30

  • walk for 150 m to the bus stop SomeBusStop [3 min]
  • take bus 987 at 7:38 in direction of SomeFarAwayBusStop
  • ....

All of this of course should be prettily formatted, perhaps even with some icons (for "bus/train/...").

One layout that I like is the one of VGN: timetable

enter image description here

  • I've done a translator from IVU to individual stop timetables some years ago.... all in LuaLaTeX with loads of Lua to parse and output TeX. Some EMBEDDED examples of what you want to achieve are welcome. – Astrinus Apr 9 '18 at 7:49
  • @Astrinus: I added an example of what it should look like, more or less. – user1583209 Apr 9 '18 at 7:57
  • Is the data in a specific form? Here Lua seems to fit a lot – Astrinus Apr 9 '18 at 8:23
  • 1
    @StevenB.Segletes Yes, I'd provide all the data myself, manually. My only concern would be layout. – user1583209 Apr 9 '18 at 10:01
  • 1
    I have continued to improve my posted answer, in case you were interested. – Steven B. Segletes Apr 9 '18 at 15:50
43

Here's a stab. I've edited to create the environment timetable, which sets up the TABstack, and lets you fill in the details. I've added a variety of helper macros for regular things, like

  1. \firststation, \nextstation, and \laststation for the symbols in the first column;

  2. \terminus{} and \waypoint{} for the names of the endpoint and waypoint stations;

  3. \routedetails[<direction modifier>]{<mode>}{<number>}{<direction>} for the route data;

  4. \onbus, \onmetro, and \ontrain to provide icons for the various transportation modes; and

  5. \depart{}, \arrive{}, and \duration{} for the timing.

EDITED to use appropriate clipart

https://www.iconsdb.com/red-icons/bus-icon.html

http://www.clker.com/clipart-subway-blue.html

http://www.softicons.com/web-icons/awt-travel-blue-icons-by-awt-media/train-icon

(Make sure you use the latest version of tabstackengine 2018/03/05 (V2.10))

The following MWE compiles as is, but if you download the cited icons, you can also uncomment the redefinitions to get those icons, as I show in the actual image.

\documentclass{article}
\usepackage[TABcline]{tabstackengine}
\usepackage{xcolor,graphicx,amssymb,environ}
\newcommand\onbus{\includegraphics[width=2ex,height=2ex]{example-image-a}}% BUS
\newcommand\onmetro{\includegraphics[width=2ex,height=2ex]{example-image-b}}% METRO
\newcommand\ontrain{\includegraphics[width=2ex,height=2ex]{example-image-c}}% TRAIN
% UNCOMMENT THE REDEFINITIONS BELOW IF YOU DOWNLOADED THE ICONS
%% https://www.iconsdb.com/red-icons/bus-icon.html
%\renewcommand\onbus{\includegraphics[width=2ex,height=2ex]{bus-xxl}}
%% http://www.clker.com/clipart-subway-blue.html
%\renewcommand\onmetro{\includegraphics[width=2ex,height=2ex]{subway-blue-md}}
%% http://www.softicons.com/web-icons/awt-travel-blue-icons-by-awt-media/train-icon
%\renewcommand\ontrain{\includegraphics[width=2ex,height=2ex]{AWT-Train}}
%%%%
% THE pt DISTANCES ON NEXT LINE MAY NEED TO VARY WITH FONT AND FONTSIZE
\newcommand\Stellemark[2]{\smash{\stackon[5.5pt]{\stackunder[-.5pt]{$\square$}{%
  \textcolor{blue!70!black}{\rule[-#2]{2\fboxrule}{#2}}}}{%
  \textcolor{blue!70!black}{\rule{2\fboxrule}{#1}}}}\kern-5pt}
\newcommand\terminus[1]{\smash{\textcolor{green!50!black}{\textbf{#1}}}}
% THE \raisebox VALUE ON THE NEXT TWO LINES MAY NEED TO VARY WITH FONT AND FONTSIZE
\newcommand\waypoint[1]{\smash{\raisebox{-4pt}{\terminus{#1}}}\rlap{\hspace{1em}\TABrule}}
\newcommand\nextstation{\smash{\raisebox{-4.4pt}{\Stellemark{14pt}{14pt}}}}
\newcommand\firststation{\Stellemark{0pt}{14pt}}
\newcommand\laststation{\Stellemark{14pt}{0pt}}
\newcommand\duration[1]{\stackunder{}{#1 min.}}
\newcommand\routedetails[4][Richtung:\ ]{#2\ \stackunder{\textbf{#3}}{#1#4}}
\newcommand\depart[1]{ab #1}
\newcommand\arrive[1]{an #1}
\let\svTABrule\TABrule
\NewEnviron{timetable}[1]{%
  \noindent%
  \footnotesize%
  \sffamily%
  \setstackgap{S}{1pt}%
  \renewcommand\stacktype{L}%
  \setstacktabulargap{1em}%
  \def\TABruleshift{-2pt}%
  \fboxrule=1pt\relax%
  \renewcommand\TABrule{\textcolor{green!50!black}{\svTABrule}}%
  \def\tmp{\tabularShortstack{#1}}%
  \expandafter\tmp\expandafter{\BODY}%
}
\begin{document}
\begin{timetable}{cclcclr}
 && \textbf{Haltestelle} & \textbf{Uhrzeit} & \textbf{Gleis} & 
 \textbf{Verkehrsmittel} & \textbf{Dauer}\\
%
 \TABcline{1-7}
%
 \firststation && \terminus{N\"urnberg Flughafen}& \depart{10:22}&& 
 \routedetails{\onmetro}{U2}{R\"othenbach}& \duration{7}\\
%
 &&&\arrive{10:29}&&&\\
%
 \nextstation&\TABrule&\waypoint{N\"urnberg Mooshof}&
 \TABrule&\TABrule&\TABrule&\TABrule\\ 
%
 &&&\depart{10:35} &7& \routedetails{\ontrain}{65}{R\"othenbach} & \duration{6}\\
%
 &&&\arrive{10:41}&12&&\\
%
 \nextstation&\TABrule&\waypoint{N\"urnberg Schoppershof}&
 \TABrule&\TABrule&\TABrule&\TABrule\\ 
%
 &&&\depart{10:45}&&\routedetails[Nur: ]{\onbus}{73}{Dutzendteich}&\duration{11}\\
%
 \laststation && \terminus{N\"urnberg-Dutzendteich} & \arrive{10:56}&&&\\
%
 \TABcline{1-7}
\end{timetable}
\end{document}

enter image description here

  • 1
    +1 Very very good. You are excellent. My compliments. – Sebastiano Apr 9 '18 at 17:58
  • It is amazing that you do this "just because". I am highly impressed. How much time did that take you? – jlinkels Apr 10 '18 at 18:45
  • 4
    @jlinkels The initial stab was pushing an hour, but I improved it throughout the day with other bells/whistles. I did it for several reasons: 1) as the developer of tabstackengine, I thought it would help show off some of its capability relative to tabular; 2) as the developer/maintainer of my multi-1000 person org's technical report \documentclass, it is good for me to constantly hone my skills; 3) I thought a successful answer was ripe for harvesting a bit of reputation upvotes; and 4) some challenges are irresistible. – Steven B. Segletes Apr 10 '18 at 19:08
  • I can understand your points 1, 2, 3 and 4. :) I just wished I was so skilled. – jlinkels Apr 11 '18 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.