我希望使用R包中的help_console函数将.Rnw函数的帮助包含到noamtools文档中,该包可以使用以下comand从github安装:
devtools::install_github('noamross/noamtools', build_vignettes = TRUE)下面给出了最低限度的工作实例:
\documentclass{article}
\begin{document}
<< label=Test, echo=FALSE >>=
library(noamtools)
# help_console(topic="mean", format = "latex")
help_console(topic="mean", format = "Rd")
@
\end{document}我没有得到正确的输出。
发布于 2015-12-29 01:36:15
解决方案是包括行
\usepackage{Rd}在.Rnw文件的开头,然后使用
help_console(topic="mean", format="latex")例如,将以下内容放入一个文件中,比如test.Rnw并编译以生成有关函数mean的文档。注意,results=tex确保R生成的Latex代码实际上是像Latex代码一样创建的。
% devtools::install_github('noamross/noamtools', build_vignettes = TRUE)
\documentclass{book}
\usepackage{Rd} % Rstudio will be able to find this .sty file
\begin{document}
<<label=Test, results=tex>>=
library(noamtools)
help_console(topic="mean", format = "latex")
@
\end{document}产生一个如下的pdf,

通过查看这里,我意识到需要包含Rd.sty文件。运行以下代码
pack <- "ggplot2"
path <- find.package(pack)
system(paste(shQuote(file.path(R.home("bin"), "R")),
"CMD", "Rd2pdf --no-clean", shQuote(path)))
# .Rd2xxxx directory created
# cd .Rd2xxxx您可以在创建的目录中查找类似于.Rd2xxxx的内容,以找到Rd2.tex,该目录显示了放在Latex文档文件中的内容,而Latex文档文件是R创建的。
https://stackoverflow.com/questions/34472935
复制相似问题