davidgohel / flextable

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

Huge cell does not split across pages in rmarkdown pdf_document #548

Open CareCT opened 1 year ago

CareCT commented 1 year ago

Hello,

when I try to render a long flextable with rmarkdown and the "pdf_document" format, the table does not split across multiple pages and the cell content gets truncated.

The rendered pdf document is 4 page long:

This is a minimal reproducible example of the .Rmd document:

---
documentclass: article
geometry: margin=2cm
output: 
  pdf_document: 
    latex_engine: lualatex
    toc: false
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(
  echo = FALSE, 
  message = FALSE, 
  warning = FALSE,
  ft.tabcolsep = 3, 
  ft.latex.float = "none",
  ft.keepnext = FALSE
)
library(flextable)
library(stringi)

set_flextable_defaults(
  float = "none",
  font.size = 12, 
  border.color = "gray",
  line_spacing = 1,
  padding.bottom = 2,
  na_str = "Not available",
  keep_with_next = FALSE
)

Test bug

loremipsum <- stri_c(stri_rand_lipsum(10), collapse = "\n")
d <- data.frame(
  name = "jack",
  value = loremipsum
)

flextable(d) |> 
  width(j = "name", width = 2) |>
  width(j = "value", width = 4) |>
  valign(valign = "top")

And this is my sessionInfo():

R version 4.2.3 (2023-03-15 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=Italian_Italy.utf8 LC_CTYPE=Italian_Italy.utf8 LC_MONETARY=Italian_Italy.utf8 [4] LC_NUMERIC=C LC_TIME=Italian_Italy.utf8

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

other attached packages: [1] stringi_1.7.12 flextable_0.9.1

loaded via a namespace (and not attached): [1] zip_2.3.0 Rcpp_1.0.10 fontBitstreamVera_0.1.1 [4] compiler_4.2.3 later_1.3.1 gfonts_0.2.0
[7] tools_4.2.3 uuid_1.1-0 digest_0.6.31
[10] evaluate_0.21 jsonlite_1.8.5 lifecycle_1.0.3
[13] rlang_1.1.1 shiny_1.7.4 cli_3.6.1
[16] rstudioapi_0.14 crul_1.4.0 curl_5.0.0
[19] fontLiberation_0.1.0 xfun_0.39 fastmap_1.1.1
[22] xml2_1.3.4 officer_0.6.2 knitr_1.43
[25] gdtools_0.3.3 systemfonts_1.0.4 askpass_1.1
[28] grid_4.2.3 glue_1.6.2 httpcode_0.3.0
[31] data.table_1.14.8 R6_2.5.1 textshaping_0.3.6
[34] rmarkdown_2.22 magrittr_2.0.3 fontquiver_0.2.1
[37] promises_1.2.0.1 htmltools_0.5.5 ellipsis_0.3.2
[40] mime_0.12 xtable_1.8-4 httpuv_1.6.11
[43] ragg_1.2.5 openssl_2.0.6 crayon_1.5.2



Finally, thanks for you great work, this package is awesome!