4

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. 
matandked
  • 1,527
  • 4
  • 26
  • 51
  • 1
    It would be nice if you gave the expected example output inside the question instead of forcing readers to chase after non-clickable links and importing project templates into overleaf. Generally speaking, you should limit your question to the information that’s necessary and not clutter it with irrelevant details. – Konrad Rudolph Feb 16 '17 at 11:16
  • 1
    Sorry, I thought it will be easier to provide full output, so that it will be fully reproducible. I amended my question. – matandked Feb 16 '17 at 15:21
  • @matandked: And how you got rid of the "0." leading numbering of all your subtitles/sections? [because it is a single document] – FairMiles Nov 02 '17 at 23:46
  • Since I have "0" in my section numbering example output, I haven't tried to remove it. – matandked Nov 05 '17 at 16:15

1 Answers1

7

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

Weihuang Wong
  • 12,868
  • 2
  • 27
  • 48
  • Thank you, but...generally speaking I have much more complex document. Once I changed heading according to your suggestion, document was unable to compile (because of the polish letter "ł" in caption of the one of the figures) – matandked Feb 16 '17 at 16:36
  • Once I removed "ł" from caption, I've also noticed that in output .tex file "\citep{PositionInBibFile}" has been replaced by "(Someone, 2012)" – matandked Feb 16 '17 at 16:39
  • And instead of including bibliography by "\bibliography{bibliography.bib}" it just includes all bibliography positions in output .tex file – matandked Feb 16 '17 at 16:42
  • OK, I would suggest that you open up new questions for these other problems (or edit your minimal working example for these complications). SO Q&A works best when each question is a specific problem, rather than a bundle of problems. – Weihuang Wong Feb 16 '17 at 16:44
  • You're correct, I think that I will need to prepare different question and minimal working example. Because...well I also discovered that there's also equation problem as well (after changing header) although I'm referencing them according to https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#equations – matandked Feb 16 '17 at 16:47
  • Regarding **this** question - is it possible to add keywords in less elegant way, so that I will be still able to use pdf_document2 (some workaround to insert keywords into abstract section)? – matandked Feb 16 '17 at 16:49
  • I prepared new example and asked different question as you suggested: http://stackoverflow.com/questions/42312601/r-markdown-bookdown-how-to-switch-to-rticles – matandked Feb 18 '17 at 07:50
  • The solution above uses `\\par` to insert a line break. That didn't work for me with the `bookdown::pdf_document2` format but I was able to use `\newline \newline` following abstract and then `Keywords: ...` on a second line. NOTE: start each new line with two blank spaces or things get wonky. – Omar Wasow Apr 11 '23 at 00:11