【问题标题】:How can I separate the title page from the table of contents in a RMarkdown Word output?如何将标题页与 RMarkdown Word 输出中的目录分开?
【发布时间】:2020-04-08 15:25:40
【问题描述】:

如何在 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

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

【问题讨论】:

    标签: r ms-word format latex r-markdown


    【解决方案1】:

    您可以考虑探索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--->
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-18
      • 2015-05-18
      • 2017-12-15
      • 2021-12-10
      • 1970-01-01
      相关资源
      最近更新 更多