0

I'm trying to define a custom template and was satisfied with a frametitle template which displays frame numbering using

\insertframenumber~/~\inserttotalframenumber

It worked perfectly fine until I decided to split my presentation into different lectures using \includeonlylecture and \lecture. Indeed, now the frame numbering displays the frame number from the complete presentation (even if other frames, from other lectures, are not available on the pdf).

I tried several modifications of the code and online search, but all I can do is replace the frame numbers by the page numbers which is quite ok except when there are overlays.

Is there any command to report the current frame number of the lecture rather than the frame number as computed from the complete presentation?

Here is a complete MWE:

\documentclass{beamer}
\usepackage[utf8]{inputenc}

\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\definecolor{titleframecolor}{RGB}{52,82,122}
\colorlet{frametitlefc}{white}

\setbeamerfont{framenumber}{size=\scriptsize}
\setbeamerfont{frametitle}{size=\large}

\defbeamertemplate*{frametitle}{x}[1][]
{
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle}[titleframecolor]
    \begin{tikzpicture}
      \useasboundingbox (0,0) rectangle(\the\paperwidth,1.2cm);
      \fill[titleframecolor] (0,0) rectangle(\the\paperwidth,1.2cm);%
      {\node[anchor=west,frametitlefc,align=left] (frametitle) at ({1cm-1.5ex,0.6cm}){\usebeamerfont{frametitle}\begin{tabular}{l}\insertframetitle\end{tabular}};}%
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      %%%%% PART THAT MUST BE FIXED
      \node [anchor=south east,white] at (\the\paperwidth,-.5ex) {\usebeamerfont{framenumber}\insertframenumber~/~\inserttotalframenumber};
      %% Alternative
      %\node [anchor=south east,white] at (\the\paperwidth,-.5ex) {\usebeamerfont{framenumber}\insertpagenumber~/~\insertpresentationendpage};
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      \end{tikzpicture}
    \end{beamercolorbox}
}


\includeonlylecture{l2}


\begin{document}
\lecture{lecture 1}{l1}
\begin{frame}{Lecure 1 Slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}

\lecture{lecture 2}{l2}
\begin{frame}{Lecture 2 slide 1 -- Should be page 1/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 2 -- Should be page 2/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 3 -- Should be page 3/3}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}


\lecture{lecture 3}{l3}
\begin{frame}{Lecture 3 slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}

\end{document}

Warm regards.

3
  • Are you using overlays and/or \pause in your slides? Sep 3, 2022 at 11:43
  • @samcarter_is_at_topanswers.xyz I'm not using \pause but uses overlays as seen in the MWE
    – vbranders
    Sep 3, 2022 at 11:51
  • Ah, sorry, missed these overlays in your code. So the easy route via pageref is ruled out. I think your best bet is using this fix topanswers.xyz/tex?q=1987#a2230 for xcntperchap to count the frames in each lecture Sep 3, 2022 at 11:59

1 Answer 1

1

This does not work with \includeonlylecture, but you could use it to get per lecture numbering in your complete presentation and then split the resulting pdf into individual lectures.

\documentclass{beamer}
\usepackage[utf8]{inputenc}

\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\definecolor{titleframecolor}{RGB}{52,82,122}
\colorlet{frametitlefc}{white}

\setbeamerfont{framenumber}{size=\scriptsize}
\setbeamerfont{frametitle}{size=\large}

\usepackage{refcount}
\newcounter{lecturestartframe}
\newcounter{lectureendframe}
\newcounter{nextlecturenum}
\newcounter{frameinlecture}

\defbeamertemplate*{frametitle}{x}[1][]
{
  \setcounterref{lecturestartframe}{lec\thelecture}
  \setcounter{nextlecturenum}{\thelecture}
  \addtocounter{nextlecturenum}{1}
  \setcounterref{lectureendframe}{lec\thenextlecturenum} 
  \addtocounter{lectureendframe}{-\thelecturestartframe}
  \setcounter{frameinlecture}{\theframenumber}
  \addtocounter{frameinlecture}{-\thelecturestartframe}
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle}[titleframecolor]
    \begin{tikzpicture}
      \useasboundingbox (0,0) rectangle(\the\paperwidth,1.2cm);
      \fill[titleframecolor] (0,0) rectangle(\the\paperwidth,1.2cm);%
      {\node[anchor=west,frametitlefc,align=left] (frametitle) at ({1cm-1.5ex,0.6cm}){\usebeamerfont{frametitle}\begin{tabular}{l}\insertframetitle \end{tabular}};}%
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      %%%%% PART THAT MUST BE FIXED
      \node [anchor=south east,white] at (\the\paperwidth,-.5ex) {\usebeamerfont{framenumber}\theframeinlecture~/~\thelectureendframe~};
      \end{tikzpicture}
    \end{beamercolorbox}
}

\AtBeginLecture{
\begin{frame}[label=lec\thelecture,noframenumbering,plain]
  \begingroup
    \centering
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}Lecture~\insertlecturenumber}
    \vskip1em\par
    \begin{beamercolorbox}[sep=16pt,center]{part title}
      \usebeamerfont{part title}\insertlecture\par
    \end{beamercolorbox}
  \endgroup
\end{frame}
}


\AtEndDocument{\lecture{foo}{foo}}



\begin{document}
\lecture{Foo}{l1}
\begin{frame}{Lecure 1 Slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}

\lecture{Bar}{l2}
\begin{frame}{Lecture 2 slide 1 -- Should be page 1/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 2 -- Should be page 2/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 3 -- Should be page 3/3}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}


\lecture{Baz}{ll}
\begin{frame}[label=foo]{Lecture 3 slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}


\end{document}

You must log in to answer this question.

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