【问题标题】:How to change font in RMarkdown when using "rticles" package?使用“rticles”包时如何更改 RMarkdown 中的字体?
【发布时间】:2019-09-26 15:32:01
【问题描述】:

我最近在 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
---

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

【问题讨论】:

    标签: r latex yaml r-markdown


    【解决方案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        
    ---
    

    【讨论】:

    • 谢谢!如果允许我提出后续问题 - 我在哪里可以找到可以在上面的代码中使用的字体列表?
    • @ben XeLaTeX 的美妙之处在于您可以使用系统中安装的任何 TTF/OTF 字体。例如 Calibri (Light) 随 Windows 或 Office 提供,但仍可从 XeLaTeX 使用。在某些系统上,您可以在命令行上使用fc-list : family 列出已安装的字体。
    猜你喜欢
    • 2015-05-18
    • 1970-01-01
    • 2019-07-07
    • 2023-03-02
    • 2015-12-15
    • 1970-01-01
    • 1970-01-01
    • 2014-08-16
    • 1970-01-01
    相关资源
    最近更新 更多