Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

knitr: Using subscript with fig.cap in Markdown

How do I go about including subscript in a figure caption when using {r fig.cap=""}?

Mock .Rmd file:

---
output:
  pdf_document:
    fig_caption: yes
---

```{r setup, include = FALSE}
library(knitr)
```{r fig.cap = "CO2 Concentration", echo = FALSE}
plot(rnorm(100))

I would like to get the 2 in CO2 in subscript. Is fig.cap the best way, or is something better?

like image 599
Martin J Lambert Avatar asked Apr 24 '21 04:04

Martin J Lambert


1 Answers

You could use standard Markdown syntax

---
output:
  pdf_document:
    fig_caption: yes
---

This is ^superscript^  
This is ~subscript~

```{r fig.cap = 'CO~2~ Concentration', echo = FALSE}
plot(rnorm(100))
```

enter image description here

like image 74
Waldi Avatar answered Sep 27 '22 20:09

Waldi