【问题标题】:Could the \include{} command be used in a knitr .Rnw file?可以在 knitr .Rnw 文件中使用 \include{} 命令吗?
【发布时间】:2013-03-01 10:44:08
【问题描述】:

使用 \include{} 通常有效,除非文件中有要包含的代码块:

\documentclass{article}
\begin{document}
% \include{test.tex}
\include{test.Rnw}  
\end{document}

用 test.tex 或 test.Rnw 定义例如由

<<echo=TRUE,eval=TRUE>>=
plot(cars)
@

不会显示汽车图。有没有机会找到绕过这个麻烦的方法?

谢谢, 朱利安

【问题讨论】:

    标签: r include knitr rstudio


    【解决方案1】:

    您可以在 child 中包含 .Rnw 文件。

    \documentclass{article}
    \begin{document}
    
    <<test, child='test.Rnw'>>=
    @
    
    \end{document}
    

    被 test.Rnw 包含:

    <<echo=TRUE,eval=TRUE>>=
    plot(cars)
    @
    

    【讨论】:

    • 哇,太好了,非常感谢EDi!这确实是 knitr 网站上的演示,真丢人...
    猜你喜欢
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    • 2016-09-25
    • 1970-01-01
    • 2017-02-15
    相关资源
    最近更新 更多