使用“ rticles”包时如何在RMarkdown中更改字体?

时间:2019-09-26 15:32:01

标签: r latex yaml r-markdown

我最近在R中安装了“ rticles”软件包,以在RMarkdown中自动设置期刊文章模板。到目前为止,我一直对它印象深刻,但是我希望能够更改字体。当然可以这样做,但是我一直找不到任何在线资源来解释如何做到这一点。

我有兴趣编织成PDF。

这是我的RMarkdown脚本顶部的YAML:

---
title: This title
author:
  - name: This author
    email: t.author@thisPlace.com
    affiliation: This institute
address:
  - code: This institute
    address: Street, City, State, etc.
abstract: |
  This is the abstract.

  It consists of two paragraphs.
keywords: "fun, happiness"
journal: "This Elsevier Journal"
date: "`r Sys.Date()`"
output: rticles::elsevier_article
---

我通过在R中运行以下代码行生成了此代码:

rmarkdown::draft("Test.Rmd", template = "elsevier_article", package = "rticles")

那么我在所有这些地方可以控制字体?在使用“ rticles”之前,我曾经通过更改乳胶引擎然后按如下所示指定字体来更改字体:

---
title: This title
author: "This author"
date: "`r Sys.Date()`"
output:
  pdf_document:
    toc: yes
    toc_depth: 4
    fig_caption: TRUE
    df_print: kable
    latex_engine: xelatex
mainfont: Calibri Light
---

是否可以在“文章”中做类似的事情?

1 个答案:

答案 0 :(得分:1)

您控制字体的方式与您之前的操作类似:

---
title: This title
author:
  - name: This author
    email: t.author@thisPlace.com
    affiliation: This institute
address:
  - code: This institute
    address: Street, City, State, etc.
abstract: |
  This is the abstract.

  It consists of two paragraphs.
keywords: "fun, happiness"
journal: "This Elsevier Journal"
date: "`r Sys.Date()`"
output:
  rticles::elsevier_article:
    latex_engine: xelatex
mainfont: Calibri Light        
---