Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to create a timeline in latex. This is what I have right now

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{chronosys}

\begin{document}


\startchronology
[startyear=0,stopyear=44,height=7ex,width=\hsize]
\chronoevent{0}{Jan 13 Quiz 1}
\chronoevent{8}{Jan 20 Quiz 2}
\chronoevent{36}{Feb 17 Quiz 6}
\chronoevent{36}{Intervention}
\stopchronology

\end{document}

I would like to have the days on top of the timeline, and the quizzes, and intervention, in the bottom.


I was able to create something close to what I want:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes}
\usepackage{fullpage}

\begin{document}



\begin{figure}
\caption{Time Line}
\centering
\resizebox{\linewidth}{!}{% Resize table to fit within

\begin{tikzpicture}[]
%draw horizontal line   
\draw (0,0) -- (41/1.7,0);
%draw vertical lines
\foreach \x in {0/1.7, 8/1.7, 15/1.7, 22/1.7, 29/1.7, 36/1.7, 41/1.7}
   \draw (\x cm,3pt) -- (\x cm,-3pt);

%draw nodes
\draw (0,0) node[below=3pt] { Quiz 1 } node[above=3pt] { Jan 13 2014  };
\draw (8/1.7,0) node[below=3pt] { Quiz 2 } node[above=3pt] { Jan 20 2014  };
\draw (15/1.7,0) node[below=3pt] { Quiz 3 } node[above=3pt] { Jan 27 2014  };
\draw (22/1.7,0) node[below=3pt] { Quiz 4 } node[above=3pt] { Feb 3 2014  };
\draw (29/1.7,0) node[below=3pt] { Quiz 5 } node[above=3pt] { Feb 10 2014  };
\draw (36/1.7,0) node[below=3pt] { Quiz 6 \& Intervention} node[above=3pt] { Feb 17 2014  };
\draw (41/1.7,0) node[below=3pt] { Course ends} node[above=3pt] { Feb 22 2014  };
\end{tikzpicture}
}
\label{fig:time_line}
\end{figure}
\end{document}

But the "draw vertical lines" is not doing what I expected.

%draw vertical lines
\foreach \x in {0/1.7, 8/1.7, 15/1.7, 22/1.7, 29/1.7, 36/1.7, 41/1.7}
   \draw (\x cm,3pt) -- (\x cm,-3pt);

Any idea why?

share|improve this question
    
Related answer about timelines (not in chronosys): tex.stackexchange.com/questions/156878/… –  Steven B. Segletes May 23 at 2:07

1 Answer 1

up vote 7 down vote accepted

You have some mistakes in your \foreach. Use

%draw vertical lines
\foreach \x in {0, 8, 15, 22, 29, 36, 41}{
   \draw (\x/1.7,3pt) -- (\x/1.7,-3pt);
}

I have used /1.7 in the coordinate instead of the list where / will be confused foe the next variable.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes}
\usepackage{fullpage}

\begin{document}



\begin{figure}
\caption{Time Line}
\centering
\resizebox{\linewidth}{!}{% Resize table to fit within

\begin{tikzpicture}[]
%draw horizontal line
\draw (0,0) -- (41/1.7,0);
%draw vertical lines
\foreach \x in {0, 8, 15, 22, 29, 36, 41}{
   \draw (\x/1.7,3pt) -- (\x/1.7,-3pt);
}
%draw nodes
\draw (0,0) node[below=3pt] { Quiz 1 } node[above=3pt] { Jan 13 2014  };
\draw (8/1.7,0) node[below=3pt] { Quiz 2 } node[above=3pt] { Jan 20 2014  };
\draw (15/1.7,0) node[below=3pt] { Quiz 3 } node[above=3pt] { Jan 27 2014  };
\draw (22/1.7,0) node[below=3pt] { Quiz 4 } node[above=3pt] { Feb 3 2014  };
\draw (29/1.7,0) node[below=3pt] { Quiz 5 } node[above=3pt] { Feb 10 2014  };
\draw (36/1.7,0) node[below=3pt] { Quiz 6 \& Intervention} node[above=3pt] { Feb 17 2014  };
\draw (41/1.7,0) node[below=3pt] { Course ends} node[above=3pt] { Feb 22 2014  };
\end{tikzpicture}
}
\label{fig:time_line}
\end{figure}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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