This question closely relates to this one: Using '$' in a tikz plot generated by knitr
I am able to get tikz graphics using knitr working with math mode as in this post:
Math mode in knitr
What I can't work out how to do is get both math mode working and special characters like '%' and '$' to show up as text.
Any help would be very much appreciated.
Best Answer
I have worked it out. In the character objects in R, the escape character also needs to be escaped.
For example, using sanitize=FALSE (or omitted) in the knitr chunk, and using "\\$" works: