mosra / m.css

A no-nonsense, no-JavaScript CSS framework, site and documentation theme for content-oriented websites
https://mcss.mosra.cz
MIT License
399 stars 88 forks source link

Number the section title #198

Closed tsung-wei-huang closed 3 years ago

tsung-wei-huang commented 3 years ago

Is there a way to number each section in addition to the heading? Without numbers, it is not very clear to see the hierarchies of a page which has subsections and so on. For example:

  1. Introduction ... 1.1 Introduction subsection with number 1.2 Introduction subsection with number ...
crisluengo commented 3 years ago

You can do this adding a bit of your own CSS: https://stackoverflow.com/questions/10340276/how-to-add-section-numbers-1-2-3-4-1-automatically-using-css

tsung-wei-huang commented 3 years ago

When I ass that customized css into HTML_STYLESHEET = custom.css, the result of the HTML totally got screw up.

body {counter-reset:section;}
h1 {counter-reset:subsection;}
h2 {counter-reset:subsubsection;}
h1:before
{
counter-increment:section;
content:counter(section) ". ";
}
h2:before 
{
counter-increment:subsection;
content:counter(section) "." counter(subsection) " ";
}
h3:before 
{
counter-increment:subsubsection;
content:counter(section) "." counter(subsection) "." counter(subsubsection) " ";
}

Am I doing it correctly?

crisluengo commented 3 years ago

You might want to use HTML_EXTRA_STYLESHEET instead, so it doesn't overwrite the standard stylesheets.

tsung-wei-huang commented 3 years ago

The result is the same. The default m-dark+documentation.compiled.css is not overwritten but the who documentation got screwed up. This is my Doxyfile-mcss.

@INCLUDE                = Doxyfile
HTML_EXTRA_STYLESHEET   = custom.css
GENERATE_HTML           = YES
GENERATE_XML            = YES
XML_PROGRAMLISTING      = NO
PROJECT_NAME            = Taskflow
PROJECT_BRIEF           = QuickStart
mosra commented 3 years ago

I'm afraid you ran into a not-really-well-documented corner case with the HTML_EXTRA_STYLESHEET option. While Doxygen has no default value for it, m.css uses it to supply its own style and if you override it, you lose the default style. The fix is to include the default there as well -- I think this could work in your case:

HTML_EXTRA_STYLESHEET = \
    https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600 \
    ../css/m-dark+documentation.compiled.css \
    custom.css
tsung-wei-huang commented 3 years ago

@mosra thanks, this fixes my problem.