Rmarkdown错误:“!段落在\ @ fileswith @ ptions完成之前结束”

时间:2015-11-06 12:26:00

标签: r latex r-markdown

我正在从rmarkdown文档渲染pdf_document。在本文档中,我在for循环中制作了十个乳胶表(来自Hmisc包的乳胶功能)。

例如,rmarkdown代码如下所示:

---
title: "test"
output:
  pdf_document:
    latex_engine: lualatex
    number_sections: yes
    toc: yes
    toc_depth: 3
  html_document: default
header-includes:
- \usepackage[dutch]{babel}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyfoot[LE,RO]{title}
- \usepackage{dcolumn}
- \usepackage[here]

---
```{r}
library(Hmisc)
```

```{r results="asis",tidy=FALSE,eval=TRUE,echo=FALSE,message=FALSE, error=FALSE, warning=FALSE, comment = NA}
data_object <- structure(list(test = structure(c(1L, 1L, 2L, 2L), .Label = c("test1", 
"test2"), class = "factor"), test2 = structure(1:4, .Label = c("1", 
"2", "3", "4"), class = "factor")), .Names = c("test", "test2"
), row.names = c(NA, -4L), class = "data.frame")

   for (i in 1:10){
     latex(data_object, title='',file='',caption="title")

   }
```

我收到此错误:

    ! Paragraph ended before \@fileswith@ptions was complete.
<to be read again> 
\par 
l.101 

pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43

如何在完成表格之前确保段落未结束?

1 个答案:

答案 0 :(得分:1)

当使用方括号{}调用包时,此错误很常见。在代码中尝试这个替代品:

#Change this:
- \usepackage[here]

#To this:
- \usepackage{here}