Headers and Footers in LaTeX

The fancyhdr package gives full control over page headers and footers.

Quick Answer

latex
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}  % clear defaults

\fancyhead[L]{My Thesis}
\fancyhead[R]{\leftmark}
\fancyfoot[C]{\thepage}

Position Keys

Use L, C, R for left/center/right, combined with H (header) or F (footer). For two-sided documents, use O (odd) and E (even).

latex
\fancyhead[L]{left header}
\fancyhead[C]{center header}
\fancyhead[R]{right header}
\fancyfoot[L]{left footer}
\fancyfoot[C]{center footer}
\fancyfoot[R]{right footer}

% Two-sided (thesis):
\fancyhead[LE]{\leftmark}   % even pages, left
\fancyhead[RO]{\rightmark}  % odd pages, right

Automatic Section/Chapter Names

latex
\leftmark   % current chapter (book) or section (article)
\rightmark  % current section (book) or subsection (article)

\fancyhead[R]{\nouppercase{\leftmark}}

Writing your thesis in LaTeX?

MonsterWriter's LaTeX Workspace gives you real-time PDF preview with no compile limits — at a fraction of Overleaf's price. Works just like Overleaf, costs 11× less.

Try MonsterWriter free

Remove the Horizontal Rule

latex
% Remove header rule:
\renewcommand{\headrulewidth}{0pt}

% Remove footer rule:
\renewcommand{\footrulewidth}{0pt}

% Custom thickness:
\renewcommand{\headrulewidth}{0.4pt}

Plain Style on Chapter Pages

LaTeX automatically switches to plain style on chapter-opening pages. Override it:

latex
\fancypagestyle{plain}{
  \fancyhf{}
  \fancyfoot[C]{\thepage}
  \renewcommand{\headrulewidth}{0pt}
}

Title Page Without Header

latex
\begin{document}
\thispagestyle{empty}  % no header/footer on title page
\maketitle
\newpage
\pagestyle{fancy}      % start fancy from page 2
\end{document}

Related Topics