How do I apply distinct page numbering by section using the officedown package?

62 Views Asked by At

I need to create a word document from an .RMD file in which the first section has no page numbers, the second section is numbered with Roman numerals, and the third section is numbered with Arabic numerals. I've tried including section breaks in my .rmd file that generates my word template (reference_docx) and then defining the different page numbering formats. But the page numbering saved in the reference docx doesn't appear to be applied to the output file.

Here's my yaml and code

---
output: 
  officedown::rdocx_document:
      number_sections: yes
      reference_docx: "document-template.docx" 
delete_merged_file: TRUE
documentclass: article
bibliography: "bibliography/refs.bib"
csl: "bibliography/springer-basic-author-date.csl" 
link-citations: false
out_asp: 0.8
out_width: 6.5
---

# Title
Title Page    

```{r section-roman}
officer::block_section(property = officer::prop_section(type = "nextPage"))
```

## Table of Contents
```{r table-of-contents}
block_toc()
```

```{r section-arabic}
officer::block_section(property = officer::prop_section(type = "nextPage"))
```

## Chapter 1

`r stringi::stri_rand_lipsum(5)`.

I've also tried adding the page number in the footer of the section like this:

```{r section-roman}
officer::block_section(property = officer::prop_section(type = "nextPage",
                                                        footer_default = block_list(run_word_field(field = "PAGE  \\* MERGEFORMAT"))))
```

But the resulting document still didn't contain page numbers

There is a note in the documentation that says "The ability to link a header or footer to a section is not (yet) implemented." (https://ardata-fr.github.io/officeverse/officer-for-word.html) So, if what I'm trying to do is related to the linking of headers and footers to sections, then someone please let me know before I waste any more time trying to figure this out..

0

There are 0 best solutions below