How to change table of content header in knitr?

南楼画角 提交于 2020-01-13 18:00:52

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/31396414/how-to-change-table-of-content-header-in-knitr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!