Adjust header and footer width

fancyhdrgeometryheader-footer

Here's the MWE:

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

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

    \pagestyle{fancy}
    \addtolength{\headwidth}{\marginparsep}
    \addtolength{\headwidth}{\marginparwidth}
    \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
    \fancyhf{}
    \fancyhead[RO]{\rightmark}
    \fancyhead[LE]{\leftmark}
    \fancyfoot[RO,LE]{\thepage}
    \renewcommand{\headrulewidth}{1pt}



\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.
enter image description here

Best Answer

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}
\addtolength{\headwidth}{.5cm}
\addtolength{\headwidth}{.5cm}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhf{}
\fancyhead[RO]{\rightmark}
\fancyhead[LE]{\leftmark}
\fancyfoot[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{1pt}



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

enter image description here