【发布时间】:2018-05-16 15:44:36
【问题描述】:
使用 R 中的 officer 包,在使用 PowerPoint 时,您可以使用函数 ph_with_text 添加文本。但是,尚不清楚如何添加多个文本项目符号或如何设置缩进级别。我想实现以下结构:
- 问题 1
- 回答1
- 回答2
- 问题 2
- 回答1
- 回答2
我尝试了两种方法都产生了非常错误的结果。我尝试使用我的文本并添加 \n 和 \n\t 来创建换行符和制表符(就像我在 PowerPoint 中创建结构的方式一样。
doc = read_pptx()
doc = add_slide(layout = "Title and Content", master = "Office Theme")
doc = ph_with_text(doc,type = "body",
str = "Question 1\n\tAnswer 1\n\tAnswer 2\nQuestion 2\n\tAnswer 1\n\tAnswer 2",
index = 1)
这会创建子弹,但不会创建深度。每个答案之前的每个项目符号后面都有一个空格选项卡。此外,这些不是新项目符号,如果我手动编辑文件并在一个项目符号点上按 Tab,则之后的每个点也会移动。显然还没有实现正确的结构。
我也尝试过反复拨打ph_with_text。
doc = add_slide(layout = "Title and Content", master = "Office Theme")
doc = ph_with_text(doc,type = "body", str = "Question 1", index = 1)
doc = ph_with_text(doc,type = "body", str = "Answer 1", index = 1)
doc = ph_with_text(doc,type = "body", str = "Answer 2", index = 1)
doc = ph_with_text(doc,type = "body", str = "Question 2", index = 1)
doc = ph_with_text(doc,type = "body", str = "Answer 1", index = 1)
doc = ph_with_text(doc,type = "body", str = "Answer 2", index = 1)
但这最终会覆盖同一行上的文本,这是一个无法阅读的混乱。
我如何通过officer向幻灯片添加文本以实现多个项目符号和缩进子元素?
【问题讨论】: