2

I am showing a table one cell per slide and, once each row is completely shown, I use tikz to draw one arrow over the row.

While the cells are appearing, the table stays fixed on the same place of the slide, however, when the arrow is shown, the table moves (usually going up on the y-axis).

Do you know what I could do to keep the table fixed the whole time?

As an example, consider the code below, which produces this PDF.

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

\begin{frame}

\begin{table} \centering \begin{tabular}{|c|c|c|} \hline & $u = 1$ & $u = 2$ \ \hline $v = 1$ & \onslide<2-7>{ A } & \onslide<3-7>{ B } \ \hline $v = 2$ & \onslide<5-7>{ C } & \onslide<6-7>{ D } \ \hline \end{tabular} \end{table}

%% draw an arrow over the first row of the table \only<4>{ \begin{tikzpicture}[overlay,remember picture] \draw [->,thick,color=red] (5, 1.25) to (8, 1.25); \end{tikzpicture} } %% draw an arrow over the second row of the table \only<7>{ \begin{tikzpicture}[overlay,remember picture] \draw [->,thick,color=red] (5, 0.75) to (8, 0.75); \end{tikzpicture} }

\end{frame} \end{document}

  • Neither in your link, nor in the result when I compile your code, I can see any difference between the slides with the red arrow and without the arrow. – Bernard Oct 14 '20 at 13:23
  • @Bernard in this particular example, the table moves just a little. When I put the slides in full screen (presentation mode), the change is clear between the slides 3 --> 4 and 6 --> 7. Could you please try to check it in full-screen mode? – Hilder Vitor Lima Pereira Oct 14 '20 at 13:49
  • On my computer, if moves it is only a fraction of a point, so there must be something else. – Bernard Oct 14 '20 at 14:10
  • @Hilder Vitor Lima Pereira, Test this:\begin{tikzpicture}[overlay,remember picture] \only<4>{\draw [->,thick,color=red] (5, 1.25) to (8, 1.25);} \only<7>{\draw [->,thick,color=red] (5, 0.75) to (8, 0.75);} \end{tikzpicture} – M.Ahmadi Oct 14 '20 at 14:21
  • @M.Ahmadi that works! Do you have any idea of why that happens? By the way, if you want, please, turn this comment into an answer so that I can accept it (and help the statistics of this site about solved questions). – Hilder Vitor Lima Pereira Oct 14 '20 at 14:28
  • The point is the environment. Edit your file I write in response. – M.Ahmadi Oct 14 '20 at 14:31

1 Answers1

4

edit file Method 1:

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}

\newcommand{\tikzmark}[2]{% \tikz[overlay,remember picture,baseline] \node[anchor=base] (#1) {$#2$};}

\begin{document}

\begin{frame}

\begin{table} \centering \begin{tabular}{|c|c|c|} \hline & $u = 1$ & $u = 2$ \ \hline $v = 1$ & \tikzmark{a}{\onslide<2-7>{ A }} & \tikzmark{b}{\onslide<3-7>{ B }} \ \hline $v = 2$ & \tikzmark{c}{\onslide<5-7>{ C }} & \tikzmark{d}{\onslide<6-7>{ D }} \ \hline \end{tabular} \end{table} % \begin{tikzpicture}[overlay,remember picture] \only<4>{ \draw [->,thick,color=red] ([xshift=-1.5mm]a.west) -- ([xshift=10mm]b.east);} \only<7>{ \draw [->,thick,color=red] ([xshift=-1.5mm]c.west) -- ([xshift=10mm]d.east);} \end{tikzpicture}

\end{frame} \end{document}

edit file Method 2:

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}

\usetikzlibrary{tikzmark}

\begin{document}

\begin{frame}

\begin{table} \centering \begin{tabular}{|c|c|c|} \hline & $u = 1$ & $u = 2$ \ \hline $v = 1$ & \tikzmark{a}\onslide<2-7>{ A } & \onslide<3-7>{ B }\tikzmark{b} \ \hline $v = 2$ & \tikzmark{c}\onslide<5-7>{ C } & \onslide<6-7>{ D }\tikzmark{d} \ \hline \end{tabular} \end{table} % \begin{tikzpicture}[overlay,remember picture] \only<4>{ \draw [->,thick,color=red] ([xshift=-1.5mm,yshift=1.3mm]pic cs:a) -- ([xshift=10mm,yshift=1.3mm]pic cs:b);} \only<7>{ \draw [->,thick,color=red] ([xshift=-1.5mm,yshift=1.3mm]pic cs:c) -- ([xshift=10mm,yshift=1.3mm]pic cs:d);} \end{tikzpicture}

\end{frame} \end{document}

output TL2020: enter image description here

M.Ahmadi
  • 1,477