sbac
sbac

Reputation: 2081

How to use greek letters in fig.caption using RMarkdown?

This code produces an error when I try to knit a pdf using RMarkdown in RStudio.

How can I write a greek letter in fig.caption as for example $\beta$?

---
title: "Untitled"
author: "SB"
date: "Thursday, January 29, 2015"
output: 
  pdf_document:
  fig_caption: yes
---


```{r var, echo=FALSE, fig.cap="Cars variation rate between year $t$ and $t-1$ for $0 < \beta < 1$"}
plot(cars)
```

Upvotes: 3

Views: 3134

Answers (1)

W. Joel Schneider
W. Joel Schneider

Reputation: 1806

In R, all backslashes inside character strings need to be doubled. "\\" becomes \.

Try this:

---
title: "Untitled"
author: "SB"
date: "Thursday, January 29, 2015"
output: 
  pdf_document:
    fig_caption: yes
---

```{r var, echo=FALSE, fig.cap="Cars variation rate between year $t$ and $t-1$ for $0 < \\beta < 1$"}
plot(cars)
```

Upvotes: 6

Related Questions