davidgohel / flextable

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

Inconsistent behaviour of italic when rendering to PDF using different engines #493

Closed RheumGlutinosa closed 1 year ago

RheumGlutinosa commented 1 year ago

Hello, I found inconsistent behaviour when rendering my document with flextable to pdf using different engines. When rendered using pdflatex, everything I need works fine. But when rendering using xelatex or lualatex, the cells in italic are shown normal. I need to use xelatex due to other issues when rendering my thesis. Other commands, e.g. bold, work fine.

Please see the attached prtsc of the outputs.

Example:

library(flextable)
library(tidyverse)
flextable(iris[1:10,]) %>%
  italic(j = 5) %>%
  bold(j = 1) %>%
  autofit() %>%
  align(j=4, align="center", part = "all")

SessionInfo:

> sessionInfo()
> R version 4.2.2 Patched (2022-11-10 r83330)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 20.04.5 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              
>  [3] LC_TIME=cs_CZ.UTF-8        LC_COLLATE=en_US.UTF-8    
>  [5] LC_MONETARY=cs_CZ.UTF-8    LC_MESSAGES=en_US.UTF-8   
>  [7] LC_PAPER=cs_CZ.UTF-8       LC_NAME=C                 
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
> [11] LC_MEASUREMENT=cs_CZ.UTF-8 LC_IDENTIFICATION=C       
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base     
> 
> other attached packages:
>  [1] glmmTMB_1.1.5   forcats_0.5.2   stringr_1.5.0   dplyr_1.0.10   
>  [5] purrr_0.3.5     readr_2.1.3     tidyr_1.2.1     tibble_3.1.8   
>  [9] ggplot2_3.4.0   tidyverse_1.3.2 flextable_0.8.3 lmerTest_3.1-3 
> [13] lme4_1.1-31     Matrix_1.5-3   
> 
> loaded via a namespace (and not attached):
>  [1] nlme_3.1-160        fs_1.5.2            lubridate_1.9.0    
>  [4] httr_1.4.4          numDeriv_2016.8-1.1 tools_4.2.2        
>  [7] TMB_1.9.1           backports_1.4.1     utf8_1.2.2         
> [10] R6_2.5.1            DBI_1.1.3           colorspace_2.0-3   
> [13] withr_2.5.0         tidyselect_1.2.0    emmeans_1.8.2      
> [16] compiler_4.2.2      cli_3.4.1           rvest_1.0.3        
> [19] xml2_1.3.3          officer_0.4.4       sandwich_3.0-2     
> [22] scales_1.2.1        mvtnorm_1.1-3       systemfonts_1.0.4  
> [25] digest_0.6.30       minqa_1.2.5         rmarkdown_2.18     
> [28] base64enc_0.1-3     pkgconfig_2.0.3     htmltools_0.5.3    
> [31] dbplyr_2.2.1        fastmap_1.1.0       rlang_1.0.6        
> [34] readxl_1.4.1        rstudioapi_0.14     generics_0.1.3     
> [37] zoo_1.8-11          jsonlite_1.8.3      zip_2.2.2          
> [40] googlesheets4_1.0.1 magrittr_2.0.3      Rcpp_1.0.9         
> [43] munsell_0.5.0       fansi_1.0.3         gdtools_0.2.4      
> [46] lifecycle_1.0.3     stringi_1.7.8       multcomp_1.4-20    
> [49] yaml_2.3.6          MASS_7.3-58.1       grid_4.2.2         
> [52] crayon_1.5.2        lattice_0.20-45     haven_2.5.1        
> [55] splines_4.2.2       hms_1.1.2           knitr_1.41         
> [58] pillar_1.8.1        uuid_1.1-0          boot_1.3-28.1      
> [61] estimability_1.4.1  codetools_0.2-18    reprex_2.0.2       
> [64] glue_1.6.2          evaluate_0.18       data.table_1.14.6  
> [67] modelr_0.1.10       vctrs_0.5.1         nloptr_2.0.3       
> [70] tzdb_0.3.0          cellranger_1.1.0    gtable_0.3.1       
> [73] assertthat_0.2.1    xfun_0.35           xtable_1.8-4       
> [76] broom_1.0.1         coda_0.19-4         survival_3.4-0     
> [79] googledrive_2.0.0   gargle_1.2.1        timechange_0.1.1   
> [82] TH.data_1.1-1       ellipsis_0.3.2     

pdflatex xelatex

davidgohel commented 1 year ago

Thanks,

I can't reproduce, it may be a font issue. Can you try with a font you are sure you have with bold and italic feaures and see if there is the issue disappear? Below an example with 'Liberation'.

library(flextable)
library(tidyverse)
flextable(iris[1:5,]) %>%
  font(fontname = "Liberation", part = "all") |> 
  italic(j = 5) %>%
  bold(j = 1) %>%
  autofit() %>%
  align(j=4, align="center", part = "all")
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.