I'm trying to add line breaks using body_replace_all_text
or body_add_par
but am having no joy. Using \r\n
shows correctly in OSX TextEdit, but not in Word.
An example:
library(officer)
library(tidyverse)
read_docx() %>%
body_add_par("Oneline\r\n\r\nAnother line") %>%
print(target = "example.docx")
is there a right way to do this?
You will have to call body_add_par
each time you want to add a paragraph (a paragraph of text ends with a new line):
library(officer)
library(tidyverse)
read_docx() %>%
body_add_par("Oneline") %>%
body_add_par("Another line") %>%
print(target = "example.docx")