How to render a single chapter (just the chapter) using Bookdown


I recently updated Bookdown to the most recent version and am having trouble knitting individual chapters. In an earlier version, I was able to use a chapter as a "child" document and knit it using a separate "render_preview.Rmd" to create a single chapter in folder just for "previews." The file would be named "render_preview.pdf" and would contain whatever chapter I included in the childs statement. Now when I do this, the entire book is knit to _main.pdf (but really it's only the chapter and section headings that appear), and I don't get the "render_preview.pdf" that I want with just a single chapter. Is there another way to zip off a chapter with the new version of Bookdown? Alternatively, how would I revert to the previous version?

I do realize that preview_chapter does something like what I'm asking for, but it also includes all of the other chapter and section headings.

Also, I did work on a minimal example but am unable to upload the zipped folder. Hopefully my description is sufficient for now.


Any thoughts? Or any thoughts about how I could upload my example to improve my chances of getting a response?

This is a pretty specific use case and don't know yet about. So I don't think you can "zip" the way you want

This is indeed the function made for previewing one file and not render the other. But it is part of the bookdown project, so it is expected to be included in the book style

What don't you share that in a Github repo ?

Was it working with render_book() or just rmarkdown::render()

I need way more information (and maybe example) so that I can understand what you where doing and know if the break is intentional or not (meaning you were doing something not expected / supported and unfortunately latest change broke that: (side note on this: this talk is really interesting about maintainance of tools: Maintaining the house the tidyverse built - RStudio)

Thank you

1 Like

So I normally render my documents using either the knit button or the "Build" button for the whole book--I almost never use the console. The knit button doesn't work in this particular use case as it did before, but I was able to get the single chapter I was looking for when using rmarkdown::render(). So thanks. It is slightly more convenient to just click the button, but I'm glad to have a solution.

A similar and more simple example would have been to ask about rendering slides from within a bookdown project. I just realized today that this poses a similar problem, i.e., I wasn't able to just click "knit" in the slides.Rmd file, even if they're in their own folder within the project. But it also has the same solution with rmarkdown::render().

I also appreciate the advice about using github. I'll consider that in the future. And the link to the talk.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.