rligaturexaringan

xaringan metropolis no ligature in code output


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

Solution

  • 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]
    ```