# How to get the lastpage of each section, so that I could put it on the headline

How to get the lastpage of each section, so that I could put it on the headline.

\documentclass{beamer}

\usepackage{lastpage}

\begin{document}
\section{1}
\begin{frame}
123 Total \pageref{LastPage} pages

How to get the pages of section 1?
\end{frame}
\begin{frame}
1234
\end{frame}
\section{1}
\begin{frame}
1235
\end{frame}

\end{document}

• Welcome to TeX.SX! You can highlight code in your post using back-ticks. To highlight code-blocks, either indent them by four spaces or use the {} on the gui.
– user30471
May 5, 2019 at 13:41

In order to access the first and last page of the current part, section or subsection the beameroffers the commands \insertZstartpage and \insertZendpage with Z= part, section or subsection. A short description of these commands can be found on page 66 of the beamer userguide.

MWE with a very simple headline:

\documentclass{beamer}

\parbox{\linewidth}{\vspace{10pt} \hspace{10pt} \insertsectionstartpage / \insertsectionendpage}}

\begin{document}
\section{1}
\begin{frame}
Section 1 starts at: \insertsectionstartpage

Section 1 ends at: \insertsectionendpage
\end{frame}

\begin{frame}
1234
\end{frame}

\section{2}
\begin{frame}
First frame of section 2

\end{frame}
\end{document}