I found this nice answer regarding grouping of enumerated list. But it does not work for lists with different width. For instance
\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}
gives
How can I fix this?


\hspace? – Majid Abdolshah Apr 02 '19 at 06:44