# [Tex/LaTex] How to insert overlays in latex beamer

beameroverlays

I have as many as 15-20 overlays within a frame. I am trying to highlight certain states in a state diagram. The problem is sometimes I would want to add an overlay, say between 5 and 6. I would need to increase the counter of all the overlays following 6 which can be quite annoying. I considered numbering overlays in multiples of 5 just so that I can insert an overlay later. However, each number would result in a new slide which is highly undesirable. Another solution is creating a separate frame. Is there a better way to handle this? Am I missing something obvious?

Here's an example of using incremental overlay specifications with offsets.

\documentclass{beamer}
\begin{document}
\begin{frame}[label=integral-of-x]{Example: Integral of $f(x) =x$}
\begin{example}<+->
Find $\int_0^3 x\,dx$.
\end{example}
\begin{solution}<+->
\action<.->{For any $n$ we have $\alert<.(5)>{\Delta x = \frac{3}{n}}$ and for each $i$ between $0$ and $n$, $\alert<.(4)>{x_i = \frac{3i}{n}}$.}
\action<+->{For each $i$, take $x_i$ to represent $f$ on the $i$th interval.}
\action<+->{So}
\begin{align*}
\action<.->{\int_0^3 x\,dx = \lim_{n\to\infty} R_n }
\action<+->{ = \lim_{n\to\infty}\sum_{i=1}^n

Basically, <+-> means increment the pause count and apply this from that pause count onwards. <.-> means from the current pause count onwards (doesn't really do anything, but useful to be organized). And things like <.(5)> mean at the current pause count plus five. So you can insert things before or after without having to change pause counts explicitly. Of course, if you refer to overlays with <.> and <.(5)> and you want to insert something in between, you will need to change <.(5)> to <.(6)> or something similar.
My workflow in creating complex sequences like this is usually to map it out on paper. I will write down what should come on, go off, or change at each step. From there it's a matter of guess-and-check. The \includeonlyframes preamble command allows you to focus on one frame while developing.