如何使用RMarkdown在fig.caption中使用希腊字母?

时间:2015-01-29 17:37:16

标签: latex r-markdown caption

当我尝试使用 RStudio 中的 RMarkdown 编织pdf时,此代码会产生错误。

如何在 fig.caption 中写一个希腊字母,例如$ \ 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)
```

1 个答案:

答案 0 :(得分:2)

在R中,字符串内的所有反斜杠都需要加倍。 "\\"变为\

试试这个:

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