使用R的flextable包时,有没有办法将字符串的粗体部分传递给add_header_lines

问题描述

我正在使用我喜欢的flextable包为Word文档创建几个表。但是,在表格标题中加粗部分文本时遇到了一些麻烦。例如,我希望标题显示为“ 表1 ”。而不是“表1。我表标题的其余部分。”

found this documentation,经过反复试验,我终于得到了想要的结果。但是感觉可能有更直接的方法来获得它。这是我当前的解决方案:

library(dplyr)
library(flextable)

mtcars_ft <- flextable(head(mtcars)) %>% 
  # Add a blank title line to top of table
  add_header_lines("") %>% 
  # Use compose to bold "Table #."
  compose(
    i = 1,part = "header",value = as_paragraph(
      as_chunk("Table 1. ",props = fp_text(bold = TRUE)),"Here is my example mtcars ft."
    ),)

这是我的结果的屏幕截图:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)