Retain the headers and footers at the start of the document in officedown while using <!---BLOCK_LANDSCAPE_START--->/<!---BLOCK_LANDSCAPE_STOP--->?

297 views Asked by At

I'm currently generating a Word document using Rmarkdown and the officedown package. I'm using a reference document to set the styles and assign headers and footers on the document. This also includes a different header and footer on the first page.

My problem is that there is a part in my document that needs to be in landscape. But when I use the <!---BLOCK_LANDSCAPE_START---> and <!---BLOCK_LANDSCAPE_STOP--->, the headers and footers start to appear only after the <!---BLOCK_LANDSCAPE_STOP--->.

On the sample below, the headers and footers only appears starting at the # Results.

---
title: "My Document"
output:
  officedown::rdocx_document:
    reference_docx: path/to/reference.docx
---

# Introduction

This is the introduction section.

# Methods

This is the methods section.

<!---BLOCK_LANDSCAPE_START--->

# Landscape Section 1

This is the content of the first landscape section.

<!---BLOCK_LANDSCAPE_STOP--->

# Results

This is the results section.

# Conclusion

This is the conclusion section.

I've been looking through the github repository of officedown as well as the documentation for the possible solution but I'm still having this issue.

I tried updating package to an earlier version as well as the latest version but I still got the same result so I'm not sure if this can be fixed.

Here are some solutions that I can think of if this can't be fixed but I can't try to figure out how:

  1. Re-apply the template once the Word file was generated. This does not need to be on the Rmarkdown code itself but can also be on a external R program. I'm not sure if this is possible but I've been looking for a way to do this both in R and Python.

  2. I've read the comment on the git repository here but I've read the documentation on prop_section() and I can't seem to find the part where I can add a custom header or footer. I need to add a different header/footer on the first page and a different header/footer on the succeeding page. The headers/footers also have different formatting/alignment and contains shape objects.

  3. A bit similar to #1, after the Word file has been generated, open the Word file in R(or possible python) and look for the page with a specific header and change it's orientation to landscape.

0

There are 0 answers