0

I was working on a beamer presentation and wanted to show in three successive frames shaded images with the first one being overlayed in the first two frames. See below for an example:

enter image description here

The idea is to show in the first two frame different aspects concerning the first picture, hence the overlayarea, whereas the last frame shows a different concept always pertaining the same image as a whole, for this reason I like the shading.

I mostly worked following these two examples:

  1. Keep text in place while replacing one element with another
  2. How to shade an image from includegraphics in beamer?

however, as you can see, in the last frame the first part of the image (which should be shaded) is missing... anyone has any idea why? Taken independently the two approaches work perfectly but when trying to combine them something goes wrong.

Ideally, in the last frame would be nice to show both picture A and B overlapped and shaded if possible. Otherwise, just B works fine as its the previous step in the process.Any help is much appreciated, thanks in advance!

MWE

\documentclass[169]{beamer}
\usetheme{Boadilla}

\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
    opinvisible/.style={opacity=0.2},
    visible on/.style={alt={#1{}{opinvisible}}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
    },
  }

\definecolor{bground}{HTML}{005EB8}
\definecolor{anti-flashwhite}{rgb}{0.95, 0.95, 0.96}

\makeatletter
\setbeamertemplate{background canvas}{%
        {\begin{tikzpicture}
        \useasboundingbox (0,0) rectangle (\paperwidth,\paperheight);
        \fill [color=bground] (0,0.868\paperheight) rectangle (\paperwidth,\paperheight);
        \end{tikzpicture}}
}
\makeatother

\makeatletter
\setbeamertemplate{headline}{%
        {\hfill\includegraphics[width=.5in,keepaspectratio]{example-image}\hspace{0.05in}\vspace{-.5in}}
}
\makeatother

\setbeamercolor{frametitle}{fg=anti-flashwhite}
\addtobeamertemplate{frametitle}{\vskip-.08in}{}

\begin{document}

\begin{frame}
\frametitle{Paths, Walks and SNARLs}
\begin{tikzpicture}[node distance=0in]

\node[visible on=<1>] (upper)
 {\includegraphics[width=.25\textwidth,keepaspectratio]{example-image-a}};

\node[visible on=<2>] (upper)
 {\includegraphics[width=.25\textwidth,keepaspectratio]{example-image-b}};

\node[visible on=<3>,below=of upper] (lower)
 {\includegraphics[width=.25\textwidth,keepaspectratio]{example-image-c}};

\end{tikzpicture}

\end{frame}

\end{document}

EDIT without overlayarea and \only{} command

As you can see, the problem here is in slide 1 where A and B overlap... I just need A to be shown. enter image description here

7
  • 1
    Most of the code isn't related to the problem at all Commented Jul 10 at 22:53
  • 2
    With \only<1>{...} you remove the node from all other overlays. If you want to show the image on another overlay, don't just specify 1. (I don't understand why you have this if you also control the appearance with visible on=...) Commented Jul 10 at 23:02
  • 2
    Don't use overlayarea inside of the tikzpicture. Move it outside. Commented Jul 10 at 23:03
  • You can set different options for what you want to happen when content is not shown e.g. visible vs invisible vs opaque vs translucent, so probably you want to choose the latter. You already are doing this with visible on, but then you're overriding it with \only which makes it disappear altogether. I don't understand how the code you show can give the result you show, though.
    – cfr
    Commented Jul 11 at 0:38
  • @samcarter_is_at_topanswers.xyz and @cfr all comments are fair, I've been doing some experiments as I said and just using the `visible on=... I have the undesired effect of picture A being overlayed o picture B. This is not good since I don't want to show that information in that frame. I edited the post, maybe this helps to narrow down the issue.
    – Matteo
    Commented Jul 11 at 6:33

1 Answer 1

1

You can use \node<2->{...} to remove the image from the first overlay:

\documentclass{beamer}
\usetheme{Boadilla}

\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
    opinvisible/.style={opacity=0.2},
    visible on/.style={alt={#1{}{opinvisible}}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
    },
  }

\begin{document}

\begin{frame}
\frametitle{Paths, Walks and SNARLs}
\begin{tikzpicture}[node distance=0in]

\node[visible on=<1>] (upper)
 {\includegraphics[width=.25\textwidth,keepaspectratio]{example-image-a}};

\node<2->[visible on=<2>] (upper)
 {\includegraphics[width=.25\textwidth,keepaspectratio]{example-image-b}};

\node[visible on=<3>,below=of upper] (lower)
 {\includegraphics[width=.25\textwidth,keepaspectratio]{example-image-c}};

\end{tikzpicture}

\end{frame}

\end{document}

enter image description here

2
  • such a simple solution but I couldn't figure it out... sorry. Basically, with\node<2-> you subtract the overlay from the previous frame but not the following, whereas simply <2> restrict that specific image/element to the current slide form what I've seen. Thanks again!
    – Matteo
    Commented Jul 11 at 8:04
  • 1
    @Matteo 2- means "on all overlays starting with 2", while 2 means "only on overlay 2" Commented Jul 11 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .