如何在可弯曲对象的标头中插入希腊字母delta(∆)?

时间:2018-09-10 19:21:58

标签: r unicode ms-word r-markdown flextable

我正在使用RMarkdown创建Word文档(我需要输出为.docx格式)。

我想使用 flextable (或其他任何软件包)正确格式化标题。

我正在尝试使希腊符号delta(∆)能够正确显示...这似乎是有可能的,因为在此处的帮助页面(https://davidgohel.github.io/flextable/articles/format.html#display-function)中,作者成功使用了\ u03BC插入“μ”符号(如果使用下面的代码,我也可以),但是我无法使用 \ u2206 \ u0394 < / strong>,如果我将\ u03BC替换为以下任一代码。我正在使用的代码会生成此表,但我想用delta代替突出显示的位。

enter image description here

这就是我尝试使用\u2206时得到的结果。

enter image description here

有什么建议吗?

library(flextable)
if( require("xtable") ){
  mat <- round(matrix(c(0.9, 0.89, 200, 0.045, 2.0), c(1, 5)), 4)
  mat <- xtable(mat)
  ft <- xtable_to_flextable(x = mat, NA.string = "-")
  print(ft$col_keys)
  ft <- flextable::display(ft, i = 1, col_key = "X1", 
    pattern = "{{val}}{{pow}}", part = "header",
    formatters = list(val ~ as.character("R"), pow ~ as.character("2") ),
    fprops = list(pow = fp_text(vertical.align = "superscript", font.size = 8))
    )
  ft <- flextable::display(ft, i = 1, col_key = "X2", 
    pattern = "{{val}}{{pow}}", part = "header",
    formatters = list(val ~ as.character("\u03BC"), pow ~ as.character("x") ),
    fprops = list(pow = fp_text(vertical.align = "superscript", font.size = 8))
    )
  ft <- flextable::display(ft, i = 1, col_key = "rowname", 
    pattern = "{{val}}{{pow}}", part = "body",
    formatters = list(val ~ as.character("y"), pow ~ as.character("t-1") ),
    fprops = list(pow = fp_text(vertical.align = "subscript", font.size = 8))
    )
  ft <- set_header_labels(ft, X3 = "F-stat", X4 = "S.E.E", X5 = "DW", rowname = "")
  ft <- autofit(ft)
  ft
}

更新

我要感谢David的有用建议,但是(对flextable不太熟悉),当我尝试以建议的方式修改标头时,我的行为很奇怪:

library(magrittr)
library(flextable)
library(officer)
AICtable <- data.frame(Model = "test", Parameters = 9, AICc = 4000, dAICc = 0, w = 1)
v.epi.aic <- flextable(AICtable) %>% 
font(fontname = "Times New Roman", part = "all") %>% 
flextable::display(col_key = "dAICc", part = "header",
                                pattern = "{{D}}{{A}}{{cbit}}", 
                                formatters = list(D ~ as.character("D"),
                                                  A ~ as.character("AIC"),
                                cbit ~ as.character("c") ),
                                fprops = list(D = fp_text(font.family = "Symbol"),
                                              A = fp_text(font.family = "Times New Roman"),
                                cbit = fp_text(vertical.align = "subscript")))

v.epi.aic

请注意,列标题现已复制,并且“ AIC”出现在“ ∆”之前。列名称应为:

模型,参数,AICc,ΔAICc,w(并且ΔAICc中的“ c”应为下标)。

enter image description here

1 个答案:

答案 0 :(得分:0)

请使用“\u394”代替“\u0394”来生成大写增量符号