# [OS X TeX] LastPage Reference

Roussanka Loukanova rloukano at stp.lingfil.uu.se
Wed Mar 7 02:50:55 CET 2007

On Tue, 6 Mar 2007, Herbert Schulz wrote:
> On Mar 6, 2007, at 3:31 PM, Maurino Bautista wrote:
>
>> I copied the following code from Roussanka's posting which works
>> properly. I added the lines marked with %%%  and I commented the right
>> footer command. I now get the following error:
>>
>> AED: lastpage setting LastPage
>> ! Missing number, treated as zero.
>>                  \protect
>> l.46 \end{document}
>>
>> Anybody knows what is wrong? All I know is that the package hyperref
>> uses (or modifies-redefines-omits?? ) the LastPage reference.
...

> Howdy,
>
> Not sure, but do you need to explicitly have
>
> \usepackage{lastpage}
>
> to use LastPage? Maybe one of the other packages loads it?

It seems that lastpage.sty doesn't get loaded after commenting it, i.e.,
with
% \usepackage{lastpage}
I do not find
(/usr/local/gwTeX/texmf.texlive/tex/latex/lastpage/lastpage.sty)
resp.
(/usr/local/texlive/2007/texmf-dist/tex/latex/lastpage/lastpage.sty)
in the log file.

However, the setting LastPage wold be available for an additional pass of
latex, then in a 2nd round, the number of LastPage is not available. (This
is my interpretation of what I see in the log file: I do not know if I'm
right.)

> Also \ifthenelse has three arguments:
>
> \ifthenelse{test}{true commands}{else commands}
>
> so
>
> \lfoot{\ifthenelse{\value{page}=\pageref{LastPage}}{\tiny\today}}

> should have an extra {} pair for the else (assuming it should be blank if
> it's not the last page).

For strictness, you are right. But since  Maurino's tex code typeset
Without being absolutely sure, ifthenelse.sty is extending (they say
compatible with) ifthen.sty and adds lasy evaluation of the logical
operators:  in cases when P is true, "if P then Q else R" wouldn't look
for the else proposition, i.e. it the same as "if P then Q".

>
> Finally, in the command
>
> \cfoot{\ifthenelse{\not\value{page}=\pageref{LastPage}}{\scriptsize (over)}}
>
> the \not is only acting on \value{page} and I believe you mean it to be

Again, because Maurino's tex code typeset ok (I've ran it several times),
it looked to me that \not (number1 = number 2) has also abbreviated form
\not number1 = number 2. The documentation is more clear to me in this
aspect (than for the lasy evaluation). But they treat "number1 = number 2"
as a syntactic unit: atomic proposition, which hints to parsing of
\not number1 = number 2 as equivalent to \not (number1 = number 2).

>
> \not{\value{page}=\pageref{LastPage}} as well as missing the extra {}; i.e.,
> it should be
>
> \cfoot{\ifthenelse{\not{\value{page}=\pageref{LastPage}}}{\scriptsize
> (over)}{}}
>
> which is the same as the simpler
>
> \cfoot{\ifthenelse{\value{page}=\pageref{LastPage}}{}{\scriptsize (over)}}.

I think, it is; and I think that one would be on the safe side by
following the strict (and clear) syntax as you suggested. Esp. with the
drawbacks of the lazy evaluation (or may I just do not like it).

Roussanka