在R flextable中,复杂的符号可以出现在列标题中吗

问题描述

使用flextable制作表格,我希望列标题为pi(带帽子)和i下标。使用flextable 6我see可以使用compose()函数为标题添加基本格式。我可以很容易地得到pi sub,但是我不知道如何在pi上戴上帽子。

test <- data.frame(hat_pi_i= c(0.1,0.9))

# devtools::install_github("davidgohel/flextable")  # version 6.x
# devtools::install_github("davidgohel/officer")  # for flextable 6 to work

library(flextable)
# compose conflicts with purrr & igraph
flextable(test) %>% 
  compose(part = "header",j = "hat_pi_i",value = as_paragraph("hat π",as_sub("i"))) 

是否可以调整上面的标题以将帽子戴在pi上而不是旁边一个单词?

解决方法

有一种方法可以做到:

flextable(test) %>% 
  compose(part = "header",j = "hat_pi_i",value = as_paragraph("\U1D70B\U0302",as_sub("i"))) 

screenshot

这使用Unicode字符:\U1D70B是数学风格pi,而\U0302表示在前一个字符上加上抑音符。您也可以使用π来做第一个字符,但是看起来并不好,因为(至少在我的系统上)抑扬符号最终放错了位置:

screenshot

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...