-
DescriptionContextI am trying to write a Quarto book in French but some of its chapter are in English. I expected the book pdf output to follow the "French" specific rules, for example:
and switch to English rules when the chapter language was specified. Using instruction from Document Language, I used the file project:
type: book
book:
title: "La marmotte"
chapters:
- index.qmd
- en_chapter.qmd
- fr_chapter.qmd
- references.qmd
bibliography: references.bib
lang: fr-FR # main language (for references, lof and lot, etc.)
format:
pdf:
documentclass: scrreprt
lof: true
editor: visual Note: I tried For the chapters written in another language, I put the following at the top of the chapter file: ---
lang: en-GB # this chapter uses a different language than the main book.
--- I am using Quarto 1.7.31 through RStudio 2025.05.0 Build 496, R version 4.5.1 on Windows 11. ProblemIn the pdf version of the book, the I searched the user guide about Quarto books (https://quarto.org/docs/books/ and https://quarto.org/docs/reference/projects/books.html) and I was not able to find a solution. QuestionsMy questions are:
A reproducible example is available here: https://github.com/KleinWurm/quarto-book-languages-test/tree/2930f17e6f564e8ed492339463e071eb491ae83a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
This is a bit tricky but I think I know what happens. Quarto Book are project - you can write your book in several .qmd files, and Quarto will handle it, including for single file book like PDF output. What happens internally is that a single .md file is created to be rendered to LaTeX and then PDF.
So I think your last Pandoc feature to have multiple language content is to use Div Block with lang attributes This would mean that your English chapter in a French book should be something like ---
title: English chapter in a french book
---
::: {lang=fr-FR}
> Cette citation est écrite en français
Et le reste du text aussi. Tout le contenu de ce chapitre est dans le bloc
:::
This would be how Pandoc supports it, and what should work in Quarto. I would expect it to work, and if not I would consider this a problem.
Unfortunately, we don't document this anywhere. This is only on Pandoc's manual. So to be documented...
To sum up
This is dependent on the output format and Pandoc support. For PDF, the language change is handled through babel and polyglossia. So this would be to see within those tooling. Thanks a lot for sharing your use case. This got me to look into it. I now wonder if we should
This would allow to 'magically' works without knowing this Pandoc's official way. 🤔 |
Beta Was this translation helpful? Give feedback.
-
For reference: |
Beta Was this translation helpful? Give feedback.
This is a bit tricky but I think I know what happens.
Quarto Book are project - you can write your book in several .qmd files, and Quarto will handle it, including for single file book like PDF output.
What happens internally is that a single .md file is created to be rendered to LaTeX and then PDF.
So when you add a YAML configuration block inside a chapter, some options could override the global one, because in Quarto (and Pandoc) multiple YAML configuration block in a single file are merged;