Instead of Chapter X when creating a PDF from bookdown, I would like it to be "Módulo X" (in Spanish).
So I would like to know how to change chapter name using bookdown.
My YAML is:
---
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"
---
I tried with the last three line codes, with no success. Any idea?
From the bookdown documentation we can learn two things:
- There is no
language.label.chapter_name
butlanguage.ui.chapter_name
. - This setting is meant for HTML output. For PDF output one should configure LaTeX.
Configuring LaTeX is quite simple. You only need to add lang: es
to your header.
However, this will use "Capítulo" instead of "Módulo". One can adjust this by redefining the LaTeX command \chaptername
. BTW, at the moment you are not using bookdown
but the standard pdf_docuemnt
from rmarkdown
. If you wont to use bookdown
features, you should use bookdown::pdf_book
or bookdown::pdf_document2
.
Putting everything together:
---
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}}
---
Result:
Note that header-includes
is nice for simple stuff in single file documents like this minimal example. In most cases one is better off including a tex
into the header via output.<your-format>.includes.in_header
, c.f. Include TeX header in R package for RMarkdown documents.
来源:https://stackoverflow.com/questions/54676107/changing-chapter-x-name-in-bookdown-pdf