TransWikia.com

Inner Spacing within Footer (fancyhdr)

TeX - LaTeX Asked by Marius Herget on July 12, 2021

How can I create exactly the following spaces/distances?
enter image description here

Margin from bottom to footerrule: 22mm
Distance from footerule to text: 5mm
Distance from Footerrule to top of footertext: 7mm

Current state:
enter image description here

MWE:

documentclass[14pt,oneside,a4paper]{article}
usepackage[
  a4paper,
  left = 16mm,
  right = 16mm,
  textwidth = 178mm,
  top = 20mm,
  bottom= 22mm, % 22m lower bound + 5mm footer to text
  % headheight=17pt, % as per the warning by fancyhdr
  % includehead,
  % includefoot,
  heightrounded, % to avoid spurious underfull messages
  headheight=0mm,%
  headsep=0mm,%
]{geometry}
usepackage[english]{babel}
usepackage{blindtext}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Necessary packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
renewcommandfamilydefault{sfdefault}
usepackage{ngerman}
usepackage[scaled]{uarial}
renewcommand{familydefault}{sfdefault}
usepackage{xcolor}
usepackage{ifthen}
setlength{parindent}{0em}
setlength{parskip}{0em}
% renewcommand{baselinestretch}{0.0}
usepackage{enumitem}
usepackage[geometry]{ifsym}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Header and Footer Format
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% letfootruleskipundefined %undefine footruleskip
usepackage{fancyhdr}
usepackage{calc}
renewcommand{headrulewidth}{0pt}
renewcommand{footrulewidth}{0.25mm}
renewcommand{footrule}{hbox toheadwidth{color{black}leadershrule height footrulewidthhfill}}
renewcommand{footruleskip}{5mm} % 7
setlength{footskip}{5mm + 0.25mm + 7mm + 2.5mm}
pagestyle{fancy}
fancyhf{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Custom Footer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fancyfoot[L]{
  % vfill
  textbf{
      {fontsize{9}{14}selectfont SOME TITLE}
  }
}
fancyfoot[R]{
  % vfill
  makebox[86mm][r]{%
       {fontsize{9}{14}selectfont Contact: [email protected]}
    hfill
       {fontsize{9}{14}selectfont www.example.com}
  }%
}


begin{document}
Blinddocument
end{document}

One Answer

I achieved my requirements with the following code.

Define the footskip in geometry: 7mm + 1em since I need the 7mm space and one line of text.

usepackage[%
  a4paper,%
  left = 16mm,%
  right = 16mm,%
  textwidth = 178mm,%
  top = 20mm,%
  bottom= 22mm,%
  heightrounded,% to avoid spurious underfull messages
  headheight=0mm,%
  headsep=0mm,%
  footskip=7mm+8pt,%
  % showframe
]{geometry}

Afterward, I corrected my fancyhdr settings like the following:

usepackage{fancyhdr}
renewcommand{headrulewidth}{0pt}
renewcommand{footrulewidth}{0.25mm}
renewcommand{footruleskip}{7mm}
makeatletter
patchcmd{footrule}
  {if@fancyplain}
  {color{gray}if@fancyplain}
  {}
  {}
makeatother
pagestyle{fancy}
fancyhf{}

I achieve the additional 5mm between the footrule and the body with an extra vspace{5mm} at the last element of each page (which is in my case always the same element).

Answered by Marius Herget on July 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP