问题描述
从 bookdown 创建 PDF 时,而不是 Chapter X,我希望它是Módulo X"(西班牙语).
所以我想知道如何使用 bookdown 更改章节名称.
我的 YAML 是:
---标题:标题"作者:马里奥·莫德斯托-马塔"日期:`r Sys.Date()`"输出:pdf_document描述:这是一个使用 bookdown 包编写书籍的最小示例.这个例子的输出格式是 bookdown::gitbook.文档类:书链接引用:是的参考书目:book.bib网站:bookdown::bookdown_site语:标签:章节名称:模块"---
我尝试了最后三行代码,但没有成功.有什么想法吗?
来自
请注意,header-includes
非常适合单文件文档中的简单内容,例如这个最小示例.在大多数情况下,最好通过 output 将
, c.f.在 RMarkdown 文档的 R 包中包含 TeX 标头.tex
包含到标题中.<your-format>.includes.in_header
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{
enewcommand{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.
这篇关于在 bookdown PDF 中更改 *Chapter X* 名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!