0

According to the documentation located at the link at the bottom of this post, I can center a ggplot on a rdocx page:

library(ggplot2)

gg <- ggplot(data = iris, aes(Sepal.Length, Petal.Length)) + 
  geom_point()

doc_section_1 <- read_docx()
doc_section_1 <- body_add_gg(
  x = doc_section_1, value = gg, 
  width = 9, height = 6,
  style = "centered")

However, I get the following error when I attempt this using a landscape orientation template (i.e. read_docx(path = <a path to a template>))

! could not match any style named 'centered' in c('Normal', 'header', 'footer')

What is the issue here?

https://ardata-fr.github.io/officeverse/officer-for-word.html#add-sections

Aegis
  • 145
  • 10
  • From the error message the issue is most likely that in contrast to the default template shipped with `officer` your template has no style with name `"centered"`. – stefan May 24 '23 at 19:27

0 Answers0