输出中的 Sweave 语法高亮显示 [英] Sweave syntax highlighting in output

查看:45
本文介绍了输出中的 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.

这篇关于输出中的 Sweave 语法高亮显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆