【发布时间】:2012-12-27 17:41:59
【问题描述】:
我曾就Sweave(
Dynamic references to figures in a R comment within Sweave document
) 并想看看在使用knitr 时是否有人作为类似的答案。
目标是拥有以下代码块
<<"example", fig.cap = "some figure", highlight = FALSE>>=
# the following code generated Figure \ref{fig:example}
plot(1:10, 1:10)
@
已在生成的 .pdf 中显示为
# the following code generated Figure 1.1
plot(1:10, 1:10)
到目前为止,我发现通过设置highlight = FALSE,R 代码被放置在生成的 .tex 文件中的verbatim 环境中。如果环境可以是alltt 而不是verbatim,那么我们就会得到想要的输出。是否可以通过knitr 选项将未突出显示的代码块放置在alltt 环境中?
【问题讨论】:
-
基于这些cmets (groups.google.com/forum/?fromgroups=#!topic/knitr/tgS5iCUpyhA),或许去掉highlight包并添加\usepackages{alltt}会使用对应的环境进行高亮。那么可以参考吗?