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…
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$
: 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 add2*(1,1)
at the coordinates of (a) so I get 1+2 and 1+2 (it's like addition of vectors)!
: 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 usepos =.5
.