在 bookdown PDF 中更改 *Chapter X* 名称

ant*_*sor 3 latex r-markdown bookdown

从 bookdown 创建 PDF 时,我希望它是“Módulo X”(西班牙语),而不是第 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"
---
Run Code Online (Sandbox Code Playgroud)

我尝试了最后三行代码,但没有成功。任何的想法?

Ral*_*ner 6

bookdown 文档中我们可以了解到两件事:

  • 没有language.label.chapter_name但是language.ui.chapter_name
  • 此设置适用于 HTML 输出。对于 PDF 输出,应该配置 LaTeX。

配置 LaTeX 非常简单。您只需要添加lang: es到您的标题。但是,这将使用“Capítulo”而不是“Módulo”。可以通过重新定义 LaTeX 命令来调整这一点\chaptername。BTW,此刻你不使用bookdown,但标准pdf_docuemntrmarkdown。如果您不习惯使用bookdown功能,则应使用bookdown::pdf_bookbookdown::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}}
---
Run Code Online (Sandbox Code Playgroud)

结果:

在此处输入图片说明

请注意,这header-includes对于像这个最小示例这样的单文件文档中的简单内容非常有用。在大多数情况下是一个更好包括tex成可经由头output.<your-format>.includes.in_header,CF包括R中包RMarkdown文档的TeX头