Using Rmarkdown, on Rstudio, in order to create a word document ; I tried to create a table of content at the second page of my document. I success using officedown
package created by @DavidGohel.
However I use a style.docx file as basic template to define the main style of my document. While using the style.docx and the officedown::rdocx_document
output in the YAML, the number of section within the tables of content disappear.
If I use the classic word_document
the table of contents is generated as I wish.
So that, finally, I got what I expected. But I do not understand what is happening here. And maybe that's would be an issue that should be reported in github ?
See below what I mean
---
title: "Example"
output:
officedown::rdocx_document:
reference_docx: Rmarkdow_to_word_biblio_styles_V1.docx
number_sections: TRUE
---
```{r setup, include=FALSE}
library(officedown)
library(officer)
knitr::opts_chunk$set(echo = TRUE)
```
\newpage
# Table of contents
```{r, echo=FALSE}
block_toc(level = 3)
```
# Title
## Subtitle
not what I expected, and
---
title: "Example"
output:
word_document:
reference_docx: Rmarkdow_to_word_biblio_styles_V1.docx
number_sections: TRUE
---
```{r setup, include=FALSE}
library(officedown)
library(officer)
knitr::opts_chunk$set(echo = TRUE)
```
\newpage
# Table of contents
```{r, echo=FALSE}
block_toc(level = 3)
```
# Title
## Subtitle
This is what I need. But this sound weird for me to mix the classic Rmarkdown
with officedown
. I think that there is probably a better solution to solve this.