# Any help with Tikz for a diagram

Lately I've been making some diagrams, I started with Tikz package but I don't know how to start with this:

I've tried with this:

\begin{tikzpicture}
[every node/.style={text depth=0pt}] % align node text

\coordinate (A) at (0,0);
\coordinate (B) at (3,0);
\coordinate (C) at (15,0);

\draw[|-|]
(A)
node at (A) [above=5pt] {$1$}
node at (A) [below=5pt] {$0$}
--
(B);
\draw[-|]
(B)
node at (B) [above=5pt] {$(1+R_{i,\tau-1})^\tau-1$}
node at (B) [below=5pt] {$i+\tau-1$};
--
(C);
node at (C) [above=5pt] {$(1+R_{i,\tau-1})^{\tau-1}(1+F_{i,\tau})^{\tau}$}
node at (C) [below=5pt] {$i+\tau$};
\end{tikzpicture}


• From the answers to your previous questions you should know how to add text (with \node), how to draw arrows from one node to another, and how to make a timeline-like thing. Given those examples you've been given previously, where do you get stuck? – Torbjørn T. Feb 19 '18 at 18:56

\documentclass[tikz,border=5mm]{standalone}

\begin{document}

\begin{tikzpicture}
[every node/.style={text depth=0pt,text height=1.5ex}]

\coordinate (A) at (0,0);
\coordinate (B) at (3,0);
\coordinate (C) at (15,0);

\draw[|-|]
(A)
node (Aa) at (A) [above=10pt] {$1$}
node (Ab) at (A) [below=5pt] {$i$}
node (Ac) at (A) [below=20pt] {$1$}
--
(B);
\draw[-|]
(B)
node (Ba) at (B) [above=10pt] {$(1+R_{i,\tau-1})^{\tau-1}$}
node (Bb) at (B) [below=5pt] {$i+\tau-1$} % omit ; here
--
(C) % omit ; here as well
node (Ca) at (C) [above=10pt] {$(1+R_{i,\tau-1})^{\tau-1}(1+F_{i,\tau})^{\tau}$}
node (Cb) at (C) [below=5pt] {$i+\tau$}
node (Cc) at (C) [below=20pt] {$(1+R_{i,\tau})^{\tau}$};

\draw[-latex] (Aa) -- (Ba);
\draw[-latex] (Ba) -- (Ca);
\draw[-latex] (Ac) -- (Cc);
\end{tikzpicture}

\end{document}


It is possible to name nodes with \node (name) at (0,0) {...}, like you can name coordinates. This way, you can reference these nodes later and e.g. connect them using a \draw command.

Edit: Added text height=1.5ex in order to make the arrows exactly horizontal. (Thanks to Earthliŋ!)

• I don't want to nitpick, but the top left arrow appears not to be horizontal. Is there an easy fix? – Earthliŋ Feb 19 '18 at 21:56

edit: corrected positions of nodes on the top line. now line is straight.

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
node distance = 5mm,
every node/.style = {font=\small}
]
\coordinate[label=below:$i$]        (A) at (0,0);
\coordinate[label=below:$i+\tau-1$] (B) at (3,0);
\coordinate[label=below:$i+\tau$]   (C) at (9,0);

\draw[|-|]  (A) -- (B);
\draw[-|]   (B) -- (C);
\node (A')  [above=of A] {1};
\node (B')  [at={(A'-| B)}] {$(1+R_{i,\tau-1})^{\tau-1}$};
\node (C')  [at={(A'-| C)}] {$(1+R_{i,\tau-1})^{\tau-1}(1+F_{i,\tau})^{\tau}$};
\draw[->]   (A') edge (B')      (B') to (C');
\node (A'') [below=of A] {1};
\node (C'') [below=of C] {$(1+R_{i,\tau})^\tau$};
\draw[->]   (A'') to (C'');
\end{tikzpicture}
\end{document}

• labels for basic line are determined with labels of coordinates
• above and below lines are drawn between nodes positioned above /below defined coordinates
• in picture is used tikz library poaitioning
• since image is very long, i shorter coordinate from (15,0) to (9,0)