1

I assume I'm not understanding something about myheadings and markboth. Here is my MWE (I'm running this on MikTeX 2.9 on a Win10 box):

\documentclass{article}

\begin{document}

\pagestyle{myheadings}

\markboth{}{Why is this not the right number? \arabic{page}}

First page.

\newpage

Another page.

\newpage

And another.

\end{document}

In all of the three pages, \arabic{page} in the header prints 1, instead of the expected 1,2,3.

  • Not sure what you're expecting: the \rightmark is set at the moment the \markboth command is processed. – egreg Nov 10 '15 at 18:32
1

You're using the wrong tool for setting page numbers. Anyway, using \protect\thepage solves the issue, as it avoids \thepage being expanded at the moment \rightmark is assigned a value and deferring its evaluation to the header's print time.

\documentclass{article}

\begin{document}

\pagestyle{myheadings}

\markboth{}{Why is this not the right number? \protect\thepage}

First page.

\newpage

Another page.

\newpage

And another.

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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