Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change table of content header in knitr?

I am using the following options to produce a pdf document with knitr:

---
title: "Test"
author: "Paulo Miramor"
date: "13-07-2015"
output: pdf_document
toc: yes
---

I would like to change the header of the table of contents (which is "Contents"), since I am producing a document in Portuguese. Is there any way to customize it?

like image 907
Paulo MiraMor Avatar asked Mar 16 '23 10:03

Paulo MiraMor


1 Answers

Thanks to @Molx and @Chris in the comments I could find a solution.

Solution 1

Add \renewcommand{\contentsname}{Índice} to the document so that the .Rmd header is:

---
title: "Test"
author: "Paulo Miramor"
date: "13-07-2015"
output: pdf_document
header-includes:
   - \renewcommand{\contentsname}{Whatever}
toc: yes
---

With this solution the header is Whatever you put inside \contentsname argument.

Solution 2

Add lang: portuguese to the document so that the .Rmd header is:

---
title: "Test"
author: "Paulo Miramor"
date: "13-07-2015"
output: pdf_document
lang: portuguese
toc: yes
---

Using this solution the header was a translation of "Contents" to Portuguese. This should work if your TeX installation supports the language.

like image 115
Paulo MiraMor Avatar answered Mar 28 '23 19:03

Paulo MiraMor