davidgohel / flextable

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

Repeat Caption in different page #485

Closed tianfeiwei closed 2 years ago

tianfeiwei commented 2 years ago

Dear David, thank you for putting time and effort into making such a great package. I've read your book and issues with caption tags but couldn't figure out a way to achieve three questions:

  1. Repeat caption on the second page: for a long table, they may cross multiple pages, but the caption only shows on the first page. add_header_lines may be a good get over trick, but I still want to know if I can use caption instead of header.
  2. Table number: table number (i.g. Table 1: ) is not showing in word output format with run_autonum (as the example below).
  3. 393 you've suggested body_add_flextable, but it requires an rdocx object, is there any way to use it in the example below without print for every table?

library(table1)
library(tidyverse)
library(flextable)
library(officer)

table1(~ ., data = mtcars) %>%
  t1flex() %>% 
  set_caption(caption = "Basic Characteristics", 
              style = "Table Caption", 
              autonum = run_autonum(seq_id = 'tab', 
                                    pre_label = "Table: ", bkm_all = T, start_at = 1,
                                    prop = fp_text(bold = TRUE, font.size = 11)))
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Ventura 13.0.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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 utils     datasets  methods   base     

other attached packages:
 [1] officer_0.4.4    flextable_0.8.3  forcats_0.5.2    stringr_1.4.1    dplyr_1.0.10     purrr_0.3.5      readr_2.1.3      tidyr_1.2.1      tibble_3.1.8    
[10] ggplot2_3.4.0    tidyverse_1.3.2  kableExtra_1.3.4 table1_1.4.2    

loaded via a namespace (and not attached):
  [1] googledrive_2.0.0   minqa_1.2.5         colorspace_2.0-3    ellipsis_0.3.2      class_7.3-20        visdat_0.5.3        rgdal_1.5-32        base64enc_0.1-3    
  [9] fs_1.5.2            rstudioapi_0.14     proxy_0.4-27        fansi_1.0.3         lubridate_1.9.0     mathjaxr_1.6-0      xml2_1.3.3          splines_4.2.2      
 [17] knitr_1.40          Formula_1.2-4       jsonlite_1.8.3      nloptr_2.0.3        broom_1.0.1         dbplyr_2.2.1        brant_0.3-0         compiler_4.2.2     
 [25] httr_1.4.4          backports_1.4.1     assertthat_0.2.1    Matrix_1.5-1        fastmap_1.1.0       gargle_1.2.1        cli_3.4.1           htmltools_0.5.3    
 [33] tools_4.2.2         gtable_0.3.1        glue_1.6.2          reshape2_1.4.4      rappdirs_0.3.3      Rcpp_1.0.9          carData_3.0-5       cellranger_1.1.0   
 [41] vctrs_0.5.0         svglite_2.1.0       nlme_3.1-160        stargazer_5.2.3     tigris_1.6.1        xfun_0.34           lme4_1.1-31         rvest_1.0.3        
 [49] timechange_0.1.1    CompQuadForm_1.4.3  lifecycle_1.0.3     googlesheets4_1.0.1 MASS_7.3-58.1       zoo_1.8-11          scales_1.2.1        hms_1.1.2          
 [57] meta_6.0-0          pwr_1.3-0           metafor_3.8-1       yaml_2.3.6          gdtools_0.2.4       stringi_1.7.8       maptools_1.1-5      e1071_1.7-12       
 [65] zip_2.2.2           boot_1.3-28         rlang_1.0.6         pkgconfig_2.0.3     systemfonts_1.0.4   blockrand_1.5       evaluate_0.18       lattice_0.20-45    
 [73] sf_1.0-8            cowplot_1.1.1       tidyselect_1.2.0    plyr_1.8.7          magrittr_2.0.3      R6_2.5.1            generics_0.1.3      DBI_1.1.3          
 [81] pillar_1.8.1        haven_2.5.1         foreign_0.8-83      withr_2.5.0         units_0.8-0         abind_1.4-5         sp_1.5-1            modelr_0.1.9       
 [89] crayon_1.5.2        car_3.1-1           uuid_1.1-0          KernSmooth_2.23-20  utf8_1.2.2          tzdb_0.3.0          rmarkdown_2.17      qcc_2.7            
 [97] grid_4.2.2          metadat_1.2-0       readxl_1.4.1        data.table_1.14.4   reprex_2.0.2        digest_0.6.30       classInt_0.4-8      webshot_0.5.4      
[105] munsell_0.5.0       viridisLite_0.4.1  

Thank you very much!

davidgohel commented 2 years ago
  1. Yes, that's captions... You can't show an illustration of your request because it is not existing
  2. No reprex, no answer possible
  3. I don't understand
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.