2

I have a beamer doc in which there are a few section and subsection title slides. Those slides do not have a page number footer, and the footer page numbering do not take them into account.

In the example below, when I use label{page:mylabel} combined with {page:mylabel}, I get p5, however, mylabel is on p2 according to the footer page number.

How can I make {page:mylabel} reference the correct page number at the footer (in this case p2)?

\documentclass{beamer}
\usetheme{metropolis} % Use metropolis theme
\title{A minimal example}
\date{\today}
\author{Matthias Vogelgesang}
\institute{Centre for Modern Beamer Themes}
\begin{document}
    \maketitle
    \section{First Section}
    \begin{frame}{First Slide}
        Hello, world!
    \end{frame}
    \section{Second Section}
    \begin{frame}{Second Slide}
        Hello, world!
        \label{page:mylabel}
    \end{frame}
    \begin{frame}{Third Slide}
        A reference to p\pageref{page:mylabel}
    \end{frame}
\end{document}
Skyork
  • 1,147
  • As you can imagine, it is next-to-impossible to reproduce the issue without an explicit example. –  Feb 28 '19 at 04:28
  • @marmot, sorry, my bad. A MWE is added to illustrate the problem – Skyork Feb 28 '19 at 06:05
  • Thanks! Is it possible that you confuse page number with frame number (see e.g. https://tex.stackexchange.com/a/452863/121799 but there are most likely other threads on this). –  Feb 28 '19 at 06:10

1 Answers1

1

As @marmot already explained, \pageref won't give the same numbers as shown in the footline because there the framenumber is shown.

However beamer has an easy method to reference frames by their frame number: You just have to label the frame with \begin{frame}[label=mylabel] and then you can use \ref{mylabel} and get the correct frame number

\documentclass{beamer}
\usetheme{moloch}% modern fork of the metropolis theme
\setbeamertemplate{page number in head/foot}[framenumber]
\title{A minimal example}
\date{\today}
\author{Matthias Vogelgesang}
\institute{Centre for Modern Beamer Themes}
\begin{document}
    \maketitle
    \section{First Section}
    \begin{frame}{First Slide}
        Hello, world!
    \end{frame}
    \section{Second Section}
    \begin{frame}[label=mylabel]{Second Slide}
        Hello, world!
    \end{frame}
    \begin{frame}{Third Slide}
        A reference to p\ref{mylabel}
    \end{frame}
\end{document}