There is a robust mechanism for this already in beamer presentations... You need to use the symbols +
and .
.
For more information about them I will refer you to the beamer manual, section 9.6.4.
For our purposes, I will provide a small explanation.
Small explanation
Basically, whenever you write a +
sign inside the overlay specification, like so:
<+>
A counter called beamerpauses
is updated, adding one unit to it. After the counter is updated, it replaces the +
sign with the value of the counter beamerpauses
.
<1>
If you write a number in parenthesis after the +
sign, it shifts the value by that much.
<+-+(2)>
will be replaced by
<1-3>
There is an issue though, even if you have more than one +
sign inside one specification, it will only updates the value of the counter once for each overlay specification. (It assumes you always want to just add "one" frame)
Therefore, you have to update the value manually afterwards.
In our example, we wanted to have a pause that lasted 3 frames. Therefore, we need to add two extra pauses after our \only<>
command is done:
\only<+-+(2)>{
%your code here
}
\addtocounter{beamerpauses}{2}
%continue
Solution
With that in mind, now we can use the relative coordinates, as showcased on this example:
The first frame
shows how you can re-write your slide to use relative overlay specifications.
The second frame
of this beamer presentation showcases how now it becomes easy to add some other slide in-between, without having to rewrite the entire frame.
With that:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{First try}
\begin{tikzpicture}
\only<+-+(2)>{
\node {First};
}
\addtocounter{beamerpauses}{2}
\only<+-+(1)>{
\node {Second};
}
\addtocounter{beamerpauses}{1}
\only<+>{
\node {Third};
}
\end{tikzpicture}
\end{frame}
\begin{frame}
\frametitle{Intermediate step}
\begin{tikzpicture}
\only<+-+(2)>{
\node {First};
}
\addtocounter{beamerpauses}{2}
\only<+-+(1)>{
\node {Second};
}
\addtocounter{beamerpauses}{1}
\only<+-+(3)>{
\node {Between second and third};
}
\addtocounter{beamerpauses}{3}
\only<+>{
\node {Third};
}
\end{tikzpicture}
\end{frame}
\end{document}
If you have multiple elements, not just your tikz picture:
If you have multiple elements, not just the tikz picture, and you want to use relative coordinates for all of those elements that come together on the same frame. You can update the beamerpauses
counter to zero before each "element" starts.
% itemize using relative overlay... with + and the like.
\setcounter{beamerpauses}{0}
\begin{tikzpicture}
\only<+-+(2)>{
%your code here
}
\addtocounter{beamerpauses}{2}
%continue
\end{tikzpicture}

.
,+
etc. – samcarter_is_at_topanswers.xyz Jan 26 '18 at 20:24