Changing *Chapter X* name in bookdown PDF

后端 未结 1 939
时光取名叫无心
时光取名叫无心 2021-01-15 11:18

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

相关标签:
1条回答
  • 2021-01-15 11:53

    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{\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.

    0 讨论(0)
提交回复
热议问题