代码之家  ›  专栏  ›  技术社区  ›  antecessor

更改Bookdown PDF中的*第X章*名称

  •  0
  • antecessor  · 技术社区  · 6 年前

    而不是 第十章 从bookdown创建pdf时,我希望它是“m_3 dulo x”(西班牙语)。

    所以我想知道如何使用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"
    ---
    

    我试过最后三行代码,但没有成功。有什么想法吗?

    0 回复  |  直到 6 年前
        1
  •  2
  •   Ralf Stubner    6 年前

    bookdown documentation 我们可以学到两件事:

    • 没有 language.label.chapter_name 但是 language.ui.chapter_name .
    • 此设置用于HTML输出。对于pdf输出,应该配置latex。

    配置乳胶非常简单。你只需要添加 lang: es 到你的头上。 但是,这将使用“captulo”而不是“mdulo”。可以通过重新定义latex命令来调整 \chaptername . 顺便说一句,现在你不用 bookdown 但是标准 pdf_docuemnt rmarkdown . 如果你不想用 书呆子 功能,您应该使用 bookdown::pdf_book 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}}
    ---
    

    结果:

    enter image description here

    推荐文章