pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.15k stars 108 forks source link

Beamer footers disappear when using TikZ with image overlay #1366

Closed christopherbabcock closed 4 weeks ago

christopherbabcock commented 4 weeks ago

Brief outline of the bug

When overlapping/overlaying images in a Beamer presentation, the footer generally disappears without much work around. I have included two slides below. The first frame does not display the footer. After the pause and second image displays, the footer appears. The second frame shows a work around with more items hard coded to force the footer to display with the first image but requires manual manipulation and placing of the image anchoring. Can TikZ operate correctly with footers displaying?

Minimal working example (MWE)

\documentclass[ 11pt]{beamer}

\graphicspath{{img/}} % Specifies where to look for included images (trailing slash required) \usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule for better rules in tables \usepackage{graphicx} % Allows including images \usepackage{multirow} \usepackage{array} \usepackage{bookmark} \usepackage{amssymb} \usepackage{tikz} \usepackage{cancel} \usepackage{physics} \usepackage{amsmath}

%---------------------------------------------------------------------------------------- % SELECT LAYOUT THEME %---------------------------------------------------------------------------------------- \usetheme{Boadilla}

%---------------------------------------------------------------------------------------- % SELECT FONT THEME & FONTS %---------------------------------------------------------------------------------------- \usefonttheme{default} % Typeset using the default sans serif font

%---------------------------------------------------------------------------------------- % SELECT OUTER THEME %---------------------------------------------------------------------------------------- \useoutertheme{miniframes}

%---------------------------------------------------------------------------------------- % PRESENTATION INFORMATION %---------------------------------------------------------------------------------------- \title[Topic]{Subject} \author[author]{author's name} \institute[Org]{Org Name} \date[September 30, 2024]{September 30, 2024}

%---------------------------------------------------------------------------------------- % DOCUMENT %---------------------------------------------------------------------------------------- \begin{document}

%-----------------------------------------------

\begin{frame} %{Vertical alignment (center)} \frametitle{Slide Title} % create a center environment, so that the contents appear at the center of the frame \begin{center} \begin{tikzpicture} {\node (img1) {\includegraphics[height=4cm]{img/imgA.jpg}};}

        \pause

        {\node (img2) at (img1.south east)
        {\includegraphics[height=4.5cm]{img/imgB.JPG}};}

    \end{tikzpicture}
\end{center}

\end{frame}

%-----------------------------------------------

\begin{frame} \frametitle{Slide Title} \begin{tikzpicture}[remember picture,overlay] \only<1->{\node[anchor=north west] (img1) at ([xshift=0.4cm,yshift=-2.5cm]current page.north west) {\includegraphics[height=4cm]{img/imgA.jpg}};}

    \only<2>{\node (img2) at (img1.south east)
        {\includegraphics[height=4.5cm]{img/imgB.JPG}};}
\end{tikzpicture}

\end{frame}

%-----------------------------------------------

\end{document} TikZ_Troubleshooting.pdf

hmenke commented 4 weeks ago

This is not a MWE.

christopherbabcock commented 4 weeks ago

This is not a MWE.

@hmenke Can you tell me what is incorrect about my post?

hmenke commented 4 weeks ago

You considering this a "post" would be top of the list, I guess. Please use the community forums for these kinds of discussions, such as https://tex.stackexchange.com/

hmenke commented 4 weeks ago

Apologies for my rather discouraging tone yesterday.

Here is what your example would look like as a minimal working example (MWE). The TeX Live distribution includes a couple of example images that can be used with \includegraphics directly without further ado.

\documentclass{beamer}
\usetheme{Boadilla} % some theme with footer

\usepackage{graphicx}
\usepackage{tikz}

\begin{document}

\begin{frame}
  \begin{tikzpicture}
    \node (img1) {\includegraphics[height=4cm]{example-image-a}};
    \pause
    \node (img2) at (img1.south east) {\includegraphics[height=4cm]{example-image-b}};
  \end{tikzpicture}
\end{frame}

\end{document} 
Frame 1 Frame 2
test-1 test-2

The problem is that \pause is not smart enough, i.e. there is no special handling of \pause inside a tikzpicture implemented in beamer. If at all, this is a bug in beamer. Here are some relevant discussions from the community forums:

The easiest workaround for this problem is to explicitly tell beamer what to show on what slide with the \onslide command and using overlays:

\documentclass{beamer}
\usetheme{Boadilla} % some theme with footer

\usepackage{graphicx}
\usepackage{tikz}

\begin{document}

\begin{frame}
  \begin{tikzpicture}
    \onslide<+->{\node (img1) {\includegraphics[height=4cm]{example-image-a}};}
    \onslide<+->{\node (img2) at (img1.south east) {\includegraphics[height=4cm]{example-image-b}};}
  \end{tikzpicture}
\end{frame}

\end{document} 
Frame 1 Frame 2
test-1 test-2
christopherbabcock commented 1 week ago

I appreciate your very thorough response @hmenke. After looking at some forums, I thought it was a bug, which is why I didn't post to a forum. Again, thanks for providing a detailed response and guidance for what I should post in the future should I have an issue. Much appreciated!