I would like to print page numbers bold (that's an example) wherever they appear. My naive MWE looks like this:
\documentclass{revtex4-1}
\renewcommand*{\thepage}{\textbf{X}}
%\usepackage{microtype}
%\renewcommand*{\thepage}{X}
\begin{document}
foo
\end{document}
This does work. However, as soon as I use a few other packages such as microtype (uncomment first commented line), this breaks. This can be fixed by uncommenting the second commented line, suggesting that it's not the messing with \thepage per se which breaks things. Still, I lose the effect that I want.
With the formatting, the aux file looks like this:
....
\newlabel{LastPage}{{}{\protect \unhbox \voidb@x \bgroup \def document{1}\let \futurelet \@let@token \let \protect \relax \protect \edef m{bx}\protect \xdef \OT1/cmr/bx/n/10 {\OT1/cmr/m/n/10 }\OT1/cmr/bx/n/10 \size@update \enc@update 1\egroup }{}{}{}}
So probably, this command in revtex4-1.cls messes things up:
\immediate\write\@auxout{\string\newlabel{LastPage}{{}{\thepage}{}{}{}}}%
How can I fix this line to make things right?
Update:
This creates a proper .aux file, but of courses messes up the document's page numbers:
\documentclass{revtex4-1}
\renewcommand*{\thepage}{\string\textbf{X}}
\usepackage{microtype}
\begin{document}
foo
\end{document}

\thepage, then I do need to care about any (future) potential use of\thepage, be it through\pageref(which you cover), otherhyperreffunctionality (which you mention) or other other custom macro (I could think of some back-referencing script, or a package breaking tables across pages and referencing them from one another). And I do not see any downside to formatting\thepageby changing its definition, so I like my answer better. (Oh, I see one downside:\pagenumberingresets\thepage. But I can deal with that.) – bers Jul 07 '15 at 19:41\usepackage{etoolbox}, then\robustify{\textbf}and finally\renewcommand{\thepage}{\textbf{\arabic{page}}. – egreg Jul 07 '15 at 19:45