当我将 kableExtra 用于 PDF 输出时,表格呈现精美,但如果程序中没有另一个非 kable 额外表格,则会出现错误。有没有其他人看到过这种行为?该文件似乎编织得很好,但随后在 pandoc 中引发错误?
例如,这段代码:
---
output:
beamer_presentation:
fontsize: 10pt
---
```{r global_options, include=FALSE}
library(rmarkdown)
library(knitr)
library(kableExtra)
```
### Slide with table
```{r echo=FALSE, warning=FALSE, message=FALSE}
df=mtcars[1:8,1:3]
kable(df,format="latex",booktabs=T,row.names=F) %>%
row_spec(6, color = "red")
```
给出这个错误
processing file: t.rmd
List of 1
$ include: logi FALSE
|....................................... | 60%
ordinary text without R code
|.................................................... | 80%
label: unnamed-chunk-1 (with options)
List of 3
$ echo : logi FALSE
$ warning: logi FALSE
$ message: logi FALSE
|.................................................................| 100%
ordinary text without R code
"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS t.utf8.md --to beamer --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output t.pdf --highlight-style tango --latex-engine pdflatex
output file: t.knit.md
! Undefined control sequence.
\beamer@doifinframe ...in {tabular}{rrr} \toprule
mpg & cyl & disp\\ \midrul...
l.86 \end{frame}
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS t.utf8.md --to beamer --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output t.pdf --highlight-style tango --latex-engine pdflatex' had status 43
Execution halted
但是,如果我再添加一张带有虚拟桌子的幻灯片,它会打印得很漂亮:
---
output:
beamer_presentation:
fontsize: 10pt
---
```{r global_options, include=FALSE}
library(rmarkdown)
library(knitr)
library(kableExtra)
```
### Slide with table
```{r echo=FALSE, warning=FALSE, message=FALSE}
df=mtcars[1:8,1:3]
kable(df,format="latex",booktabs=T,row.names=F) %>%
row_spec(6, color = "red")
```
### Non-kableExtra table needed for some reason?
```{r echo=FALSE}
kable(df)
```
有没有其他人看到过这种行为?除了“将虚拟表作为最后一张幻灯片”之外的任何解决方法?