6

I'm working on a presentation in Beamer, I have a tikz flow chart that I want to repeat after a block on the chart is handeld in the presentation. To make it visually easy for the users I would like to highlight the next block I'm going to talk about and dim the blocks that I've already discussed.

I figured out how to create an alert style for the block that should be highlighted. Below is my code.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}
\usepackage{xcolor}


\definecolor{uablue}{RGB}{0,61,100}
\colorlet{uablue100}{uablue}
\colorlet{uablue75} {uablue!75!white}
\colorlet{uablue50} {uablue!50!white}
\colorlet{uablue25} {uablue!25!white}
\colorlet{uablue10} {uablue!10!white}
\colorlet{uablue5}  {uablue!5!white}

\definecolor{uared}{RGB}{126,0,47}
\colorlet{uared100}{uared}
\colorlet{uared75} {uared!75!white}
\colorlet{uared50} {uared!50!white}
\colorlet{uared25} {uared!25!white}
\colorlet{uared10} {uared!10!white}
\colorlet{uared5}  {uared!5!white}
\begin{document}

\begin{frame}
\label{overview}
\frametitle{Overview}
\begin{figure}
\centering
\tikzstyle{block} = [rectangle, draw, fill=blue!25,text width=4em, text centered, rounded corners, minimum height=2em, line width=1pt ]
\tikzstyle{line} = [draw, -latex', line width=1pt]
\tikzstyle{alert} = [text=red, fill=red!25, draw=red]

\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [block, alert] (client) {Web Client};
    \node [block, right of=client, node distance=3cm] (python) {Python Service};
    \node [block, right of=python, node distance=3cm] (wavefront) {Wavefront};
    \node [block, above of=wavefront] (AMCL) {AMCL};
    \node [block, below of=wavefront] (VFH) {VFH};
    % Draw edges
    \path [line] (client) -> (python);
    \path [line] (python) -> (client);
    \path [line] (python) -- (wavefront);
    \path [line] (wavefront) -- (AMCL);
    \path [line] (AMCL) -- (python);
    \path [line] (wavefront) -- (VFH);
\end{tikzpicture}
\end{figure}
\end{frame}

\end{document}

So the idea is that I only define the tikzfigure once and when I use \againframe I can select which block should be highlighted and which should be dimmed. I've looked at other examples but they wanted to highlight different parts in sequential frames. I use this frame as my 'overview frame'

EDIT: I have my overview frame, then some other frames and then I want to repeat my overview frame again using \againframe and select a different block to highlight.

thanks!

3
  • 2
    Could you please provide a complete MWE (minimal working example). The colors are not defined, so one can't really run your example. May 12, 2013 at 10:28
  • 1
    What @UweZiegenhagen said. I would have been able to provide an answer sooner if I had not needed to use detective work to know that I would need to load the positioning and arrows libraries, and where the colors come from. The ideal MWE should include everything from \documentclass to \end{document} (hence W for "working.") May 12, 2013 at 10:41
  • I'm sorry I forgot to include everything, next time I'll add everything in the MWE :)
    – DanFritz
    May 12, 2013 at 10:55

1 Answer 1

8

You can adapt this answer to How to make beamer overlays with Tikz node:

\tikzset{onslide/.code args={<#1>#2}{%
  \only<#1>{\pgfkeysalso{#2}} % \pgfkeysalso doesn't change the path
}}
\tikzset{alt/.code args={<#1>#2#3}{%
  \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
}}
\tikzset{temporal/.code args={<#1>#2#3#4}{%
  \temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}} % \pgfkeysalso doesn't change the path
}}

This allows you to put for instance temporal=<overlay specification>{before}{during}{after} in the keyval list anywhere in a TikZ command. onslide works the same way with \only and I included \alt to round out the set.

Here is the complete code:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\usepackage{xcolor}

\definecolor{uablue}{RGB}{0,61,100}
\colorlet{uablue100}{uablue}
\colorlet{uablue75} {uablue!75!white}
\colorlet{uablue50} {uablue!50!white}
\colorlet{uablue25} {uablue!25!white}
\colorlet{uablue10} {uablue!10!white}
\colorlet{uablue5}  {uablue!5!white}

\definecolor{uared}{RGB}{126,0,47}
\colorlet{uared100}{uared}
\colorlet{uared75} {uared!75!white}
\colorlet{uared50} {uared!50!white}
\colorlet{uared25} {uared!25!white}
\colorlet{uared10} {uared!10!white}
\colorlet{uared5}  {uared!5!white}

\tikzset{onslide/.code args={<#1>#2}{%
  \only<#1>{\pgfkeysalso{#2}} % \pgfkeysalso doesn't change the path
}}
\tikzset{alt/.code args={<#1>#2#3}{%
  \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
}}
\tikzset{temporal/.code args={<#1>#2#3#4}{%
  \temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}} % \pgfkeysalso doesn't change the path
}}

\begin{document}
\begin{frame}<1>[label=overview]
\frametitle{Overview}
\begin{figure}
\centering
\tikzstyle{block} = [rectangle, draw, fill=uablue25, 
    text width=4em, text centered, rounded corners, minimum height=2em, line width=1pt ]
\tikzstyle{line} = [line width=1pt, -triangle 45]
\tikzstyle{alert} = [text=uared100, fill=uared25, draw=uared100]
\tikzstyle{dim} = [text=uablue25, fill=uablue5, draw=uablue25]

\begin{tikzpicture}[node distance=1.5cm, auto]
    % Place nodes
    \node [block,onslide=<2->{dim}] (client) {Web Client};
    \node [block,onslide=<2->{dim}] (python) [right of=client, node distance=3cm] {Python Service};
    \node [block,onslide=<2->{dim}] (wavefront) [right of=python, node distance=3cm] {Wavefront};
    \node [block,onslide=<2->{dim}] (AMCL) [above of=wavefront] {AMCL};
    \node [block,temporal=<2>{}{alert}{dim}] (VFH) [below of=wavefront] {VFH};
    \node [block,onslide=<2->{dim}] (laser) [above right=0.5cm and 1.2cm of AMCL] {Laser};
    \node [block,onslide=<2->{dim}] (dash7) [right of=AMCL, node distance=3cm] {DASH7};
    \node [block,onslide=<2->{dim},temporal=<3>{}{alert}{dim}] (robot) [right of=wavefront, node distance=3cm] {Robot};
    % Draw edges
    \draw [line] (client.east) -> (python.west);
    \draw [line] (python) -> (client);
    \draw [line] (python) -- (wavefront);
    \draw [line] (AMCL) -- (wavefront);
    \draw [line] (AMCL) edge[out=180,in=90] (python);
    \draw [line] (python) edge[out=270,in=180] (VFH);
    \draw [line] (wavefront) -- (VFH);
    \draw [line] (laser) -> (AMCL);
    \draw [line] (dash7) -> (AMCL);
    \draw [line] (robot) -> (AMCL);
    \draw [line] (VFH) edge[out=0,in=270] (robot);
\end{tikzpicture}
\end{figure}
\end{frame}

\begin{frame}{Introductory stuff}
\begin{itemize}[<+->]
\item Stuff
\item Stuff
\item Stuff
\item Stuff
\end{itemize}
\end{frame}

\againframe<2>{overview}

\begin{frame}{Stuff about VFH}
\begin{itemize}[<+->]
\item Stuff
\item Stuff
\item Stuff
\item Stuff
\item Stuff
\end{itemize}
\end{frame}

\againframe<3>{overview}

\begin{frame}{Stuff about Robot}
\begin{itemize}[<+->]
\item Stuff
\item Stuff
\item Stuff
\end{itemize}
\end{frame}

\end{document}

sample code output

7
  • Oke when using your code I get 8 slides and all the different blocks are highlighted. But I asked if its possible to use \againframe so I could invoke the tikz diagram again but with another block highlighted.
    – DanFritz
    May 12, 2013 at 11:05
  • I think what the OP really needs is not an alternative, but rather something temporal; say: normal block blue with black text, highlighted block red with red text and "dim" block gray with blue text. Some months ago I was thinking to implement this (switch from \alt to \temporal) to the styles defined in Highlighting in beamer using TikZ nodes, but I gave up at some point (don't remember the point though). May 12, 2013 at 11:13
  • So I'm not looking for sequentially frames, I want to invoke the frames when I want. So for example I have my overview frame, everything is blue, 5 frames later I want to repeat my overview frame but now select the VFH block, because thats the block I'm going to discuss. 6 slides later I repeat my overview frame, make the VFH block dim and select the robot block, and so on and on.
    – DanFritz
    May 12, 2013 at 11:18
  • 1
    @DanFritz Hope this is more useful. May 12, 2013 at 12:12
  • 1
    @DanFritz: I just noticed that I had the Robot node visible normally while VFH was highlighted. I updated with an extra onslide key to fix. May 12, 2013 at 12:37

You must log in to answer this question.

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