r - 将 Posterdown 包 (R) 中的 HTML 文件呈现为 PDF
问题描述
我正在尝试使用posterdown
RMarkdown 中的包(https://pythonawesome.com/use-rmarkdown-to-generate-pdf-conference-posters-via-html-or-latex/)生成一个不错的 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
---
蒂亚!
解决方案
您可以使用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;
}
```