I am building a pkgdown
website for my R package. Everything is working well, but one customization I haven't managed to figure out is how to align article headings and subheadings in a table of content (TOC).
In the image below,
On the left: article from my ggstatsplot
package website
(https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/effsize_interpretation.html)
On the right: article from broom
package website
(https://broom.tidyverse.org/articles/adding-tidiers.html)
Note that the headings (red arrows) in the TOC in ggstatsplot
article are all vertically aligned with the subheadings, while the TOC for broom
article distinguishes between a heading and a subheading in terms of lateral separation. This is what I want but can't seem to figure out how to do.
In short: how can I turn the left TOC to look like the one on the right in terms of creating lateral separation between a given heading and subheadings below it?
Here is _pkgdown.yml
for my package:
https://github.com/IndrajeetPatil/ggstatsplot/blob/master/_pkgdown.yml
The following CSS rule should fix the indentation issue. You can add this to pkgdown/extra.css.
#tocnav ul ul {
margin-left: 25px;
}
The CSS adds a left margin of 25px to any nested list under #tocnav
. Adjust the margin size as needed. Targeting only the #tocnav
is a conservative approach, but there may be other places in your pkgdown site that need this rule as well.