如何在Bookdown单文档中修改图表及目录的标题标签名称?
Great question! Let’s break this down step by step to get your German labels working consistently across both HTML and PDF outputs:
1. Create the _bookdown.yml configuration file
Even for a single-document bookdown project, you can create this file in the same directory as your .Rmd file. Open a plain text editor, make a new file, and save it exactly as _bookdown.yml (include the leading underscore, and avoid extra extensions like .txt).
2. Add language label overrides to _bookdown.yml
Paste this content into your new file—it will replace the default English labels for figures, tables, and the table of contents for both output formats:
language: label: fig: "Abbildung " # Keep the trailing space to separate from the figure number tab: "Tabelle " ui: toc: "Inhalt" # Updates the TOC title in HTML output pdf: toc-title: "Inhalt" # Updates the TOC title in PDF output
3. Linking the file to your Rmd (no extra steps needed!)
Bookdown automatically scans the working directory for _bookdown.yml when rendering your document. As long as the file is in the same folder as your .Rmd file, it will be applied automatically—you don’t need to add any special code to your Rmd to reference it.
4. Render your document
When you knit your .Rmd (via the RStudio "Knit" button or bookdown::render_book()), you’ll see:
- HTML output: Figure captions start with "Abbildung", table captions with "Tabelle", and the table of contents is titled "Inhalt".
- PDF output: Same label changes, plus the TOC title will show "Inhalt" instead of "Table of Contents".
This method is far more reliable than \renewcommand because it handles both output formats consistently, and you don’t have to rely on LaTeX commands that only work for PDF.
内容的提问来源于stack exchange,提问作者frkbr

