davidgohel / flextable

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

Autonumber does not work with out bookmarks #497

Closed thebioengineer closed 1 year ago

thebioengineer commented 1 year ago

Not a bug or feature request? If you are looking for help on how to use the package correctly, please read the doc first at https://davidgohel.github.io/flextable/. You can also visit Stackoverflow and tag your question with [flextable]. We usually read them and answer WHEN possible.

When submitting a new issue:

Greetings, with the latest version of flextable, when you use autonumber() without the bookmark options, the number will not be added to the table caption. If you do use the bookmark, it does add the number. See the reprex below.

library(officer)
#> Warning: package 'officer' was built under R version 4.1.3
library(flextable)
#> Warning: package 'flextable' was built under R version 4.1.3

doc <- read_docx()

ft <- flextable(head(airquality))
ft1 <- ft |>
  set_caption(
    caption = "airquality dataset", 
    autonum = run_autonum(seq_id = "tab", bkm = "airquality"))

ft2 <- ft |> 
  set_caption(
    caption = "airquality dataset", 
    autonum = run_autonum(seq_id = "tab"))
doc <- doc |> 
  body_add_flextable(ft1) |> 
  body_add_flextable(ft2)

print(doc, target = "Test.docx")

sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19044)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] flextable_0.8.3 officer_0.5.1  
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.8.3      zip_2.2.0         pillar_1.8.1      compiler_4.1.1   
#>  [5] highr_0.9         base64enc_0.1-3   R.methodsS3_1.8.1 R.utils_2.11.0   
#>  [9] tools_4.1.1       digest_0.6.29     uuid_1.1-0        evaluate_0.15    
#> [13] lifecycle_1.0.3   tibble_3.1.7      R.cache_0.15.0    pkgconfig_2.0.3  
#> [17] rlang_1.0.6       reprex_2.0.1      cli_3.3.0         rstudioapi_0.13  
#> [21] yaml_2.3.5        xfun_0.31         fastmap_1.1.0     withr_2.5.0      
#> [25] styler_1.6.2      stringr_1.4.1     knitr_1.39        xml2_1.3.3       
#> [29] systemfonts_1.0.2 gdtools_0.2.3     fs_1.5.2          vctrs_0.4.1      
#> [33] askpass_1.1       grid_4.1.1        data.table_1.14.2 glue_1.6.2       
#> [37] R6_2.5.1          fansi_0.5.0       rmarkdown_2.14    purrr_0.3.4      
#> [41] magrittr_2.0.3    backports_1.4.1   ellipsis_0.3.2    htmltools_0.5.3  
#> [45] utf8_1.2.2        stringi_1.7.6     openssl_2.0.4     R.oo_1.24.0

Created on 2023-01-13 by the reprex package (v2.0.1)

davidgohel commented 1 year ago

thanks, it should be fixed

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.