Create header and footer except the first page in LaTeX

In this tutorial, you will learn how to add header and footer in your document except the first page.

In order to get this you can use the fancyhdr package. With this package, you can do this very easily and also this package gives you many more options with which you can align your header and footer contents very well.

LaTeX provides a \thispagestyle command, with this command you set a style for a single page. So, in order to turn off the header and footer on the first page you can use \thispagestyle{plain} command. You need to enter this command before writing any content.

See this example for better understanding.

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum} 

% Declare header and footer for every page
\pagestyle{fancy}
\fancyhead[C]{CodeSpeedy} % Centered header
\fancyfoot[C]{Page \thepage} % Centered footer

\begin{document}

% Off header and footer on the first page
\thispagestyle{plain}
\lipsum[1-20]

\end{document}

Output:

First page:
first page without header and footer.
Second page:

second page with header and footer.

More options of fancyhdr package

Also, this package provides more useful options to align your header and footer contents. Follow the table to know more.

CommandAlignment
\lhead{}Left (header)
\rhead{}Right (header)
\chead{}Center (header)
\lfoot{}Left (footer)
\rfoot{}Right (footer)
\cfoot{}Center (footer)
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lastpage} % To get last page number
\usepackage{lipsum} 

% Declare header and footer for every page
\pagestyle{fancy}
\lhead{CodeSpeedy}
\chead{Parvez.A.P}
\rhead{Page: \thepage}
\cfoot{\thepage\ of \pageref{LastPage}}

\begin{document}

% Off header and footer on the first page
\thispagestyle{plain}
\lipsum[1-20]

\end{document}

Output:

First page:
First page without header and footer.
Second page:

Second page with header and footer.

Leave a Reply

Your email address will not be published. Required fields are marked *