0
votes

I'm using officedown with Rmarkdown to knit word docs and currently it's not reading level 4 and 5 headers in the Table of Contents (though it's correctly adding headers levels 1-3). My YAML is:

date: XX
author: XX
title: XX
output: 
  officedown::rdocx_document:
    reference_docx: reference_style_01.docx
bibliography: Thesis.bib
csl: apa
editor_options: 
  markdown: 
    wrap: 72

and this is the code block immediately after the YAML:

knitr::opts_chunk$set(echo = FALSE, fig.cap = TRUE)
library(officedown)
library(officer)
install.packages("knitr", repo = "http://cran.rstudio.com")
library(knitr)

fp <- fp_par(
  text.align = "center", 
  padding.bottom = 20, padding.top = 120, 
  border.bottom = fp_border())

ft <- fp_text(shading.color='#EFEFEF', bold = TRUE)

I'm using #'s to identify headers. # header 1, ## header 2, and ### header 3 are correctly identified by officedown and put in the TOC. But #### header 4 and ##### header 5 aren't. Do I need to change my style guide or YAML or something else? All help appreciated.

1
Read here ardata-fr.github.io/officeverse/officedown-for-word.html#toc and use block_toc or use toc_depth (see ?rmarkdown::word_document)David Gohel
Thank you. I'm currently using <!---BLOCK_TOC---> and level 4 and 5 headers aren't included if I change it to block_toc(). I've also put toc_depth in the YAML (as both a stand alone line or under the 'output: officedown::rdocx_document:' section in the YAML) and the header value hasn't changed at all (either more or less). Is there something in the YAML I need to add to make toc_depth work? Any other thoughts are appreciated.PsychBrief
OK, if using block_toc, you can adjust the toc depth with block_toc(level = 5)David Gohel
That did it thank you! Sorry you had to hold my hand throughout the entire process haha.PsychBrief
no problem, glad it helps :)David Gohel

1 Answers

0
votes

Changing the table of contents block from <!---BLOCK_TOC--->

to

block_toc(level = 5)

fixed it. Thanks David Gohel for the help.