134

I want a header similar to Microsoft word that appears at the top of each page. However I do not want this on the first page. I would like to have the name of the project on the left, my name in the middle, and the date on the right.

  1. What packages and commands will create a header as described above?
  2. What approaches can I take to customize the header?
2

3 Answers 3

137

You can use fancyhdr to facilitate making headers and footers. If you want the first page to have no header or footer---without using any special packages---you can issue \thispagestyle{empty} on the first page.

\documentclass{article}
\usepackage{lipsum}%% a garbage package you don't need except to create examples.
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{This is my name}
\rhead{this is page \thepage}
\cfoot{center of the footer!}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}

\thispagestyle{empty}

\lipsum[1-20]

\end{document}

header and footer

1
  • I found that this also removes the page nuber from the first page. Any way to have the page nuber on the first page in the footer but not anything else that I choose to have in the footer?
    – Shreya
    Commented Dec 10, 2021 at 22:18
46

The most obvious package is fancyhdr which allows you to set up left, right and center adjusted headers and footers.

Your document ned to start with:

\documentclass{...}
\usepackage{fancyhdr}
\pagestyle{fancy}

You can then format your header and footer with

\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{}

Just leave them empty if you do not need any entry. you should check the fancyhdr manual for details on all possibilities with the package.

4
  • What if I don't want the horizontal line that comes with "fancy"?
    – user71207
    Commented Apr 28, 2021 at 11:53
  • 1
    You can set the \headrulewidth to zero. Commented Apr 29, 2021 at 12:34
  • Whats the exact command? \headrulewidth{set=0} ?
    – user71207
    Commented May 2, 2021 at 13:17
  • 1
    You should take a look at the fancyhdr documentation, it contains a lot of useful information. So \renewcommand{\headrulewidth}{0pt} Commented May 2, 2021 at 17:51
22

It depends which document class you are using.

If you are using document class memoir you please have a look to the question simple footers with only a page number. Document class memoir has its own header and footer mechanismn.

If you are using KOMA-Script, for example scrbook, you should use the KOMA-Script package scrpage2.

If you are using the classical document classes, for example book, you can use fancyhdr or scrpage2.

Meanwhile KOMA-Script has changed and was updated. The package scrpage2 has now changed to scrlayer-scrpage with more possibilites. I changed the following MWE to use the new package scrlayer-scrpage (only the call of the package has to be changed) instead of the old version scrpage2 (I only commented the call).

MWE for the usage of scrpage2 or scrlayer-scrpage (just move the comment sign to change the loaded package...):

\documentclass[
  fontsize=12pt  %
 ,english        % 
 ,headinclude    %
 ,headsepline    % line between head an document text
%,BCOR=12mm      % 
]{scrbook}       % twosided, A4 paper

\usepackage[latin9]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}

\usepackage{blindtext} % provides blindtext with sectioning

%\usepackage{scrpage2}  % header and footer for KOMA-Script, old version
\usepackage{scrlayer-scrpage}  % header and footer for KOMA-Script

\clearscrheadfoot                 % deletes header/footer
\pagestyle{scrheadings}           % use following definitions for header/footer
% definitions/configuration for the header
\rehead[]{This is my name}        % equal page, right position (inner) 
\lohead[]{This is my name}        % odd   page, left  position (inner) 
\lehead[]{this is page \pagemark} % equal page, left (outer) position
\rohead[]{this is page \pagemark}
% definitions/configuration for the footer
\cefoot[]{center of the footer!}  % equal page, center position
\cofoot[\pagemark]{\pagemark}     % odd   page, center position

\begin{document}

\Blinddocument

\end{document}

You must log in to answer this question.

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