Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python syntax highlighting in LaTeX in Rstudio with knitR

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}

enter image description here

like image 811
kdauria Avatar asked Nov 10 '22 02:11

kdauria


1 Answers

Install highlight: andre-simon.de. See @Yihui's post in the question's comments.

like image 175
kdauria Avatar answered Nov 14 '22 23:11

kdauria



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!