输出中的 Sweave 语法高亮显示
有没有人设法在 Sweave 文档的输出中使用颜色语法高亮显示?我已经能够通过在 Sweave.sty
文件中添加框等来自定义输出样式,如下所示:
Has anyone managed to get color syntax-highlighting working in the output of Sweave documents? I've been able to customize the output style by adding boxes, etc. in the Sweave.sty
file as follows:
\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontseries=bc,frame=single}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{frame=leftline}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontseries=bc}
而且我可以使用 minted
包对文档中的逐字代码块进行语法高亮显示,如下所示:
And I can get the minted
package to do syntax highlighting of verbatim-code blocks in my document like so:
\begin{minted}{perl}
use Foo::Bar;
...
\end{minted}
但我不确定如何将两者结合用于 R 输入部分.我尝试了以下方法:
but I'm not sure how to combine the two for R input sections. I tried the following:
\DefineVerbatimEnvironment{Sinput}{minted}{r}
\DefineVerbatimEnvironment{Scode}{minted}{r}
有什么建议吗?
这个话题 tex.StackExchange 可能对你很有趣,因为它建议加载 R 中的 SweaveListingUtils 包以方便解决.
This topic on tex.StackExchange might be interesting for you, as it suggest loading the SweaveListingUtils package in R for easy solution.