Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put greek letters in latex knitr figure caption?

Tags:

r

latex

knitr

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?

like image 600
Patrick McCarthy Avatar asked Nov 04 '12 00:11

Patrick McCarthy


People also ask

How do you put Greek letters in latex?

You can add a Greek letter to your document by using the command that corresponds with the Greek letter you wish to enter. Commands for Greek letters in LaTeX are the same as the name of the letter, e.g., $\alpha$ , $\beta$ , $\gamma$ .

How do you make a gamma symbol in latex?

Put it in math mode: $\gamma$.


1 Answers

Nevermind - you simply need to escape the \ for alpha

<<fig.cap='$\\alpha_1$'>>=
 plot(1:5,1:5)
@
like image 155
Patrick McCarthy Avatar answered Nov 08 '22 16:11

Patrick McCarthy