从bookdown创建PDF时,我不想使用第X章,而是希望它是“MóduloX”(西班牙文)。
所以我想知道如何使用bookdown更改章节名称。
我的YAML是:
---
title: "TITLE"
author: "Mario Modesto-Mata"
date: "`r Sys.Date()`"
output: pdf_document
description: This is a minimal example of using the bookdown package to write a book.
The output format for this example is bookdown::gitbook.
documentclass: book
link-citations: yes
bibliography: book.bib
site: bookdown::bookdown_site
language:
label:
chapter_name: "Módulo"
---
我尝试了最后三行代码,没有成功。任何的想法?
从bookdown documentation我们可以学到两件事:
language.label.chapter_name
但language.ui.chapter_name
。配置LaTeX非常简单。您只需要在标题中添加lang: es
。但是,这将使用“Capítulo”而不是“Módulo”。可以通过重新定义LaTeX命令\chaptername
来调整它。顺便说一句,目前你没有使用bookdown
,而是使用来自pdf_docuemnt
的标准rmarkdown
。如果你不习惯使用bookdown
功能,你应该使用bookdown::pdf_book
或bookdown::pdf_document2
。
把所有东西放在一起:
---
title: "TITLE"
author: "Mario Modesto-Mata"
date: "`r Sys.Date()`"
output: bookdown::pdf_book
description: This is a minimal example of using the bookdown package to write a book.
The output format for this example is bookdown::gitbook.
documentclass: book
lang: es
link-citations: yes
bibliography: book.bib
site: bookdown::bookdown_site
header-includes:
- \AtBeginDocument{\renewcommand{\chaptername}{Módulo}}
---
结果:
请注意,header-includes
对于单个文件文档中的简单内容很有用,例如这个最小的例子。在大多数情况下,最好通过tex
,c.f。将output.<your-format>.includes.in_header
包括在标题中。 Include TeX header in R package for RMarkdown documents。