【发布时间】:2018-06-07 06:35:33
【问题描述】:
四处寻找我的问题的答案,但我很困惑。
我正在尝试在脚本中使用 rmarkdown::render 批量渲染一些 pdf,但它一直给我这个错误:
! Use of \@array doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
#2}\def \reserved@b {#3}\f...
l.85 ...2in}|>{\raggedright\arraybackslash}p{4in}}
Error: Failed to compile C:/Users/cmykim/Desktop/stackoverflow/testfile.tex.
See testfile.log for more info.
In addition: Warning messages:
1: running command '"pdflatex" -halt-on-error -interaction=batchmode
"C:/Users/cmykim/Desktop/stackoverflow/testfile.tex"' had status 1
2: running command '"pdflatex" -halt-on-error -interaction=batchmode
"C:/Users/cmykim/Desktop/stackoverflow/testfile.tex"' had status 1
但是,当我运行 .Rmd 文件本身时,它会生成一个没有问题的 PDF。
我创建了一个示例,但出现以下错误:
rmarkdown 文件:
---
output: pdf_document
---
```{r setup, include=FALSE}
## Packages
library(tidyverse)
library(knitr)
library(kableExtra)
library(tinytex)
dat <- data.frame(stringsAsFactors=FALSE,
id = c(1L, 2L, 3L),
name = c("bob", "sam", "jane"),
question1 = c("Lorem ipsum dolor sit amet", "consectetur adipiscing",
"Integer quis")
)
dat <- dat %>% slice(1) %>% gather("key", "value")
```
```{r echo=FALSE}
dat %>%
kable("latex", col.names = NULL) %>%
# making column 2 4 inches wide
column_spec(2, width = "4in") %>%
# making column 1 2 inches wide
column_spec(1, width = "2in")
r 脚本:
library(rmarkdown)
rmarkdown::render(input =
"C:\\Users\\cmykim\\Desktop\\stackoverflow\\reproducible.Rmd",
output_format = "pdf_document",
output_file = "testfile.pdf",
output_dir = "C:\\Users\\cmykim\\Desktop\\stackoverflow")
我安装了 tinytex,希望它能修复它,但它没有。
任何帮助将不胜感激!
【问题讨论】:
标签: r latex r-markdown