2

I am using xaringan (metropolis theme) to prepare some slides for teaching R, thus I would like to see the code "as is". Xaringan currently uses ligatures in the code, which I think looks nice but is really bad when teaching the language to someone who starts from zero.

To give you an example <- gets rendered as

enter image description here

and != gets rendered as

enter image description here

Is there any way around this?

A MWE looks like this (removing the metropolis-fonts removes the ligatures but changes the fonts of course)

---
output:
  xaringan::moon_reader:
    lib_dir: libs
    css: [default, metropolis, metropolis-fonts]
    nature:
      highlightStyle: github
      highlightLines: true
      highlightSpans: true
      countIncrementalSlides: false
---

```{r}
x <- 1:10
x[1] != x[2]
```
David
  • 9,216
  • 4
  • 45
  • 78

1 Answers1

2

Looking through the metropolis theme, gave the solution as using the following css, where we switch from Fira Code to Fira Mono.

mycss.css

.remark-code, .remark-inline-code {
   font-family: 'Fira Mono', 'Lucida Console', Monaco, monospace;
   font-size: 80%;
}

presentation.Rmd

---
output:
  xaringan::moon_reader:
    lib_dir: libs
    css: [default, metropolis, metropolis-fonts, mycss.css]
    nature:
      highlightStyle: github
      highlightLines: true
      highlightSpans: true
      countIncrementalSlides: false
---

No change in fonts here

```{r}
x <- 1:10
x[1] != x[2]
```
David
  • 9,216
  • 4
  • 45
  • 78