#content { counter-reset: heading; } #content h2:not(.toc):before { content: counter(heading)") "; counter-increment: heading; } #content h2:not(.toc) { counter-reset: subheading; } #content h3:not(.toc):before { content: counter(heading)"." counter(subheading)") "; counter-increment: subheading; } #content h3:not(.toc) { counter-reset: subsubheading; } #content h4:not(.toc):before { content: counter(heading)"." counter(subheading)"." counter(subsubheading)") "; counter-increment: subsubheading; } #toc { float: right; width: fit-content; font-size: smaller; padding: 0 0.5em; border-width: 2px; border-style: solid; border-radius: 10px; max-height: 50vh; overflow: auto; } #toc_wrap { display: none; } @media (min-width: 1000px) { #toc_wrap { display: block; float: right; position: sticky; max-width: 12%; top: 1em; } } @media (min-height: 750px) { #toc_wrap { top: 8em; } } @media (min-width: 1500px) { #toc_wrap { right: 100px; } } #toc ul, .toc { margin: 0.25em 0; } #toc ul { padding-left: 1em; } #toc_close { opacity: 0.666; } #toc_close:hover { cursor: pointer; }