3

So I am making a presentation in beamer for a class and I decided on using curly braces around multiple items in an itemize environment that are uncovered one by one. So, following the advice I got from another question here, I got the curly braces to show up around chosen items when I want them too, except some braces are inexplicably rotated. Here is what I mean, screenshot
Here is my best attempt at a MWE:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{metropolis}
\usepackage[normalem]{ulem}
\usepackage{amsmath,lmodern,calc,tikz,textcomp}
\usetikzlibrary{tikzmark,calc, decorations.pathreplacing}

\begin{document}


\begin{frame}

\begin{itemize}
\setlength\itemsep{0.7em}
\item\only<1>{\(b > v > p\)}\onslide<2->{\sout{\(b > v > p\)}}\tikzmark{start}
\item\only<2>{\(p > b > v\)}\only<3->{\sout{\(p > b > v\)}}\tikzmark{end}
\item\only<3>{\(b > p > v\)}\only<4->{\sout{\(b > p > v\)}}\tikzmark{start1} \tikzmark{end1}
\item\only<4>{\(v > b > p\)}\only<5->{\sout{\(v > b > p\)}}\tikzmark{start2}
\item\only<5>{\(p > v > b\)}\only<6->{\sout{\(p > v > b\)}}\tikzmark{end2}
\item\only<6>{\(v > p > b\)}\only<7->{\sout{\(v > p > b\)}}\tikzmark{start3} \tikzmark{end3}

\only<3->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
  ([yshift=2ex]{{pic cs:end}|-{pic cs:start}}) --
    node[xshift=15pt,anchor=west] {No change by raising} 
  ([yshift=-0.5ex]pic cs:end);
\end{tikzpicture}}

\only<4->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
  ([yshift=2ex]{{pic cs:end}|-{pic cs:start1}}) --
    node[xshift=15pt,anchor=west] {Raising won, but now neg. profit} 
  ([yshift=-0.5ex]pic cs:end1);
\end{tikzpicture}}

\only<6->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
  ([yshift=2ex]{{pic cs:end}|-{pic cs:start2}}) --
    node[xshift=15pt,anchor=west] {No change by lowering} 
  ([yshift=-0.5ex]pic cs:end2);
\end{tikzpicture}}

\only<7->{\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,raise=12pt}]
  ([yshift=2ex]{{pic cs:end}|-{pic cs:start3}}) --
    node[xshift=15pt,anchor=west] {Lost by lowering} 
  ([yshift=-0.5ex]pic cs:end3);
\end{tikzpicture}}

\end{itemize}

\end{frame}


\end{document}

No matter what I do, or how much I increase the space between the items, the rotation on some braces remain. Can someone please help me with this error?

gernot
  • 49,614
  • I'm afraid I can't compile your example on my system (MacTeX2016) because the tikzpicture package can't be found. Is it a custom package? Is it available online somewhere? – Mico Dec 10 '16 at 08:07
  • 2
    @Mico I'm pretty sure that loading tikzpicture was a last minute edit action by the OP when minimizing the code (not realizing that tikz is the name of the package). Obviously the code was not tried before being posted. – gernot Dec 10 '16 at 08:15
  • I am not running any custom packages anywhere apart from the default live installation. The code does run on my mac with TexShop, and what I have to do is press enter during a "tikzpicture.sty not found, press enter to proceed" dialogue during the loading screen to make sure it fully compiles. This is another error I have but one that I thought was innocuous, I apologize for the inconvenience. – Coolio2654 Dec 10 '16 at 18:09

1 Answers1

5

The minimal fix:

  • Remove the space between the \tikzmarks: replace \tikzmark{start1} \tikzmark{end1} by \tikzmark{start1}\tikzmark{end1}, and likewise for the other space between tikzmark{start3} and tikzmark{end3}.

  • In the code for the second brace, replace {pic cs:end}|-{pic cs:start1} by {pic cs:end1}|-{pic cs:start1} (adding 1 to end). Do the same for the third and fourth brace: replace end by end2 and end3, respectively.

To clean up the code a bit, I suggest to define the command

\mybrace{<start mark>}{<end mark>}{<alignment mark>}{<text>}

as

\newcommand\mybrace[4]%
   {\begin{tikzpicture}[remember picture,overlay]
    \draw[decorate,decoration={brace,raise=12pt}]
      ([yshift=2ex]{{pic cs:#3}|-{pic cs:#1}}) --
      node[xshift=15pt,anchor=west] {#4} 
      ([yshift=-0.5ex]{{pic cs:#3}|-{pic cs:#2}});
    \end{tikzpicture}%
   }

Then the code for the braces reduces to

\only<3->{\mybrace{start}{end}{end}{No change by raising}}
\only<4->{\mybrace{start1}{end1}{end}{Raising won, but now neg. profit}}
\only<6->{\mybrace{start2}{end2}{end}{No change by lowering}}
\only<7->{\mybrace{start3}{end3}{end}{Lost by lowering}}

The extra alignment mark helps to align the braces below each other if the itemized texts are of different lengths. If there is nothing to align with (like for the first brace), take the end mark as alignment mark.

Here is the complete code and the result.

enter image description here

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{metropolis}
\usepackage[normalem]{ulem}
\usepackage{amsmath,lmodern,calc,tikz,textcomp}
\usetikzlibrary{tikzmark,calc, decorations.pathreplacing}
\newcommand\mybrace[4]%
   {\begin{tikzpicture}[remember picture,overlay]
    \draw[decorate,decoration={brace,raise=12pt}]
      ([yshift=2ex]{{pic cs:#3}|-{pic cs:#1}}) --
      node[xshift=15pt,anchor=west] {#4} 
      ([yshift=-0.5ex]{{pic cs:#3}|-{pic cs:#2}});
    \end{tikzpicture}%
   }
\begin{document}
\begin{frame}

\begin{itemize}
\setlength\itemsep{0.7em}
\item\only<1>{\(b > v > p\)}\onslide<2->{\sout{\(b > v > p\)}}\tikzmark{start}
\item\only<2>{\(p > b > v\)}\only<3->{\sout{\(p > b > v\)}}\tikzmark{end}
\item\only<3>{\(b > p > v\)}\only<4->{\sout{\(b > p > v\)}}\tikzmark{start1} \tikzmark{end1}
\item\only<4>{\(v > b > p\)}\only<5->{\sout{\(v > b > p\)}}\tikzmark{start2}
\item\only<5>{\(p > v > b\)}\only<6->{\sout{\(p > v > b\)}}\tikzmark{end2}
\item\only<6>{\(v > p > b\)}\only<7->{\sout{\(v > p > b\)}}\tikzmark{start3} \tikzmark{end3}
\only<3->{\mybrace{start}{end}{end}{No change by raising}}
\only<4->{\mybrace{start1}{end1}{end}{Raising won, but now neg. profit}}
\only<6->{\mybrace{start2}{end2}{end}{No change by lowering}}
\only<7->{\mybrace{start3}{end3}{end}{Lost by lowering}}
\end{itemize}

\end{frame}
\end{document}
gernot
  • 49,614
  • I can't believe that one of my mistakes was not naming the tikz anchors correctly down below my text, so I guess I have to still watch our for amateur mistakes like those. Anyway, your reworked code looks much better and has fixed the problem! Thank you so much, I will try to learn from how you simplified my previous code for future reference. – Coolio2654 Dec 10 '16 at 18:24