# Incorrect frame numbers when pages included using pdfpages in beamer

I am including some pages using pdfpages in beamer. I understand that these pages can not be included a frames. Rather these are included as simple texts. So far so good.

However, I get incorrect frame counts in slide footers. Please see this minimal example,

\documentclass{beamer}

\usepackage{pdfpages}

\mode<presentation>
{
\usetheme{Luebeck}
\setbeamercovered{transparent}
}

\usepackage{times}

% Frame numbers
\expandafter\def\expandafter\insertshorttitle\expandafter{%

\begin{document}

\begin{frame}
\frametitle{First Frame}
\end{frame}

\begingroup
\setbeamercolor{background canvas}{bg=}
\includepdf[pages=1-10]{mypdf.pdf}
\endgroup

\begin{frame}
\frametitle{Last Frame}
\end{frame}

\end{document}


While I need the first slide to have the number 1/12, and the last slide 12/12, this actually comes out to be 1/2 and 2/2. I know that beamer is doing nothing wrong. This is mathematically 100% correct. But from a user point of view, this is not intended.

Is there any way I can incorporate non-frame pages in slide counts?

After a number of trial and errors and code hacking, I have found the solution like this.

\def\getpdfpages#1#2{\begingroup
\setbeamercolor{background canvas}{bg=}
\includepdf[pages={#1},%
\expandafter\def\expandafter\insertshorttitle\expandafter{%
]{#2}
\endgroup}


For the above macro, the first argument is the range of pages, the second one is the .pdf file name. So, you call it like this,

\getpdfpages{{4-5}}{mypdf.pdf}


or

\getpdfpages{{4,7}}{mypdf.pdf}


or

\getpdfpages{{4-5,7,10-12}}{mypdf.pdf}

• This doesn't work as expected with overlays such that there are multiple pdf pages for a single frame. If on frame 1, there is a \pause, and then a pdf page is included, then default beamer shows 1/1, 1/1, nothing in the bottom corner of each page, and your solution yields 1/3, 1/3, 3/3 – Fred Schoen Nov 16 '16 at 8:48

To expand on Masroor's answer, this produces incorrect frame numbers if you use overlays. To prevent this, use:

\global\setcounter{framenumber}{%


to count up by one for every frame instead of

\global\setcounter{framenumber}{\value{page}}


which sets the framenumber counter to page. The two differ when using \pause/overlays.

(I would have commented on that post, but I don't have the necessary reputation)

For the special case where the included pdf is also a beamer presentation, one can use the following technique:

In the presentation which should be included in the other one, label the last frame with a name of your choice, e.g. lastframe

\begin{frame}[label=lastframe]

\end{frame}


Then the framenumber can automatically be added in the main presentation:

\documentclass{beamer}

\usepackage{refcount}
\usepackage{zref-xr}
\usepackage{pdfpages}

\zxrsetup{toltxlabel}
\zexternaldocument*{OtherPresentation}

\begin{document}