【问题标题】:Can i change the formatting of specific words In my docx file with officer package in R?我可以使用 R 中的官员包更改我的 docx 文件中特定单词的格式吗?
【发布时间】:2020-09-07 00:40:51
【问题描述】:

我正在尝试将某些特定单词的格式更改为粗体,但找不到方法。

例如:

我想在此代码中将“文本”一词更改为粗体:

doc <- read_docx() %>%
   body_add_par("This is a sample text", style = "centered")

我该怎么做?

【问题讨论】:

    标签: r officer


    【解决方案1】:

    您可以使用body_add_fpar 来实现这一点。来自文档:

    bold_face <- shortcuts$fp_bold(font.size = 30)
    bold_redface <- update(bold_face, color = "red")
    fpar_ <- fpar(ftext("Hello ", prop = bold_face),
                  ftext("World", prop = bold_redface ),
                  ftext(", how are you?", prop = bold_face ) )
    doc <- read_docx() %>% body_add_fpar(fpar_)
    

    【讨论】:

    • 谢谢!这帮助我解决了我的问题!
    猜你喜欢
    • 1970-01-01
    • 2020-01-30
    • 2012-03-26
    • 2020-10-24
    • 1970-01-01
    • 2011-04-16
    • 2023-02-03
    • 2012-03-26
    • 2019-05-21
    相关资源
    最近更新 更多