我正在起草一份需要目录并需要编写到Word 中的rmd。我正在使用 officedown 包,虽然我可以获得目录,但我需要让表格不包含目录的节标题。我有这个:
---
output:
officedown::rdocx_document:
reference_docx: word_styles_ref_01.docx
---
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.cap = TRUE)
library(officedown)
library(officer)
<!---CHUNK_PAGEBREAK--->
# Table of Contents
<!---BLOCK_TOC--->
<!---CHUNK_PAGEBREAK--->
My report starts here.
# Heading 1
My report starts here.
## Heading 2
And I have this next subsection.
但我不希望“目录”在实际目录中重复。在上面的代码中,它在带有页码的单词文档中重复。有没有办法不将其包含在目录中?
根据 https://bookdown.org/yihui/rmarkdown-cookbook/toc-unlisted.html,只需在标题后添加 {.unlisted .unnumbered} 即可。
@Gregory 谢谢,你的解决方案对我有用。