latexr-markdownbookdown

Changing *Chapter X* name in bookdown PDF


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?


Solution

  • From the bookdown documentation we can learn two things:

    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:

    enter image description here

    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.