How to knit to Word doc containing a footer with dynamic text.

I’m using an RMarkdown document that knits to a Word document. I want to include a footer in the Word doc that contains some dynamic information.
I am using a Word reference document in the RMarkdown file. I’ve added a footer to the WordStyles_Reference.docx. I’ve added some static text to the footer. I’ve tried adding a R variable to the footer. r footer_variable. When the RMarkdown doc knits to the Word doc, the footer is present with the static text but the R variable does not display. The R variable does not get evaluated. I see only the text r footer_variable.

Is there a way to do what I want to do? Have a RMarkdown doc knit to a Word document which contains a footer with dynamic information?

Top of R Markdown doc:

output:
word_document:
reference_docx: WordStyles_Reference.docx

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

This is not something possible using word_document with rmarkdown.

You would need to use a tool like officer to post process the file (Manipulation of Microsoft Word and PowerPoint Documents • officer) or maybe officedown if it is supporting doing that from R Markdown directly.

Hope it helps

1 Like