rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.88k stars 977 forks source link

Indent of wraped line h1 heading (floating toc) #997

Closed sammerk closed 7 years ago

sammerk commented 7 years ago

Out of aesthetic reasons I would prefer the same indent in all lines of a level 1 heading entry in the floating toc (see screenshot). This was fixed for higher level headings already ...

grafik

Thank's Samuel

yihui commented 7 years ago

This is caused by https://github.com/rstudio/rmarkdown/blob/d31ec87679571a84092b5bec4f7de6f42511e9a4/inst/rmd/h/tocify-1.9.1/jquery.tocify.css#L28-L31

You can specify your custom CSS to override it, e.g.,

.tocify-header {
    text-indent: initial;
}

http://rmarkdown.rstudio.com/html_document_format.html#custom_css

In the future you can try to ask questions on StackOverflow first, where you might be quicker responses. Thanks!

slowkow commented 5 years ago

I don't like the way the text is indented in the table of contents. See the instructions below for how to change it.

@yihui I would like to ask if you might consider changing the defaults so the text is wrapped nicely for all of the headers.

image

Instructions

First, add the following header to your .Rmd file:

---
title: "Your Title"
author: "Your Name"
date: "`r Sys.Date()`"
output:
  html_document:
    css: style.css
    toc: true
    toc_float:
      collapsed: false
      smooth_scroll: false
---

In the same folder as your .Rmd file, create a new file called style.css with the following contents:

.tocify-subheader > .tocify-item {
  text-indent: initial;
  padding-left: 2em;
}

Finally, knit your document and you should have nicely indented headings in the table of contents.

jstover79 commented 4 years ago

I know this has been closed, but it would be nice to be able to apply this solution to sub-sub-header as well (and possible further down the toc hierarchy. Thanks! It would be great to have this built into the Rmarkdown toc functionality, to have some kind of padding/margin/wrapping option for the toc display.

cderv commented 4 years ago

It would be great to have this built into the Rmarkdown toc functionality, to have some kind of padding/margin/wrapping option for the toc display.

@jstover79 Can you open a new issue about this Feature request if non already exists ? Without it, it won't be in the backlog to even been consider because closed issue won't often be noticed.