单元格高度改变后的文字调整

问题描述 投票:0回答:1

我正在尝试在 R 中重新创建最初在 Word 中创建的表。目的是让Rmarkdown用这个表格模板创建word文档。我已将单元格的宽度和高度调整为原始单元格的宽度和高度,但更改高度后,单元格中的文本未遵循更改。我尝试使用 valign 将文本垂直对齐居中,但它没有任何作用。如何将文本垂直对齐在表格单元格中?

我想要它的外观:

enter image description here

外观如何:

enter image description here

这是我正在使用的代码:

column_names <- c("Date", "DD(Month)2024")
row_names <- c("identifier", "diameter", "depth", "type", "duration (hh:mm:ss)")
pil_table <- data.frame(Date = row_names, DD.Month.2024 = rep(NA, length(row_names))) 
set_flextable_defaults(font.family = "Arial Nova Cond", font.size = 9, theme_fun = theme_box)

pil_table <- flextable(pil_table)
pil_table <- pil_table %>%
    width(j = 1,
          width = 3.8) %>%
    width(j = 2,
          width = 1.36) %>%
    align(align = "center", part = "header") %>%
    valign(valign = "center", part = "all") %>%
    height_all(height = 0.2) %>%
    hrule(rule = "exact", part = "all") %>%
    bg(i = 1, j = 1:2, bg = "#034F94", part = "header") %>%
    color(pil_table, i = 1, j = 1:2, color = "white", part = "header")`
r r-markdown flextable
1个回答
0
投票

这是 CSS 吗? 可能缺少 justify Flex 内容中心

© www.soinside.com 2019 - 2024. All rights reserved.