# 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}

-