# [Tex/LaTex] Timeline with automatized hours and minutes

automationtikz-pgf

Some time ago I've asked a question about Timelines, many solutions were given, but in the end I decided to go with TikZ and also presented my solution. But I couldn't have done it without Torbjørn T.'s comment, where he suggested to make the creation of dates automatic, and this helped since I didn't need to type all of that myself and above all, it saved space in my Tex document. The solution was1:

\documentclass[10pt]{article}

\usepackage[a4paper, landscape]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{pgfplots}
%\usepackage{changepage}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds,snakes}

\begin{document}

\begin{tikzpicture}

%draw horizontal line
\draw[|->, -latex] (0,0) -- (17,0);
\draw[-, dashed] (-1,0) -- (0,0);

%draw years

\foreach \x [evaluate=\x as \year using int(1790+\x*10)] in {0,1,...,17}{

\draw (\x,0) node[below=7pt,anchor=east,xshift=0,rotate=45] {$\year$};
}

\draw[] (0,-0.1) -- (0,0.1);
\draw[] (1,-0.1) -- (1,0.1);
\draw[] (2,-0.1) -- (2,0.1);
\draw[] (3,-0.1) -- (3,0.1);
\draw[] (4,-0.1) -- (4,0.1);
\draw[] (5,-0.1) -- (5,0.1);
\draw[] (6,-0.1) -- (6,0.1);
\draw[] (7,-0.1) -- (7,0.1);
\draw[] (8,-0.1) -- (8,0.1);
\draw[] (9,-0.1) -- (9,0.1);
\draw[] (10,-0.1) -- (10,0.1);
\draw[] (11,-0.1) -- (11,0.1);
\draw[] (12,-0.1) -- (12,0.1);
\draw[] (13,-0.1) -- (13,0.1);
\draw[] (14,-0.1) -- (14,0.1);
\draw[] (15,-0.1) -- (15,0.1);
\draw[] (16,-0.1) -- (16,0.1);

\end{tikzpicture}

\end{document}


The result was:

… And it continues (too long to fit here). Now I want to recreate this but with hours and minutes, so that at the bottom of the line I can see 00:00 then 01:00 and so on.

This could be indefinite, as I have the intention of making a long horizontal document (not going to be printed, only digital use so no problem).

I have tried tweaking that code and searching this site but to no avail. How should I go about it? Is the code good for years but not for time as I want it? I really don't know where to start.

1: This is actually a minimal working example. I'm referring to the lines reported in the comment.

By a slight change to the \foreach loop you get what I think is the desired result:

## Notes:

You can greatly simplify your code:

• I commented out the package not needed for this MWE.
• By setting \MaxNumberyou can easily change one parameter and increase the width of the picture (page dimensions need to be adjust).
• The individual \draw commands could be in the \foreach loop.

## Code:

\documentclass[10pt]{article}

\usepackage[a4paper, landscape]{geometry}
%\usepackage[utf8]{inputenc}
%\usepackage{rotating}
%\usepackage{pgfplots}
%\usepackage{changepage}
\usepackage{tikz}
%\usetikzlibrary{arrows,backgrounds,snakes}

\newcommand*{\MaxNumber}{17}%
\begin{document}
\begin{tikzpicture}
%draw horizontal line
\draw[|->, -latex] (0,0) -- (\MaxNumber,0);
\draw[-, dashed] (-1,0) -- (0,0);

%draw hours
\foreach \x  in {0,...,\MaxNumber} {%
\draw (\x,0) node[below=7pt,anchor=east,xshift=0,rotate=45] {\x:00};
\draw[] (\x,-0.1) -- (\x,0.1);
}
\end{tikzpicture}
\end{document}