davidgohel / flextable

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

Table captions no longer render for `bookdown::html_document2` after updating to {knitr} 1.46 #645

Closed tdwils closed 3 months ago

tdwils commented 4 months ago

When using {knitr} 1.46 and greater, table captions don't render correctly for bookdown::html_document2. Captions render correctly for html_document, but not for bookdown::html_document2.

Here is a reproducible example:

---
title: "Untitled"
output: bookdown::html_document2
---

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

library(flextable)
#| tab.cap: Table caption 1

flextable(head(cars))
flextable(head(cars))
flextable(head(cars)) |>
set_caption(
  caption = "Table caption 3"
  )

Result for knitr v1.46 and v1.48:

![image](https://github.com/user-attachments/assets/c1211bbd-4902-4808-8f42-fd453a40d82f)

What the result should look like (using knitr v1.45):

![image](https://github.com/user-attachments/assets/7d4ee76c-4283-4728-aed7-1d085579f7c0)

Here is the `sessionInfo()`:

sessionInfo() R version 4.2.3 (2023-03-15) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] flextable_0.9.6 tcltk2_1.2-11

loaded via a namespace (and not attached): [1] zip_2.3.0 Rcpp_1.0.11 fontBitstreamVera_0.1.1 compiler_4.2.3
[5] later_1.3.1 gfonts_0.2.0 tools_4.2.3 uuid_1.1-1
[9] digest_0.6.33 lifecycle_1.0.4 jsonlite_1.8.7 evaluate_0.23
[13] rlang_1.1.2 shiny_1.7.5.1 cli_3.6.1 rstudioapi_0.15.0
[17] curl_5.1.0 crul_1.4.0 yaml_2.3.7 fontLiberation_0.1.0
[21] xfun_0.45 fastmap_1.1.1 xml2_1.3.5 officer_0.6.6
[25] httr_1.4.7 knitr_1.46 askpass_1.2.0 systemfonts_1.0.5
[29] gdtools_0.3.7 grid_4.2.3 glue_1.6.2 httpcode_0.3.0
[33] data.table_1.14.8 R6_2.5.1 textshaping_0.3.7 rmarkdown_2.25
[37] bookdown_0.40 fontquiver_0.2.1 magrittr_2.0.3 ellipsis_0.3.2
[41] promises_1.2.1 htmltools_0.5.7 xtable_1.8-4 mime_0.12
[45] httpuv_1.6.12 ragg_1.2.6 openssl_2.1.1 crayon_1.5.2

davidgohel commented 3 months ago

hello, thanks for letting us know about that issue. It should be fixed now.

tdwils commented 3 months ago

Thank you! I have confirmed that this works with knitr v1.48 and flextable v0.9.7.005.