Rmarkdown的主题格式
Rmarkdowm作为可复用报告的优秀工具,除了提供文档编辑、图表输出外,还有许多主题格式供使用者选择。除了默认的主题外,还可以通过加载rticles、prettydoc、rmdformats、tufte等包获取更多主题格式。下面我们看看几类扩展包里的主题样式。
注: 接下来的教程我是已经安装这些包了,没安装的记得提前安装好!不然运行会出错。
1 rticles包
官网:https://github.com/rstudio/rticles;
具体教程:https://bookdown.org/yihui/rmarkdown/rticles-templates.html
rticles软件包提供了各种期刊和出版商的模板:
- JSS articles (Journal of Statistical Software)
- R Journal articles
- CTeX documents(中文pdf,强烈推荐!)
- ACM articles (Association of Computing Machinery)
- ACS articles (American Chemical Society)
- AMS articles (American Meteorological Society)
- PeerJ articles
- Elsevier journal submissions
- AEA journal submissions (American Meteorological Society)
- IEEE Transaction journal submissions
- Statistics in Medicine journal submissions
- Royal Society Open Science journal submissions
- Bulletin de l’AMQ journal submissions
- MDPI journal submissions
- Springer journal submissions
在此只对下面一个模板进行演示,其他模板操作类似,但是一般模板是不能包含中文字体的哦!
- CTeX Documents(中文版本)
下载完对应的包之后,找到对应模板打开即可。输出pdf是需要配置tex环境的哦!建议安装Tinytex,具体安装教程见前面。
编译后得到的结果,这是他模板原始的样子,如果想调整页面行间距,字体颜色等,请见下次推文(公众号:庄闪闪的R语言手册),我将会把这些小细节进行汇总。
2 rmdformats包
之后的这几个包,内部都包含了挺多模板的,下面yaml文件只是其中一个,如果想尝试该包内部其他模板,请根据上述操作进行,选择好模板,编译之后看看是不是你想要的模板。
接下来我对部分相对不错的模板进行展示,你可以直接复制我的头部文件到.rmd格式中,或者打开模板窗口进行选择(操作在下面)。
- 方法一
--- title: "Rmarkdown入门教程" author: "庄闪闪的R语言手册" date: "2/18/2021" output: rmdformats::readthedown: self_contained: true thumbnails: true lightbox: true gallery: false highlight: tango ---
方法二:
在你安装完该包之后你可以使用通过按钮新建该模版(其实他有很多类似的模板,我这里只展现了一种):
以下模板也可以通过这种方式构建,前提是你安装了这个包,这样你就可以在From Template中找到该包对应的模板了。
3 prettydoc包
--- title: "Rmarkdown入门教程" author: "庄闪闪的R语言手册" date: "2/18/2021" output: prettydoc::html_pretty: theme: cayman highlight: github ---
4 tufte包
--- title: "Rmarkdown入门教程" author: "庄闪闪的R语言手册" date: "2/18/2021" output: tufte::tufte_html: default ---
5 cerulean包
--- title: "Rmarkdown入门教程" author: "庄闪闪的R语言手册" date: "2/18/2021" output: html_document: theme: cerulean highlight: tango ---

![WL[ZGQU]P`G5[3VDA)NV}8T.png WL[ZGQU]P`G5[3VDA)NV}8T.png](https://ucc.alicdn.com/pic/developer-ecology/a8fd194e3b8d46019053a30f6f25c58c.png?x-oss-process=image/resize,w_1400/format,webp)
![%JU~A@QT4FU_1D52507JA]V.png %JU~A@QT4FU_1D52507JA]V.png](https://ucc.alicdn.com/pic/developer-ecology/c27e4b5a4e6f475990880e5627c00559.png?x-oss-process=image/resize,w_1400/format,webp)

![]QD{NBB{ZDE3%0Y)8QZXOF3.png ]QD{NBB{ZDE3%0Y)8QZXOF3.png](https://ucc.alicdn.com/pic/developer-ecology/6f2d9c8768164cc9bcd476a0671e19f4.png?x-oss-process=image/resize,w_1400/format,webp)


