9

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.

Marta Cz-C
  • 699
  • 1
  • 9
  • 15

3 Answers3

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
  • 23,618
  • 14
  • 112
  • 204
2

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
  • 699
  • 1
  • 9
  • 15
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
  • 1,990
  • 2
  • 19
  • 31
  • Thank 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