10

I would like to have a header and a footer throughout the document, however on the first page I would like no header with the footer remaining as it is throughout the document. So far all I can do is change the the first page style to plain, however this only gives the footer to be a page number, not the information I want.

I believe I have included a minimum working example below, however it's most likely i've done something wrong as i'm quite new to this all. I'm also aware this may be marked as a duplicate question however my search has provided me no results with this issue specifically.

\documentclass[]{article}
\usepackage{fancyhdr}
\begin{document}

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.1mm}
\fancyfoot[R]{Assignment No.}
\fancyfoot[C]{\thepage}
\fancyfoot[L]{\today}
\fancyhead[L]{\leftmark}
\fancyhead[R]{Name:First Last}

\section{First page}
No header here
\clearpage
\section{Second page}
Header should be back
\end{document}
2
  • a) What document class do you use? b) Do you want to change only the very first page of the document (the title page) or the first page of every chapter?
    – lockstep
    Commented Mar 2, 2014 at 13:05
  • a)using \documentclass[]{article} b) no, just the very first page, however the first page is not really a titlepage, just a unique title at the top of the page indicating the start (hence why I do not wish to have the header at the start)
    – yorkie1990
    Commented Mar 2, 2014 at 13:52

3 Answers 3

5

Only the very first page has no header:

\documentclass{book}    
\usepackage{fancyhdr}   
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.1mm}
\fancyfoot[R]{Assignment No.}
\fancyfoot[C]{\thepage}
\fancyfoot[L]{\today}
\fancyhead[L]{\leftmark}
\fancyhead[R]{Name:First Last}

\fancypagestyle{plain}{%
  \fancyhf{}%
  \renewcommand{\footrulewidth}{0.1mm}%
  \fancyfoot[R]{Assignment No.}%
  \fancyfoot[C]{\thepage}%
  \fancyfoot[L]{\today}%
  \renewcommand{\headrulewidth}{0mm}%
}   
\usepackage{blindtext}

\begin{document}

\blinddocument
\makeatletter\let\ps@plain\ps@fancy\makeatother % anywhere after the first page/chapter

\blinddocument

\end{document}

enter image description here

2
  • I'm using article as the document class, I should have said this early, apologies. I still cannot adapt this into my code to work unfortunately, even if I change the class to book as it is here, there is still a header. Is there anyway your code could be adapted to article class and still work as intended?
    – yorkie1990
    Commented Mar 2, 2014 at 14:02
  • Apologies - please ignore the above. I have solved that issue simply by adding \thispagestyle{plain}. The code now works. Thank you for your help and quick response.
    – yorkie1990
    Commented Mar 2, 2014 at 14:05
7

You might want to leave the plain style as it is and define a new style, let's say firstpage

\fancypagestyle{firstpage}{%
  \fancyhf{}%
  \renewcommand{\footrulewidth}{0.1mm}%
  \fancyfoot[R]{Assignment No.}%
  \fancyfoot[C]{\thepage}%
  \fancyfoot[L]{\today}%
  \renewcommand{\headrulewidth}{0mm}%
} 

and, at the very beginning of the document, issue

\thispagestyle{firstpage}

MWE:

\documentclass{article}

\usepackage{fancyhdr}

\fancypagestyle{firstpage}{%
  \fancyhf{}%
  \renewcommand{\footrulewidth}{0.1mm}%
  \fancyfoot[R]{Assignment No.}%
  \fancyfoot[C]{\thepage}%
  \fancyfoot[L]{\today}%
  \renewcommand{\headrulewidth}{0mm}%
}  

\fancyhf{}
\renewcommand{\footrulewidth}{0.1mm}
\fancyfoot[R]{Assignment No.}
\fancyfoot[C]{\thepage}
\fancyfoot[L]{\today}
\fancyhead[L]{\leftmark}
\fancyhead[R]{Name:First Last}

\pagestyle{fancy}

\usepackage{blindtext} % just for the example

\begin{document}

\thispagestyle{firstpage}

\blinddocument

\end{document} 

enter image description here

2

According to the fancyhdr manual the \fancypagestyle command is what you're looking for (see section 7 of the manual):

This command can be used to redefine existing pagestyles (like plain) or to define new ones, e.g. if part of your document is to use a different pagestyle.

\documentclass{scrartcl}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancypagestyle{fancy}{%
\fancyhf{}
\renewcommand{\footrulewidth}{0.1mm}
\fancyfoot[R]{Assignment No.}
\fancyfoot[C]{\thepage}
\fancyfoot[L]{\today}
\fancyhead[L]{\leftmark}
\fancyhead[R]{Name:First Last}}


\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[R]{Assignment No.}
\fancyfoot[C]{\thepage}
\fancyfoot[L]{\today}
\renewcommand{\footrulewidth}{0.1mm}}

\usepackage{blindtext}
\title{Test document}
\begin{document}
\maketitle

\blinddocument

\end{document}

You must log in to answer this question.

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