首页 > 解决方案 > 为 Rmarkdown 标题创建类似作者的添加

问题描述

Rmarkdown用来创建一个.docx文件。

我想指定用于一些文本的 Word 样式。通常它默认为First Paragraph(不知道为什么),但我希望它默认为Normal并可以选择其他内置样式之一(例如CompactBody Text)。

标题:

---
title: "Report title"

output: 
  word_document:
    toc: yes
    reference_docx: "SMC-Style.docx"
---

我已将 设置SMC-Style.docx为模板并根据需要格式化所有样式。我只是不知道如何使特定的文本部分使用这些样式。我可以得到标题 1-6(使用###),但不知道如何为其他样式做同样的事情,例如Body Text.

我试过的:

我试图重现这里的例子,但没有一个奏效

  1. [Test1 - this is 'First Paragraph' style]

  2. [Test2 - Still 'First Paragraph' style]{#Normal}

  3. [Test3 - Still 'First Paragraph' style]{custom-style = #Normal}

::: {#Normal}
Test5 - Still 'First Paragraph' style
:::
  1. ::: {custom-style = #Normal}
    Test4 - Still 'First Paragraph' style
    :::
    

似乎没有什么能改变与这些文本相关的风格。任何人都可以帮忙吗?

会话信息:

R 版本 3.6.1、RStudio 版本 1.1.456 和 rmarkdown v1.18,在 Office 2013 中输出到 Word。

标签: rr-markdown

解决方案


这可能是您的 yaml 标头的问题,请尝试将您的标头编辑为此

toc: true
reference_docx: SMC-Style.docx

推荐阅读