在 R markdown pdf 的每一页上包含徽标(图像)

Include logo (image) on every page of R markdown pdf

我正在尝试将我公司的徽标包含在 R 降价报告中。输出必须是pdf。徽标必须用作文件左上角报告每一页的模板。例如,您可以使用此 google 徽标 https://en.wikipedia.org/wiki/Google#/media/File:Google_2015_logo.svg

我希望报告看起来像这样(抱歉图像模糊,但我只是想举个例子)-

左上角的 google 徽标应该出现在每个页面上。

我进行了搜索,但我进行的所有搜索都显示了如何使用乳胶或 HTML 输出来执行此操作。

https://bookdown.org/yihui/rmarkdown-cookbook/latex-logo.html

我最接近的是这个名为 reports.Rmd 的降价文档,它看起来像 -

---
title: "Report"
output: pdf_document
params: 
  study: NA
  mid : NA
---

![Caption.](google.png)

```{r, echo=FALSE}
paste0("Study : ", params$study)
paste0("ID",  params$mid)
```

我运行这个来自另一个R脚本作为-

library(rmarkdown)
study <- 'ABC'
mid <- '73023'

rmarkdown::render('reports.Rmd', pdf_document(), params = list(
  study = study, mid = mid
))

这 运行s 并产生这个输出

我可以使用 How to set size for local image using knitr for markdown? 调整图像的大小,但我不知道如何将其放在页面的左上角。感谢阅读。

这是适合您的模板:

---
title: 'You are really need to use LaTeX'
author: "You"
date: "`r Sys.Date()`"
output:
  pdf_document

header-includes:
     \usepackage{fancyhdr}
     \usepackage{graphicx}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

\addtolength{\headheight}{3.0cm} 
\fancypagestyle{plain}{} 
\pagestyle{fancy} 
\fancyhead[R]{\includegraphics[width = 100pt]{your_pic.png}}
\renewcommand{\headrulewidth}{0pt} 


This is an R Markdown document. Markdown is a simple formatting syntax for 
authoring HTML, PDF, and MS Word documents. For more details on using R Markdown 
see <http://rmarkdown.rstudio.com>.

and blah-blah...

所以,不要忘记安装 LaTeX 和软件包 fancyhdr, graphics

具体怎么做,可以看看there. 或者您可以安装 MikTeX 等。您可以在 SO/in 网上找到很多信息。

LaTeX知识让你以后的生活一次也省不了;)