My example is:

<<eg, dev='tikz', size='normalsize', echo=FALSE, message=FALSE, warning=FALSE>>=
ggplot(cars) + geom_histogram(aes(speed), binwidth=1) + xlab("\$")

When running knitr, I get the error: "\$" is an unrecognized escape in character string starting ""\$".

Using "$" also gives an error.

How do I get the symbol '$' to appear here?

1 Answer 1


I just worked it out. Using the option sanitize=TRUE in the knitr chunk and using $ without the escape character works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .