【问题标题】:Adding bullet before statement in powerpoint via officer in R通过 R 中的官员在 powerpoint 中的语句之前添加项目符号
【发布时间】:2020-09-22 00:01:47
【问题描述】:

我正在使用 R 中的 officer 包来创建可重现的幻灯片。当句子位于 powerpoint 模板的“正文”对象中时,我可以毫无问题地在句子前面添加项目符号,但是当我尝试分配句子的确切位置时,不包含项目符号。请看下面的脚本:

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放置时,是否也可以分配项目符号。谢谢!

【问题讨论】:

    标签: r formatting officer


    【解决方案1】:

    这应该会有所帮助。

    • 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')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-27
      • 2018-11-01
      • 2017-01-12
      • 2020-10-24
      • 2013-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多