2

I need to make a timeline using TikZ and I'am noob to this but I want to learn over just adding an image to my text. This is what I need to do: enter image description here First, I don't know why but the line created is too long (I've tried several ways but is always the same) and also another problem is that the text is too long and when I try to use \\ to separate it in different lines, it doesn't work (this is the most important problem that i need to solve). And the last question is how could I put circles or dots to replace the lines to separate the periods? This is my poor result: enter image description here

And my code is this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes}
\usetikzlibrary{positioning}
\begin{figure}
\begin{tikzpicture}[x=5cm]
\draw[black,->,thick,>=latex]
  (0,0) -- (5,0);
\foreach \Xc in {0,...,5}
{
  \draw[black,thick] 
    (\Xc,0) -- ++(0,5pt);
}

\node[below,align=left,anchor=north,inner xsep=0pt,color=black] 
  at (0,0) 
  {Dueño diseña y ofrece un esquema de incentivos $w(a)$};  

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (1,0) 
  {Gerente acepta o rechaza};  

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (2,0) 
  {Gerente elige una (verificable) $a\in\lbrace m,s\rbrace$};

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (3,0) 
  {Naturaleza juega};

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (4,0) 
  {Flujos de caja $x$ y los beneficios $b$ son realizados. Compensación $w(a)$ es pagada};

\end{tikzpicture}
\end{figure}
\end{document}

I will appreciate any comments to improve my tikz timeline. Thanks to everyone :)

1

1 Answer 1

4

If you want to use \\ you need to specify an alignment such as align=left. However, in this case you may just go with text width.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\begin{tikzpicture}[x=2.5cm,nodes={text width=2.2cm,align=left}]
\draw[black,->,thick,>=latex,line cap=rect]
  (0,0) -- (5,0);
\foreach \Xc in {0,...,4}
{
  \draw[black,thick] 
    (\Xc,0) -- ++(0,5pt);
}

\node[below,align=left,anchor=north,inner xsep=0pt,color=black] 
  at (0,0) 
  {Due\~no dise\~na y ofrece un esquema de incentivos $w(a)$.};  

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (1,0) 
  {Gerente acepta o rechaza.};  

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (2,0) 
  {Gerente elige una (verificable) $a\in\lbrace m,s\rbrace$.};

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (3,0) 
  {Naturaleza juega.};

\node[below,align=left,anchor=north,inner xsep=0pt] 
  at (4,0) 
  {Flujos de caja $x$ y los beneficios $b$ son realizados. Compensaci\'on
  $w(a)$ es pagada.};

\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

Or with circles and everything done in the loop.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\begin{tikzpicture}[x=2.5cm,nodes={text width=2.2cm,align=left}]
\draw[black,->,thick,>=latex,line cap=rect]
  (0,0) -- (5,0);
\foreach \Text [count=\Xc starting from 0] in 
{{Due\~no dise\~na y ofrece un esquema de incentivos $w(a)$.},%
 {Gerente acepta o rechaza.},%
 {Gerente elige una (verificable) $a\in\lbrace m,s\rbrace$.},%
 {Naturaleza juega.},%
 {Flujos de caja $x$ y los beneficios $b$ son realizados. Compensaci\'on
  $w(a)$ es pagada.}}  
{\fill (\Xc,0) circle[radius=1.5pt];
\node[below=0.2ex] at (\Xc,0) {\Text};}  
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

2
  • Thanks so much! Last question: Do yo know how to replace the vertical lines (in each period) to put a black circle instead? Like in the first picture.
    – oldenios
    Apr 17, 2020 at 20:00
  • @oldenios I added a version of that type.
    – user194703
    Apr 17, 2020 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .