I'm writing a report using multiple R Markdown files, and to facilitate combining them I decided to use the bookdown package. I face a problem with inserting a logo as header using fancyhdr LaTeX package, that worked fine in a regular .Rmd
file.
index.Rmd file:
---
documentclass: book
classoption: openany
site: bookdown::bookdown_site
subparagraph: true
output:
bookdown::pdf_book:
includes:
in_header: preamble.tex
toc_depth: 4
latex_engine: xelatex # to receive Arial as font --> install.packages("xelatex") works for R users
link-citations: yes
fontsize: 12pt
linestretch: 1.25
---
The preamble.tex is:
\usepackage[german]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{fontspec}
\setmainfont{Arial}
\pagestyle{fancy}\setlength\headheight{100pt}
\fancyhead[L]{\includegraphics[width=456px]{INS_logo.png}}
\fancyhead[R]{\includegraphics[width=4.1cm]{shurp-2018-logo-blue-transparent.png}}
\renewcommand{\headrulewidth}{0pt}
\rfoot{Seite \thepage \hspace{1pt} von \pageref{LastPage}}
\geometry{a4paper, total={170mm,257mm}, left=20mm, top=10mm, }
\titleformat{\chapter}
{\normalfont\LARGE\bfseries}{\thechapter}{1em}{}
\titlespacing*{\chapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
Everything works fine except that the necessary logos don't appear in the header. Using the same code in a plain pdf_document
format works fine.
I guess it has something to do with the book-option - does anyone know more here? I consulted https://bookdown.org/yihui/bookdown/, their github-repo as well as StackOverflow and the documentation on fancyhdr.
my sessioninfo (R Studio 1.2.1070):
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 backports_1.1.2 bookdown_0.7 rprojroot_1.3-2 htmltools_0.3.6 tools_3.5.1 yaml_2.2.0
[8] Rcpp_0.12.19.3 rmarkdown_1.10 knitr_1.20 xfun_0.4 digest_0.6.18 evaluate_0.12
Thank you for any suggestions.