bookdown
bookdown copied to clipboard
[FR] A few questions about bs4_book: sidebars, tabsets and etc
Hi!
Since some of the questions relate to feature request, and some may be solved by recommendations on css/html developers, I decided to issue it here on the topic bs4_book:
Sometimes I need to put a very long table on the page + we have a lot of owners of wide screens, so:
- How to remove the limit on the width of the text body? It would be great if the width of the text absorbed all the space.

- How to hide the sidebar on the right and left of the document manually with some button, and not just by narrowing the page?
And so on:
- have the tabset not appeared yet? This is a very powerful content management tool. It would be great to see this in bookdown.
- It seems that one level of the table of contents was pulled to the left sidebar, and the groups of chapters below the 3rd order are still not displayed. Can expand to infinity, or at least 6-7 sublevels?
- Is there no analogue to PART-sections in bs4_book?
- Is it not possible to forcibly specify the path to the primary file somewhere in the configurations instead of
index.rmdin the root of the project?
I'm also interested in the first question.
How to remove the limit on the width of the text body? It would be great if the width of the text absorbed all the space.
I believe the size are defined in the CSS: https://github.com/rstudio/bookdown/blob/main/inst/resources/bs4_book/bs4_book.css
You can probably tweak those for your content. Maybe adding another level of min-width for @media rule would help
How to hide the sidebar on the right and left of the document manually with some button, and not just by narrowing the page?
This is not part of the bs4_book() template. You would need to use some custom JS or even tweaking the template or make your own format.
have the tabset not appeared yet? This is a very powerful content management tool. It would be great to see this in bookdown.
html_document() {.tabset} feature is not supported in bs4_book(). External tooling need to be used. Ex: https://stackoverflow.com/a/65921791/3436535
It seems that one level of the table of contents was pulled to the left sidebar, and the groups of chapters below the 3rd order are still not displayed. Can expand to infinity, or at least 6-7 sublevels?
It is a limitation of the format by design. See https://github.com/rstudio/bookdown/issues/1254 for context. I can reopen if you want to submit a PR for such feature.
Is there no analogue to PART-sections in bs4_book?
PART section should work in bs4_book().
Ex:
- https://github.com/hadley/mastering-shiny/blob/0628a35189c62f9bba3814388d9c844a172cd211/reactivity.Rmd#L1

Is it not possible to forcibly specify the path to the primary file somewhere in the configurations instead of index.rmd in the root of the project?
Not sure what you mean. You don't want to use index.Rmd as main file ?
This is a convention as main HTML file for a online HTML book project should be index.html so that when you reach the folder it appears in browser without typing the filename. bookdown and RStudio IDE will look for some information in index.Rmd
it is best to keep this convention. I am not sure there would be much advantage to support a configuration for this main file, but maybe I am missing something.
Overall, if you fill limited with current formats in bookdown, you may be interested in a new tools called Quarto which has Quarto Books (https://quarto.org/docs/books/) based on HTML5 and Bootstrap5. Most of the feature of bookdown and more are there too.
Hope I answered most of your questions
For the first question I found a solution. I added the following lines in the style.css:
.container-fluid {
max-width: 120rem;
}
.container-fluid main {
max-width: 55rem;
}
@cderv hi! Thank you for your quick and detailed response!
1 - How to remove the limit on the width of the text body? It would be great if the width of the text absorbed all the space.
The solution from @ShinyFabio unfortunately does not completely solve the problem. Here is an explanation picture.

Any ideas how to remove these fields?
2 - Why not a part? You have already implemented it:

I just have a request to make an option for its permanent addition to bs4_book, which, coupled with solution 1, would greatly improve the functionality of the book.
At the same time, you don't even need to do almost anything - the button and the show/hide mechanism are already implemented
3 - Tabs have a complicated history
I see that not only I, but also other guys have been asking for this functionality for a long time, here are the links:
- https://community.rstudio.com/t/using-tabset-with-bookdown-bs4-book/94218
- https://github.com/rstudio/bookdown/issues/393
- https://stackoverflow.com/questions/43706851/r-bookdown-tabbed-headings
- etc
I'm just another person who needs this functionality because
- It is a very powerful tool for content submission
- PDF format in practice always requires separate formatting for itself. You can't just write your guitar book and make an assembly in PDF, where everything will look cool at the output
- Why get so attached to paper media? The electronic bookdown format may well be interactive and autonomous
Please take another look at the request for such functionality from me and the authors of the requests from the links above.
At a minimum, I want to use this functionality without any crutches. As a maximum, I have problems downloading the package that implements tabs (from the answer you gave):

And I've been trying to implement tabs in other ways for a long time - they all gave the high-quality result that is in the markdown((
4 - It seems that one level of the table of contents was pulled to the left sidebar, and the groups of chapters below the 3rd order are still not displayed. Can expand to infinity, or at least 6-7 sublevels?
Yes, I would like to. At least 1-2 more levels
5 - Is there no analogue to PART-sections in bs4_book?
When I do according to the provided guide (https://github.com/hadley/mastering-shiny/blob/0628a35189c62f9bba3814388d9c844a172cd211/reactivity.Rmd#L1), then, unfortunately, I get such an error:

I have tried such lines:
-
# (PART) Mastering reactivity {-}- This string works correctly in gitbook and does not work in bs4_book -
# (PART\*) Mastering reactivity {.unnumbered}
6 - Is it not possible to forcibly specify the path to the primary file somewhere in the configurations instead of index.rmd in the root of the project?
You have given weighty arguments. I'll probably think about it separately and raise this FR separately in the future. I will not overload the current topic with them.