-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Quarto book: multiple chapters in one qmd chapter #1712
Comments
Currently chapters do indeed need to be in different qmd files. The best way to share data between chapters is to use the |
The main issue is not actually sharing data between chapters. Rather it is arising when we don't know how many chapters we will need. This is common when using R Markdown (and now) Quarto for government reports. We are dynamically creating the content (meaning the content in the qmd). Here is a repo where I am working on a template for government reports with dynamic content. The problem is most acute for appendices. This is the area where we are most likely to not know the number of chapters (appendices). Fortunately, Word and PDF output seems to figure out how to deal with the multiple h1 levels in the one appendix qmd. But the HTML is totally messed up. Look just at the appendices. HTML: https://rverse-tutorials.github.io/QmdReport/ |
Okay, got it! Dynamic number of HTML chapters we indeed do not handle well right now (mostly b/c we build a static index of them before rendering so that we can build the sidebar for each chapter as we go -- kind of a chicken and egg problem unless we move the generation of the sidebar entirely outside of pandoc rendering). Need to think more carefully about it but I am hopeful this is something we can ultimate resolve. Will target this for work in our v1.2 release (later this fall). |
Got it. The Quarto default HTML looks so similar to bookdown::bs4_book that I assumed it was working under the hood in the same way. This is generated with bookdown at this RStudio Cloud project: https://rstudio.cloud/content/4350137 Anyhow I'll look forward to Quarto v1.2 in the fall! |
Here is a related minimal example. Our real life example: a report with a standardised chapter for every species (almost 100 species and increasing). Currently we have the report as a
|
@ThierryO side note regarding your example :
I am surprised you don't have issue with this. Usual pattern to do this is to use See |
Quarto version: I tried a few version. Started with 1.0.37 then I updated to the latest dev version (says 99.9.9) using this
Then went back to v1.0.38 by re-installing.
RStudio: 2022.02.2
OS: Mac Big Sur 11.6.2
This is specific to a Quarto book project.
If have 2 h1 headers in a chapter qmd, the first appears in TOC and the others appear with the right sequential chapter numbers but don't appear in the TOC and later chapters don't "know" about the new chapters.
Example
_quarto.yml
chap1and2.qmd
This is the output. Notice the TOC.

quarto check
Outputquarto tools check
OutputUse case, why is this needed?
In report writing situation, you often don't know how many chapters (appendices) you will need. You are using
knit_expand()
with an child.Rmd that is creating all your chapters (appendices) based on the data (which vary). Thatknit_expand()
is a for loop (or map function) and is creating the markdown dynamically. This works fine in Quarto...except that it doesn't recognize the later h1 levels as proper chapters.Checklist
quarto check
in the "Quarto Check Output" text area?quarto tools check
in the "Quarto Tools Check Output" text area?The text was updated successfully, but these errors were encountered: