通过R中的官员在PowerPoint中的声明之前添加项目符号 [英] Adding bullet before statement in powerpoint via officer in R

查看:67
本文介绍了通过R中的官员在PowerPoint中的声明之前添加项目符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R中的 people 包来创建可复制的幻灯片.当句子位于PowerPoint模板的"body"对象中时,可以毫无问题地在句子前面添加项目符号,但是当我尝试分配句子的确切位置时,不包括项目符号.请参见以下脚本:

I am using the officer package in R to create reproducible slides. I can add bullets in front of sentences without problem when the sentences are places in the "body" object of the powerpoint template, but when I try to assign the exact location of the sentence, no bullets are included. Please see the script as below:

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

I wonder if bullet can also be assigned when the sentences are placed using ph_location instead of ph_location_type. Thanks!

推荐答案

这应该有所帮助.

  • ph_location_template:需要使用,以便我们可以重用 body 中的属性(body在属性中具有关联的项目符号)
  • (如果使用的话), level_list 表示为要添加的每个段落添加项目符号
  • ph_location_template: need to be used so that we can reuse properties from body (body has associated bullets in properties)
  • if used, level_list mean to add bullets for each paragraph to add
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中的官员在PowerPoint中的声明之前添加项目符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆