Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当表头是中文的情况下,生成的表格内容错位 #835

Open
chuxinyuan opened this issue Apr 7, 2024 · 6 comments
Open

当表头是中文的情况下,生成的表格内容错位 #835

chuxinyuan opened this issue Apr 7, 2024 · 6 comments

Comments

@chuxinyuan
Copy link

chuxinyuan commented Apr 7, 2024

我的代码

---
title: "测试案例"
date: "2024-06-04"
output: html_document
---

```{r}
library(kableExtra)
df = data.frame(
  姓名 = c("张三", "李四"),
  工资 = c(8000, 7500)
)
df %>% 
  kable() %>% 
  kable_styling(font_size = 12)
```

生成的表格

202406050053_1

系统环境

xfun::session_info("kableExtra")
#> R version 4.2.3 (2023-03-15 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19045)
#> 
#> Locale:
#>   LC_COLLATE=Chinese (Simplified)_China.utf8 
#>   LC_CTYPE=Chinese (Simplified)_China.utf8   
#>   LC_MONETARY=Chinese (Simplified)_China.utf8
#>   LC_NUMERIC=C                               
#>   LC_TIME=Chinese (Simplified)_China.utf8    
#> 
#> Package version:
#>   base64enc_0.1.3    bslib_0.7.0.9000   cachem_1.1.0       cli_3.6.2         
#>   colorspace_2.1.0   cpp11_0.4.7        digest_0.6.35      evaluate_0.23     
#>   farver_2.1.2       fastmap_1.2.0      fontawesome_0.5.2  fs_1.6.4          
#>   glue_1.7.0         graphics_4.2.3     grDevices_4.2.3    highr_0.11        
#>   htmltools_0.5.8.1  jquerylib_0.1.4    jsonlite_1.8.8     kableExtra_1.4.0  
#>   knitr_1.47         labeling_0.4.3     lifecycle_1.0.4    magrittr_2.0.3    
#>   memoise_2.0.1      methods_4.2.3      mime_0.12          munsell_0.5.1     
#>   R6_2.5.1           rappdirs_0.3.3     RColorBrewer_1.1.3 rlang_1.1.3       
#>   rmarkdown_2.27     rstudioapi_0.16.0  sass_0.4.9         scales_1.3.0      
#>   stats_4.2.3        stringi_1.8.4      stringr_1.5.1      svglite_2.1.3     
#>   systemfonts_1.1.0  tinytex_0.51       tools_4.2.3        utils_4.2.3       
#>   vctrs_0.6.5        viridisLite_0.4.2  xfun_0.44          xml2_1.3.6        
#>   yaml_2.3.8

Created on 2024-06-05 with reprex v2.1.0

@chuxinyuan chuxinyuan changed the title Table headers generated under the hugo stack theme are misaligned 当表头是中文的情况下,生成的表格内容错位 Jun 4, 2024
@chuxinyuan
Copy link
Author

@haozhu233 朱兄,我把问题简化了以下,烦请帮忙看看,谢谢!

@haozhu233
Copy link
Owner

Screenshot 2024-06-09 at 10 19 28 PM

在我这看这是正常的啊

@chuxinyuan chuxinyuan reopened this Jun 10, 2024
@chuxinyuan
Copy link
Author

xfun::session_info(c("kableExtra", "rmarkdown"))
#> R version 4.4.0 (2024-04-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Manjaro Linux
#> 
#> Locale:
#>   LC_CTYPE=zh_CN.UTF-8       LC_NUMERIC=C              
#>   LC_TIME=zh_CN.UTF-8        LC_COLLATE=zh_CN.UTF-8    
#>   LC_MONETARY=zh_CN.UTF-8    LC_MESSAGES=zh_CN.UTF-8   
#>   LC_PAPER=zh_CN.UTF-8       LC_NAME=C                 
#>   LC_ADDRESS=C               LC_TELEPHONE=C            
#>   LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C       
#> 
#> Package version:
#>   base64enc_0.1.3    bslib_0.7.0        cachem_1.1.0       cli_3.6.2         
#>   colorspace_2.1.0   cpp11_0.4.7        digest_0.6.35      evaluate_0.23     
#>   farver_2.1.2       fastmap_1.2.0      fontawesome_0.5.2  fs_1.6.4          
#>   glue_1.7.0         graphics_4.4.0     grDevices_4.4.0    highr_0.11        
#>   htmltools_0.5.8.1  jquerylib_0.1.4    jsonlite_1.8.8     kableExtra_1.4.0  
#>   knitr_1.47         labeling_0.4.3     lifecycle_1.0.4    magrittr_2.0.3    
#>   memoise_2.0.1      methods_4.4.0      mime_0.12          munsell_0.5.1     
#>   R6_2.5.1           rappdirs_0.3.3     RColorBrewer_1.1.3 rlang_1.1.3       
#>   rmarkdown_2.27     rstudioapi_0.16.0  sass_0.4.9         scales_1.3.0      
#>   stats_4.4.0        stringi_1.8.4      stringr_1.5.1      svglite_2.1.3     
#>   systemfonts_1.1.0  tinytex_0.51       tools_4.4.0        utils_4.4.0       
#>   vctrs_0.6.5        viridisLite_0.4.2  xfun_0.44          xml2_1.3.6        
#>   yaml_2.3.8        
#> 
#> Pandoc version: 3.1.11

Created on 2024-06-10 with reprex v2.1.0

xfun::session_info(c("kableExtra", "rmarkdown"))
#> R version 4.2.2 Patched (2022-11-10 r83330)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Debian GNU/Linux 12 (bookworm)
#> 
#> Locale:
#>   LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>   LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>   LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>   LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>   LC_ADDRESS=C               LC_TELEPHONE=C            
#>   LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> Package version:
#>   base64enc_0.1.3    bslib_0.7.0        cachem_1.1.0       cli_3.6.2         
#>   colorspace_2.1.0   cpp11_0.4.7        digest_0.6.35      evaluate_0.23     
#>   farver_2.1.2       fastmap_1.2.0      fontawesome_0.5.2  fs_1.6.4          
#>   glue_1.7.0         graphics_4.2.2     grDevices_4.2.2    highr_0.11        
#>   htmltools_0.5.8.1  jquerylib_0.1.4    jsonlite_1.8.8     kableExtra_1.4.0  
#>   knitr_1.47         labeling_0.4.3     lifecycle_1.0.4    magrittr_2.0.3    
#>   memoise_2.0.1      methods_4.2.2      mime_0.12          munsell_0.5.1     
#>   R6_2.5.1           rappdirs_0.3.3     RColorBrewer_1.1.3 rlang_1.1.3       
#>   rmarkdown_2.27     rstudioapi_0.16.0  sass_0.4.9         scales_1.3.0      
#>   stats_4.2.2        stringi_1.8.4      stringr_1.5.1      svglite_2.1.3     
#>   systemfonts_1.1.0  tinytex_0.51       tools_4.2.2        utils_4.2.2       
#>   vctrs_0.6.5        viridisLite_0.4.2  xfun_0.44          xml2_1.3.6        
#>   yaml_2.3.8        
#> 
#> Pandoc version: 2.18

Created on 2024-06-10 with reprex v2.1.0

xfun::session_info(c("kableExtra", "rmarkdown"))
#> R version 4.2.3 (2023-03-15 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19045)
#> 
#> Locale:
#>   LC_COLLATE=Chinese (Simplified)_China.utf8 
#>   LC_CTYPE=Chinese (Simplified)_China.utf8   
#>   LC_MONETARY=Chinese (Simplified)_China.utf8
#>   LC_NUMERIC=C                               
#>   LC_TIME=Chinese (Simplified)_China.utf8    
#> 
#> Package version:
#>   base64enc_0.1.3    bslib_0.7.0.9000   cachem_1.1.0       cli_3.6.2         
#>   colorspace_2.1.0   cpp11_0.4.7        digest_0.6.35      evaluate_0.23     
#>   farver_2.1.2       fastmap_1.2.0      fontawesome_0.5.2  fs_1.6.4          
#>   glue_1.7.0         graphics_4.2.3     grDevices_4.2.3    highr_0.11        
#>   htmltools_0.5.8.1  jquerylib_0.1.4    jsonlite_1.8.8     kableExtra_1.4.0  
#>   knitr_1.47         labeling_0.4.3     lifecycle_1.0.4    magrittr_2.0.3    
#>   memoise_2.0.1      methods_4.2.3      mime_0.12          munsell_0.5.1     
#>   R6_2.5.1           rappdirs_0.3.3     RColorBrewer_1.1.3 rlang_1.1.3       
#>   rmarkdown_2.27     rstudioapi_0.16.0  sass_0.4.9         scales_1.3.0      
#>   stats_4.2.3        stringi_1.8.4      stringr_1.5.1      svglite_2.1.3     
#>   systemfonts_1.1.0  tinytex_0.51       tools_4.2.3        utils_4.2.3       
#>   vctrs_0.6.5        viridisLite_0.4.2  xfun_0.44          xml2_1.3.6        
#>   yaml_2.3.8        
#> 
#> Pandoc version: 3.1.11

Created on 2024-06-10 with reprex v2.1.0

我试了三个系统了,都不正常。

@haozhu233
Copy link
Owner

感觉是encoding的问题,只用knitr::kable呢,有问题吗

@chuxinyuan
Copy link
Author

只用 knitr::kable 没问题。

@chuxinyuan
Copy link
Author

我记得以前是正常的,至少2022年12月份是正常的(我有篇文章是那个时候发出来的)。这次更新博客才发现不正常了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants