使用R Markdown创建pdf a时出现此错误:
output file: NCERA-210_Results.knit.md
! LaTeX Error: Environment threeparttable undefined.
Error: Failed to compile NCERA-210_Results.tex. See NCERA-210_Results.log for more info.
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
我的代码是:
---
title: "NCERA-210 Results"
author: "NAME"
date: "8/29/2018"
output: pdf_document
---
```{r setup, echo=FALSE, results="asis", message=FALSE, warning=FALSE}
加载包
库(“MOTE”)
库(“tidyverse”)
库(“broom”)
库(“ggpubr”)
library("markovchain")
库(“gmodel”)
库(“scale”)
库(“格式化”)
库(“rmarkdown”)
库(“knitr”)
库(“igraph”)
库(“papaja”)
库(“citr”)
```{r, echo=FALSE, results="hide", message=FALSE, warning=FALSE,
Fig.show=“隐藏”}
来源(“Thesis_Code.R”)
## Summary of Ratings
```{r 'Table Rating Count', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(rating.dist,
caption =“数据集中评分计数”)
## Plot of Rating Distribution
```{r 'Plot of Rating Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
ggplot(rating.dist,
aes(额定值,计数)+
geom_col() +
ggtitle(“评分分布”)
## Summary of Short Ratings
```{r 'Table Short Rating Count', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(s_rating.dist,
caption =“数据集中短评等的计数”)
## Plot of Short Rating Distribution
```{r 'Plot of Short Rating Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
ggplot(s_rating.dist,
aes(Short_Rating,计数))+
geom_col() +
ggtitle(“短评等分布”)
## Summary of Co-op Location Distribution
```{r 'Co-op Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(state.dist,
caption =“数据集中的位置分布”)
## Plot of Co-op Distribution
```{r 'Plot of Co-op Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
ggplot(state.dist,
aes(状态,计数))+
geom_col() +
ggtitle(“美国各地的合作组织分布”)
## Co-op Activity
```{r 'Co-op Activity Summary',echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(coop_activity,
caption = "Count of Co-ops by Activity")
## Co-op Sales Quartiles by Decade & Short Rating
```{r 'Sales Quartiles', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(sales.qt,
caption =“十年合作公寓销售额四分位数&短评等”)
## Co-op Liabilities by Decade & Short Rating
```{r 'Liabilities Quartiles', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(liab.qt,
caption = "Co-op负债四分位数(按十年和短评级)“)
## Co-op Cash Patronage Paid by Decade & Short Rating
```{r 'Cash Patronage Paid Quartiles', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(pat.paid,
caption = "Co-op Cash Patronage Paid Quartiles by Decade & Short Rating")
我正在使用papaja软件包来制作一份APA风格的手稿。我可以使用Rmd脚本创建word文档,但当输出为pdf_document时出现该错误。然而,我能够使用papaja模板创建一个手稿"APA文章(第6版),但这条路线需要大量的脚本编辑,以删除不必要的代码。
我想这个问题与the installed有关,但我似乎找不到任何关于使用R的指导。我使用的是Mac,并且安装了MacTex。
发布于 2018-08-31 10:44:40
修复是安装"kableExtra“,因为某些原因,如果没有它,pdf将无法呈现。
发布于 2020-04-20 09:29:00
这个建议的解决方案似乎不再有效。
请查看以下线程:新解决方案的LaTeX Error: Environment ThreePartTable undefined,它需要通过运行以下命令来更新RMarkdown:
remotes::install_github('rstudio/rmarkdown')
这将纠正threeparttablex包和rmarkdown之间的冲突。如果bookdown没有自动安装,您可能还需要运行以下命令,以mentioned on the tinytex page身份手动安装软件包:
library(tinytex)
tlmgr_install('threeparttablex') # install the threeparttablex package
tlmgr_update() # update everything
最后,我发现有必要终止R会话并重新启动,以便预订rmarkdown包和更新的latex包可用。在此之后,您可以使用apa_table =‘as-is’,例如:
```{r apatable, results='asis'}
Apa_table(头部(虹膜,20),caption =‘这是一张不错的桌子!’)
而且,bookdown还将处理标签,就像它自己的基于kable的表一样。
https://stackoverflow.com/questions/52090721
复制相似问题