Search code examples
latexbeamertikz

Latex: stretchable curly braces outside math


I am producing some latex beamer slides (but I think it is not a beamer specific question per se).

I have the following:

\begin{itemize}
\item Issue1
\item Issue2
\item Issue3
\end{itemize}

Now, I want to have a right curly brace (i.e. '}') behind the items spreading over issue1 and issue2. And of course I want to write something behind that curly brace.

In a perfect world I would write something like:

\begin{itemize}
\left .
\item Issue1
\item Issue2
\right \} One and Two are cool
\item Issue3
\end{itemize}

This does not work because I am not in a math environment and I can not put the whole snippet inside a math environment because itemize would not work in that case.

Is there a clean solution or a hack to produce my desired result?

Regards, Bastian.


Solution

  • I'd use tikz and make an overlay.

    First include the proper packages (you may not need to include tikz since this is a beamer question):

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

    Then when you make your list, give names to the places after each item:

    \begin{itemize}
        \item Issue 1     
            \tikz[remember picture] \node[coordinate,yshift=0.5em] (n1) {}; 
        \item Issue 2
            \tikz[remember picture] \node[coordinate] (n2) {};
        \item Issue 3
    \end{itemize}
    

    (Note: I shifted the y value up by 1/2 of a line maybe more would be better.)

    Because we used remember picture we can refer to these places in an overlay:

      \begin{tikzpicture}[overlay,remember picture]
          \path (n2) -| node[coordinate] (n3) {} (n1);
          \draw[thick,decorate,decoration={brace,amplitude=3pt}]
                (n1) -- (n3) node[midway, right=4pt] {One and two are cool};
      \end{tikzpicture}
    

    The path is there to deal with items that do not have the same width. This edit comes from ESultanik's answer.

    The result is:

    alt text

    Side note: You can remove all of the remember picture options and add the following to automatically add remember to all pictures:

    \tikzstyle{every picture}+=[remember picture]