How to translate title of `abstract` in a pandoc's markdown (e.g., Rmd) document?
Asked Answered
H

3

7

In the YAML header of a pandoc's markdown file, it's possible to write an abstract. I wonder if there is a way to change the word "abstract" in the rendered document to something else like either word "summary" or equivalent in another language.

If not, what alternatives could be suggested? I'm using R Markdown.

p.s. My question is related to this comment.

Hekking answered 23/12, 2017 at 17:31 Comment(0)
O
3

If your main interest is in localization of your document, you can add an lang meta value to your document. E.g., setting lang: lt will give "Santrauka" instead of "Abstract" in the produced PDF.

Outsmart answered 23/12, 2017 at 21:14 Comment(2)
For PDF output, in addition to lang: lt, I had to include header-includes: \usepackage[L7x]{fontenc} into YAML header to get the word correctly translated to Lithuanian. Any ideas for HTML?Hekking
The default pandoc template for HTML doesn't include the abstract (should probably be changed). Using a custom template is probably your best bet in that case.Outsmart
A
6

Yes. But not automatically. You would have to redefine the abstract environment to start with a different header, or at least redefine the \abstractname variable as article.cls has this:

\newenvironment{abstract}{%
      \titlepage
      \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname           %%%% This what you need to redefine
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}

So you can do something like the following minimal example:

---
title: "Test Document"
author: "Some User"
output: pdf_document
abstract: >
  One or two sentences describing it all.
header-includes:
  \renewcommand{\abstractname}{My Very Own Summary}
---    

## R Markdown

This is an R Markdown document.

which does what you desire:

enter image description here

Algetic answered 23/12, 2017 at 18:10 Comment(3)
This solution works for PDF. Nice. And what about HTML: is there a solution?Hekking
"Probably". You will have to follow its code to its template use and alter / override there.Algetic
Ultimately, rmarkdown calls pandoc with a given template. You may have to modify that template, or write a new one. I am generally more concerned with pdf output.Algetic
O
3

If your main interest is in localization of your document, you can add an lang meta value to your document. E.g., setting lang: lt will give "Santrauka" instead of "Abstract" in the produced PDF.

Outsmart answered 23/12, 2017 at 21:14 Comment(2)
For PDF output, in addition to lang: lt, I had to include header-includes: \usepackage[L7x]{fontenc} into YAML header to get the word correctly translated to Lithuanian. Any ideas for HTML?Hekking
The default pandoc template for HTML doesn't include the abstract (should probably be changed). Using a custom template is probably your best bet in that case.Outsmart
E
1

The HTML template now includes the abstract, and its heading can be customized using the metadata variable abstract-title:

---
title: A title
author: An author
abstract: >
  The abstract.
abstract-title: Summary
---

Notice that this only affects the HTML, EPUB, and docx writers, though.

Erubescence answered 9/8, 2023 at 4:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.