# pageref to label in last page in resume.cls

I am using the class resume.cls for writing my curriculum.

I would like to use as page numbers the text "page k out of n", but I seem not to be able to get a reference to the last page.

• If I add a simple label 'lastone' at the end of the resume and use \pageref{lastone} the reference stays undefined no matter how many times I compile the source.
• If I use the package 'lastpage' I get an error related to a missing curly brace (which disappears as soon as I do not include that package).
• If I use the package 'zref-lastpage' and refer to the last one with \zpageref{LastPage}, I get an error related to an undefined macro.

Is there any way I can have a reference to the last page in order to insert its page number?

This is an example (you need to download the .cls file because I could not find a way to attach files).

\documentclass[margin,line]{resume}

\usepackage{zref-lastpage}
\usepackage{fancybox}

\makeatletter \renewcommand{\@evenfoot}%
{\normalsize\slshape CV di Tizio \hfil \upshape pag. {\thepage} di \zpageref{LastPage}} % \pageref{ultima}} % \zpageref{LastPage}}
\renewcommand{\@oddfoot}{\@evenfoot} \makeatother

\begin{document}
\name{\Large Tizio -- \it Curriculum Vitae et Studiorum}

\begin{resume}
\pagenumbering{arabic}

\section{\mysidestyle Informazioni\\ personali}\vspace{2mm}\label{informazioni-personali}
This is me

% ENDING
bye

\label{ultima}\end{resume}
\end{document}


\label uses a deferred writing, when the page is shipped out. At this time the page number is known for sure. Because of the asynchronous output routine this is not guaranteed otherwise. However, deferred writing is void after the last page is shipped out, because there is no page for the writing to take place.

Therefore the packages uses \immediate\write for the last label, e.g. package lastpage:

\documentclass{article}
\usepackage{lastpage}
\begin{document}
First page.
Last page is \pageref{LastPage}.
\newpage
Last page
\end{document}


The same example with package zref-lastpage. Note: \zpageref is provided by package zref-user:

\documentclass{article}
\usepackage{zref-lastpage,zref-user}
\begin{document}
First page.
Last page is \zpageref{LastPage}.
\newpage
Last page
\end{document}


The total number of pages can be different from the page number of the last page, because the numbering might change (title page, front matter, ...). zref provides package zref-totpages for this purpose:

\documentclass{article}
\usepackage{zref-totpages}
\begin{document}
First page.
Number of pages is \ztotpages.
\newpage
Last page
\end{document}


Also \ztotpages uses the reference system, because the number of pages is known after the last page.

## Class resume

The class resume from the question sabotages the reference system by using \nofiles. Then auxiliary files are not written, including references, thus labels remain unknown regardless of the number of LaTeX runs.

Workaround:

\let\nofiles\relax
\documentclass{resume} % http://linux.dsplabs.com.au/files/p54-resume/resume.cls

• I have already tried using zref-totpages, but \ztotpages gives always zero. I think it's a problem related to the resume class. However, for my resume I have full control of the page numbering so something pointing at the last page or the one before would be ok. – Antonio Sesto Mar 28 '14 at 11:43
• @AntonioSesto: Two LaTeX runs are needed. The total number of pages is known after the last page, but \ztotpages is usually used before. – Heiko Oberdiek Mar 28 '14 at 11:46
• I know: I run latex (pdflatex) four or five times before posting the comment. – Antonio Sesto Mar 28 '14 at 11:48
• @AntonioSesto: See the updated answer, the class resume from the question calls \nofiles that disables auxiliary files. – Heiko Oberdiek Mar 28 '14 at 11:54
• Thanks a lot!!! That fixed the problem! It's the first time I see that configuration: what's the reason not to produce any aux file? – Antonio Sesto Mar 28 '14 at 11:54