Search code examples
rofficer

How to remove the number in "Heading 1" - officeR


Is it possible to remove the number when I add a heading in a word document?

my_doc <- read_docx() %>% 
body_add_par("This is a heading", style = "heading 1")
print(my_doc, target = 'dummy.docx')

The result in word is 1. This is a heading

But I would like to have without the number: This is a heading


Solution

  • officer uses styles from so called 'initial document' (or 'template')

    When you call read_docx with unspecified path argument, empty document located in the package directory is used as intial file. So go there and edit Heading 1 style.