Company logo in PDF output only on the first page

不打扰是莪最后的温柔 提交于 2019-12-10 11:18:14

问题


I was wondering if there is a way to include the company logo to a PDF document created by R Markdown only on the first page of the document. I have searched for an answer and the closest I could find is this. There are multiple solutions presented in the answers, however, neither of them works for me because they either:

  • include the logo at every page of the document (not just first); or
  • include the chapter title in the header (and a horizontal line below it) along with the logo.

I am looking for a way to include just the plain logo, with no chapter titles only on the first page of a PDF R Markdown document and I've ran out of all the resources I could find online. Is there someone who could aid me?

Before anyone asks: yes, it strictly has to be a PDF document, not HTML.


回答1:


The \includegraphics code line is insert after the R SETUP chunk in markdown. Here is an example of where I put the line \includegraphics :

---
geometry: "margin=1.5cm"
classoption: landscape
output:
  pdf_document: # Export to pdf
    number_sections: yes 
includes:
          in_header: ltx.sty
---



```{r SETUP, include=FALSE, message=FALSE, warning=FALSE}

knitr::opts_chunk$set(echo = FALSE,  
                  warning = FALSE,  
                  message = FALSE,  
                  results = "asis")

library(knitr) 
library(kableExtra) 
library(some_packages)

options(scipen = 999,
    digits = 2,
    width = 110)

```

\definecolor{astral}{RGB}{87,146,204}
\allsectionsfont{\color{astral}}
\setcounter{tocdepth}{5}


<!-- Title page -->
\includegraphics[width=7cm]{logo.jpg}

\begin{center}\begin{Large}
Project 1
\end{Large}\end{center}

\vfill


# Some R chunk
```{r results='asis'}
# Table, code, graphics.
```

So the line is insert between the R SETUP chunk and the next R chunk.



来源:https://stackoverflow.com/questions/56327814/company-logo-in-pdf-output-only-on-the-first-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!