1

Problem

I am trying to align a one-line right footer to the last line of a four-lines center one.

My current solution is to force line breaks using \- \\ three times before the actual page numbering. I also have to account for font size differences so I end up with \small{\-} \\ \scriptsize \- \\ \- \\ managing the vertical space.

Not only does this appear extremely inefficient and wrong but since the fourth lines of each footer are not of the same size, it is not looking quite nice.

fancyhdr footer

Bonus question

Why is it that in the screenshot the fourth line (4) is not properly centered with the others?

MWE

\documentclass[a4paper, draft, 12pt]{article}
\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{lipsum}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{
  \centering
  \small{1} \\
  \scriptsize
  2 \\
  3 \\
  4
}
\fancyfoot[R]{\footnotesize \thepage\ of \pageref{LastPage}}
\begin{document}
\pagestyle{fancy}
\lipsum
\end{document}
1

Put them in a tabular environment.

\fancyfoot[C]{%
  \scriptsize
  \begin{tabular}[b]{c}
  \small 1 \\
  2 \\
  3 \\
  4
  \end{tabular}%
}
1

Use this:

\fancyfoot[C]{
  \centering\footnotesize
  \begin{tabular}[b]{c}%
  1 \\
  2 \\
  3 \\
  4
\end{tabular}
}
\fancyfoot[R]{\footnotesize \thepage\ of \pageref{LastPage}}
1

Use a \Longstack:

\documentclass[a4paper, draft, 12pt]{article}
\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{stackengine}
\setstackEOL{\\}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{
  \centering\scriptsize\Longstack{\small 1\\2\\3\\4}%
}
\fancyfoot[R]{\footnotesize \thepage\ of \pageref{LastPage}}
\begin{document}
\pagestyle{fancy}
\lipsum
\end{document}

enter image description here

  • Works as expected, thanks. I do, however, prefer the tabular solution as it appears simpler. – Florian Nov 16 '16 at 13:07

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.