[Tex/LaTex] How to space the header and footer to sit on the text box, without the white space between the header,footer and text

fancyhdrgeometryheader-footersectstyspacing

Due to the details of my project, I can't have any header/footer text beyond 2.0cm. Since the outer margins reject my geometry code, is there any way to make the headers and footers sit exactly on the border of the text box?

\documentclass[11pt]{article}

\usepackage{sectsty,fancyhdr}
\sectionfont{\LARGE\bfseries}%this will keep the formating of sections
\usepackage{geometry}
\usepackage{lipsum}%remove 

\pagestyle{fancy}
\fancyhf{}
\rhead{} % right side of upper footer
\lhead{Project tile}
\renewcommand{\headrulewidth}{2.0pt}% Width of the top line
\renewcommand{\footrulewidth}{1.0pt} 
\setlength{\headheight}{13.6pt}%used to remove the \fancyhf{} \headheight error
\rfoot{Page \thepage}% opposite of above
\lfoot{\leftmark}% show the name of section 

\geometry{% margin settings
    paper=a4paper, 
    inner=2.0cm, % Inner margin
    outer=2.0cm, % Outer margin
    bindingoffset=0.0cm, % Binding offset
    top=2.0cm, % Top margin
    bottom=2.0cm, % Bottom margin
    showframe,% show how the type block is set on the page
}

\makeatletter
\renewcommand{\sectionmark}[1]{%this avoids the \makecaptical of footers
  \markboth{\ifnum \c@secnumdepth>\z@%this allowes symbols in foorters
      \thesection\hskip 1em\relax
    \fi #1}{}}
\makeatother

\begin{document}

\section{Introduction}
\subsection{Super introduction}
  \lipsum[4-11]%remove
\end{document}  

Any ideas?

Best Answer

There is an option called includeheadfoot for the geometry. To additionally change the space between the head and the text you might use headsep and for the space between the foot and the text footskip:

\documentclass[11pt]{article}

\usepackage{sectsty,fancyhdr}
\sectionfont{\LARGE\bfseries}%this will keep the formating of sections
\usepackage{geometry}
\usepackage{lipsum}%remove 

\pagestyle{fancy}
\fancyhf{}
\rhead{} % right side of upper footer
\lhead{Project tile}
\renewcommand{\headrulewidth}{2.0pt}% Width of the top line
\renewcommand{\footrulewidth}{1.0pt} 
\setlength{\headheight}{13.6pt}%used to remove the \fancyhf{} \headheight error
\rfoot{Page \thepage}% opposite of above
\lfoot{\leftmark}% show the name of section 

\geometry{% margin settings
    paper=a4paper, 
    inner=2.0cm, % Inner margin
    outer=2.0cm, % Outer margin
    bindingoffset=0.0cm, % Binding offset
    top=2.0cm, % Top margin
    bottom=2.0cm, % Bottom margin
    showframe,% show how the type block is set on the page
    includeheadfoot,
    headsep=5mm,
    footskip=5mm
}

\makeatletter
\renewcommand{\sectionmark}[1]{%this avoids the \makecaptical of footers
  \markboth{\ifnum \c@secnumdepth>\z@%this allowes symbols in foorters
      \thesection\hskip 1em\relax
    \fi #1}{}}
\makeatother

\begin{document}

\section{Introduction}
\subsection{Super introduction}
  \lipsum[4-11]%remove
\end{document}  

This results in the foot and head being inside of the specified textheight (outside of the top and bottom margins).