Adding background image to R Markdown (.rmd) file for PDF output?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 14:16:21

问题


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

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


回答1:


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}
  }%
}

And add to your yaml:

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

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



来源:https://stackoverflow.com/questions/44043187/adding-background-image-to-r-markdown-rmd-file-for-pdf-output

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