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.

I am trying to print out page number/total number of pages in the handout that I get from this code: This is my MWE:

\documentclass[11 pt, handout,xcolor=pdftex,x11names,table]{beamer}
\mode<beamer>{\usetheme{CambridgeUS}}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[letterpaper,border shrink=10mm]
\pgfpageslogicalpageoptions{1}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{2}{border code=\pgfusepath{stroke}}

\begin{document}

\begin{frame}
\frametitle{First}
\begin{itemize}
\item check1
\item check 2
\end{itemize}
\end{frame}

\begin{frame}
Text 1
\end{frame}

\end{document} 

I am well aware that I can do it using pDfpages as pointed out in Actual page number (and total number of pages) in the handout . However, the problem with using pDfpages is that it does not preserve the original document's bookmarks. I was wondering if this is possible to do using pGfpages or any other package?

share|improve this question
2  
I had to read this a few times to notice the difference between pdfpages and pgfpages (pGf vs pDf)! This comment may help someone else too... –  cyberSingularity Nov 19 '12 at 1:12
    
Thank you! I also edited the question make it very clear –  N Nik Nov 19 '12 at 1:23
    
My only idea so far would be to use the textpos package and add some textblock* environments as part of the border code for the first logical page, and put the header/footer in those, but it would need a fair amount of work which I'm afraid I'm not able to do right now, but maybe this will be a starting point for someone to find a solution... –  cyberSingularity Nov 19 '12 at 1:34
    
Related: How can I put page numbers or headers inside my handouts (handoutWithNotes)?. Maybe some more inspiration is possible from this other answer by Andrew Stacey about how to draw horizontal rules in specific locations on the physical page with pgfpages. –  cyberSingularity Nov 19 '12 at 1:44

1 Answer 1

up vote 6 down vote accepted

Here's a possible solution using the lastpage package to get the total number of pages and the background package to place the text <current page> of <total pages>; I counted only physical (not logical) pages of the handout, but this can be easily changed if desired. I chose to place the text centered at the top, but this can also be easily changed:

\documentclass[11 pt, handout,xcolor=pdftex,x11names,table]{beamer}
\mode<beamer>{\usetheme{CambridgeUS}}
\usepackage{pgfpages}
\usepackage{lastpage}
\usepackage{refcount}
\usepackage{ifthen}
\pgfpagesuselayout{2 on 1}[letterpaper,border shrink=10mm]
\pgfpageslogicalpageoptions{1}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{2}{border code=\pgfusepath{stroke}}

\usepackage{background}
\SetBgAngle{0}
\SetBgScale{1}
\SetBgOpacity{1}
\SetBgColor{black}
\SetBgPosition{current page.north}
\SetBgVshift{10pt}
\SetBgContents{}
\makeatletter
\AddEverypageHook{%
\ifthenelse{\isodd{\thepage}}%
{\SetBgContents{\the\numexpr\thepage/2\relax\ of \the\numexpr\getpagerefnumber{LastPage}/2\relax}}%
{\SetBgContents{}}%
\bg@material}
\makeatother

\begin{document}

\begin{frame}
\frametitle{First}
\begin{itemize}
\item check1
\item check 2
\end{itemize}
\end{frame}

\begin{frame}
Text 1
\end{frame}

\begin{frame}
Text 2
\end{frame}

\begin{frame}
Text 3
\end{frame}

\begin{frame}
Text 4
\end{frame}

\end{document}

enter image description here

share|improve this answer
    
Thank you so much; this works like a charm! –  N Nik Nov 19 '12 at 2:06
    
Interested reader may also look at this post as well: tex.stackexchange.com/questions/82920/… –  N Nik Nov 19 '12 at 2:09

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.