Search code examples
rnewlinereporters

Add line break in title in ReporteRs


In this example, I would like to put a line break between "Episode IV" and "A New Hope" but \n isn't working... how can I do it?

library("ReporteRs")
deck <- pptx( title = "Star Wars Movies")  
deck <- addSlide( deck, slide.layout = "Title and Content" )
deck <- addTitle( deck, "Episode IV\nA New Hope")
# spoiler alert
deck <- addParagraph(deck, paste("This movie is about Luke Skywalker, Han Solo,",
                                 "Obi-Wan Kenobi, and some droids who rescue",
                                 "Princess Leia and blow up the Death Star.") )
writeDoc(deck, file = "temp.pptx" )

enter image description here


Solution

  • Use \r\n instead of \n only

    library("ReporteRs")
    deck <- pptx( title = "Star Wars Movies")  
    deck <- addSlide( deck, slide.layout = "Title and Content" )
    deck <- addTitle( deck, "Episode IV\r\nA New Hope")
    # spoiler alert
    deck <- addParagraph(deck, paste("This movie is about Luke Skywalker, Han Solo,",
                                     "Obi-Wan Kenobi, and some droids who rescue",
                                     "Princess Leia and blow up the Death Star.") )
    writeDoc(deck, file = "temp.pptx" )