文本默认为垂直,幻灯片上的对象太多 ReporteRs R
Text defaults to vertical with too many objects on slide ReporteRs R
当我在幻灯片上放置九个以上的对象时,最新的对象默认为垂直(文本会发生这种情况,图表或图像不确定)。我的公司确实有在幻灯片上放太多信息的习惯,但如果可能的话,他们希望保持相同的格式。我不确定 ReporteRs 包是否有设置最大对象数的选项,或者这可能是 运行 包的依赖项之一的问题。我将附上屏幕截图和代码。我创建了一个名为 Presentation1.pptx 的空白文档并将其放在我的工作目录中。
代码:
library("ReporteRs")
pres <- pptx(template = "Presentation1.pptx")
pres <- addSlide(pres, slide.layout = 'Blank')
pres <- addParagraph(par.properties = parProperties(),
doc = pres, text.align = "left", value = pot("SOME TEXT",
textBold(color = "black", font.size = 36, font.family = "Arial")),
offx = 0.5, offy = 0, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 1),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 21, font.family = "Arial")),
offx = 0.25, offy = 1, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 1.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 2, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 1),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 21, font.family = "Arial")),
offx = 0.25, offy = 2.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 3, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 3.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 4, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 4.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Copyright Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 3, offy = 7, width = 0, height = 1)
writeDoc(pres, file = "pres.pptx")
首先,如果可能,请转到包 officer
并阅读该页面:https://davidgohel.github.io/officer/articles/powerpoint.html#append-text-sequentially-in-a-shape。
在您的脚本中,您使用设置为 0 的宽度和每个新段落的新形状。 text.align
不是 addParagraph 的参数。所以让我们简化一下:
library(ReporteRs)
pres <- pptx()
pres <- addSlide(pres, slide.layout = 'Title and Content')
style_36 <- textBold(color = "black", font.size = 36, font.family = "Arial")
style_17 <- textBoldItalic(color = "black", font.size = 17, font.family = "Arial")
style_21 <- textBoldItalic(color = "black", font.size = 21, font.family = "Arial")
par_lev_1 <- parProperties(list.style = "unordered", level = 1)
par_lev_2 <- parProperties(list.style = "unordered", level = 2)
par_lev_3 <- parProperties(list.style = "unordered", level = 3)
pres <- addParagraph(par.properties = parProperties(), doc = pres, value = pot("SOME TEXT", style_36),
offx = 0.5, offy = 0, width = 8, height = 6)
pres <-addParagraph(par.properties = par_lev_1, append = TRUE,
doc = pres, value = pot("Some Text", style_21) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_3, append = TRUE,
doc = pres, value = pot("Some Text", style_21) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text",style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_3, append = TRUE,
doc = pres, value = pot("Copyright Text", style_21) )
writeDoc(pres, file = "pres.pptx")
当我在幻灯片上放置九个以上的对象时,最新的对象默认为垂直(文本会发生这种情况,图表或图像不确定)。我的公司确实有在幻灯片上放太多信息的习惯,但如果可能的话,他们希望保持相同的格式。我不确定 ReporteRs 包是否有设置最大对象数的选项,或者这可能是 运行 包的依赖项之一的问题。我将附上屏幕截图和代码。我创建了一个名为 Presentation1.pptx 的空白文档并将其放在我的工作目录中。
代码:
library("ReporteRs")
pres <- pptx(template = "Presentation1.pptx")
pres <- addSlide(pres, slide.layout = 'Blank')
pres <- addParagraph(par.properties = parProperties(),
doc = pres, text.align = "left", value = pot("SOME TEXT",
textBold(color = "black", font.size = 36, font.family = "Arial")),
offx = 0.5, offy = 0, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 1),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 21, font.family = "Arial")),
offx = 0.25, offy = 1, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 1.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 2, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 1),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 21, font.family = "Arial")),
offx = 0.25, offy = 2.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 3, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 3.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 4, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 4.5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Some Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 0.75, offy = 5, width = 0, height = 1)
pres <-addParagraph(par.properties = parProperties(list.style = "unordered", level = 2),
doc = pres, text.align = "left", value = pot("Copyright Text",
textBoldItalic(color = "black", font.size = 17, font.family = "Arial")),
offx = 3, offy = 7, width = 0, height = 1)
writeDoc(pres, file = "pres.pptx")
首先,如果可能,请转到包 officer
并阅读该页面:https://davidgohel.github.io/officer/articles/powerpoint.html#append-text-sequentially-in-a-shape。
在您的脚本中,您使用设置为 0 的宽度和每个新段落的新形状。 text.align
不是 addParagraph 的参数。所以让我们简化一下:
library(ReporteRs)
pres <- pptx()
pres <- addSlide(pres, slide.layout = 'Title and Content')
style_36 <- textBold(color = "black", font.size = 36, font.family = "Arial")
style_17 <- textBoldItalic(color = "black", font.size = 17, font.family = "Arial")
style_21 <- textBoldItalic(color = "black", font.size = 21, font.family = "Arial")
par_lev_1 <- parProperties(list.style = "unordered", level = 1)
par_lev_2 <- parProperties(list.style = "unordered", level = 2)
par_lev_3 <- parProperties(list.style = "unordered", level = 3)
pres <- addParagraph(par.properties = parProperties(), doc = pres, value = pot("SOME TEXT", style_36),
offx = 0.5, offy = 0, width = 8, height = 6)
pres <-addParagraph(par.properties = par_lev_1, append = TRUE,
doc = pres, value = pot("Some Text", style_21) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_3, append = TRUE,
doc = pres, value = pot("Some Text", style_21) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text",style_17) )
pres <-addParagraph(par.properties = par_lev_2, append = TRUE,
doc = pres, value = pot("Some Text", style_17) )
pres <-addParagraph(par.properties = par_lev_3, append = TRUE,
doc = pres, value = pot("Copyright Text", style_21) )
writeDoc(pres, file = "pres.pptx")