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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please can anyone tell me the source of the following error?

I simply entered

\label{xlastpage} on last page

and the call

\setkeys[KV]{fam}{lhead={Page \thepage of \pageref{xlastpage}}}

gave the following funny errors.

%%%%%%%%% Trace log %%%%%%%%%%

\T@pageref #1->\NR@setref {#1}\@secondoffive {#1}

\NR@setref #1->\begingroup \@safe@activestrue \expandafter \endgroup \expandaft
er \NR@@setref \csname r@#1\endcsname
{entering semi simple group (level 19) at line 141}

\@safe@activestrue ->\let \if@safe@actives \iftrue
{changing \if@safe@actives=\iffalse}
{into \if@safe@actives=\iftrue}
{restoring \if@safe@actives=\iffalse}
{leaving semi simple group (level 19) entered at line 141}

\NR@@setref #1->\ifx \@undefined #1\let #1\relax \fi \@setref #1

\@setref #1#2#3->\ifx #1\relax \protect \G@refundefinedtrue \nfss@text {\reset@
font \bfseries ??}\@latex@warning {Reference `#3' on page \thepage \space undef
ined}\else \expandafter \Hy@setref@link #1\@empty \@empty \@nil {#2}\fi

\r@xlastpage ->{2}{4}

\Hy@setref@link #1#2#3#4#5#6\@nil #7->\begingroup \toks 0={\hyper@@link {#5}{#4
}}\toks 1=\expandafter {#7{#1}{#2}{#3}{#4}{#5}}\edef \x {\endgroup \the \toks 0
 {\the \toks 1 }}\x
! Argument of \Hy@setref@link has an extra }.
<inserted text>
<to be read again>
share|improve this question

closed as not a real question by Will Robertson, Loop Space Feb 8 '11 at 9:26

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Please supply a minimal working example. We can't debug this without knowing what exactly you are doing. – Lev Bishop Sep 8 '10 at 23:50
@Lev: Are you sure you don't mean a minimal failing example? – SamB Oct 1 '10 at 15:57
@SamB: Minimal working example is a standard term, where "working" means "working just enough to show the problem". – Lev Bishop Oct 2 '10 at 20:01
@Lev, @SamB — I've never understood where the ‘working’ term came from, myself. I just call them ‘minimal examples’ ;) – Will Robertson Feb 7 '11 at 23:30
More seriously, I've flagged this question because it's largely useless to keep around, considering it's all but been retracted as a question by its author in a comment below. – Will Robertson Feb 7 '11 at 23:33

I don't know what's causing your error; to even have a chance, I'd have to reproduce it, but I don't know what packages, etc., you're using.

But have you tried doing what you're doing by loading the lastpage package with \pageref{LastPage}?

Or alternatively, with \total{page} provided by the totcount package?

Or with \ref{TotPages} from the totpages package?

share|improve this answer
Problem solved: I had a look at how the hyperref package redefines \newlabel, and also at nameref and gettitlestring packages. – Ahmed Musa Sep 9 '10 at 16:29
@Pluto: Great that you found it! In such cases it would also be great if you post it as answer instead of a comment, just for clarity. This helps readers finding your solution easier. You could even mark your own answer as accepted. – Stefan Kottwitz Feb 4 '11 at 20:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.