Python syntax highlighting in LaTeX in Rstudio with knitR

How to highlight python code in my Rnw files (LaTeX files)? I use RStudio "Compile PDF" to run pdflatex .

There are two related questions ( Q1 , Q2 ) for markdown files, but these questions are 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

+5
source share
2 answers

Set backlight: andre-simon.de . See @Yihui Post in the comments on the question.

+1
source

I used IPython notepad and you can convert it to latex quite easily.

 $ ipython nbconvert notebook.ipynb 

And you will have a .tex file.

0
source

Source: https://habr.com/ru/post/1234655/


All Articles