When I use the fancyhdr
package, the paper margins stretched and the white space decrease, how can I set the paper margins correctly when using the fancyhdr
package?
Here is the code,
\documentclass[a4paper, 14pt,oneside]{extreport}
\usepackage[top=2cm,bottom=2cm,left=3cm,right=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{lipsum}
\usepackage{fancyhdr}
\parindent=2cm
\sloppy
\hyphenation{}
\hyphenpenalty=4000
\exhyphenpenalty=4000
\begin{document}
\pagenumbering{arabic}
\pagestyle{fancy}
%\rhead{\nouppercase{\textbf{\textsc{\textsf{\thepage}}}}}
\rhead{}
\lhead{\nouppercase{\textbf{\textsc{\textsf{\leftmark}}}}}
\renewcommand{\headrulewidth}{1pt}
\fancyfoot{}
\cfoot{\nouppercase{\textbf{\textsc{\textsf{\thepage}}}}}
\chapter{Bla bla}
\lipsum
\end{document}
Best Answer
When you set the margins with
geometry
, the header and footer are not taken into consideration by default. You have to explicitly add theincludehead
andincludefoot
options for that.Here's a better version of your code; note that sans serif bold small caps is not available with Computer Modern fonts (and I suggest using just one layer of emphasis, so either bold or small caps, not both).
Don't issue
\sloppy
. Your aim is to avoid problems in paragraph formatting, but this is not the solution as it allows very bad paragraphs.