rms-wordr-markdownofficedown

R markdown landscape-only word document


I am trying to knit an .Rmd file to a word document that is entirely in landscape format. Based on this post, I have tried using a reference doc. I created a Word document, changed the layout to landscape and saved it in the same folder as the .Rmd. However, this doesn't seem to work for me. Maybe I am missing something and saving a file in landscape format is not enough?

Previously, I was using the HTML comments/tags <!---BLOCK_LANDSCAPE_START---> and <!---BLOCK_LANDSCAPE_STOP---> from {officedown}, but since those can only be placed before and after code chunks, the title of the document would end up on a separate page that is portrait. Also, it gives a last page that is blank and portrait and that I don't know how to get rid of.

The current YAML header looks as follows:

---
title: "Summary Report"
output:
  officedown::rdocx_document:
    reference_docx: landscape_template.docx
---

I am also sure that the reference file is used because I get a warning in the console about not having set a Figure style:

Warning message:
paragraph style for plots "Figure" has not been found in the reference_docx document. Style 'Normal' will be used instead. 

Does anyone have any suggestions on what I am missing?


Solution

  • After reaching out to the developer of {officedown} on GitHub, here is the very simple solution to the problem:

    YAML header of .Rmd file:

    ---
    output:
      officedown::rdocx_document:
        page_size:
          orient: "landscape"
    ---