答案1
由于这是用 Metapost 标记的,因此这是 MP 中的一项工作。它包含在内,luamplib
因此您需要用 进行编译lualatex
。
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
path timeline;
timeline = origin -- 260 right;
pair m[];
m0 = point 0 of timeline;
m1 = point 2/9 of timeline;
m2 = point 5/9 of timeline;
m3 = point 7/9 of timeline;
drawarrow timeline;
for i=0 upto 3:
draw (down--up) scaled 3 shifted m[i];
endfor
interim labeloffset := 6;
label.bot("\strut $0$", m0) withcolor 2/3 blue;
label.bot("\strut $k$", m1) withcolor 2/3 blue;
label.bot("\strut $n$", m2) withcolor 2/3 blue;
label.bot("\strut $r$", m3) withcolor 2/3 blue;
label.top("X", m1) withcolor 1/2 red;
label.top("Y", m2) withcolor 1/2 red;
label.top("Z", m3) withcolor 1/2 red;
interim ahangle := 30;
drawarrow (m1 -- m2
cutbefore fullcircle scaled 12 shifted m1
cutafter fullcircle scaled 16 shifted m2)
shifted 9.6 up withcolor 2/3 blue;
drawarrow (m2 -- m3
cutbefore fullcircle scaled 12 shifted m2
cutafter fullcircle scaled 16 shifted m3)
shifted 9.6 up withcolor 2/3 blue;
drawarrow (m1 -- m3) shifted 20 up withcolor 1/2 red;
endfig;
\end{mplibcode}
\end{document}
您可以从此处列出的资源中获得有关语法的所有详细信息Metapost 的 TUG 页面。
需要指出的一点是,我尝试根据中央时间线上的位置来定义绘图。因此,如果你改变时间线,绘图的其余部分也会自动改变。因此,只需将上面的第二行更改为
timeline = origin -- 180 right;
您将获得更紧密的版本,可以适合更小的列。
单位是 PostScript 点 72: = 1in,28.35 = 1cm。
答案2
使用 TikZ。(您想要更精美的盒子吗?)
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,time/.style={minimum height=5mm,minimum width=6mm,fill=#1,text=white}]
\def\k{1.5}
\def\n{4}
\def\r{6}
\draw[teal,-latex] (0,0)--(\r+1,0);
\draw[teal] (0,.1)--(0,-.1) node[below=2mm,time=teal]{$0$}
(\k,.1) node[above=2mm,time=red] (x) {$x$}--
(\k,-.1) node[below=2mm,time=teal]{$k$}
(\n,.1) node[above=2mm,time=red] (y) {$y$} --
(\n,-.1) node[below=2mm,time=teal]{$n$}
(\r,.1) node[above=2mm,time=red] (z) {$z$}--
(\r,-.1) node[below=2mm,time=teal]{$r$};
\draw[teal,->,shorten >=1mm,shorten <=1mm] (x)--(y);
\draw[->,shorten >=1mm,shorten <=1mm] (y)--(z);
\draw[red,->,shift={(90:1.3)}] (\k,0)--(\r,0);
\end{tikzpicture}
\end{document}
更新:按照 OP 的要求删除盒子。
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,time/.style={minimum height=5mm,minimum width=6mm}]
\def\k{1.5}
\def\n{4}
\def\r{6}
\draw[teal,-latex] (0,0)--(\r+1,0);
\draw[teal] (0,.1)--(0,-.1) node[below=2mm,time]{$0$}
(\k,.1) node[above=2mm,time,red] (x) {$x$}--
(\k,-.1) node[below=2mm,time]{$k$}
(\n,.1) node[above=2mm,time] (y) {$y$} --
(\n,-.1) node[below=2mm,time]{$n$}
(\r,.1) node[above=2mm,time] (z) {$z$}--
(\r,-.1) node[below=2mm,time]{$r$};
\draw[teal,->] (x)--(y);
\draw[->] (y)--(z);
\draw[red,->,shift={(90:1.3)}] (\k,0)--(\r,0);
\end{tikzpicture}
\end{document}