Here's the MWE:

\documentclass[a4paper,twoside=true,11pt,openright]{book}

% packages:
\usepackage{blindtext}
\usepackage{geometry}
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhf{}
\fancyfoot[RO,LE]{\thepage}

\begin{document}
\blinddocument
\end{document}


Here's what the document looks like, the header (and footer) goes outside the page. I would like both of them to extend slightly beyond the text width.

• Loading package geometry changes the page layout and enlarges marginparwidth. You can remove the package or load it with option pass (disables all of the geometry options and calculations except verbose and showframe) or you adjust marginparwidth to ensure that the marginpar does not go outside of the paper: eg.\usepackage[marginparwidth=2cm]{geometry}.
– esdd
Oct 26, 2021 at 18:45
• fancyhdr is not the only way to customise headers and footers: titleps, which is a companion package of titlesec, has a widenhead(*) command. Oct 26, 2021 at 19:28
• @esdd Thanks your last suggestion with 1cm instead of 2cm did the exact job I wanted! Oct 26, 2021 at 19:37
• For completeness: The fancyhdr way to enlarge the header/footer width would be \fancyhfoffset[LE,RO]{1cm}. It extends to the left on even and to the right on odd pages. See the documentation. Oct 26, 2021 at 21:40

Two little changes to your MWE and you are done:

\documentclass[a4paper,twoside=true,11pt,openright]{book}

% packages:
\usepackage{blindtext}
\usepackage{geometry}
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhf{}

• You could reduce the 2 lines \addtolength{\headwidth}{.5cm} to one line \addtolength{\headwidth}{1cm}. Oct 27, 2021 at 14:37