The label
key of the beamer
frame
uses the \label<>
macro internally. This uses the normal \label
macro of LaTeX which uses the \@currentlabel
macro for the label text. This macro is set by \refstepcounter
which is used by sectioning macros, captions and also frames. It uses the content of the corresponding \the...
macro, so setting \theframenumber
, not \insertframenumber
is important.
Note that \insertframenumber
is by default set to \@arabic\c@framenumber
which is the lower-level version of \arabic{framenumber}
, i.e. the default definition of \theframenumber
. So my first step was to redefine \theframenumber
and make \insertframenumber
use it:
\renewcommand{\theframenumber}{\thesection-\arabic{framenumber}}
\renewcommand{\insertframenumber}{\theframenumber}
However, this doesn't work. After some debugging I found out that actually the subsectionslide
counter is used for the label
key. I have no idea why. Maybe the \refstepcounter{subsectionslide}
is processed after the \refstepcounter{framenumber}
. The related file is beamerbaseframe.sty
.
It doesn't like it in the code, but I don't had time to follow all the conditionals in it.
Anyway, the solution is to also(?) set \thesubsectionslide
to \thesection-\arabic{framenumber}
or \theframenumber
. Then the references are displayed as you want. However, references to the subsectionslide
(whatever this is exactly) might be wrong.
\documentclass{beamer}
\makeatletter
\renewcommand{\insertframenumber}{\theframenumber}
\renewcommand{\theframenumber}{\thesection-\arabic{framenumber}}
\renewcommand{\thesubsectionslide}{\thesection-\arabic{framenumber}}
\setbeamertemplate{headline}[text line]{This is frame: \insertframenumber}
\AtBeginSection{\setcounter{framenumber}{0}}
\begin{document}
\section{One}
\subsection{a}
\begin{frame}{First Frame in Section One}
Slide content\par
\pause
More content
\end{frame}
\subsection{b}
\begin{frame}[label=interesting]{Second Frame in Section One -- The one to crossref to}
Slide content
\end{frame}
\section{Two}
\begin{frame}{First Frame in Section Two}
Now I want to crossref to interesting slide by section-framenumber (that is, somehow generate \textbf{1-2})
\begin{itemize}
\item \textbackslash{}ref yields: \ref{interesting}, apparently that is the frame number
\item \textbackslash{}page yields: \pageref{interesting}, apparently that is the PDF page number
\item \textbackslash{}autoref yields: \autoref{interesting}, apparently that is the frame number again
\item nothing there that yields \textbackslash{}thesection of our target label?
\end{itemize}
\end{frame}
\end{document}
You may be looking for the internal counter
\beamer@slideinframe
as defined in beamerbasedecode.sty
: It is the value beamer
consults when encountering something like \only<1,3-5>{...}
to check whether to display or to hide the content.
A small demonstration on how to access this value:
\documentclass{beamer}
\makeatletter
\newcommand*{\overlaynumber}{\number\beamer@slideinframe}
\makeatother
\begin{document}
\begin{frame}
\only<1>{ Some internal number must be \overlaynumber\ in here }
\only<2>{ But \overlaynumber\ in here }
\only<1-5>{Graphic \overlaynumber}
\end{frame}
\end{document}
Best Answer
3 different possibilities how not to increase the frame counter from one page to the next:
Excluding a frame from contributing to the frame counter
Manually adjusting the frame counter
Not using different frames