R Markdown关键字未出现在文档中

时间:2019-04-09 09:53:45

标签: r r-markdown

我想编织一个pdf文档,但是关键字没有出现在最终文档中。有人可以说我在做什么错吗?

---
title: "title"
subtitle: "subtitle"
author: "author"
date: "09 04 2019"
output:
  pdf_document:
keywords: "word1, word2, word3"
footerdate: yes
abstract: 'Insert abstract here'
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Introduction

enter image description here

2 个答案:

答案 0 :(得分:0)

编织为PDF时,关键字将发送到文件元数据,但实际上在文件中不可见。 Source

答案 1 :(得分:0)

您可以customize the template for PDF generationrender Rmd files with base_format: rticles::elsevier_article。 但是,还有另一种方法可以通过在 Rmd 文件中添加一些代码来在 PDF 上显示关键字:

  1. 添加 LaTeX 代码以将 \keyword 命令 (\providecommand{\keywords}[1]{\textbf{\textit{Keywords---}} #1}) 提供到 YAML 的 header-includes 键中;
  2. 使用 LaTeX 命令在文本部分添加关键字
---
title: "title"
subtitle: "subtitle"
author: "author"
date: "09 04 2019"
output:
  pdf_document:
# keywords: "word1, word2, word3" # <- You don't have to add your keywords here since they only appear as the 'invisible' metadata of PDF
footerdate: yes
abstract: 'Insert abstract here'
header-includes:
  - |
    ```{=latex}
    \providecommand{\keywords}[1]{\textbf{\textit{Keywords---}} #1}
    ```
---

```{=latex}
\keywords{word1, word2, word3}
```

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Introduction