Is there a way to add LaTeX symbols, like infinity \infty
to figure captions within R markdown?
I can get LaTeX text formatting to work, but I can't figure out a way to use symbols.
Here is a working example using LaTeX text formatting:
---
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)
```
I have tried every combination I can think of an none have worked. For instance, double escape \\infty
, brackets {\infty}
, double escape within brackets {\\infty}
, using the inline LaTeX $\infty$
, inline with escape, etc. etc.
Any advice will be greatly appreciated.
In side a text chunk, you can use mathematical notation if you surround it by dollar signs $ for “inline mathematics” and $$ for “displayed equations”. Do not leave a space between the $ and your mathematical notation. Example: $\sum_{n=1}^{10} n^2$ is rendered as ∑10n=1n2.
How to write Latex symbol belongs to : \in means "is an element of", "a member of" or "belongs to".
How to write Latex symbol for all x : \forall . Given any or for all in predicate logic is a a type of quantifier.
$\\infty$
works. You need to escape the \
in \infty
and IIRC this is a math mode symbol, so you need to invoke that too.
```{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)
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With