Custom table of contents#964
Custom table of contents#964cjdbarlow wants to merge 2 commits intorstudio:mainfrom cjdbarlow:master
Conversation
Allows a custom TOC file to be specified in _bookdown.yml, so component rmd files (and the order of) can be specified. Is mutually exclusive with other build options (e.g. rmd_subdir). Additionally, when used in the gitbook style: - Can define "headers" in the TOC without an associated page, which are styled appropriately - Can insert custom dividers between TOC elements - Can set page names in TOC to be different from the actual page name (the H1 header) - Best results seen/designed seen when _output.yml has toc_depth: 1 and split_by: rmd
|
|
Tiny change so that extra_dependencies (e.g. css) piped to gitbook() take precedence over default options, because it means they will be loaded later in the DOM
|
Hi @Chrisjake, Thanks for your contribution. In order to better understand the need of this, as there was no issue opened to discuss this prior to the PR, I am curious about why the classic header 1, header 2, ... structure that is usually reflecting in the TOC does not work for you ? IMO h1 / h2 / h3 represented by #/##/## are meant to structure the content first and not provide styling - there is css for that. I am just trying to better understand the problem you aim to solve with this PR before looking at it any further. Thank you very much. |
|
Hi @cderv ,
|
I think this is equivalent to the already supported special (PART) header (https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#special-headers) : Have you tried that already ?
Bookdown is currently design to have one file per header 1 chapter, otherwise it could lead to undesired issues with some features (like #947 (comment)). Having the ability to be more free on how to organize the source file is an often asked question, and it is not just a matter of TOC. There is a splitting that happens from the rendered HTML to the multiple files - this is the challenge I think here. But it is definitly a asked-feature we should look into. |
I had not seen that! That would provide the same function but also translate better to other formats; I will use that instead.
I agree; though I am not sure the best way to do this (YAML probably better than what I have done...) - I am not a software engineer by any stretch. Provided there is only 1 H1 header per file it seems to behave though, and I do like the flexibility it provides. I think functionality like this is valuable, even if this is not the mechanism by which it should be implemented. |
Allows a custom TOC file to be specified in _bookdown.yml, so component rmd files (and the order of) can be specified. This is mutually exclusive with other build options (e.g. rmd_subdir).
An example toc could be:
Additionally, when used in the gitbook style:
Other stuff: