输出-重访中的Sweave语法突出显示 [英] Sweave syntax highlighting in output - revisit

查看:19
本文介绍了输出-重访中的Sweave语法突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与链接Sweave syntax highlighting in output中的问题相同。

我遵循了daroczighttps://tex.stackexchange.com/questions/5113/how-to-colorize-syntax-using-r-sweave的建议,并创建了以下test.Rnw文件:

documentclass{article}
RequirePackage{fancyvrb}
RequirePackage{listings}
SweaveOpts{keep.source=TRUE}
<<SweaveListingsPreparations, results=tex, echo=FALSE, strip.white=false>>=
require(SweaveListingUtils)
SweaveListingPreparations()
 setToBeDefinedPkgs(pkgs = c("SweaveListingUtils","distr"),
                   keywordstyles = c("\bf\color{blue}","\bf\color{red}"))
@

egin{document}
SweaveOpts{concordance=TRUE}
section{Example}
This is an example with three variables in R.

<<>>=
options(continue = " ")
x  <- 10
t <- 'The brown fox'
b <- TRUE
@

<<>>=
x
@

<<>>=
t
@

<<>>=
b
@
end{document}

<<cleaup, echo=FALSE>>=
unloadNamespace("SweaveListingUtils")
@
但是,我收到以下错误消息:

建议?

推荐答案

因为您的文档中没有usepackage{Sweave},所以Sweave将插入它。但SweaveListingsUtils包也插入了冲突的代码。

因此您需要遵循SweaveListingsUtils文档中的建议,并添加评论

% usepackage{Sweave}

在您的文档开头附近。这将阻止R插入它。

但是,请注意,对SweaveListingsUtils的支持即将结束;您最好使用knitr

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

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