ben
ben

Reputation: 799

How to change font in RMarkdown when using "rticles" package?

I recently installed the "rticles" package in R to automatically set up a journal article template in RMarkdown. I've been pretty impressed with it so far, but I'd like to be able to change the font. Surely this is possible somehow, but I have been unable to find any online resource explaining how to do it.

I am interested in knitting to PDF.

Here is the YAML at the top of my RMarkdown script:

---
title: This title
author:
  - name: This author
    email: [email protected]
    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
---

I generated this by running the following line of code in R:

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

So where in all of this can I control font? Before using "rticles" I used to change the font by changing the latex engine and then specifying the font as follows:

---
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
---

Is it possible to do something analogous to this in "rticles"?

Upvotes: 3

Views: 495

Answers (1)

Ralf Stubner
Ralf Stubner

Reputation: 26833

The way you control fonts is analogous to what you did before:

---
title: This title
author:
  - name: This author
    email: [email protected]
    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        
---

Upvotes: 1

Related Questions