rjournal / rjtools

Tools for AUTHORS to use for checking and submitting articles to the R Journal
https://rjournal.github.io/rjtools/
Other
31 stars 14 forks source link

flextable not compatible with PDF render #70

Closed fawda123 closed 1 year ago

fawda123 commented 1 year ago

I know that table formatting between HTML and PDF is a pain, but the flextable package seems to do a good job. The render works for HTML output, but not for PDF using the rjtools template. It works fine for normal .Rmd documents.

Doesn't work:

---
draft: true
type: package
output: 
  rjtools::rjournal_web_article:
    self_contained: yes
    toc: no
header-includes:
- \usepackage{longtable}
---

```{r}
library(flextable)
flextable(head(cars))
The LaTeX error is long, but the offending part states:

! Undefined control sequence.

\Oldarrayrulewidth ``` Again, this works fine for normal .Rmd files: ```` --- output_format: pdf_document --- ```{r} library(flextable) flextable(head(cars)) ``` ```` The command `\Oldarrayrulewidth` is from the LaTeX kernel and not an existing package, so I'm confused what the rjtools package is doing to render to PDF. I'm also using tinytex for the build, session info below: ``` > sessionInfo() R version 4.2.3 (2023-03-15 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000) Matrix products: default locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=C [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C [5] LC_TIME=English_United States.utf8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] flextable_0.9.2 loaded via a namespace (and not attached): [1] xslt_1.4.4 tinytex_0.45 xfun_0.38 purrr_1.0.1 [5] V8_4.3.0 fontquiver_0.2.1 vctrs_0.6.1 htmltools_0.5.5 [9] yaml_2.3.7 rlang_1.1.0 later_1.3.1 glue_1.6.2 [13] httpcode_0.3.0 gfonts_0.2.0 gdtools_0.3.3 hunspell_3.0.2 [17] uuid_1.1-0 lifecycle_1.0.3 stringr_1.5.0 ragg_1.2.5 [21] zip_2.2.2 evaluate_0.21 knitr_1.42 yesno_0.1.2 [25] fastmap_1.1.1 httpuv_1.6.9 fontLiberation_0.1.0 curl_5.0.0 [29] equatags_0.2.0 Rcpp_1.0.10 katex_1.4.1 xtable_1.8-4 [33] cranlogs_2.1.1 openssl_2.0.6 promises_1.2.0.1 BiocManager_1.30.20 [37] jsonlite_1.8.4 mime_0.12 fs_1.6.2 systemfonts_1.0.4 [41] fontBitstreamVera_0.1.1 textshaping_0.3.6 askpass_1.1 digest_0.6.31 [45] stringi_1.7.12 shiny_1.7.4 rjtools_1.0.10 grid_4.2.3 [49] cli_3.6.1 tools_4.2.3 magrittr_2.0.3 crul_1.3 [53] crayon_1.5.2 ellipsis_0.3.2 rsconnect_0.8.29 data.table_1.14.8 [57] xml2_1.3.4 rmarkdown_2.21 httr_1.4.5 officer_0.6.2 [61] rstudioapi_0.14 R6_2.5.1 compiler_4.2.3 ```
fawda123 commented 1 year ago

Solved here https://github.com/davidgohel/flextable/issues/553