通过 R 中的 officer 在 powerpoint 中的语句之前添加项目符号
Adding bullet before statement in powerpoint via officer in R
我正在使用 R 中的 officer
包创建可重现的幻灯片。当句子位于 powerpoint 模板的 "body" 对象中时,我可以毫无问题地在句子前面添加项目符号,但是当我尝试分配句子的确切位置时,没有包含项目符号。请看下面的脚本:
library(officer)
library(dplyr)
pptx.output.st00 <- read_pptx()
pptx.content1 <- c('sample sentence #1',
'sample sentence #2',
'sample sentence #3')
pptx.content2 <- block_list(fpar(ftext(c('sample sentence #1'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #2'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #3'),
prop = fp_text(font.family = 'Calibri',font.size=32))))
pptx.output.st01 <- pptx.output.st00 %>%
add_slide(.,layout = 'Title and Content',master = 'Office Theme') %>%
ph_with(.,value='Background',location=ph_location_type(type='title')) %>%
ph_with(.,value=pptx.content1,location=ph_location_type(type='body',id = 1)) %>%
ph_with(.,value=pptx.content2,location=ph_location(left = 0.5,top = 5.25,width = 8.5,height = 2))
print(pptx.output.st01,'presentation.output.pptx')
我想知道如果用ph_location
而不是ph_location_type
来放置句子,是否也可以分配bullet。谢谢!
这应该有所帮助。
- ph_location_template:需要使用以便我们可以重用 body 中的属性(body 在属性中有关联的项目符号)
- 如果使用,
level_list
表示为每个段落添加项目符号
library(officer)
library(dplyr)
pptx.output.st00 <- read_pptx()
pptx.content1 <- c('sample sentence #1',
'sample sentence #2',
'sample sentence #3')
pptx.content2 <- block_list(fpar(ftext(c('sample sentence #1'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #2'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #3'),
prop = fp_text(font.family = 'Calibri',font.size=32))))
pptx.output.st01 <- pptx.output.st00 %>%
add_slide(.,layout = 'Title and Content',master = 'Office Theme') %>%
ph_with(.,value='Background',location=ph_location_type(type='title')) %>%
ph_with(.,value=pptx.content1,location=ph_location_type(type='body',id = 1)) %>%
ph_with(.,value=pptx.content2,
location = ph_location_template(left = 0.5,top = 5.25,width = 8.5,height = 2, type="body"),
level_list = 1:3)
print(pptx.output.st01,'presentation.output.pptx')
我正在使用 R 中的 officer
包创建可重现的幻灯片。当句子位于 powerpoint 模板的 "body" 对象中时,我可以毫无问题地在句子前面添加项目符号,但是当我尝试分配句子的确切位置时,没有包含项目符号。请看下面的脚本:
library(officer)
library(dplyr)
pptx.output.st00 <- read_pptx()
pptx.content1 <- c('sample sentence #1',
'sample sentence #2',
'sample sentence #3')
pptx.content2 <- block_list(fpar(ftext(c('sample sentence #1'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #2'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #3'),
prop = fp_text(font.family = 'Calibri',font.size=32))))
pptx.output.st01 <- pptx.output.st00 %>%
add_slide(.,layout = 'Title and Content',master = 'Office Theme') %>%
ph_with(.,value='Background',location=ph_location_type(type='title')) %>%
ph_with(.,value=pptx.content1,location=ph_location_type(type='body',id = 1)) %>%
ph_with(.,value=pptx.content2,location=ph_location(left = 0.5,top = 5.25,width = 8.5,height = 2))
print(pptx.output.st01,'presentation.output.pptx')
我想知道如果用ph_location
而不是ph_location_type
来放置句子,是否也可以分配bullet。谢谢!
这应该有所帮助。
- ph_location_template:需要使用以便我们可以重用 body 中的属性(body 在属性中有关联的项目符号)
- 如果使用,
level_list
表示为每个段落添加项目符号
library(officer)
library(dplyr)
pptx.output.st00 <- read_pptx()
pptx.content1 <- c('sample sentence #1',
'sample sentence #2',
'sample sentence #3')
pptx.content2 <- block_list(fpar(ftext(c('sample sentence #1'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #2'),
prop = fp_text(font.family = 'Calibri',font.size=32))),
fpar(ftext(c('sample sentence #3'),
prop = fp_text(font.family = 'Calibri',font.size=32))))
pptx.output.st01 <- pptx.output.st00 %>%
add_slide(.,layout = 'Title and Content',master = 'Office Theme') %>%
ph_with(.,value='Background',location=ph_location_type(type='title')) %>%
ph_with(.,value=pptx.content1,location=ph_location_type(type='body',id = 1)) %>%
ph_with(.,value=pptx.content2,
location = ph_location_template(left = 0.5,top = 5.25,width = 8.5,height = 2, type="body"),
level_list = 1:3)
print(pptx.output.st01,'presentation.output.pptx')