问题描述
从书本中创建PDF时,我希望它是MóduloX"(西班牙语),而不是第X章.
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.
我的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"
---
我尝试了最后三行代码,但没有成功.有什么主意吗?
I tried with the last three line codes, with no success. Any idea?
推荐答案
来自 bookdown文档我们可以学习两件事:
From the bookdown documentation we can learn two things:
- 除了
language.ui.chapter_name
之外没有language.label.chapter_name
. - 此设置用于HTML输出.对于PDF输出,应该配置LaTeX.
- 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.
配置LaTeX非常简单.您只需要在标题中添加lang: es
.但是,这将使用Capítulo"而不是Módulo".您可以通过重新定义LaTeX命令\chaptername
来进行调整.顺便说一句,目前您不使用bookdown
,而是使用rmarkdown
中的标准pdf_docuemnt
.如果您不想使用bookdown
功能,则应该使用bookdown::pdf_book
或bookdown::pdf_document2
.
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
.
将所有内容放在一起:
---
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
非常适合单文件文档中的简单内容,例如此最小示例.在大多数情况下,最好通过c.f通过output.<your-format>.includes.in_header
将tex
包含在标题中. 在R包中包含RMarkdown文档的TeX标头.
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.
这篇关于在手册PDF中更改* Chapter X *名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!