How do one use a math-mode in knitr
? For example as a label for X-Y axis:
<<fe, echo=FALSE, sanitize=TRUE, dev="tikz">>=
plot(1:10, main="${}^{57}Fe$", xlab="$\\\\lambda$", ylab="\\\\$I\\\\$", pch=20, family="CM Roman")
@
This produces the $I$
and $lambda$
as a labels.
Best Answer
To use latex (such as math mode) directly in the images, you will need to install the R package
tikzDevice
, and also the Latex packagetikz
for Latex (and you will need to explicitly put\usepackage{tikz}
in your document).