5

The default function (example Table: Table one) for getting table captions in your R Markdown pdf-documents is nice. But I struggle to change from default English "Table" to something else while at the same time keeping placement (above table) and numbering. Numbering is solveable, I could write my own count-function but placement have to be above the table.

I have tried to use Pander to set a new prefix but that seems to break both placement and numbering.

Do anyone have any idea for what I should do, can I change the default table caption while (at minimum) keeping default placement above table but preferably keeping numbering as well?

ErrantBard
  • 1,421
  • 1
  • 21
  • 40

1 Answers1

10

You can do so by using the caption Latex package and changing the caption name in a separate header.tex file. Then tell rmarkdown to include it:

file.Rmd

---
output: 
  pdf_document:
    includes:
      in_header: header.tex
---

```{r cars}
knitr::kable(mtcars, caption = "This is a test")
```

header.tex

\usepackage{caption}
\captionsetup[table]{name=Test}
Tutuchan
  • 1,527
  • 10
  • 19
  • Thanks @Tutuchan, elegant and simple :) – ErrantBard Aug 25 '16 at 09:07
  • @Tutuchan: Is it also possible to print the capute in italics? Also: Is it possible to include the number that follows in italics but not the rest of the capute? Because apa6h style wants the following: "_Figure 1._ Some figure caption" – Jaynes01 May 26 '18 at 11:09
  • 2
    Never mind. I found it: Just use this captionsetup: `\captionsetup[figure]{name=Figure,labelfont=it,labelsep = period}` – Jaynes01 May 26 '18 at 11:23