1

I'm trying to set and resize an image as a footer in the title page of a markdown document.

I got the desired results in LaTex with:

\documentclass{article}


\title{Test}
\author{}
\date{}
\usepackage{graphicx}
\usepackage{fancyhdr}


\fancypagestyle{plain}{
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \lfoot{\includegraphics[width=400px]{footer.png}}
}

\begin{document}
    \maketitle
\end{document}

But when I try to do the same thing in the Markdown document I get the following error:

Error in yaml::yaml.load(string, ...) : Scanner error: while scanning a plain scalar at line 6, column 5 found a tab character that violate intendation at line 7, column 1 Calls: ... parse_yaml_front_matter -> yaml_load_utf8 -> Execution halted

The code I have is:

---
title: "Test"
author: ""
header-includes:
- \usepackage{graphicx}
- \usepackage{fancyhdr}
- \fancypagestyle{plain}{
- \fancyhf{}
- \renewcommand{\headrulewidth}{0pt}
- \renewcommand{\footrulewidth}{0pt}
- \lfoot{\includegraphics[width=400px]{footer.png}}}
output: pdf_document
---

I've tried solutions like Creating a footer for every page using R markdown but it does't do the job for the title page.

Lonbot
  • 15
  • 5
  • 1
    Here is a similar issue: https://github.com/rstudio/rmarkdown/issues/1425. @mb21's answer below basically said you would need a pipe after `header-includes`, which is also what I said in the Github issue. – Yihui Xie Sep 15 '18 at 03:28

2 Answers2

2

Try:

---
title: "Test"
author: ""
header-includes: |
  \usepackage{graphicx}
  \usepackage{fancyhdr}
  \fancypagestyle{plain}{
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
  \lfoot{\includegraphics[width=400px]{footer.png}}}
output: pdf_document
---
mb21
  • 34,845
  • 8
  • 116
  • 142
  • 1
    The pipe did make the picture appear but it wouldn't grow. In order to make the image as big as I wanted it I also had to specify its height with: `\lfoot{\includegraphics[width=400px, height=100px]{footer.png}}`. – Lonbot Sep 15 '18 at 11:31
0

Yaml is a beast for escaping quotes and suchlike. You might want to create a separate file containing your latex header and just include that.

---
header-includes: yourfile.tex
---
bjw
  • 2,046
  • 18
  • 33