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.

When I try to use the nameref package together with the lastpage package (version earlier than 2013/01/28, of course) I have following two errors:

! Package lastpage Error: no auxiliary file allowed
! Extra \else

But without the nameref package (and referencing chapters by names) my LaTeX document builds without problems.
What does this error mean? And what are possible causes?

My document file:

\documentclass[a4paper,oneside,12pt]{report}
\usepackage[polish]{babel}
\usepackage[latin2]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{indentfirst}
\usepackage{titlesec}
\usepackage{nameref}
\usepackage{lastpage}
\usepackage{fancyhdr}
\onehalfspacing
\titleformat*{\section}{\normalsize\bfseries}
\setlength{\parindent}{1cm}
\begin{document}
\pagestyle{plain}
Text.
%\input{./title.tex}
\pagenumbering{arabic}
\fancypagestyle{plain}{% 
    \fancyhf{}
        \fancyfoot[C]{Strona \normalsize\thepage\ z \pageref{LastPage}}
    \renewcommand{\headrulewidth}{0pt} % remove line between header and main text
}
\tableofcontents
\listoffigures
\pagestyle{plain}
Text.
%\input{./ch1.tex}
%\input{./ch2.tex}
%\input{./ch3.tex}
%\input{./ch4.tex}
%\input{./biblio.tex}
\end{document}
share|improve this question

2 Answers 2

up vote 6 down vote accepted

For some reasons, nameref and lastpage fight each other when trying to do something to the .aux file just before finishing.

All works if you say

\usepackage{zref-user,zref-lastpage}

instead of \usepackage{lastpage} and

\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyfoot[C]{\normalsize Strona \thepage\ z \zpageref{LastPage}}
  \renewcommand{\headrulewidth}{0pt} % remove line between header and main text
}

Note the command \zpageref. (Also \normalsize should go before Strona).

share|improve this answer
    
Works like a charm :) –  Michał Herman Jan 27 '13 at 11:43
    
"For some reasons, nameref and lastpage fight each other when trying to do something to the .aux file just before finishing." Well, the reason was a little bit different (see my answer), but zref-lastpage works, of course. –  Stephen Jan 28 '13 at 19:42

lastpage 2012/01/28 v1.2l has been submitted to CTAN to fix the incompatibility with nameref and should soon become available there.

The nameref package redefines \label to have five arguments instead of two, therefore

\newlabel{LastPage}{{}{\thepage}{}{}{}}

instead of

\newlabel{LastPage}{{}{\thepage}}

must be used in the lastpage package, when also nameref is used in the document. (When nameref and hyperref were both used, there was no problem, because hyperref uses another label format, which was already regarded by lastpage.)

Using lastpage since version 1.2l, 2013/01/28, your MWE works without any problem.

Thanks for reporting the incompatibility! (See at Acknowledgements and History in the package's documentation.)

share|improve this answer

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.