I encountered similar issues in this post when rendering a flextable in a Beamer presentation.
Surprisingly, it worked fine for all other document formats like Word, PDF, PPTX, and HTML, except for Beamer. And I can also knit everything to beamer (text, figure, tables by kable), except a flextable.
So the problem is only at knitting a felxtable to beamer presentation. Example codes:
---
output:
beamer_presentation: default
pdf_document: default
powerpoint_presentation: default
ioslides_presentation: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(flextable)
```
## Slide
```{r echo=FALSE, results='asis'}
example_ft <-
iris |> head() |>
flextable()
example_ft
```
Every attempt to debug the problem was unsuccessful, despite trying the following steps:
Unfortunately, the issue persists and the error message continues to appear.
processing file: test2.Rmd
/usr/local/bin/pandoc +RTS -K512m -RTS test2.knit.md --to beamer --from markdown+autolink_bare_uris+tex_math_single_backslash --output test2.tex --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --highlight-style tango --pdf-engine pdflatex --embed-resources --standalone output file: test2.knit.md
! Undefined control sequence. \Oldarrayrulewidth
Error: LaTeX failed to compile test2.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test2.log for more info. Execution halted
I would appreciate it if you could give me any solution for this.
My session information:
sessionInfo()
R version 4.3.1 (2023-06-16) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Monterey 12.3
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Asia/Tokyo tzcode source: internal
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] gtsummary_1.7.1 kableExtra_1.3.4.9000 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0
[6] dplyr_1.1.2 purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1
[11] ggplot2_3.4.2 tidyverse_2.0.0 flextable_0.9.2loaded via a namespace (and not attached): [1] tidyselect_1.2.0 viridisLite_0.4.2 fastmap_1.1.1 xaringan_0.28 fontquiver_0.2.1
[6] broom.helpers_1.13.0 promises_1.2.0.1 digest_0.6.33 timechange_0.2.0 mime_0.12
[11] lifecycle_1.0.3 ellipsis_0.3.2 gfonts_0.2.0 processx_3.8.2 magrittr_2.0.3
[16] compiler_4.3.1 sass_0.4.6 rlang_1.1.1 tools_4.3.1 gt_0.9.0
[21] utf8_1.2.3 yaml_2.3.7 data.table_1.14.8 knitr_1.43 askpass_1.1
[26] prettyunits_1.1.1 htmlwidgets_1.6.2 pkgbuild_1.4.2 curl_5.0.1 xml2_1.3.5
[31] rsconnect_0.8.29 pkgload_1.3.2.1 httpcode_0.3.0 miniUI_0.1.1.1 withr_2.5.0
[36] grid_4.3.1 fansi_1.0.4 urlchecker_1.0.1 profvis_0.3.8 gdtools_0.3.3
[41] xtable_1.8-4 colorspace_2.1-0 scales_1.2.1 crul_1.4.0 tinytex_0.45
[46] cli_3.6.1 rmarkdown_2.23 crayon_1.5.2 ragg_1.2.5 generics_0.1.3
[51] remotes_2.4.2 rstudioapi_0.15.0 httr_1.4.6 tzdb_0.4.0 sessioninfo_1.2.2
[56] cachem_1.0.8 rvest_1.0.3 vctrs_0.6.3 devtools_2.4.5 webshot_0.5.5
[61] jsonlite_1.8.7 fontBitstreamVera_0.1.1 xaringanthemer_0.4.2 callr_3.7.3 hms_1.1.3
[66] systemfonts_1.0.4 jquerylib_0.1.4 glue_1.6.2 ps_1.7.5 DT_0.28
[71] stringi_1.7.12 gtable_0.3.3 later_1.3.1 munsell_0.5.0 pillar_1.9.0
[76] htmltools_0.5.5 openssl_2.0.6 R6_2.5.1 textshaping_0.3.6 evaluate_0.21
[81] shiny_1.7.4.1 memoise_2.0.1 bslib_0.5.0 fontLibera
Every attempt to debug the problem was unsuccessful, despite trying the following steps:
Re-installing/Updating R. Re-installing/Updating R Studio. Re-installing/Updating all the packages. Restarting the R session. Following the debugging instructions provided in the error below.
I ran in to this same problem recently when I tried running my script on a new computer. I found the issue is related to versioning of the flextable package. I had been running 0.6.6 on my old computer and obviously updated to the latest version on the new machine. I "solved" the problem by copying the 0.6.6 version from my old machine to the new one. It's not the ideal solution, and it doesn't explain the cause of the problem, but it's holding me over for now.
I used packageVersion("flextable")
to find my version, and .libPath()
to learn where my packages were stored so I could replace new with old.