将 Posterdown Package (R) 中的 HTML 文件渲染为 PDF

问题描述

我正在尝试使用 RMarkdown (https://pythonawesome.com/use-rmarkdown-to-generate-pdf-conference-posters-via-html-or-latex/) 中的 posterdown 包来生成一个不错的 PDF 文件。我注意到安装包后,认模板会生成为 HTML 文件。有什么方法可以将其设置为生成为 PDF 而不是 HTML 文件吗?

此外,有没有办法将标题标题中的认颜色(绿色)自定义为我选择的 HTML 颜色代码

这是认的 YAML

---
title: Generate Reproducible & Live HTML and PDF Conference Posters Using RMarkdown
author:
  - name: Brent Thorne
    affil: 1
    orcid: '0000-0002-1099-3857'
  - name: Another G. Author
    affil: 2
affiliation:
  - num: 1
    address: Department of Earth Science,brock University
  - num: 2
    address: Department of Graphics and Layouts,University of Posters; Canada
column_numbers: 3
logoright_name: https://raw.githubusercontent.com/brentthorne/posterdown/master/images/betterhexlogo.png
logoleft_name: https://raw.githubusercontent.com/brentthorne/posterdown/master/images/betterhexlogo.png
output: 
  posterdown::posterdown_html:
    self_contained: false
bibliography: packages.bib
---

TIA!

解决方法

您可以使用 YAML 或内联 CSS 控制颜色,您需要将 knit: pagedown::chrome_print 添加到您的 YAML 以打印为 PDF 并保留 CSS 代码。我也出于习惯将代码更改为 self_contained: TRUE。当我运行下面的代码时,我改变了 posterdown 标题颜色,它在我的默认 PDF 查看器中打开,因为它现在是 .PDF

---
title: Generate Reproducible & Live HTML and PDF Conference Posters Using RMarkdown
author:
  - name: Brent Thorne
    affil: 1
    orcid: '0000-0002-1099-3857'
  - name: Another G. Author
    affil: 2
affiliation:
  - num: 1
    address: Department of Earth Science,Brock University
  - num: 2
    address: Department of Graphics and Layouts,University of Posters; Canada
column_numbers: 3
logoright_name: https://raw.githubusercontent.com/brentthorne/posterdown/master/im    ages/betterhexlogo.png
logoleft_name: https://raw.githubusercontent.com/brentthorne/posterdown/master/ima    ges/betterhexlogo.png
output: 
  posterdown::posterdown_html:
    self_contained: TRUE
knit: pagedown::chrome_print
---

```{css,echo=FALSE}
div.title_container{
   background-color: #ff7f50;
}

div.logo_left{
  background-color: #ff7f50;
}
div.logo_right{
  background-color: #ff7f50;
}
```

enter image description here