【问题标题】:Input .Rtex file into Latex (knitr)将 .Rtex 文件输入到 Latex (knitr)
【发布时间】:2018-05-20 17:22:53
【问题描述】:

我无法使用 /input{file} 或 include{file} 命令将 .Rtex 文件输入到我的 shareLatex 项目中。

有没有办法像其他 .tex 文件一样包含它?

文件如下所示:

<<>>=
# Create a sequence of numbers
X = 2:10

# Display basic statistical measures
summary(X)

@

如果我将代码放在 main.Rtex 文件中,则代码会被编译,但如果我尝试包含它,则不会。这个问题类似于one on tex.stackexchange

【问题讨论】:

  • 你不能只使用.tex作为包含文件的扩展名吗?
  • @RalfStubner 我可以这样做,但效果不佳。包含这种代码的文件需要保存为.Rtex文件,根据sharelatex
  • @MatthiasAdriaans,您是否考虑或尝试过使用knitr child documents

标签: r latex knitr tex sharelatex


【解决方案1】:

以下内容在 Overleaf 中工作(名为 *.Rtex 的主文件)。

\documentclass{standalone}
\begin{filecontents*}{tmp999.Rtex}
<<>>=
rnorm(3)
@
\end{filecontents*}
\begin{document}
\input{tmp999}
\end{document}

【讨论】:

  • 实际上,我认为彼得建议子文档的评论比使用 \input 更好。就个人而言,现在我有一个主 .Rtex 文件,每章都有 .Rtex,我将其包含在 >= @ 之类的内容中
猜你喜欢
  • 1970-01-01
  • 2017-08-04
  • 2012-12-14
  • 2014-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-05
  • 1970-01-01
相关资源
最近更新 更多