Search code examples
rbookdown

How to put first level sections on different HTML pages?


In order to make first level sections instead of only chapters html pages of their own, I tried to alter the split_by in the yaml.

I used this code:

---
title: "new book"
author: "My name"
date: "`r Sys.Date()`"
subtitle: "subtitle"
site: bookdown::bookdown_site
output:
  bookdown::gitbook:
      split_by: chapter
      config:
        toc:
          collapse: subsection
          scroll_highlight: yes
          before: null
          after: null
        toolbar:
          position: fixed
        edit : null
        download: null
        search: yes
        fontsettings:
          theme: white
          family: sans
          size: 2
        sharing:
          facebook: yes
          twitter: yes
          google: no
          linkedin: no
          weibo: no
          instapaper: no
          vk: no
          all: ['facebook', 'google', 'twitter', 'linkedin', 'weibo', 'instapaper']         
   #bookdown::pdf_book: default
documentclass: book
---

When I change "chapter" into "section", R throws an error.

How can I make sure there will be seperated pages for chapters as well as first level sections?


Solution

  • There were (in this early stage of the document) some chapters without subsections. split_by: section will cause an error in case of chapters without sections.