10

I'm using the fancyhdr package to include a header on each page. In order to surpress the section title also being cited in the header of each page, I'm using the command \fancyhf{}, however this also erases all page numbers after the first page. Does anybody know how to get them back in?

See code below

\documentclass[10pt, letter]{article}
\usepackage{setspace}
\usepackage[margin=1.250in]{geometry}
\singlespacing
\usepackage{fancyhdr}
\fancyhf{}
\pagestyle{fancy}
\rhead{\textcolor{gray}{Mock Draft}}
\renewcommand{\headrulewidth}{0pt}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor

\begin{document}
xxxxx
\clearpage
xxxx
\clearpage
xxxx
\end{document}

Many thanks!

3
  • 1
    You can just put \thepage into the appropriate header/footer part (\rhead, \cfoot ... etc.)
    – Alan Munn
    Jul 1, 2013 at 18:17
  • With your setting the page number doesn't appear in the first page. Perhaps you have a \maketitle command in your real document.
    – egreg
    Jul 1, 2013 at 20:42
  • @egreg if you comment out \fancyhf{} the first page has the page number. Jul 1, 2013 at 20:57

4 Answers 4

8

This can be done with the help of the afterpage package.

Before the page where you want the page number begins, put:

\afterpage{\cfoot{\thepage}}

So, your MWE can be rewritten as:

\documentclass[10pt]{article}
\usepackage{setspace}
\usepackage[margin=1.250in]{geometry}
\singlespacing
\usepackage{fancyhdr}
\usepackage{afterpage}
\fancyhf{}
\pagestyle{fancy}
\rhead{\textcolor{gray}{Mock Draft}}
\renewcommand{\headrulewidth}{0pt}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor

\begin{document}
xxxxx
\afterpage{\cfoot{\thepage}}
\clearpage
xxxx
\clearpage
xxxx
\end{document}

Note that I deleted letter from the options of the article class. The default is already the letter paper and anyway the right option is letterpaper.

7

Using \fancyhf{} clears the header and footer of anything. However, if you wish to insert the page number, just add \thepage to the appropriate location. If you wish to do this conditionally, that is also possible through something like

\fancyhead[L]{\ifnum\value{page}<2\relax\else\thepage\fi}

which will place \thepage int the [L]eft header if its value is at least 2.

2

There's no need of special settings, assuming you don't want the header in the first page; just define the center footer (or any other field you like) to contain the page number.

\documentclass[10pt, letter]{article}

\usepackage[margin=1.250in]{geometry}
\usepackage[table]{xcolor}

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\textcolor{gray}{Mock Draft}}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}

\begin{document}
\thispagestyle{plain} % not needed if a \maketitle command is issued

xxxxx
\clearpage

xxxx
\clearpage

xxxx

\end{document}
2
  • The OP do wants the header in the first page, but doesn't want the page number there. Jul 1, 2013 at 20:51
  • @karlkoeller I'm reading the question differently.
    – egreg
    Jul 1, 2013 at 21:07
0

After \begin{document} (or in the document preamble), issue

\renewcommand{\thepage}{\roman{page}}% Roman page numbers

On the page where you want it to change to Arabic numbering, use

\renewcommand{\thepage}{\arabic{page}}% Arabic page numbers

The above just modifies the page number/counter printing mechanism. In contrast, using \pagenumbering{arabic} will change the numbering to Arabic but also resets the page counter.

This text is copied from: https://tex.stackexchange.com/a/56133/110064 (Werner)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .