如何在R markdown中添加LaTeX符号到fig.cap?

问题描述 投票:4回答:1

有没有办法添加LaTeX符号,如infinity \infty来标记R markdown中的字幕?

我可以让LaTeX文本格式化工作,但我无法找到使用符号的方法。

以下是使用LaTeX文本格式的工作示例:

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

```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(
  echo=FALSE,
  message=FALSE,
  warning=FALSE,
  fig.align = 'center'
  )
```

## Testing LaTeX syntax within captions

```{r pressure, fig.cap="\\label{testPlot}This caption has LaTeX with 
{\\small small text} and some {\\footnotesize footnote text and 
\\textbf{bold footnote}} and \\textit{italic}"}
plot(pressure)
```

我已经尝试了我能想到的每一个组合都没有效果。例如,双重逃脱\\infty,括号{\infty},括号{\\infty}内的双重逃脱,使用内联LaTeX $\infty$,内联逃生等。

任何建议将不胜感激。

r latex r-markdown
1个回答
4
投票

$\\infty$的作品。你需要逃离\和IIRC中的\infty,这是一个数学模式符号,所以你也需要调用它。

```{r pressure, fig.cap="\\label{testPlot}This caption has LaTeX with {\\small small text} and some {\\footnotesize footnote text and \\textbf{bold footnote}} and \\textit{italic} and $\\infty$"}
plot(1:10)
```
© www.soinside.com 2019 - 2024. All rights reserved.