创建PDF版本时的LaTeX错误。这通常表明Rd问题。发现LaTeX错误:!未定义的控制序列

时间:2016-05-16 14:09:16

标签: r pdf latex

我是乳胶新手。我正确安装了MikTeX 2.9,GhostScript,GSView,TeXnicCenter,并正确设置了设置。

我的包裹(名为“mypackage”)通过了包裹检查
通过
来自R控制台:devtools::check("C:/Users/User/Documents/Revolution/mypackage")
从DOS命令提示符:R CMD check mypackage
没有任何问题,我最终自动获得了mypackage.PDF文件。

我决定制作数学表达式,例如

enter image description here

在生成的.PDF文件中。所以,我在.R文件的行中添加了以下乳胶表达式:

#' @param max selected ...The default is Schwert's approximation: \eqn{\lfloor 12(length(t) \over 100)^{\sfrac{1}{4}} \rfloor}

我再次氧化并再次触发上述包裹检查。这次,在包检查中,我收到以下错误(在命令提示符中):

* checking PDF version of manual ...Warning: running command '"C:/Revolution/R-Enterprise-7.3/R-3.1.1/bin/x64/Rcmd.exe" Rd2pdf  --batch --no-preview --build-dir
="C:/Users/User/AppData/Local/Temp/RtmpysnRGn/Rd2pdf1b3050f426ea" --no-clean -o mypackage-manual.pdf  

"C:/Users/User/Documents/Revolution/mypackage.Rcheck/mypackage"' had status 1
 WARNING LaTeX errors when creating PDF version. This typically indicates Rd problems. LaTeX errors found: ! Undefined control sequence.
<argument> ...oor 12(length(t) \over 100)^{\sfrac
    {1}{4}} \rfloor
l.67 ...th(t) \over 100)^{\sfrac{1}{4}} \rfloor}{}

checking PDF version of manual without hyperrefs or index ...Warning: running command '"C:/Revolution/R-Enterprise-7.3/R-3.1.1/bin/x64/Rcmd.exe" Rd2pdf  --bat
ch --no-preview --build-dir="C:/Users/User/AppData/Local/Temp/RtmpysnRGn/Rd2pdf1b3069b07b94" --no-clean --no-index -o  mypackage-manual.pdf  

C:/Users/User/Documents/Revolution/mypackage.Rcheck/mypackage' had status 1 ERROR

我做了什么:我分析了SOF中的类似错误,但无法弄清楚出了什么问题。我不确定错误发生在哪里:我的乳胶语法或R中的某些内容。

我非常感谢任何帮助。

编辑(根据Werner的评论完成序言;在强制执行以下解决方案后):

#' adfcs
#'
#' Augmented Dickey-Fuller test that uses common (sub-)sample for all of the lags when a selected max order is given to find optimal minimal lag order of the autoregressive process.
#'
#' Augmented Dickey-Fuller test (for unit root testing) that uses common (sub-)sample for all of the lags when a selected max order is given to find optimal minimal lag order of the autoregressive process. 
#' The test is based on J.G. McKinnons' numerical distribution functions. 
#' MacKinnon, J.G. (1996); Numerical distribution functions for unit root and cointegration tests, J of Applied Econometrics 11, p. 601 618.
#' The default value of max is Schwert's approximation (Schwert, G.W. (1989). Tests for Unit-Roots: A Monte Carlo investigation. Journal of Business and Economic Statistics 7, 147-159.) 
#' Usage: adfcs(t, max = floor(12*(length(t)/100)^(1/4)), type = c("c")). I thank Fabian Scheipl, Dept. of Statistics, LMU Munich for his helpful suggestions during the construction of adfcs. 
#' When data frame is supplied for the parameter t, specify the column of the variable for which the ADF test is wanted .
#'
#' @param t a numeric vector or time series object whose stationarity is examined
#' @param max selected max lag order to find optimal minimal lag order for the autoregressive process in ADF test. The default is Schwert's approximation: \eqn{\left\|12\left(\frac{length(t)}{100}\right)^{1/4}\right\|}
#' @param type a character string describing the type of the unit root  regression. Valid choices are "nc" for a regression  with no intercept (constant) nor time trend, and "c"  for a regression with an intercept (constant) but no time  trend, "ct" for a regression with an intercept  (constant) and a time trend. The default is "c".
#' @return Augmented Dickey-Fuller test that uses common sample for all of the lags.
#' @author Erdogan Cevher erdogancevher@@gmail.com
#' @seealso \code{\link{VARomlop}}
#' @examples
#' ## ADF test for the 1st variable in granger.df, max length is that of Schwert's approximation (default).
#' # adfcs(granger.df[,1])
#' ## ADF test for the 3rd variable in granger.df, max length is 10.
#' # adfcs(granger.df[,3], 10)
#' @importFrom fUnitRoots unitrootTest
#' @export
adfcs <- function(...

1 个答案:

答案 0 :(得分:0)

1. 我找到了免费的在线/实时/ WYSIWYG乳胶转换器:https://www.codecogs.com/latex/eqneditor.php

在本网站;通过反复试验,我发现了Schwertz公式的乳胶语法:

\left\|12\left(\frac{length(t)}{100}\right)^{1/4}\right\|

(我建议通过空格将乳胶标签彼此分开(当点击上面的数学符号时)以进一步发现/学习乳胶标签的工作。)删除标签之间的所有空格不会影响结果数学表达

2. 然后,我在\eqn{...}标记内替换了codecogs上面的乳胶代码:

#' @param max selected ...The default is Schwert's approximation: \eqn{\left\|12\left(\frac{length(t)}{100}\right)^{1/4}\right\|}

我没有在.R文件中的前导码中添加任何内容。

3. 然后,我从DOS命令提示符重新触发R CMD check mypackage

这次,检查包没有任何问题。我获得了.PDF文件,其中上面的.jpg的内容经过必要的修改后显示。

(如果我可以执行Werner的解决方案,我也会把它放在这里)