I wonder how to suffix equivalent frametitles with a counter or index. So for example, when I would have two slides with the same \frametitle (e.g. "Marvelous title"), it should result in

Marvelous title (1)
Marvelous title (2)

I know, adding the "(1)" and "(2)" manually is not much work, but I'm asking myself whether it could be done automatically.

  • 1
    You can check the option frametitle continuation for slides that don't have overlays. – percusse Aug 5 '12 at 20:40
  • @percusse Thanks, it seems that I also need the [allowframebreaks] flag for the relevant frames. However, although all frames also have a vertical top alignment [t], the continued frame aligns the text (also when it's exactly the same as on the previous slide) a little higher. Is this to be expected? – Ailurus Aug 5 '12 at 22:51
  • Edit: This also happens when using [allowframebreaks=1]. Note, just for testing this option I'm using \pagebreak. The continued frame is the one that is off, it starts a little higher than other (normal) frames. – Ailurus Aug 5 '12 at 22:59
  • It is indeed a little tricky and probably needs some modification. The main reason for that is usually the main slide is too full and hence needs to be divided into different parts and you can expect that the continuing frames need to be packed to minimize the extra frame number. So this suggestion might not be useful to you. – percusse Aug 5 '12 at 23:02
  • According to the manual, using allowframebreaks is incompatible with overlays so this might not be what is wanted here. – Andrew Stacey Aug 10 '12 at 10:12

Here's a solution for you. Each time the frame title is typeset, we write a line to the aux file. When read back in, this gives us a count of the number of times that frame is used. If this is greater than 1 then when we encounter that frame title we need to append the number of that frame, which is given by another count.

Caveats: we write the frame title only on the first slide of a frame. So if the first slide is skipped for some reason, strange things might happen. Similarly, it is possible to use overlays to change the title from one slide to another. This makes no check for that and might go horribly wrong if this is done.

Here's the code, it was an adaptation of the code in my answer to Re-using the title of the previous Beamer slide:



    \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle continuation}\fi}}%
    \ifnum\csname beamer@framecount@max@#2\endcsname>1\relax
    \gdef\insertframetitle{{#2\beamer@autobreakcount\csname beamer@framecount@cur@#2\endcsname\relax{}\space\usebeamertemplate*{frametitle continuation}}}%
    \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle continuation}\fi}}%

    \expandafter\gdef\csname beamer@framecount@#1@#2\endcsname{1}%
    \@tempcnta\csname beamer@framecount@#1@#2\endcsname\relax%
    \advance\@tempcnta by 1\relax
    \expandafter\xdef\csname beamer@framecount@#1@#2\endcsname{\the\@tempcnta}%


\begin{frame}{The Frame Title}
A frame with a title
A frame without a title
\frametitle{The Next Frame Title}
A frame with a title
A second frame without a title
\begin{frame}{The Third Frame Title}
But not the third frame
\begin{frame}{The Fourth Frame Title}
Another title,\pause another frame.


Auto-number of beamer frames with the same name

| improve this answer | |
  • Andrew, thanks for the effort and time to come up with this solution! Would it be possible for you to add some comments to the code above? Apart from using it, I'd like to learn something from it as well :) – Ailurus Aug 17 '12 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.