【问题标题】:Knit to pdf doesn't work when using Kable使用 Kable 时,Knit to pdf 不起作用
【发布时间】:2020-10-02 01:02:55
【问题描述】:

我在 rstudio 中使用 rmarkdown 并想编织成 pdf。这很好用,除了我使用 kable 时。我正在使用以下 yaml,过去它曾经可以工作,但现在我不得不重新安装 R、Rstudio 和 MacTex,现在它不再工作了。

---
title: "example"
output:
  pdf_document:
    df_print: kable
    latex_engine: xelatex
---

```{r}
cars
```

我得到的错误信息是:

输出文件:example.knit.md

! LaTeX 错误:环境 kable-table 未定义。

错误:LaTeX 无法编译 example.tex。有关调试提示,请参阅https://yihui.org/tinytex/r/#debugging。有关详细信息,请参阅 Study-1.log。

有人知道怎么解决吗?

【问题讨论】:

  • 如果你重新安装了 R,你是否也重新安装了所有的包,例如rmarkdown, kabelExtra, ...?
  • 我重新安装了其中的大部分,但我可能仍然缺少一些。例如,我有 rmarkdown、kabelExtra 和 knitr,但我不能 100% 确定我需要哪些。
  • 你能上传完整的 RMD 文件吗(例如到 github 或其他地方)?
  • 我会在这里上传一个基本版本:---标题:“示例”输出:pdf_document:df_print:kable latex_engine:xelatex---{r setup, include=FALSE} library(tidyverse) library(kableExtra) library(dplyr) library(base) library(broom) library(pander) library(knitr) {r cars, echo=FALSE} cars
  • 没有 df_print: kable 在 yaml 中它确实可以工作,但是输出相当难看。在我不得不重新安装所有软件之前,它曾经在 yaml 中为我工作

标签: pdf r-markdown knitr kable


【解决方案1】:

这是 rmarkdown 的一个错误(针对更高版本的 Pandoc),I just fixed on Github。请尝试:

remotes::install_github('rstudio/rmarkdown')

【讨论】:

  • 对不起,确实如此。是否已经通过清除缓存解决了?
  • 如果生成表的代码块被缓存了,是的,请清理缓存。
猜你喜欢
  • 2012-12-24
  • 2021-12-13
  • 2020-07-29
  • 1970-01-01
  • 1970-01-01
  • 2021-02-08
  • 1970-01-01
  • 2019-06-11
  • 1970-01-01
相关资源
最近更新 更多