3

I am trying to generate a numbered list with a bracket to the right of the list to group the list items into additional categories. I am trying to get something like:

enter image description here

I have fiddled around with \mbox and \frame, and even thought about using a table, but I would have to re-start the list numbering, and I want to make sure that the alignment is correct.

Is this something that can be done?

Glenn

2
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – cfr
    Commented Jun 2, 2014 at 0:02
  • I believe there is something called tikzmark which you can use to mark places in the enumeration and then use to position the curly brackets appropriately. There was a similar question earlier about doing this with a table and one of the comments mentioned this method.
    – cfr
    Commented Jun 2, 2014 at 0:03

2 Answers 2

4

Yep, this can easily be done with \tikzmark. With this you

  • complete the enumerate list as you normally would
  • mark specfic points with a \tikzmark{<name>}
  • access these \tikzmarks in a \tikzpicture with the [overlay,remember picture] options and draw as desired.

enter image description here

Note:

References:

Code:

\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 2\tikzmark{bottom 1}
\item Item 3\tikzmark{top 2}
\item Item 4
\item Item 5
\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}
4
  • Is there an advantage to defining tikzmark yourself rather than using the library? (It was the library I had in mind though I'd never used it before so I am sure my answer is sub-optimal in many ways.) EDIT: Is it that your marks are more node-like? I couldn't get mine to behave in a way which let me refer to anchors like that. (The documentation says something about subnodes but I haven't really understood it at this point.)
    – cfr
    Commented Jun 2, 2014 at 0:54
  • 1
    @cfr: I am sure the library is fine, I just got used to defining it and haven't transitioned to using the library. Commented Jun 2, 2014 at 0:58
  • OK. Thanks. Probably just unfamiliarity on my part, then. I saw you mentioned in the documentation and wondered if you had specific reason for avoiding the library in this particular case.
    – cfr
    Commented Jun 2, 2014 at 0:59
2

This example uses the tikzmark library which was developed in response to questions asked on this site of the sort Peter Grill linked to in his answer:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}[remember picture, overlay]
  \node (rightenum) at (.15\textwidth,0) {};
  \draw [decorate, decoration={brace}, thick] ($({pic cs:top1} -| rightenum) + (0, 1em)$) -- ({pic cs:bot1} -| rightenum) node [midway, right] {first two items};
  \draw [decorate, decoration={brace}, ultra thick] ($({pic cs:top2} -| rightenum) + (0, 1em)$) -- ({pic cs:bot2} -| rightenum) node [midway, right] {last four items};
\end{tikzpicture}

\begin{enumerate}
    \item\tikzmark{top1} first
    \item\tikzmark{bot1} second
    \item\tikzmark{top2} third
    \item fourth
    \item fifth
    \item\tikzmark{bot2} sixth
\end{enumerate}

\end{document}

Curly brackets with enumerate

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .