0

How do I fix the horizontal alignment of my footer in a PDF file produced from an R Markdown using LaTex?

Here's my header.tex file:

\usepackage{graphicx}
\usepackage{fancyhdr}
\fancyhf{}
\newcommand {\changefont} {%
  \fontsize{6}{8}\selectfont
}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[LE, LO]{\includegraphics[height=1.5cm]{image1.png}}
\fancyfoot[CE, CO]{\changefont This is the placeholder for the middle footer text that is very lengthy and occupies at least 3 lines}
\fancyfoot[RE, RO]{\includegraphics[height=1.5cm]{image2.png}}
\fancypagestyle{plain}{\pagestyle{fancy}}

And my RMD file has the following yaml:

---
  title: "PDF Outpuf File"
output: 
  pdf_document:
  includes:
  in_header: Span_Data_Explorer/header.tex
---

How do I make the footer so that they're well-aligned horizontally (either bottom-, center-, or top-aligned)?

This is what I want my footer to look like (in-general).

enter image description here

But my bare pdf output looks like this (sorry had to blur the images and actual text). enter image description here

1

For center and bottom aligned, you can place the contents of the footer items inside minipages like this:

\documentclass{book}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{fancyhdr}
\fancyhf{}
\newcommand {\changefont} {\fontsize{6}{8}\selectfont}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[LE, LO]{
\begin{minipage}[c]{1.55cm}\includegraphics[height=1.5cm]{example-image-b}\end{minipage}}
\fancyfoot[CE, CO]{\begin{minipage}[c]{.6\textwidth}\changefont This is the placeholder for the middle footer text that is very lengthy and occupies at least 3 lines is very lengthy and occupies at least 3 lines is very lengthy and occupies at least 3 lines\end{minipage}}
\fancyfoot[RE, RO]{\begin{minipage}[c]{1.55cm}\includegraphics[height=1.5cm]{example-image-b}\end{minipage}}
\fancypagestyle{plain}{\pagestyle{fancy}}
\setlength{\footskip}{3cm}
\begin{document}
\lipsum
\end{document}

Output:

enter image description here

enter image description here

For bottom needs some hacks or other way...

PS: For better results in bottom, inner sep=0 would help too...

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.