点列表,用线连接各点

点列表,用线连接各点

有人知道如何制作一个用线连接点的列表,如下图所示吗?

在此处输入图片描述

答案1

enumitem带有和的版本TikZ,应用overlayremember picture,绘制圆形节点和连接器到它们。

然而,它不适用于分页的列表。

\documentclass{article}


\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{enumitem}

\newcounter{itemdot}
\DeclareRobustCommand{\dottedlinked}{%
  \begin{tikzpicture}[remember picture,overlay]
    \node[draw,anchor=base,inner sep=0pt,outer sep=0pt,circle,cyan] (itemdot\number\value{itemdot}) {\phantom{\textbullet}};
    \ifnum0<\value{itemdot}
    \draw[cyan,line width=0.5pt] (itemdot\number\value{itemdot}) -- (itemdot\the\numexpr\value{itemdot}-1);
    \fi
    \stepcounter{itemdot}
  \end{tikzpicture}%
}
\makeatletter
\g@addto@macro{\itemize}{\setcounter{itemdot}{0}} % reset the itemdot counter for a new itemize environment
\makeatother
\setlist[itemize,1]{label={\dottedlinked}}

\begin{document}
\begin{itemize}
  \item foo
  \item foobar
  \item foobar foobar
\end{itemize}

\begin{itemize}
  \item foo
  \item foobar
  \item foobar foobar
\end{itemize}

\end{document}

在此处输入图片描述

编辑——使用新列表

\documentclass{article}

\usepackage{blindtext}
\usepackage{tikz}

\usepackage{enumitem}

\newcounter{itemdot}
\DeclareRobustCommand{\dottedlinked}{%
  \begin{tikzpicture}[remember picture,overlay]
    \node[draw,anchor=base,inner sep=0pt,outer sep=0pt,circle,cyan,line width=1pt,yshift=0.1ex] (itemdot\number\value{itemdot}) {\phantom{\textbullet}};
    \ifnum0<\value{itemdot}
    \draw[cyan,line width=1pt,] (itemdot\number\value{itemdot}) -- (itemdot\the\numexpr\value{itemdot}-1);
    \fi
    \stepcounter{itemdot}%
  \end{tikzpicture}%
}
\makeatletter
\g@addto@macro{\itemize}{\setcounter{itemdot}{0}} % reset the itemdot counter for a new itemize environment
\makeatother

\newlist{itemcon}{itemize}{1}
\setlist[itemcon,1]{label={\dottedlinked}}

\begin{document}
\begin{itemcon}
  \item foo
  \item foobar

    \blindtext
  \item foobar foobar
  \item foobar foobar
  \item foobar foobar
    \blindtext[2]
  \item Foo
\end{itemcon}

\begin{itemize}
  \item foo
  \item foobar

        \blindtext
  \item foobar foobar
\end{itemize}



\end{document}

相关内容