I want to run a command (writing page ranges to a file) at the end of each frame.
I can capture the page the frame started with at the beginning with \AtBeginEnvironment{frame}{\global\edef\framebeginpage{\thepage}}
.
But if I try to write the page range at the end of the frame, it does not work:
It seems that \AtEndEnvironment{frame}{\immediate\write\notesfile{\framebeginpage-\thepage}}
doesn't get executed.
Is there anything I can do instead?
MMWE:
\documentclass{beamer}
\usepackage{etoolbox}
\newwrite\notesfile
\AtBeginEnvironment{frame}{\global\edef\framebeginpage{\thepage}}
\AtEndEnvironment{frame}{\immediate\write\notesfile{\framebeginpage-\thepage}}
\begin{document}
\immediate\openout\notesfile=frames.txt
\immediate\write\notesfile{Begin}
\begin{frame}
\begin{itemize}[<+->]
\item foo
\item bar
\item baz
\end{itemize}
\end{frame}
\begin{frame}
\begin{itemize}[<+->]
\item foo
\item bar
\item baz
\end{itemize}
\end{frame}
\immediate\write\notesfile{End}
\immediate\closeout\notesfile
\end{document}