无序列表中的多种文本格式
Multiple text formats in unordered list
我正在尝试将无序列表项目符号(PPT 中)的句子中的单个单词加粗。这可能吗?将 fpar/ftext 个对象的组合放入 unordered_list 内的 str_list 会引发错误。提前致谢。
编辑,添加我的意思的例子:
example
这在此处记录:
https://davidgohel.github.io/officer/articles/offcran/powerpoint.html#unordered-lists
library(officer)
doc <- read_pptx()
ul <- unordered_list(
level_list = c(1, 2, 2, 3, 3, 1),
str_list = c("Level1", "Level2", "Level2", "Level3", "Level3", "Level1"),
style = fp_text(color = "red", bold = TRUE, font.size = 25) )
doc <- add_slide(doc)
doc <- ph_with(x = doc, value = ul, location = ph_location_type(type = "body") )
print(doc, target = "ph_with_ul.pptx")
我有同样的问题。我的同事给了我这段代码:
pres_1 <- read_pptx(path = template) %>%
add_slide(layout = 'Title and Content', master = 'Office Theme') %>%
ph_empty(type = 'body') %>%
ph_add_par() %>%
ph_add_text(str = 'this is a red text', style = fp_text(color = 'red', font.size = 20)) %>%
ph_add_text(str = ' followed by a blue text', style = fp_text(color = 'blue', font.size = 20)) %>%
ph_add_par(level = 2) %>%
ph_add_text(str = 'Level 2', style = shortcuts$fp_italic() ) %>%
ph_add_par(level = 3) %>%
ph_add_text(str = 'Level 3', style = shortcuts$fp_bold())
print(pres_1, "test.pptx")
它仍然适用于 officer 0.3.5,但在当前软件包版本 (https://davidgohel.github.io/officer/index.html) 的文档页面上不再有任何记录。
我想知道使用上述站点的功能文档来实现它的预期方法是什么。
您可以尝试以下方法,这对我有用:
library(officer)
doc <- read_pptx()
ul <- unordered_list(
level_list = c(1, 2, 2, 3, 3, 1),
str_list = c("Level1", "Level2", "Level2", "Level3", "Level3", "Level1"),
style = list(fp_text(color = "red", bold = TRUE, font.size = 25),
fp_text(color = "blue", bold = TRUE, font.size = 25)
fp_text(color = "yellow", bold = TRUE, font.size = 25)
fp_text(color = "red", bold = TRUE, font.size = 25)
fp_text(color = "blue", bold = TRUE, font.size = 25)
fp_text(color = "yellow", bold = TRUE, font.size = 25)))
doc <- add_slide(doc)
doc <- ph_with(x = doc, value = ul, location = ph_location_type(type = "body") )
print(doc, target = "ph_with_ul.pptx")
我正在尝试将无序列表项目符号(PPT 中)的句子中的单个单词加粗。这可能吗?将 fpar/ftext 个对象的组合放入 unordered_list 内的 str_list 会引发错误。提前致谢。
编辑,添加我的意思的例子:
example
这在此处记录:
https://davidgohel.github.io/officer/articles/offcran/powerpoint.html#unordered-lists
library(officer)
doc <- read_pptx()
ul <- unordered_list(
level_list = c(1, 2, 2, 3, 3, 1),
str_list = c("Level1", "Level2", "Level2", "Level3", "Level3", "Level1"),
style = fp_text(color = "red", bold = TRUE, font.size = 25) )
doc <- add_slide(doc)
doc <- ph_with(x = doc, value = ul, location = ph_location_type(type = "body") )
print(doc, target = "ph_with_ul.pptx")
我有同样的问题。我的同事给了我这段代码:
pres_1 <- read_pptx(path = template) %>%
add_slide(layout = 'Title and Content', master = 'Office Theme') %>%
ph_empty(type = 'body') %>%
ph_add_par() %>%
ph_add_text(str = 'this is a red text', style = fp_text(color = 'red', font.size = 20)) %>%
ph_add_text(str = ' followed by a blue text', style = fp_text(color = 'blue', font.size = 20)) %>%
ph_add_par(level = 2) %>%
ph_add_text(str = 'Level 2', style = shortcuts$fp_italic() ) %>%
ph_add_par(level = 3) %>%
ph_add_text(str = 'Level 3', style = shortcuts$fp_bold())
print(pres_1, "test.pptx")
它仍然适用于 officer 0.3.5,但在当前软件包版本 (https://davidgohel.github.io/officer/index.html) 的文档页面上不再有任何记录。
我想知道使用上述站点的功能文档来实现它的预期方法是什么。
您可以尝试以下方法,这对我有用:
library(officer)
doc <- read_pptx()
ul <- unordered_list(
level_list = c(1, 2, 2, 3, 3, 1),
str_list = c("Level1", "Level2", "Level2", "Level3", "Level3", "Level1"),
style = list(fp_text(color = "red", bold = TRUE, font.size = 25),
fp_text(color = "blue", bold = TRUE, font.size = 25)
fp_text(color = "yellow", bold = TRUE, font.size = 25)
fp_text(color = "red", bold = TRUE, font.size = 25)
fp_text(color = "blue", bold = TRUE, font.size = 25)
fp_text(color = "yellow", bold = TRUE, font.size = 25)))
doc <- add_slide(doc)
doc <- ph_with(x = doc, value = ul, location = ph_location_type(type = "body") )
print(doc, target = "ph_with_ul.pptx")