3

So in my Beamer slides, I'm using this to highlight various parts of a tikz figure on different slides.

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{positioning,automata}

\tikzset{onslide/.code args={<#1>#2}{%
  \only<#1>{\pgfkeysalso{#2}}
}}
\tikzstyle{highlight}=[red,ultra thick]

\begin{document}
\begin{frame}
  \begin{figure}
    \centering
    \begin{tikzpicture}[->]
      \node[state, onslide={<1>{highlight}}, initial by arrow, initial text={}, initial where=above, label={above left:\(\varnothing\)}] (1) {\(s_1\)};
      \node[state, onslide=<1>{highlight}, label={above left:\(\{a\}\)}] (2) [right= of 1] {\(s_2\)};

      \draw[onslide={<2>{highlight}}] (1) edge node [above] {0.3} (2);
    \end{tikzpicture}
  \end{figure}
\end{frame}
\end{document}

Note: I'm using the tikz libraries positioning and automata.

It works fine for highlighting the nodes and the edge. However, on the next slides I want to be able to highlight:

  • The labels of the states
  • The labels of the edges (and optimally not highlight them on the second slide)
  • (optionally) the initial by arrow of s_1

I tried inserting onslide=... into label={...} for the states, but that gives the following error:

! Package PGF Math Error: Unknown function `onslide' (in 'onslide').
SideSwipe
  • 131

1 Answers1

2

I am not entirely sure which elements you want highlight, but if you just want to change the font colour of S_1 etc, use \textcolor<overlay>{color}{text}. So for example \textcolor<2>{green}{\(\varnothing\)} will change the colour to green on the second slide.

\documentclass{beamer}

\usepackage{tikz} \usetikzlibrary{positioning,automata}

\tikzset{onslide/.code args={<#1>#2}{% \only<#1>{\pgfkeysalso{#2}} }} \tikzset{highlight/.style={red,ultra thick}}

\begin{document} \begin{frame} \begin{figure} \centering \begin{tikzpicture}[->] \node[state, onslide={<1>{highlight}}, initial by arrow, initial text={}, initial where=above, label={above left:\textcolor<2>{green}{(\varnothing)}}] (1) {(s_1)}; \node[state, onslide=<1>{highlight}, label={above left:({a})}] (2) [right= of 1] {(s_2)};

  \draw[onslide={&lt;2&gt;{highlight}}] (1) edge node [above] {0.3} (2);
\end{tikzpicture}

\end{figure} \end{frame} \end{document}

enter image description here