I am trying to create a table using apa_table()
, Papaja, and RMarkdown in RStudio. Whenever I include longtable
in the apa_table
function, I get the error:
! LaTeX Error: Environment ThreePartTable undefined.
Strangely, the error log that's produced includes:
(/home/tim/.TinyTeX/texmf-dist/tex/latex/threeparttable/threeparttable.sty
Package: threeparttable 2003/06/13 v 3.0
and
Package caption Info: threeparttable package is loaded.
Note the different capitalization between the error and the loaded package, which makes me wonder if that's the issue.
Note that this is the same error as reported in an earlier question: ! LaTeX Error: Environment threeparttable undefined. However, the solution provided there does not work for me.
I'm not sure if this will be reproducible outside of my particular setup, but here is some code that produces the problem for me.
Note that I do not have the same issue if I simply use kable()
(also included below).
---
title : "The title"
shorttitle : "Title"
author:
- name : "First Author"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "Postal address"
email : "[email protected]"
- name : "Ernst-August Doelle"
affiliation : "1,2"
affiliation:
- id : "1"
institution : "Wilhelm-Wundt-University"
- id : "2"
institution : "Konstanz Business School"
authornote: |
abstract: |
keywords : "keywords"
wordcount : "X"
floatsintext : no
figurelist : no
tablelist : no
footnotelist : no
linenumbers : yes
mask : no
draft : no
tables : yes
documentclass : "apa6"
classoption : "man"
output : papaja::apa6_pdf
---
```{r setup, include = FALSE}
library("papaja")
library("knitr")
library("kableExtra")
```
```{r, results="asis"}
kable(mtcars, longtable=TRUE)
```
```{r, results="asis"}
apa_table(mtcars, longtable=TRUE)
```
\begingroup
\setlength{\parindent}{-0.5in}
\setlength{\leftskip}{0.5in}
<div id = "refs"></div>
\endgroup
Here is the output from sessionInfo()
in case it helps:
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19.2
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
[5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 LC_PAPER=en_AU.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.3 digest_0.6.23 crayon_1.3.4 withr_2.1.2 assertthat_0.2.1 evaluate_0.14 rlang_0.4.2
[8] cli_1.1.0 rstudioapi_0.10 rmarkdown_1.18 tools_3.6.1 xfun_0.11 yaml_2.2.0 compiler_3.6.1
[15] sessioninfo_1.1.1 papaja_0.1.0.9842 htmltools_0.4.0 knitr_1.26
You need the threeparttablex
style for the ThreePartTable
environment. In principle papaja
tries to load this style, but there seems to be an incompatibility with recent rmarkdown
. Since this seems to be a regression in rmarkdown
, I have opened an issue for it. As a workaround you can downgrade to an older version of rmarkdown
. Meanwhile, you can also install a fixed version from GitHub: remotes::install_github('rstudio/rmarkdown')
.