使用 Tikz 绘制跳跃列表

使用 Tikz 绘制跳跃列表

我基本上想绘制这样的跳过列表(没有蓝色箭头)跳过列表

我在网上没有找到类似的例子

答案1

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[box/.style={on chain,draw,minimum width=1.5em,
    text=green!60!black,join=by abc},
    c/.style={on chain,circle,draw,inner sep=1ex},
    node distance=1.5em,abc/.style={stealth-}]
 \path[abc/.style={-stealth},start chain=going right,nodes={alias=1-\X}]
  foreach \X in {0,1,5,6,8,12,17,22,33,40,44,47} {\ifnum\X=0
  node[c]{}
  \else
  node[box]{\X}
  \fi};
 \begin{scope}[start branch=b0 going above] 
  \chainin(1-0);
  \node[c,alias=2-0]{};
  \node[c,alias=3-0]{};
 \end{scope}
 \begin{scope}[start branch=b6 going above] 
  \chainin(1-6);
  \node[box,alias=2-6]{6};
 \end{scope}
 \begin{scope}[start branch=b6 going above] 
  \chainin(1-6);
  \node[box,alias=2-6]{6};
 \end{scope}
 \begin{scope}[start branch=b17 going above] 
  \chainin(1-17);
  \node[box,alias=2-17]{17};
 \end{scope}
 \begin{scope}[start branch=b40 going above] 
  \chainin(1-40);
  \node[box,alias=2-40]{40};
  \node[box,alias=3-40]{40};
 \end{scope}
 \path foreach \X in {1,2,3} {(\X-0) node[left=1em]{$h=\X$}};
 \path[every edge/.append style={-stealth}] (2-0) edge (2-6) edge (1-0)
  (3-0) edge (2-0) edge (3-40)
  (2-6) edge (2-17) (2-17) edge (2-40);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容