add tag
topnush
Consider the following MWE:

```
\documentclass{beamer}

\usepackage{accents}

\usepackage{tikz}

\begin{document}


\begin{frame}[fragile]{}

\begin{itemize}[<+(1)->]
\item one
\item two
\item three
\end{itemize}
\pause
\uncover<4->{
First line:

\[
\foreach \x [count=\y] in {1,2,3,4,5,6,7,8,9}{
\alt<\y>{\underaccent{\bar}{\x}}{\x}
}
\]


\vskip 0.5cm

\hspace*{1cm}
\uncover<1-9>
{
 $S$ = \foreach [count=\y] \x in {{\{1\}},{\{1,2\}},{\{1,2,3\}},{\{1,4,3\}},{\{5,4,3\}},{\{5,6,3\}},{\{5,6,3\}},{\{5,6,3\}},{\{5,6,9\}}}{\only<\y>{\x}}\\
\hspace*{1.25cm}$\frac{s}{t}$ = \foreach [count=\y] \x in  {1,1,1,0.75,0.6,0.5,0.429,0.375,0.333}{\only<\y>{\x}}
}
}


\end{frame}
\end{document}
```

When it gets to First line I would like the counter to be back at 1 so that it underlines from the 1..9 instead of 5..9. Similarly for the two lines below they should be going from index 1, not 5. Is there any way to do that?
Top Answer
marmot
You can use the counter `beamerpauses` (I think).
```
\documentclass{beamer}
\usepackage{accents}
\usepackage{pgffor}

\begin{document}

\begin{frame}[fragile]{}

\begin{itemize}[<+(1)->]
\item one
\item two
\item three
\end{itemize}
\pause
First line:

\[\edef\myoffset{\number\value{beamerpauses}}
\foreach \x [count=\y from \myoffset] in {1,2,3,4,5,6,7,8,9}{
\alt<\y>{\underaccent{\bar}{\x}}{\x}
}
\]


\vskip 0.5cm

\hspace*{1cm}\edef\myoffsetB{\number\value{beamerpauses}}
$\begin{aligned}
S &= \foreach [count=\y from \myoffsetB] \x in 
{{\{1\}},{\{1,2\}},{\{1,2,3\}},{\{1,4,3\}},{\{5,4,3\}},{\{5,6,3\}},{\{5,6,3\}},{\{5,6,3\}},{\{5,6,9\}}}{%
\only<\y>{\x}}\\
\frac{s}{t} &= 
\foreach [count=\y from \myoffsetB] \x in  
{1,1,1,0.75,0.6,0.5,0.429,0.375,0.333}{\only<\y>{\x}}
\end{aligned}$
\end{frame}
\end{document}
```
![ani.gif](/image?hash=7167b1d7f6f109b48cc77accd06c19415fb92cab011a0404bf047cf4262eecb5)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.