[Tex/LaTex] Large braces over several items in an itemize with text by the brace

tikz-pgf

This question is related to this question: Adding large brace next to body text, but is not a duplicate.

I have an itemize in a beamer presentation. I want to put a brace over some of these items. So here's what I have so far:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{frame}
  \frametitle{Here is text}
  \begin{itemize}[<+->]
  \item A first item \tikzmark{topbrace}
  \item Another item, also inside the brace \tikzmark{bottombrace}\tikzmark{right}
  \item Outside the brace
  \end{itemize}
\onslide<+->{
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={brace,amplitude=0.5em},decorate,ultra thick,black]
 ($(right)!(topbrace.north)!($(right)-(0,1)$)$) --  ($(right)!(bottombrace.south)!($(right)-(0,1)$)$);
\end{tikzpicture}
}
\end{frame}
\end{document}

(needs compiling twice to get the right result). Incidentally, why is this? Is it something to do with the remember picture thing?

I have two issues with this excellent solution: the spacing doesn't look right (I'd like the top of the brace to be higher), and I'd like to add text to the right of the brace (see picture).

I can't quite fathom the complicated positioning commands used to add an extra node with text, or modify the spacing…

where I want text

What I'd really like from an answer to this question is an explanation of what the ! and $ are doing…

Best Answer

These symbols are used for coordinate calculations. You need to load the library calc with \usetikzlibrary{calc} in order to use the coordinate calculation functions

\documentclass{scrartcl}
\usepackage{tikz} 
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture} 
\draw [help lines] (0,0) grid (5,3);
\path coordinate (a) at (1,1) 
      coordinate (b) at (5,3) 
      coordinate (c) at (2,3); 
\fill [blue] (a) circle (2pt); 
\fill [green] (b) circle (2pt); 
\fill [red] ($(a) + 2*(1,1)$) circle (2pt); 
\fill [purple] ($(a)!-.5!(b)$) circle (2pt);
\coordinate (d) at ($(a)!(c)!(b)$);
\fill [black] (c) circle (2pt) (d) circle (2pt); 
\draw (c) -- (d); 
\end{tikzpicture}
\end{document}

result

  1. How to use $: As you can see, the syntax uses the TEX math symbol $ to indicate that a “mathematical computation”. The red circle is placed from (a). I add 2*(1,1) at the coordinates of (a) so I get 1+2 and 1+2 (it's like addition of vectors)
  2. How to use !: I want to get a coordinate of point between (a) and (b). If I want the middle I use ($(a)!.5!(b)$). I use (...) to search coordinates. Then I use $..$ to make a calculation. Finally, I use !number! to get a point on the line (a)--(b). It's like to use pos =.5.
Related Question