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 am using the TikZ package to create stacked timelines. See example below. Whenever I make some small modification to the timelines, I have to spend lots of time adjusting all the coordinates. If anyone could help me simplify this, it'd be greatly appreciated. My more specific questions follow:

  • How can a tikz image be made to conform to the dimensions of the page body?
  • How can nodes placed along timelines maintain their relative spacing if the dimensions of the timeline change?
  • How can informational nodes referred to in the timelines be spaced horizontally so that they don't overlap one another? (note: I would consider using chains or matrix to do this, but I'm not sure how to incorporate the other elements of the timelines with them.)

code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{tikz}
\usetikzlibrary{snakes,positioning}
%% define help lines
\tikzset{help lines/.style={color=black!50,very thin}}
\tikzset{main labels/.style={
%Shape
rectangle,
% Size
minimum size=6mm,
rounded corners=2mm,
% Border
very thick,
draw=red!50!black!50,
%Filling
top color =white,
bottom color=red!50!black!20,
% Font
font=\sffamily,}}
\tikzset{side labels/.style={
%Shape
rectangle,
% Size
minimum size=6mm,
rounded corners=2mm,
% Border
very thick,
draw=black!50,
%Filling
top color =white,
bottom color=black!20,
% Font
font=\sffamily,
% Anchor
anchor=east,}}
\tikzset{date labels/.style={
% Font
font=\sffamily,
% Anchor
anchor=north east,
%Angle
rotate=45}}
\tikzset{event/.style={
%Shape
rectangle,
% Size
rounded corners=2mm,
% Border
thick,
draw=#1!50,
%Filling
fill = #1!20,
% Font
align=center,
font=\sffamily\scriptsize,
}}
\tikzset{outline/.default=black}
\begin{document}
\begin{tikzpicture} %
% draw help lines
\foreach \a in {1,2,6,7,11,12}
\draw [help lines](-1,\a) -- (10,\a);
% draw labels and titles
\node [main labels] at (5,13.5) {Community \#1};
\node [main labels] at (5,8.5) {Community \#2};
\node [main labels] at (5,3.5) {Community \#3};
\foreach \b in {2.5,7.5,12.5}
\node [side labels] at (-1,\b) {Response};
\foreach \c in {1.5,6.5,11.5}
\node [side labels] at (-1,\c) {Impact};
\foreach \d in {0.5,5.5,10.5}
\node [side labels] at (-1,\d) {Historical Event};
% draw dates
\draw [->] (0,9.9) -- (10,9.9);
\draw [->] (0,4.9) -- (.2, 4.9) {[snake] (.2, 4.9) -- (.8,4.9)} (.8,4.9) -- (1,4.9) -- (10,4.9);
\draw [->] (0,-0.9) -- (10,-0.9);
% draw date labels
\draw (0,4.85) node [date labels] {1690} -- (0,4.95) node (hua1690a) {};
\draw (1,4.85) node [date labels] {1970} -- (1,4.95) node (hua1970a) {};
\draw (3.076923,4.85) node [date labels] {1979} -- (3.076923,4.95) node (hua1979a) {};
% draw events
\begin{scope}[on grid]
\node (huafound) [event=blue] at (0,5.5) {\small Founded};
\draw [blue!50] (huafound) -- (hua1690a);
\node (huaroad) [event=blue] [right= 1.35 of huafound] {\small Road};
\draw [blue!50] (huaroad) -- (hua1970a);
\node (huaconasupo) [event=blue] at (3.076923,5.5) {\small CONASUPO};
\draw [blue!50] (huaconasupo) -- (hua1979a);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this question
    
Your code doesn't compile for me. Try altering the option to babel. –  qubyte Feb 22 '12 at 16:21
    
I can compile the document. For the first question you need to read this answer : tex.stackexchange.com/questions/6388/… –  Alain Matthes Feb 22 '12 at 16:31
    
@MarkS.Everitt: I compiled using pdflatex –  proge Feb 22 '12 at 16:51
    
@proge Same here, but babel complained until I changed the option. –  qubyte Feb 22 '12 at 16:58
    
Ah, embarrassing. It was a dodgy aux file. My apologies! –  qubyte Feb 22 '12 at 17:12
show 3 more comments

1 Answer 1

up vote 2 down vote accepted

My first idea is something like the next code but the problem is that 10/300 is very little You can perhaps modify a little the values.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{tikz}

\tikzset{date labels/.style={
font=\small\sffamily,
anchor=north east,
rotate=45}}    

\usetikzlibrary{snakes,positioning}
\begin{document} 
\pgfmathsetmacro{\lentime}{0.9*\linewidth/28.45 pt} 
\pgfmathsetmacro{\dateone}{0.9*\linewidth*(1.970-1.690)/(2.012-1.690)/28.45274 pt}  
\pgfmathsetmacro{\datetwo}{0.9*\linewidth*(1.979-1.690)/(2.012-1.690)/28.45274 pt}
\begin{tikzpicture}  
\draw [->] (0,0) -- (.2, 0) {[snake] (.2, 0) -- (\dateone,0)} (\dateone,0) -- (\lentime,0);

% draw date labels  
\newcommand\ydelta{0.05}
\draw (0,0-\ydelta) node [date labels] {1690} -- (0,0+\ydelta) node (hua1690a) {};
\draw (\dateone,0-\ydelta) node [date labels] {1970} -- (\dateone,0+\ydelta) node (hua1970a) {};
\draw (\datetwo,0-\ydelta) node [date labels,anchor=south west] {1979} -- (\datetwo,0+\ydelta) node (hua1979a) {};

\end{tikzpicture}

\end{document} 
share|improve this answer
add comment

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.