I am writing my first .rmd report using RMarkdown and then I knit it to pdf file. As I write it in my national language, I would like to have figures captions in my language too. The problem is that the default caption format is "Figure 1: My caption". I would like to change this generative "Figure 1:" part but I couldn't find how. Any help will be appreciated.
Asked
Active
Viewed 3,398 times
3 Answers
7
Try specifying the language in the YAML header of an rmarkdown
document (documentation link):
---
title: "Crop Analysis Q3 2013"
output: pdf_document
fontsize: 11pt
geometry: margin=1in
lang: german
---
The language code will be processed by the babel
LaTeX package (at least in the case of pdflatex
).

krlmlr
- 25,056
- 14
- 120
- 217
-
1I just needed to set `lang: de` as a "correct IETF language tag". – stats-hb Jul 08 '20 at 07:23
3
I found out that it is possible to do using LaTeX:
---
title: "My raport"
output:
pdf_document:
fig_caption: yes
header-includes:
- \usepackage{caption}
---
\def\figurename{MyFigureName}
Still: is there any simpler way?

Marta Cz-C
- 759
- 1
- 8
- 18
-
If the Rmd file might end up as part of a longer document, it may be preferable to use `\renewcommand{\figurename}{MyFigureName}` – Martin Smith Apr 07 '23 at 08:43
0
It should work like this:
---
output:
pdf_document:
fig_caption: true
---
```{r figWithCaption, echo=F, fig.cap="My Figure Caption"}
plot(cars) # your figure
```

jmjr
- 2,090
- 2
- 21
- 31
-
1Thank you, but it still generates caption: "Figure 1: My Figure Caption". I want it to be "MyFigureName 1: My figure caption". – Marta Cz-C Jul 10 '15 at 20:21
-
Ah sorry, I haven't read your question thoroughly enough. Does it need to be a specific figure name, or is it about language? If the latter is the case, you can include: `header-includes: - \usepackage[english]{babel} ` in the YAML header, and instead of "english" type your desired language. Else I don't know an answer to your question.. – jmjr Jul 11 '15 at 09:50