在 bookdown PDF 中更改*第 X 章*名称
Changing *Chapter X* name in bookdown PDF
在从 bookdown 创建 PDF 时,我希望它不是 第 X 章,而是 "Módulo X"(西班牙语)。
所以我想知道如何使用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
。
- 此设置用于 HTML 输出。对于 PDF 输出,应该配置 LaTeX。
配置 LaTeX 非常简单。您只需要将 lang: es
添加到您的 header。
但是,这将使用 "Capítulo" 而不是 "Módulo"。可以通过重新定义 LaTeX 命令 \chaptername
来调整这一点。顺便说一句,目前您没有使用 bookdown
,而是使用 rmarkdown
中的标准 pdf_docuemnt
。如果您不想使用 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
非常适合单个文件文档中的简单内容,例如这个最小示例。在大多数情况下,最好通过 output.<your-format>.includes.in_header
、c.f 将 tex
包含到 header 中。 Include TeX header in R package for RMarkdown documents.
在从 bookdown 创建 PDF 时,我希望它不是 第 X 章,而是 "Módulo X"(西班牙语)。
所以我想知道如何使用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
。 - 此设置用于 HTML 输出。对于 PDF 输出,应该配置 LaTeX。
配置 LaTeX 非常简单。您只需要将 lang: es
添加到您的 header。
但是,这将使用 "Capítulo" 而不是 "Módulo"。可以通过重新定义 LaTeX 命令 \chaptername
来调整这一点。顺便说一句,目前您没有使用 bookdown
,而是使用 rmarkdown
中的标准 pdf_docuemnt
。如果您不想使用 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
非常适合单个文件文档中的简单内容,例如这个最小示例。在大多数情况下,最好通过 output.<your-format>.includes.in_header
、c.f 将 tex
包含到 header 中。 Include TeX header in R package for RMarkdown documents.