davidgohel / flextable

table farming
https://ardata-fr.github.io/flextable-book/
553 stars 80 forks source link

flextable_to_rmd and pdf output is broken in 0.8.4 #503

Closed pjledge closed 1 year ago

pjledge commented 1 year ago

flextable 0.8.4 is not producing valid LaTeX code, resulting in the following error when knitting a markdown document:

processing file: test.Rmd

/_Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc +RTS -K512m -RTS test.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.tex --lua-filter /Users/pjl/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.2/aarch64-apple-darwin20/rmarkdown/2.20/716fde5382293cc94a71f68c85b78d19/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Users/pjl/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.2/aarch64-apple-darwin20/rmarkdown/2.20/716fde5382293cc94a71f68c85b78d19/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in' --include-in-header /var/folders/_q/w2h9lglx6vn7374sdbk6qnb80000gn/T//Rtmpj3MYeN/rmarkdown-str98e163dd1815.html 
output file: test.knit.md

! Undefined control sequence.
<argument> \Oldarrayrulewidth 

Error: LaTeX failed to compile test.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test.log for more info.
Execution halted_

The underlying TeX code is:

\textbackslash global\setlength{\Oldarrayrulewidth}{\arrayrulewidth}

0.8.3 works fine. The following R markdown will cause the issue:


---
title: "Untitled"
output:
  pdf_document: default
  html_document: default
date: "2023-01-26"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(flextable)
library(tidyr)

TEST


myfunc2 <- function() {
    m <- as.data.frame(matrix(rnorm(18*8), nrow=8))
    fmttable <- flextable(m)
    flextable_to_rmd(fmttable)
}

myfunc2()

sessionInfo() R version 4.2.2 (2022-10-31) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.1

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices datasets utils methods base

other attached packages: [1] flextable_0.8.4

loaded via a namespace (and not attached): [1] zip_2.2.2 Rcpp_1.0.10 compiler_4.2.2 later_1.3.0 base64enc_0.1-3
[6] gfonts_0.2.0 tools_4.2.2 uuid_1.1-0 digest_0.6.31 jsonlite_1.8.4
[11] evaluate_0.20 memoise_2.0.1 lifecycle_1.0.3 rlang_1.0.6 shiny_1.7.4
[16] cli_3.6.0 rstudioapi_0.14 crul_1.3 curl_5.0.0 yaml_2.3.6
[21] xfun_0.36 fastmap_1.1.0 xml2_1.3.3 officer_0.5.1 knitr_1.41
[26] askpass_1.1 gdtools_0.3.0 systemfonts_1.0.4 grid_4.2.2 glue_1.6.2
[31] httpcode_0.3.0 data.table_1.14.6 R6_2.5.1 rmarkdown_2.20 magrittr_2.0.3
[36] promises_1.2.0.1 htmltools_0.5.4 ellipsis_0.3.2 mime_0.12 xtable_1.8-4
[41] renv_0.16.0 httpuv_1.6.8 openssl_2.0.5 cachem_1.0.6 crayon_1.5.2

davidgohel commented 1 year ago

thanks, it should be fixed now.

pjledge commented 1 year ago

It appears to work as expected now. Thanks!

github-actions[bot] commented 1 year ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.