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}
-
1Thanks for posting the example code, this is very useful! – Juan A. Navarro Oct 04 '10 at 10:51
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.
- 62,139
- 32
- 140
- 169
- 250,273
-
1Sorry lockstep, I didn't notice you'd posted your solution as I was posting mine. Here's +1 by way of apology
;)– Geoffrey Jones Oct 03 '10 at 14:03 -
3Changing
\thepagethis way is a really bad idea. It will makesee page \pageref{lbl} for more informationExpand tosee page \small\sffamily3 for more information(setting "for more information" small and sans serif") which is surely not desired, and it will causehyperrefto fail completely. – Lev Bishop Oct 03 '10 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. – lockstep Oct 03 '10 at 15:40
-
But the KOMA-script info should still be correct. Could you edit your answer so that it mainly shows that. – Caramdir Oct 03 '10 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. – Juan A. Navarro Oct 04 '10 at 10:50
-
I like your version of my answer better. ;-) Give a correct solution and only then mention your initial blunder. – lockstep Oct 04 '10 at 17:51
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.
- 757,742
- 45,462
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\ --}}
- 14,435
-
5Changing
\thepagethis 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 causehyperrefto fail completely. – Lev Bishop Oct 03 '10 at 15:23 -
Lev's right of course. Now he points it out, it's quite obviously a really bad idea. – Geoffrey Jones Oct 03 '10 at 22:15