【发布时间】:2016-01-27 16:27:32
【问题描述】:
如何在我的Rnw 文件(LaTeX 文件)中突出显示 python 代码?我正在使用 RStudio 的“编译 PDF”功能来运行 pdflatex。
markdown 文件有两个相关问题(Q1、Q2),但这个问题是针对Rnw 文件的。
例子:
\documentclass{article}
\begin{document}
<<>>=
print("This is R")
@
<<engine='python'>>=
print "This is python"
@
\end{document}
【问题讨论】:
-
你需要安装highlight:andre-simon.de
-
这很容易。谢谢@易慧!在我的 Mac 上,
brew install highlight完成了这项工作。随时将您的评论作为答案。否则,我会在几天后自己回答这个问题来“结束”这个问题。 -
请随时回答您自己的问题。 PS:我很高兴你使用 Homebrew,否则我真的很讨厌解释如何安装 highlight :)