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.

Here is the code, that demonstrates the problem:

\documentclass{article}
\usepackage{lipsum}
\usepackage[a4paper]{geometry}

\begin{document}

\lipsum[1-6]
\begin{minipage}{\textwidth}
\lipsum[7]
\end{minipage}
current page = \thepage

\end{document}

All text in minipage appears on the second page (this is the desired behavior), but I get 'current page = 1' on the second page. Why?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

This is due to the asynchronous page breaking of TeX. \thepage in the document body is not reliable. Use it only in headers and footers. In the document body use \label{A}\pageref{A}.

share|improve this answer
    
I've been wondering ... do you mark code according to a specific pattern? Do you mind if your posts are edited to format all code as code? –  doncherry Sep 21 '11 at 13:51
    
Well I'm trying to mark all commands but sometimes I overlook one (like I overlook typing errors). I don't mind if someone correct them but I also don't think it is really necessary when there is no danger of misunderstanding. –  Ulrike Fischer Sep 21 '11 at 13:56
add comment

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.