1

enter image description here

Can someone help me in drawing this in LaTeX?

It should be really easy with tikz package, but I am really failing to get the result I want.

This is what I tried:

\begin{tikzpicture}
%draw horizontal line
\draw (0,0) -- (4,0);
\begin{tikzpicture}[snake=zigzag, line before snake = 5mm, line after snake = 5mm]

%draw vertical lines
\foreach \x in {0,2,5,7}
\draw (\x cm,3pt) -- (\x cm,-3pt);

%draw nodes
\draw (0,0) node[below=3pt] {$ 0 $} node[above=3pt] {$   $};
\draw (2,0) node[below=3pt] {$ 1 $} node[above=3pt] {$ CPN $};
\draw (5,0) node[below=3pt] {$ 2 $} node[above=3pt] {$ CPN $};
\draw (7,0) node[below=3pt] {$ n $} node[above=3pt] {$ CPN + M $};
\end{tikzpicture}
  • Hey this is what I have so far, I copied the structure from an old answer (stackoverflow.com/questions/217834/…) of this website. – Carmine Ragone Nov 17 '17 at 17:46
  • Please can you make your example compile? You seem to be nesting tikzpictures. That's not supported and is expected not to work as expected. – cfr Nov 18 '17 at 1:50
4

With decoration you can choose the style (zigzag), how long should be the line before the decoration (pre length) and after it (post length) and also its amplitude:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\CPN}{\mathit{CPN}}
%\newcommand{\CPN}{\text{CPN}} %possible alternative
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, arrows.meta, positioning, matrix}

\begin{document}
    \begin{tikzpicture}
        %draw horizontal line
        \draw[decorate,
            decoration={zigzag,
                pre length=5.5cm, 
                post length=1cm,
                amplitude=2.5mm
                }
            ] 
        (0,0) -- (7,0);

        %draw vertical lines
        \foreach \x in {0,2,5,7} 
            \draw (\x cm,3pt) -- (\x cm,-3pt);

        %draw nodes
        \draw (0,0) node[below=3pt] {$ 0 $} node[above=3pt] {};
        \draw (2,0) node[below=3pt] {$ 1 $} node[above=3pt] {$ \CPN $};
        \draw (5,0) node[below=3pt] {$ 2 $} node[above=3pt] {$ \CPN $};
        \draw (7,0) node[below=3pt] {$ n $} node[above=3pt] {$ \CPN + M $};

        \matrix[matrix of math nodes, 
            anchor=north east,
            inner sep=0pt,
            nodes={text width=6em, align=center, inner sep=4pt}
            ] (m) at (0,-.5) {
            \dfrac{\CPN_{1}}{(i+i)^{1}} \\
            \dfrac{\CPN_{2}}{(i+i)^{2}} \\
            \dots\\
            \dfrac{\CPN_{n}+M}{(i+i)^{n}} \\
        };

        % draw gray arrows 
        \foreach \mypos/\mylen in {1/2,2/5,4/7} 
            \draw[Stealth-, gray, very thick] (m-\mypos-1.east) -- +(\mylen,0);     
    \end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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