Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following minimal example comiles:

\documentclass[c]{beamer}

\usepackage{tikz,times}

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

\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}
\tikzstyle{StateNormal} = [fill=white]
\tikzstyle{StateSelected} = [fill=orange]

\coordinate (ONE) at (0,0);
\coordinate (TWO) at (4,0);
\coordinate (THREE) at (8,0);

\draw (ONE) -- (TWO) -| (THREE);

\draw
    node at (ONE)                      [StateSelected, visible on=<1>]{ONE}
    node at (ONE)                      [StateNormal, visible on=<2->]{ONE}
    node at (TWO)                      [StateSelected, visible on=<2>]{TWO}
    node at (TWO)                      [StateNormal, visible on=<3->]{TWO}
    node at (THREE)                    [StateSelected, visible on=<3>]{THREE}
    node at (THREE)                    [StateNormal, visible on=<4->]{THREE}
    ;
\end{tikzpicture}

%DO NOT INDENT THE END OF A FRAGILE FRAME
\end{frame}
\end{document}

I have a couple of problems with this example and i dont know how to go about solving them:

I define each node twice only so it has different properties on different slides. There is redundancy there and all i know how to fix it is a new command. It seems like a common problem - is there another standars solution?

    node at (ONE)                      [StateSelected, visible on=<1>]{ONE}
    node at (ONE)                      [StateNormal, visible on=<2->]{ONE}

My next problem is that there is always a connection between numbers. If i want to insert a slide at the front end i have to rename all the slides from there until the end.

    node at (ONE)                      [StateSelected, visible on=<1>]{ONE}
    node at (ONE)                      [StateNormal, visible on=<2->]{ONE}
    node at (TWO)                      [StateSelected, visible on=<2>]{TWO}
    node at (TWO)                      [StateNormal, visible on=<3->]{TWO}
    node at (THREE)                    [StateSelected, visible on=<3>]{THREE}
    node at (THREE)                    [StateNormal, visible on=<4->]{THREE}

If i insert here this would create a new list with huge renaming effort.

    node at (ZERO)                     [StateSelected, visible on=<1>]{ZERO}
    node at (ZERO)                     [StateNormal, visible on=<2->]{ZERO}
    node at (ONE)                      [StateSelected, visible on=<2>]{ONE}
    node at (ONE)                      [StateNormal, visible on=<3->]{ONE}
    node at (TWO)                      [StateSelected, visible on=<3>]{TWO}
    node at (TWO)                      [StateNormal, visible on=<4->]{TWO}
    node at (THREE)                    [StateSelected, visible on=<4>]{THREE}
    node at (THREE)                    [StateNormal, visible on=<5->]{THREE}

I would want to write:

    count = 1;      
    node at (ZERO)  [StateSelected, visible on=<(count)>]{ZERO}
    node at (ZERO)  [StateNormal, visible on=<(count+1)->]{ZERO}
    count ++;       
    node at (ONE)   [StateSelected, visible on=<(count)>]{ONE}
    node at (ONE)   [StateNormal, visible on=<(count+1)->]{ONE}
    count ++;       
    node at (TWO)   [StateSelected, visible on=<(count)>]{TWO}
    node at (TWO)   [StateNormal, visible on=<(count+1)->]{TWO}
    count ++;       
    node at (THREE) [StateSelected, visible on=<(count)>]{THREE}
    node at (THREE) [StateNormal, visible on=<(count+1)->]{THREE}

but i dont know how to write such statements in MikTex.

share|improve this question
    
For the second problem: have you read the beamer manual on overlay specs? You can use the special + and . symbols to mean "the next overlay" and "the current one" –  Bordaigorl Jul 9 at 16:19

1 Answer 1

up vote 5 down vote accepted

You can use \temporal instead of \alt to specify a "before" "on slide" and "after" style and use that directly to avoid duplication of nodes.

To avoid hardcoding of slide numbers just use the special overlay specification + which means "insert a new slide and refer to the new one as the reference for the spec":

\documentclass[c]{beamer}

\usepackage{tikz,times}

\tikzset{
    invisible/.style={opacity=0},
    temporal/.code args={<#1>#2#3#4}{
    \temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}
    },
  }

\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}
\tikzstyle{StateNormal} = [fill=white]
\tikzstyle{StateSelected} = [fill=orange]

\coordinate (ONE) at (0,0);
\coordinate (TWO) at (4,0);
\coordinate (THREE) at (8,0);

\draw (ONE) -- (TWO) -| (THREE);

\draw
    node at (ONE)   [temporal=<+>{invisible}{StateSelected}{StateNormal}]{ONE}
    node at (TWO)   [temporal=<+>{invisible}{StateSelected}{StateNormal}]{TWO}
    node at (THREE) [temporal=<+>{invisible}{StateSelected}{StateNormal}]{THREE}
    ;
\end{tikzpicture}

%DO NOT INDENT THE END OF A FRAGILE FRAME
\end{frame}
\end{document}

You can even make the syntax more readable by defining the following styles:

\tikzset{
    invisible/.style={opacity=0},
    normal/.style={fill=white},
    selected/.style={fill=orange},
    temporal/.code args={<#1>#2#3#4}{%
        \temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}
    },
    change style/.code args={start #1 then on <#2> to #3 and after to #4}{\temporal<#2>{\pgfkeysalso{#1}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}},
    reveal on/.style={change style=start invisible then on #1 to selected and after to normal},
    reveal/.style={reveal on=<+>}
  }

And your code becomes

\draw
    node at (ONE)   [reveal]{ONE}
    node at (TWO)   [reveal]{TWO}
    node at (THREE) [reveal]{THREE}
    ;

If you want something to be revealed on slide 2 you can use the style reveal on=<2> and if you want to make something visible only between slide 3 and 5 you can do change style=start invisible then on <3-5> to normal and after to invisible.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.