LaTeX 中的时间线 - 具体示例

LaTeX 中的时间线 - 具体示例

在此处输入图片描述

有人可以帮我用 LaTeX 画这个吗?

使用软件包应该很容易tikz,但我真的无法得到我想要的结果。

这是我尝试过的:

\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}

答案1

decoration可以选择样式 ( )、装饰前 ( ) 和装饰后 ( )zigzag的线的长度,以及它的:pre lengthpost lengthamplitude

\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}

在此处输入图片描述

相关内容