5

Let's say this is my presentation:

\documentclass{beamer}

\usetheme{Berlin}

\begin{document}

\section{Section}
\subsection{The beginning}
\frame{\frametitle{Begin}
    some text
}

\frame{\frametitle{Begin}
    some text
}

\frame{\frametitle{Begin}
    some text
}

\end{document}

I'd like the first slide's title to be Begin (part 1), the second slide's title Begin (part 2) and the third one Begin (part 3). I can simply type the extra (part x) with only 3 frames, but it gets quite a lot of work when one's working with a lot more frames.

How can I do this?

2
  • Will there be slides in between part 1 and part 2?
    – Herr K.
    Dec 6, 2013 at 20:39
  • @KevinC: Not for the moment, but I'd like the titles to be "renumbered" when I add frames between them in the future.
    – Jeroen
    Dec 6, 2013 at 20:44

1 Answer 1

3

If there are no slides between part x and part (x+1), then you can use the current page number minus the page where subsection starts plus 1. The following macro does the calculation:

\newcommand\subsectnum{%
  (part~\number\numexpr \insertpagenumber-\insertsubsectionstartpage+1\relax)%
}

Full Code

\documentclass{beamer}

\usetheme{Berlin}

\newcommand\subsectnum{%
  (part~\number\numexpr \insertpagenumber-\insertsubsectionstartpage+1\relax)%
}

\begin{document}

\section{Section}
\subsection{The beginning}
\frame{\frametitle{Begin \subsectnum}
    some text
}

\frame{\frametitle{Begin \subsectnum}
    some text
}

\frame{\frametitle{Begin \subsectnum}
    some text
}

\end{document}

Output

enter image description here

6
  • Absolutely perfect and very elegant! Thanks a lot!
    – Jeroen
    Dec 6, 2013 at 21:00
  • If you get the occasion, perhaps you should post an output of the updated code, so as not to confuse future visitors of this page.
    – jub0bs
    Dec 6, 2013 at 21:13
  • @Jubobs: Done. Thanks for making the edits :) It takes an experienced TeXnician to notice that spurious space ;)
    – Herr K.
    Dec 6, 2013 at 21:29
  • @KevinC Thanks, but I'm more an "aspiring TeXnician". One day, maybe. No problem. Keep up the good work.
    – jub0bs
    Dec 6, 2013 at 21:37
  • @HerrK. there is any way to do this if exists pages between the slides? There is not insertsubsectionstartframe. May 10, 2015 at 15:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .