knitr: Using subscript with fig.cap in Markdown

Viewed 693

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?

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

Related