0

How can one do "soft" returns for docx files from officer? To do it manually, I'd press SHIFT + ENTER and alter the ruler tabs to offset subsequent lines. But the heading will show as one line in the table of contents.

I have not been able to reproduce this programmatically.

No methods found in the documentation.

candronikos
  • 159
  • 1
  • 13

2 Answers2

0

Soft return is not a feature of officer. If you want a new line of text, you will have to add a new paragraph.

library(magrittr)

doc <- read_docx() %>%
  body_add_par("A paragraph", style = "Normal") %>%
  body_add_par("A new paragraph is starting on a new line", style = "Normal")
David Gohel
  • 9,180
  • 2
  • 16
  • 34
-4

If you're just looking to enter a return into the same paragraph, you can use \n:

library(officer)

my_doc <- read_docx() $>$
  body_add_par("This is on the first line.\nThis is on the next line")
Sven
  • 1,203
  • 1
  • 5
  • 14