18.5 \thepage

If you want to change the appearance of page numbers only in the page headers, for example by adding an ornament, typesetting in small caps, etc., then the fancyhdr package, as mentioned in a previous section, is the best approach.

On the other hand, you may want to change how page numbers are denoted everywhere, including the table of contents and cross-references, as well as the page headers. In this case, you should redefine \thepage, which is the command LaTeX uses for the representation of page numbers.

However, \thepage should do any typesetting or other complicated maneuvers, but merely expand to the intended page number representation. The results of a complicated redefinition of \thepage are not predictable, but LaTeX’s report of page numbers in diagnostic messages, at least, will become unusable.

There is some discussion of this issue at https://tex.stackexchange.com/questions/687258.


Unofficial LaTeX2e reference manual