# why minipage environment prevents \thepage counter update?

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?

-

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}.