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 know that you need to rerun latex to resolve references -- it doesn't matter how many times I rerun it -- I get the same warning messages.

This sample program:

\documentclass[12pt]{article}
\begin{document}
\label{pg:first}
\newpage
Pages \pageref{pg:first} through \pageref{pg:last}.
\newpage
\label{pg:last}
\end{document}

yields:

Pages 1 through ??.

and the warnings:

LaTeX Warning: Reference `pg:last' on page 1 undefined on input line 6.
LaTeX Warning: There were undefined references.

on every run.

A .aux file is generated, but consists only of "/relax". Running under sudo has no effect.

Am I just missing something basic in this example? A more complex one used to work in MikTex.

share|improve this question
    
Welcome to TeX.SE! LaTeX needs to "attach" each \label to some object (section, figure, table, footnote, whatever) in order to "know" what to do with it. However, your MWE is so minimal that there's literally nothing for LaTeX to attach the second label to. Try providing some "real" item before issuing the second \label command, and you should be OK. –  Mico Jul 26 '12 at 8:16
2  
I can't explain exactly why, but it seems to happen because there isn't anything on the last page. Add a letter, or even \null after the \newpage, and it works. –  Torbjørn T. Jul 26 '12 at 8:18
2  
Only to avoid the impression that miktex is doing something magic: The simply example doesn't work on miktex either as - like Torbjorn has already mentioned - there isn't anything on the second page. –  Ulrike Fischer Jul 26 '12 at 8:22
    
Thank you all, the lack of content was the certainly the issue with this example. What I was actually trying to do was have the pg:last label be placed at the close of an environment surrounding various figures (then the label would be associated with a figure). I am computing page counts in counters using pg:last, and these are not coming out properly, where I believe that they were under MikTex. I can get correct behavior by moving the pg:last label to the last figure definition, but it would be better to hide this in an abstraction so that I don't have to keep remembering to move it. –  Steven Ganz Jul 26 '12 at 9:03

1 Answer 1

labels are shipped out with the rest of a page; it's at that time that the .aux file is written.

with nothing on the second page of your document, there's no shipout ... \label commands don't count in evaluating the content of a page.

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.