如何在 knitr 中更改内容 header 的 table?

How to change table of content header in knitr?

我正在使用以下选项通过 knitr 生成 pdf 文档:

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

我想更改内容 table 的 header(即 "Contents"),因为我正在制作葡萄牙语文档。有什么方法可以自定义吗?

感谢@Molx 和@Chris 的评论,我找到了解决方案。

解决方案 1

\renewcommand{\contentsname}{Índice} 添加到文档中,这样 .Rmd header 就是:

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

有了这个解决方案,header 就是 Whatever 你放在 \contentsname 参数中。

解决方案 2

lang: portuguese 添加到文档中,这样 .Rmd header 就是:

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

使用此解决方案,header 是 "Contents" 的葡萄牙语翻译。如果您的 TeX 安装支持该语言,这应该可以工作。