2

Consider the following MWE

\documentclass{beamer}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{positioning}% To get more advances positioning options
\usetikzlibrary{arrows}% To get more arrow heads
\usetikzlibrary{math,calc}
\usetikzlibrary{arrows.meta, bending, decorations.markings, angles, quotes, fit}
\usetikzlibrary{tikzmark}
\usetikzlibrary{scopes}
\mode<presentation> {
    \usetheme{Boadilla}

    \setbeamertemplate{footline}{}% get rid of footer completely 
}

\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{amssymb, mathtools, amsfonts}

\definecolor{MyColor1}{rgb}{0.24, 0.59, 0.32}
\definecolor{MyColor2}{rgb}{0.85, 0.49, 0.19}
\definecolor{MyColor3}{rgb}{0.22, 0.42, 0.69}

\usepackage{tikz}

\usefonttheme{serif}

\begin{document}

\begin{frame}\frametitle{Examples}
    \begin{center}
        \begin{tabular}{c|c}
            \onslide<1->{
                $\langle\alpha,\beta\rangle = \langle\beta,\alpha\rangle =-1$ 
                & $3\langle\alpha,\beta\rangle= \langle\beta,\alpha\rangle=-3$\\\midrule
                & \\
                \begin{tikzpicture}[scale=0.7, every node/.style={transform shape}]
                    \draw (-2,-2) rectangle (2,2);
                    \node (alpha) at (1.2,0) {$\alpha$};
                    \node (beta) at (120:1.2) {$\beta$};
                    \draw[->] (0,0) -- (0:1);
                    \draw[->] (0,0) -- (120:1);
                    \only<1>{
                    \foreach \angle in {60,180,240,300}{
                        \draw[->] (0,0) -- (\angle:1);
                    }
                    }
                    \draw[MyColor1] (0.5,0) arc (0:120:0.5);
                    \draw[fill=MyColor1, opacity=0.3] (0,0) -- (0.5,0) arc (0:120:0.5) -- cycle;
                \end{tikzpicture} &
                \begin{tikzpicture}[scale=0.7, every node/.style={transform shape}]
                    \draw (-2,-2) rectangle (2,2);
                    \node (alpha) at (1.2,0) {$\alpha$};
                    \node (beta) at (150:1.9) {$\beta$};
                    \draw[->] (0,0) -- (150:1.7320);
                    \draw[->] (0,0) -- (0:1);
                    \only<1>{
                    \foreach \angle in {30,60,90,120,180,210,240,270,300,330}{
                        \pgfmathsetmacro{\bigradius}{sqrt(3)}
                        \ifthenelse{\angle=30 \OR 
                                    \angle=90 \OR 
                                    \angle=150 \OR 
                                    \angle=210 \OR
                                    \angle=270 \OR 
                                    \angle=330}{
                                        \draw[->] (0,0) -- (\angle:\bigradius);
                                    }{
                                        \draw[->] (0,0) -- (\angle:1);
                                    };
                    }
                    }
                    \draw[MyColor1] (0.5,0) arc (0:150:0.5);
                    \draw[fill=MyColor1, opacity=0.3] (0,0) -- (0.5,0) arc (0:150:0.5) -- cycle;
                \end{tikzpicture}\\
                & \\}
            \only<2->{
            \only<3>{
                $\begin{pmatrix*}[r] \hphantom{-2}  & \hphantom{-1}\\ 
                                 \hphantom{-1} & \hphantom{-2}
                \end{pmatrix*}$}
            \only<4->{
                $\begin{pmatrix*} 
                    \only<4->{-2}  & \only<5->{\color<5->{MyColor1}{-1}}\\ 
                    \only<5->{\color<5->{MyColor1}{-1}} & \only<4->{-2}
                \end{pmatrix*}$} 
                & 
            \only<3>{
                $\begin{pmatrix} \hphantom{-2}  & \hphantom{-1}\\ 
                                    \hphantom{-1} & \hphantom{-2}
                \end{pmatrix}$}
            \only<4->{
            $\begin{pmatrix*}[r] \only<4->{-2}  & \only<5->{\color<5->{MyColor1}{-1}}\\ 
                             \only<5->{\color<5->{MyColor1}{-3}} & \only<3->{-2}
            \end{pmatrix*}$}
            }
        \end{tabular}
    \end{center}
\end{frame}
\end{document}

It shows what it should at the the right position, i.e. the order of things that gets revealed is correct.. The only problem I have with the output is that the borders of the table (the central line and the first row) shift when some elements get revealed. I managed to get the two tikzpictures to stay in place, but when I add the matrices to the table they also start shifting...

I don't really understand where the problem is, since I think I applied the same technique to keep things in place in the entire frame, but it seems to sometimes not work (this is what I took as guidline)... I'm probably approaching this problem in the wrong way, but I don't really know how to keep things in place other than adding empty space where necessary.

Any hints on how I can get the entire table to stay fixed while revealing the different parts is appreciated.

Sito
  • 681
  • 1
    See if changing \begin{frame} to \begin{frame}[t] helps. –  Apr 24 '20 at 20:22
  • @Schrödinger'scat Thank you for the suggestion. Unfortunately this doesn't help, the length of the central line and the position of the matrices still shifts around.. – Sito Apr 24 '20 at 20:24
  • You could also encapsulate your content in an \begin{overlayarea}{\textwidth}{0.5\paperheight} <content> \end{overlayarea}. Regarding the horizontal shifting you should write \only<overlay->{% (newline) <content of \only> }% (newline) otherwise a blank space is inserted after each \only{ } – BambOo Apr 24 '20 at 20:27
  • 2
    BTW, this is completely off-topic (and perhaps unfair) but I guess a reason why users refrain from upvoting this in principle well-defined question may be that not many have seen Cartan matrices with negative diagonal entries. Are you sure about the signs? (And sorry for asking if it is stupid but I was a bit shocked when I saw them.) –  Apr 25 '20 at 02:05
  • 1
    @Schrödinger'scat There is a story behind these.. In the beginning i didn't use pmatrix* but had some hphantoms. I replaced the hphantom with pmatrix* but forgot to remove the minus.. Then postet the question and you were answered before I noticed.. And after that I felt like I shouldn' t modify the question anymore – Sito Apr 25 '20 at 07:15

2 Answers2

4

If you use the [t] option and the overlay-beamer-styles library, which is made for this, and discard hidden spaces you get

\documentclass{beamer}
\usepackage{tikz}
\usepackage{ifthen}
\usetikzlibrary{overlay-beamer-styles}
\mode<presentation> {
    \usetheme{Boadilla}

    \setbeamertemplate{footline}{}% get rid of footer completely 
}

\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{amssymb, mathtools, amsfonts}

\definecolor{MyColor1}{rgb}{0.24, 0.59, 0.32}
\definecolor{MyColor2}{rgb}{0.85, 0.49, 0.19}
\definecolor{MyColor3}{rgb}{0.22, 0.42, 0.69}


\usefonttheme{serif}

\begin{document}

\begin{frame}[t]
\frametitle{Examples}
    \begin{center}
        \begin{tabular}{c|c}
            \onslide<1->{
                $\langle\alpha,\beta\rangle = \langle\beta,\alpha\rangle =-1$ 
                & $3\langle\alpha,\beta\rangle= \langle\beta,\alpha\rangle=-3$\\\midrule
                & \\
                \begin{tikzpicture}[scale=0.7, every node/.style={transform shape}]
                    \draw (-2,-2) rectangle (2,2);
                    \node (alpha) at (1.2,0) {$\alpha$};
                    \node (beta) at (120:1.2) {$\beta$};
                    \draw[->] (0,0) -- (0:1);
                    \draw[->] (0,0) -- (120:1);                 
                    \foreach \angle in {60,180,240,300}{
                        \draw[->,visible on=<1>] (0,0) -- (\angle:1);
                    }
                    \draw[MyColor1] (0.5,0) arc (0:120:0.5);
                    \draw[fill=MyColor1, opacity=0.3] (0,0) -- (0.5,0) arc (0:120:0.5) -- cycle;
                \end{tikzpicture} &
                \begin{tikzpicture}[scale=0.7, every node/.style={transform shape}]
                    \draw (-2,-2) rectangle (2,2);
                    \node (alpha) at (1.2,0) {$\alpha$};
                    \node (beta) at (150:1.9) {$\beta$};
                    \draw[->] (0,0) -- (150:1.7320);
                    \draw[->] (0,0) -- (0:1);
                    \begin{scope}[visible on=<1>]
                    \foreach \angle in {30,60,90,120,180,210,240,270,300,330}{
                        \pgfmathsetmacro{\bigradius}{sqrt(3)}
                        \ifthenelse{\angle=30 \OR 
                                    \angle=90 \OR 
                                    \angle=150 \OR 
                                    \angle=210 \OR
                                    \angle=270 \OR 
                                    \angle=330}{
                                        \draw[->] (0,0) -- (\angle:\bigradius);
                                    }{
                                        \draw[->] (0,0) -- (\angle:1);
                                    };
                    }
                    \end{scope}
                    \draw[MyColor1] (0.5,0) arc (0:150:0.5);
                    \draw[fill=MyColor1, opacity=0.3] (0,0) -- (0.5,0) arc (0:150:0.5) -- cycle;
                \end{tikzpicture}\\
                & \\}
            \only<2->{%
            \only<3>{%
                $\begin{pmatrix*}[r] \hphantom{-2}  & \hphantom{-1}\\ 
                                 \hphantom{-1} & \hphantom{-2}
                \end{pmatrix*}$}%
            \only<4->{%
                $\begin{pmatrix*} 
                    \only<4->{-2}  & \only<5->{\color<5->{MyColor1}{-1}}\\ 
                    \only<5->{\color<5->{MyColor1}{-1}} & \only<4->{-2}
                \end{pmatrix*}$}% 
                & 
            \only<3>{%
                $\begin{pmatrix} \hphantom{-2}  & \hphantom{-1}\\ 
                                    \hphantom{-1} & \hphantom{-2}
                \end{pmatrix}$}%
            \only<4->{%
            $\begin{pmatrix*}[r] \only<4->{-2}  & \only<5->{\color<5->{MyColor1}{-1}}\\ 
                             \only<5->{\color<5->{MyColor1}{-3}} & \only<3->{-2}
            \end{pmatrix*}$}%
            }%
        \end{tabular}
    \end{center}
\end{frame}
\end{document}

enter image description here

The important point is to make stuff that is to appear only on special slides invisible on the other slides. That way this stuff still contributes to the bounding box, and thus allows to avoid jumps.

As for the shifts of the matrices, they come from spurious spaces, which I removed by adding the % chars where appropriate.

Off-topic: I removed libraries that are not in use here. Whether or not one should use the \ifthenelse macro when one has pgf at ones disposal I do not know but I kept it.

  • I believe the last problem that was pointed out is the horizontal shifting of the matrices. See my last comment in the question. – BambOo Apr 24 '20 at 20:31
  • 1
    @BambOo Thanks for the heads up! IMHO these are just spurious spaces which one can kill in the usual way. –  Apr 24 '20 at 20:35
  • 2
    Totatlly agreed. I guess the OP did not know that and empty new line in text mode leads to a space insertion – BambOo Apr 24 '20 at 20:37
  • @BambOo No I didn't know, but I'll certainly be looking out for it from now on. Thank you for the info! – Sito Apr 24 '20 at 20:53
3

Just for the sake of a solution using overlayarea

\documentclass{beamer}
\usepackage{tikz}
\usepackage{ifthen}
\usetikzlibrary{overlay-beamer-styles}
\mode<presentation> {
    \usetheme{Boadilla}

    \setbeamertemplate{footline}{}% get rid of footer completely 
}

\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{amssymb, mathtools, amsfonts}

\definecolor{MyColor1}{rgb}{0.24, 0.59, 0.32}
\definecolor{MyColor2}{rgb}{0.85, 0.49, 0.19}
\definecolor{MyColor3}{rgb}{0.22, 0.42, 0.69}


\usefonttheme{serif}

\begin{document}

\begin{frame}\frametitle{Examples}
    \begin{overlayarea}{\textwidth}{0.5\paperheight}

        \begin{center}
            \begin{tabular}{c|c}
                \onslide<1->{%
                    $\langle\alpha,\beta\rangle = \langle\beta,\alpha\rangle =-1$ 
                    & $3\langle\alpha,\beta\rangle= \langle\beta,\alpha\rangle=-3$\\\midrule
                    & \\
                    \begin{tikzpicture}[scale=0.7, every node/.style={transform shape}]
                        \draw (-2,-2) rectangle (2,2);
                        \node (alpha) at (1.2,0) {$\alpha$};
                        \node (beta) at (120:1.2) {$\beta$};
                        \draw[->] (0,0) -- (0:1);
                        \draw[->] (0,0) -- (120:1);
                        \only<1>{
                            \foreach \angle in {60,180,240,300}{
                                \draw[->] (0,0) -- (\angle:1);
                                }
                                }
                                \draw[MyColor1] (0.5,0) arc (0:120:0.5);
                                \draw[fill=MyColor1, opacity=0.3] (0,0) -- (0.5,0) arc (0:120:0.5) -- cycle;
                            \end{tikzpicture} &
                            \begin{tikzpicture}[scale=0.7, every node/.style={transform shape}]
                                \draw (-2,-2) rectangle (2,2);
                                \node (alpha) at (1.2,0) {$\alpha$};
                                \node (beta) at (150:1.9) {$\beta$};
                                \draw[->] (0,0) -- (150:1.7320);
                                \draw[->] (0,0) -- (0:1);
                                \only<1>{
                                    \foreach \angle in {30,60,90,120,180,210,240,270,300,330}{
                                        \pgfmathsetmacro{\bigradius}{sqrt(3)}
                                        \ifthenelse{\angle=30 \OR 
                                        \angle=90 \OR 
                                        \angle=150 \OR 
                                        \angle=210 \OR
                                        \angle=270 \OR 
                                        \angle=330}{
                                            \draw[->] (0,0) -- (\angle:\bigradius);
                                            }{
                                                \draw[->] (0,0) -- (\angle:1);
                                                };
                                                }
                                                }
                                                \draw[MyColor1] (0.5,0) arc (0:150:0.5);
                                                \draw[fill=MyColor1, opacity=0.3] (0,0) -- (0.5,0) arc (0:150:0.5) -- cycle;
                                            \end{tikzpicture}\\
                                            & \\}%
            \only<2->{%
                \only<3>{%
                    $\begin{pmatrix*}[r] \hphantom{-2}  & \hphantom{-1}\\ 
                        \hphantom{-1} & \hphantom{-2}
                    \end{pmatrix*}$}%
                    \only<4->{%
                        $\begin{pmatrix*} 
                            \only<4->{-2}  & \only<5->{\color<5->{MyColor1}{-1}}\\ 
                            \only<5->{\color<5->{MyColor1}{-1}} & \only<4->{-2}
                        \end{pmatrix*}$}
                        & 
                        \only<3>{%
                            $\begin{pmatrix} \hphantom{-2}  & \hphantom{-1}\\ 
                                \hphantom{-1} & \hphantom{-2}
                            \end{pmatrix}$}%
                            \only<4->{%
                                $\begin{pmatrix*}[r] \only<4->{-2}  & \only<5->{\color<5->{MyColor1}{-1}}\\ 
                                    \only<5->{\color<5->{MyColor1}{-3}} & \only<3->{-2}
                                \end{pmatrix*}$}%
                                }%
                            \end{tabular}
                        \end{center}
                    \end{overlayarea}
                    \end{frame}
                    \end{document}
BambOo
  • 8,801
  • 2
  • 20
  • 47