按不同宽度对枚举列表进行分组?

按不同宽度对枚举列表进行分组?

我发现关于枚举列表分组的很好的答案。但它不适用于具有不同宽度的列表。例如

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node[baseline] (#1) {};}

\tikzset{My Node Style/.style={midway, right, xshift=3.0ex, align=left, font=\small, draw=none, thin, text=black}}

\newcommand\VerticalBrace[4][]{%
    % #1 = draw options
    % #2 = top mark
    % #2 = bottom mark
    % #4 = label
\begin{tikzpicture}[overlay,remember picture]
  \draw[decorate,decoration={brace, amplitude=1.5ex}, #1]
    ([yshift=1ex]#2.north east)  -- ([yshift=-1ex]#3.south east)
        node[My Node Style] {#4};
\end{tikzpicture}
}

\begin{document}
\begin{enumerate}
\item Item 1\tikzmark{top 1}
\item Item wide wide wide\tikzmark{bottom 1}
\item Item 3\tikzmark{top 2}
\item Item 4
\item Item wide wide wide
\item Item 6\tikzmark{bottom 2}
\end{enumerate}

\VerticalBrace[ultra thick, blue]{top 1}{bottom 1}{The first two items}
\VerticalBrace[ultra thick, blue]{top 2}{bottom 2}{The last four items}
\end{document} 

给出

在此处输入图片描述

我怎样才能解决这个问题?

答案1

您可以跟踪哪个子弹最长,并将所有 y 坐标设置为该子弹。

\begin{enumerate}
\item Item 1\tikzmark{top 1}
\item Item wide wide wide\tikzmark{bottom 1}
\item Item 3\tikzmark{top 2}
\item Item 4
\item Item wide wide wide wide\tikzmark{longest 2}
\item Item 6\tikzmark{bottom 2}
\end{enumerate}

\VerticalBrace[ultra thick, blue]{top 1 -| bottom 1}{bottom 1}{The first two items}
\VerticalBrace[ultra thick, blue]{top 2 -| longest 2}{bottom 2 -| longest 2}{The last four items}

在此处输入图片描述

相关内容