4 级和 5 级标题未包含在 officedown 目录中

问题描述

我正在使用 officedown 和 Rmarkdown 来编写 word 文档,目前它没有读取目录中的第 4 级和第 5 级标题(尽管它正确地添加了第 1-3 级标题)。我的 YAML 是:

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

这是紧接在 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)

我使用#'s 来标识标题。 # header 1、## header 2 和### header 3 被officedown 正确识别并放入TOC。但是 #### 标题 4 和 ##### 标题 5 不是。我是否需要更改我的样式指南或 YAML 或其他内容?感谢所有帮助。

解决方法

更改目录块的表

block_toc(level = 5)

修复了它。感谢 David Gohel 的帮助。