简体   繁体   中英

How to put greek letters in latex knitr figure caption?

I searched for this, but wasn't able to find it. In a knitr document, I want to put $\\alpha_1$ as the caption to a plot like so:

<<fig.cap='$\alpha_1$'>>=
 plot(1:5,1:5)
@

Trying to knit this comes back with the error

! Text line contains an invalid character.
l.172 ...axwidth]{figure/plotSigma1} \caption[$^^G
                                              lpha_1$]{$^^Glpha_1$\label...

Is there a way?

Nevermind - you simply need to escape the \\ for alpha

<<fig.cap='$\\alpha_1$'>>=
 plot(1:5,1:5)
@

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM