我如何将标题页与RMarkdown Word输出中的目录分开?

问题描述 投票:0回答:1

如何在RMarkdown Word输出中将标题页与目录分开?我在这里看到了很多关于pdf和html输出的信息,但是关于Word却看得很少。我尝试使用LaTex的一些功能,但似乎大多数功能只适用于pdf输出,而适用于Word的功能却不能满足我的需求。

---
title: "Sample Title"
subtitle: "Sample Subtitle"
date: "April 8, 2020"
output:
  word_document:
    toc: yes
---

\newpage

# Header 1

sample text


## Header 2

more sample text


# Another Header 1

loren ipsum

## Another Header 2

foo bar

这只是将目录的空白页放在[[after,而不是之前。感觉好像缺少一些简单的东西。

r ms-word format latex r-markdown
1个回答
0
投票
[您可能考虑研究officedown程序包及其block_toc功能(连同<!---CHUNK_PAGEBREAK--->内联Yaml):

--- title: "Sample Title" subtitle: "Sample Subtitle" date: "April 8, 2020" output: officedown::rdocx_document --- <!---CHUNK_PAGEBREAK---> # Table of Contents `r officedown::block_toc(level = 5, style = NULL, separator = ";")` <!---CHUNK_PAGEBREAK---> # Header 1 sample text ## Header 2 more sample text # Another Header 1 loren ipsum ## Another Header 2 foo bar

甚至简单,如讨论的here

<!---CHUNK_PAGEBREAK---> # Table of Contents <!---BLOCK_TOC---> <!---CHUNK_PAGEBREAK--->

© www.soinside.com 2019 - 2024. All rights reserved.