将背景图像添加到 R Markdown (.rmd) 文件以进行 PDF 输出? [英] Adding background image to R Markdown (.rmd) file for PDF output?

查看:38
本文介绍了将背景图像添加到 R Markdown (.rmd) 文件以进行 PDF 输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将背景图像添加到用于 PDF 输出的 R Markdown (.rmd) 文件?

Is it possible to add a background image to a R Markdown (.rmd) file for PDF output?

我已经浏览了 Pandoc 的 R Markdown 文档,但找不到任何提及添加背景图片.

I have scoured through Pandoc's R Markdown documentation but cannot find any mention of adding a background image.

推荐答案

来自 this tex.SE answer:将以下内容另存为 header.tex(用背景图片的路径替换 image.jpg):

From this tex.SE answer: save the following as header.tex (replacing image.jpg by the path to your background image):

\usepackage{background}

\backgroundsetup{
scale=1,
color=black,
opacity=0.4,
angle=0,
pages=all,
contents={%
  \includegraphics[width=\paperwidth,height=\paperheight]{image.jpg}
  }%
}

并添加到您的 yaml 中:

And add to your yaml:

---
output: 
  pdf_document:
    includes:
      in_header: header.tex
---

请参阅 background 文档,了解有关如何自定义输出.

See the background documentation for tips on how to customize the output.

这篇关于将背景图像添加到 R Markdown (.rmd) 文件以进行 PDF 输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆