7

In the MWE, geometry is set to leave a top margin of 1cm on the top and on the back of the page. Yet, with FancyHDR on the top of that, occupy some parts of this margin and I have to manually tweak the margins in geometry to get an descent margin.

Is there some correction I could do to have this sorted out automatically ? NB: I compile with xelatex.

\documentclass[twoside]{report}
\usepackage{fontspec} % 

\usepackage[hidelinks,xetex]{hyperref}

\usepackage[top=1cm,bottom=1cm,left=0.5cm,right=0.5cm,asymmetric]{geometry}
\geometry{bindingoffset=2.1cm}
\usepackage{lipsum}

\usepackage{fancyhdr}

\fancypagestyle{style}{
    \fancyhf{}                          
    \fancyhead[LE]{\leftmark} %\slshape 
    \fancyhead[RO]{\rightmark} %\slshape
    \fancyfoot[LE,RO]{\hyperlink{toc}{\thepage}}
    \renewcommand{\headrulewidth}{1pt}  
    \renewcommand{\footrulewidth}{1pt}}
\pagestyle{style}

\begin{document}
\chapter{Chapter}

\lipsum[1-30]

\end{document}
6

It actually is very easy, and I should have read the manual for geometry before asking this question. But now it is asked, all there is to do is to add includeheadfoot in the options of the geometry package and problem solved.

\documentclass[twoside]{report}
\usepackage{fontspec} % 

\usepackage[hidelinks,bookmarksnumbered,pagebackref,xetex]{hyperref}

\usepackage[top=0cm,bottom=0cm,left=0.5cm,right=0.5cm,includeheadfoot,asymmetric]{geometry}
\geometry{bindingoffset=2.1cm}
\usepackage{lipsum}

\usepackage{fancyhdr}

\fancypagestyle{style}{
    \fancyhf{}                          
    \fancyhead[LE]{\leftmark} %\slshape 
    \fancyhead[RO]{\rightmark} %\slshape
    \fancyfoot[LE,RO]{\hyperlink{toc}{\thepage}}
    \renewcommand{\headrulewidth}{1pt}  
    \renewcommand{\footrulewidth}{1pt}}
\pagestyle{style}

\begin{document}
\chapter{Chapter}

\lipsum[1-30]

\end{document}
| improve this answer | |
1

You have to fit your header and footer inside a narrow space; so you need to reduce headsep and footskip. Here's an example:

\documentclass[twoside]{report}

\usepackage[
  top=1cm,
  bottom=1cm,
  left=0.5cm,
  right=0.5cm,
  headsep=3pt,
  footskip=20pt,
  asymmetric,
  bindingoffset=2.1cm
]{geometry}

\usepackage{fontspec}
\usepackage{fancyhdr}
\usepackage[hidelinks,xetex]{hyperref}

\usepackage{lipsum}

\pagestyle{fancy}
\fancypagestyle{style}{%
    \fancyhf{}                          
    \fancyhead[LE]{\leftmark} %\slshape 
    \fancyhead[RO]{\rightmark} %\slshape
    \fancyfoot[LE,RO]{\hyperlink{toc}{\thepage}}
    \renewcommand{\headrulewidth}{1pt}  
    \renewcommand{\footrulewidth}{1pt}}
\pagestyle{style}

\begin{document}
\chapter{Chapter}

\lipsum[1-30]

\end{document}

Are you sure you want to use those specifications?

| improve this answer | |
  • Thanks, but this only moves the problem from having to tweak top and bottom margins to headsep and footskip. Is there a way it can automatically determine the size of the headings and footers, so if I type top and bottom to 0, the headings and footer touch the edges of the page. – HcN Sep 10 '15 at 14:29
  • @HcN No, there isn't. – egreg Sep 10 '15 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.