How do I highlight python code in my Rnw
files (LaTeX files)? I'm using RStudio's "Compile PDF" function to run pdflatex
.
There are two related questions (Q1, Q2) for markdown files, but this questions is specific to Rnw
files.
Example:
\documentclass{article}
\begin{document}
<<>>=
print("This is R")
@
<<engine='python'>>=
print "This is python"
@
\end{document}