Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Beamer class differentiates between pages and frames. To get the first page of a part beamer provides the command \insertpartstartpage and for the last page \insertpartendpage.

Is there a chance to get the first and the last frame of the current part?

share|improve this question

1 Answer 1

There seems to be no built-in way to access the frame number of the first and last slide of a part, but you can define the necessary macros \insertpartstartframe and \insertpartendframe yourself:

\documentclass{beamer}

% How can I get the first and the last frame of an part in beamer class?
% (http://tex.stackexchange.com/q/73142/3323)
\usepackage{etoolbox}
\makeatletter
\newcount\beamer@partstartframe
\beamer@partstartframe=1
\apptocmd{\beamer@part}{\addtocontents{nav}{\protect\headcommand{%
        \protect\beamer@partframes{\the\beamer@partstartframe}{\the\c@framenumber}}}}{}{}
\apptocmd{\beamer@part}{\beamer@partstartframe=\c@framenumber\advance\beamer@partstartframe by1\relax}{}{}
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
        {\noexpand\headcommand{\noexpand\beamer@partframes{\the\beamer@partstartframe}{\the\c@framenumber}}}}}{}{}
\def\beamer@startframeofpart{1}
\def\beamer@endframeofpart{1}
\def\beamer@partframes#1#2{%
  \ifnum\c@framenumber<#1%
  \else%
    \ifnum\c@framenumber>#2%
    \else%
      \gdef\beamer@startframeofpart{#1}%
      \gdef\beamer@endframeofpart{#2}%
    \fi%
  \fi%
}
\newcommand\insertpartstartframe{\beamer@startframeofpart}
\newcommand\insertpartendframe{\beamer@endframeofpart}
\makeatother

\setbeamertemplate{footline}{\insertpart: \insertpartstartframe--\insertpartendframe}

\begin{document}
\part{Part 1}
\frame{1\pause 2\pause 3}
\frame{1\pause 2}
\frame{1}
\part{Part 2}
\frame{1\pause 2}
\frame{1\pause 2\pause 3}
\part{Part 3}
\frame{1}
\frame{1\pause 2\pause 3\pause 4}
\end{document}

The code (between \usepackage{etoolbox} and \makeatother) is basically the same as the one beamer uses to access the start and end page of a part, but stores the frame number instead of the page number.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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