在 bookdown PDF 中更改 *Chapter X* 名称 [英] Changing *Chapter X* name in bookdown PDF

查看:12
本文介绍了在 bookdown PDF 中更改 *Chapter X* 名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 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 将 tex 包含到标题中.<your-format>.includes.in_header, c.f.在 RMarkdown 文档的 R 包中包含 TeX 标头.

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 but language.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* 名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆