So, I'm using the article class, and I'd like to make the page number smaller, and set it in a different font. I don't need to create a new pagestyle, necessarily, and I'm hesitant to do so without understanding the ramifications.
4 Answers
Thanks for the suggestion to use fancyhdr/redefine page styles. From the fancyhdr manual:
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[C]{\sffamily\fontsize{9pt}{9pt}\selectfont\thepage} % except the center
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
\pagestyle{plain}
-
1
You could use a KOMA-script class (e.g. scrartcl
instead of article
) and add the following to the preamble:
\addtokomafont{pagenumber}{\small\sffamily}
I initially recommended to redefine the \thepage
command but, as Lev Bishop has pointed out, this has adverse effects and shouldn't be done.
-
1Sorry lockstep, I didn't notice you'd posted your solution as I was posting mine. Here's +1 by way of apology
;)
Oct 3, 2010 at 14:03 -
3Changing
\thepage
this way is a really bad idea. It will makesee page \pageref{lbl} for more information
Expand tosee page \small\sffamily3 for more information
(setting "for more information" small and sans serif") which is surely not desired, and it will causehyperref
to fail completely. Oct 3, 2010 at 15:29 -
@Lev Bishop: You're of course right. Not sure what I was thinking. :-( @Marcin: Disregard the first part of my answer. You should either use a KOMA-script class or wait for someone who doesn't give blindfold pieces of advice.– lockstepOct 3, 2010 at 15:40
-
But the KOMA-script info should still be correct. Could you edit your answer so that it mainly shows that.– CaramdirOct 3, 2010 at 15:47
-
@lockstep, hope you don't mind that I've edited your answer to remove the incorrect information and only leave the valid suggestion of using KOMA-script. Please feel free to revert these changes, or edit the question yourself if you feel this doesn't represent the original intention of your answer. Oct 4, 2010 at 10:50
The correct way to achieve this is to make a new page style. As this FAQ answer discusses, redefining the \thepage
will only cause problems with all the places page numbers are used (\pageref
, table of contents, hyperref labels, etc, etc). Such changes will also not survive past a book-class change from \frontmatter
to \mainmatter
and so on.
Changing the pagestyle is easy enough with the fancyhdr package.
EDIT: As Lev kindly pointed out in his comment about it breaking various things, you definitely shouldn't think of this:
I can't help you with your font unless you mention which font you'd like. However, this code should give you a start:
\let\oldthepage\thepage
\renewcommand*\thepage{\small{\ttfamily-- \oldthepage\ --}}
-
5Changing
\thepage
this way is a really bad idea. It will makesee page \pageref{lbl}.
Expand tosee page {\small{\ttfamily-- 3\ --}}.
which is surely not desired, and it will causehyperref
to fail completely. Oct 3, 2010 at 15:23 -
Lev's right of course. Now he points it out, it's quite obviously a really bad idea. Oct 3, 2010 at 22:15