Formatting the TOC in a book with CSS #6451
-
DescriptionI'm trying to format the TOC in a book with CSS but I can't figure out how. I have chapter numbers left aligned in the sidebar but I would like them to be "decimal" aligned. That is, when I reach chapter 10, I want the 1 to stick out on the left side, rather than being aligned with the single digits above. I tried changing ol to decimal alignment but that simply added a numbered list outside the chapter number box. I also tried to add padding to the chapter number but that seemed to have no effect. I also would like the chapter titles in the sidebar to have a hanging indent, so that a long title that extends to a second line, aligns with the above text rather than aligning with the above chapter number. I tried to examine using the inspector, but found it indecipherable. I realize that I need to learn more to get more precise results, but would appreciate help on these two items as a stopgap. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Your best chance is to use your favourite browser "inspect/developer mode" and fiddle with CSS. |
Beta Was this translation helpful? Give feedback.
-
I see how a sidebar like yours would like nice with this treatment. Imagining the sidebar in your project with properly decimal aligned chapters and a hanging indent - would you expect the 'preface' and 'references' heading to align with the chapter titles (not the chapter numbers)? |
Beta Was this translation helpful? Give feedback.
I was tinkering a bit with CSS and that was one of the issue I ran into.
This got it in the neighborhood, though there still needs to be some tweaking. I was just including this in the
format
key of my_quarto.yml
file to make hacking easy: