Search code examples
rofficer

Second line of text in pptx subtitle


I have added a Title Slide to a pptx object, and want to add a second line in the subtitle location.

I've tried using ph_add_fpar function with no success. I'm still new with the package so probably not using the correct functions!

    mypowerpoint <- read_pptx() %>%
      add_slide("Title Slide","Office Theme") %>%
    ph_with("Flashy Title",ph_location_type("ctrTitle",position_right = TRUE)) %>%
    ph_with("Catchy Subtitle 1",ph_location_type("subTitle")) %>%
    ph_with("Catchy Subtitle 2",ph_location_type("subTitle")) 

Running the above gives me two subtitles overlaid on top of each other, rather than the second subtitle text as a new line in the same objects as the first. Can anyone please tell me what I'm missing, or a better function to use for this?


Solution

  • ph_with support vector with length > 1

    library(magrittr)
    library(officer)
    mypowerpoint <- read_pptx() %>%
      add_slide("Title Slide","Office Theme") %>%
      ph_with("Flashy Title",ph_location_type("ctrTitle",position_right = TRUE)) %>%
      ph_with(c("Catchy Subtitle 1", "Catchy Subtitle 2"),ph_location_type("subTitle"))