【发布时间】:2018-05-31 17:57:49
【问题描述】:
我的问题与链接Sweave syntax highlighting in output中的问题相同。
我遵循了 daroczig https://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}"))
@
\begin{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")
@
建议?
【问题讨论】:
标签: r syntax-highlighting sweave