【问题标题】:Sweave to LaTeX "undefined control sequence" errorSweave 到 LaTeX“未定义的控制序列”错误
【发布时间】:2012-09-25 14:48:25
【问题描述】:

我正在尝试使用 RStudio 在 TeX 文档中包含一些 R 结果。我已经设法让 RStudio 生成,在我看来,这是一个很好的 tex 文件,但它无法编译 pdf。

我得到错误返回说!未定义的控制序列。 ' 这似乎是由于 str(data) 调用的第一行和显示显着性级别的行而返回的:

"! Undefined control sequence.
<argument> '
            data.frame':    1980 obs. of  5 variables:
l.39 'data.frame':  1980 obs. of  5 variables:

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined."

"! Undefined control sequence. <argument> 
Signif. codes:  0 '
                              ***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
l.95 ...**' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined."

例如只有摘要(数据)的文件可以正常工作

查看其他邮件列表等我发现这可能是因为 tex 找不到 Sweave 包,因此将其复制到不同位置(与 Rnw 和 tex 文件相同的文件夹,以及路径中没有空格的目录)和试图重新运行该文件。似乎没有任何效果。

同样,这不起作用,但使用 summary(cars) 而不是 str(cars) 可以。这表明它与 ' 字符有关。

\documentclass [a4paper]{article}
\usepackage{Sweave} 
\title {Sweave Example 1}
\author {Friedrich Leisch}
\begin {document}
\maketitle
In this example we embed parts of the examples from the
\texttt {kruskal.test} help page into a \ LaTeX {} document :
<<>>=
data ( cars )
str(cars)
@
\end{document}

(改编自 sweave 手册) 关于我做错了什么有什么想法吗?

任何建议将不胜感激。

【问题讨论】:

    标签: tex sweave rstudio


    【解决方案1】:

    [noae] 包选项添加到您的\usepackage{Sweave} 语句中。

    【讨论】:

    • @ArunRaja 不是。如果您遇到同样的问题并且此解决方案没有帮助,您需要创建一个新问题并详细描述您的问题。另外,链接到这个问题并解释为什么这里的解决方案对你没有帮助(它给出了什么错误)。
    • 昨天能够修复它。我刚刚添加了 results=tex。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-21
    • 1970-01-01
    • 2013-09-28
    • 2016-09-12
    • 2020-04-02
    • 1970-01-01
    相关资源
    最近更新 更多