R Bookdown - Customize width of TOC/Sidebar

2020-07-16 08:19发布

问题:

Although I can change the width and position of different elements in the body of an r bookdown doc by modifying the page wrapper in the .css, is there a way to change the width of the sidebar by modifying the styles sheet?

I'm not looking to change the font or color of the words in the TOC, just the width. Something like:

width: 50px; margin-right: 0;

I don't need a wide sidebar, but I do need more width in the body.

I already widened the inner body as much as possible, so all that is left is the sidebar.

回答1:

In your _output.yml add the css filename

bookdown::gitbook:
  css: style.css

Create style.css to change the default 300px

.book .book-summary {
  width: 350px;
  position:absolute;
  top:0;
  left:-350px;
}

.book.with-summary .book-header.fixed {
    left: 350px;
}

.book.with-summary .book-body {
    left: 350px;
}