Search code examples
rknitrbookdown

R markdown / bookdown - how to display keywords below an abstract?


I defined keywords in the .Rmd file, but they are not visible in the output PDF.


Current Output

output without keywords


Expected results

expected results with keywords


Current .Rmd

First lines of .Rmd file looks as follows:

---
title: "No keywords within the output file"
abstract: "This is sample text for abstract. Generally speaking, I would like to show keywords list below an abstract (as in case of the linked example)"
keywords: "keywordA, keywordB"
author: "Mateusz Kędzior"
output: 
  bookdown::pdf_document2:
    keep_tex: true
    number_sections: yes
    toc: false
base_format: rticles::elsevier_article
---

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

## Elsevier article

This is an R Markdown document.

I'm trying to prepare an Elsevier article. 

Solution

  • I wonder if base_format is actually doing any work in your example (the output looks the same with and without base_format). Since base_format is an argument to pdf_book, consider changing your YAML header to

    ---
    title: "No keywords within the output file"
    author: 
    - name: "Mateusz Kędzior"
    abstract: "This is sample text for abstract. Generally speaking, I would like to show keywords list below an abstract (as in case of the linked example)"
    keywords: "keywordA, keywordB"
    output: 
      bookdown::pdf_book:
        keep_tex: true
        number_sections: yes
        toc: false
        base_format: rticles::elsevier_article
    ---
    

    which gives you the following output:

    enter image description here


    Alternatively, add keywords to the abstract:

        abstract: "This is sample text for abstract. Generally speaking, I would like
     to show keywords list below an abstract (as in case of the linked example) \\par
     \\textbf{Keywords:} a, b"
    

    to get

    enter image description here