2

Using fancyhdr how can I achieve that on specific pages the page number is omitted. For example, in the minimal example I want the page number to appear on the third page and the page number of the third page should be 1.

\documentclass{article}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\usepackage{blindtext}
\pagestyle{fancy}
\chead{HEADER
}
\begin{document}
 \blindtext
 \newpage

 \blindtext
 \newpage

 \blindtext
 \newpage
\end{document}
2
  • Either use different page styles or use conditionals for your \cfoot etc. stuff. What is HEADER supposed to be? The page number?`
    – user31729
    Jul 31, 2015 at 7:46
  • No, the header is supposed to be a name and address. On the pages where the page number should appear it is supposed to be default style, that is centered in the foot. Actually exactly as in the min expl just no page number on page 1 and 2 and page number on page equal to 1.
    – lpdbw
    Jul 31, 2015 at 7:48

1 Answer 1

2
\documentclass{article}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\usepackage{blindtext}
\pagestyle{fancy}



\chead{HEADER
}
\cfoot{\ifnum\value{page} > 2 \the\numexpr\value{page}-2 \fi}
\begin{document}
 \blindtext
 \newpage

 \blindtext
 \newpage

 \blindtext
 \newpage
\end{document}

Edit Corrected version, with hyperref links working

\documentclass{article}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\usepackage{blindtext}
\pagestyle{fancy}


\usepackage{hyperref}
\chead{}%
\cfoot{}%
\begin{document}
\tableofcontents

\blindtext
\newpage

\blindtext

\clearpage

\pagenumbering{arabic}
\chead{HEADER}%  Better here
\cfoot{\ifnum\value{page} > 0 \thepage \fi}

\section{My first section}
\blindtext
\newpage
\end{document}
4
  • Good, only I need to reset the page number on the third page to be =1. Otherwise exactly what I need. Hoe can I do the resetting?
    – lpdbw
    Jul 31, 2015 at 7:50
  • 1
    @lpdbw: Changed it already, because I posted the first version. But it's not correct still, because the wrong pagenumber would be entered in the ToC
    – user31729
    Jul 31, 2015 at 7:51
  • OK, saw it now, you were too quick :-) Thx a lot. I do not need a ToC, so for my purpose it's fine. But maybe for other people it might be more helpful if you can fix it.
    – lpdbw
    Jul 31, 2015 at 7:52
  • 1
    @lpdbw: As soon as you have a ToC my first version is wrong, especially when hyperref is used. I suggest to use completely empty header for the first two pages and shift \chead{} to the appropiate place, after \pagenumbering{arabic}
    – user31729
    Jul 31, 2015 at 7:59

You must log in to answer this question.

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