Numbering ordered lists: Difference between revisions

No edit summary
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
To number nested ordered lists , you can add the following CSS to the page ''MediaWiki:Common.css''.<syntaxhighlight lang="text">
To number bullets in the page text consecutively, you can add the following CSS to the page ''MediaWiki:Common.css''. Please note that this custom styling  may not work if it is incompatible with CSS declarations from other stylesheets in the wiki.
/*Numbering nested ordered lists */
{{Textbox|boxtype=important|header=Important!|text=This styling does NOT apply in the PDF export.|icon=yes}}Example for separately numbered footnotes.<ref>Footnote 1</ref> <ref>Footnote 2</ref><syntaxhighlight lang="css">
.mw-content-ltr ol, .ve-ce-branchNode ol{ counter-reset: item; margin-left:1.5em }
/* Styles for formatting sub-ordered-list-items with 1.1., 1.1.1., etc.)*/
.mw-content-ltr ol li { display: block }
.mw-content-ltr ol li:before, .ve-ce-branchNode ol li:before { content: counters(item, ".") "."; counter-increment: item; margin-right:0.5em  }
/* First, set all numbered lists to use counter-reset */
.ve-ce-branchNode ol li p { display: inline}
#mw-content-text ol, ol.ve-ce-branchNode {
</syntaxhighlight>
      counter-reset: item;
      margin: 0.3em 0 0 2.2em;
}


Output:
/* Display all list items in a numbered list in block display */
#mw-content-text ol>li, ol.ve-ce-branchNode>li {
      display: block;
}
ol.ve-ce-branchNode>li > p {display:inline}
 
/* Use a counter that checks the number of items and adds a "." between them and ends with ". " */
#mw-content-text ol>li:before, ol.ve-ce-branchNode>li:before {
      content: counters(item, ".") ". ";
      counter-increment: item;
}
 
/*Number footnotes separately */
#mw-content-text  .references ::marker {
    content: " ";
}
#mw-content-text  ol.references {
    counter-reset:ref; list-style-type:none;
}
#mw-content-text  ol.references li:before{
    counter-increment:ref;
    content:counter(ref) ". ";
    float: left;
    margin-right: 1em;
}
#mw-content-text  ol > li li {
    margin-left:-0.3em;
}
 
</syntaxhighlight>Output:


# Step 1
# Step 1
## Substep 1
## Substep 1
## Substep 2
## Substep 2
### Sub-substep 1
### SubSubstep 1
### SubSubstep 2
### SubSubstep 3
# Step 2
# Step 2
# Step 2
Bulleted lists that are not numbered are not affected by the CSS declarations:


* List item
** List item level 2
*** List item level 3


Alternatively, to create numbering as 1., 1.1, 1.1.1 and so on use the following style:<syntaxhighlight lang="text">
Numbering in a new "ordered list" starts back at 1:
article ol {
 
counter-reset:section; list-style-type:none;
# Step 1
}
## Substep 1
article ol li {
## Substep 2
list-style-type:none;
### SubSubstep 1
}
### SubSubstep 2
article ol li ol {
### SubSubstep 3
counter-reset:subsection;
# Step 2
}
# Step 2
article ol li ol li ol{
# Step 2
counter-reset:subsubsection;
 
}
== Example for footnote numbering ==
article ol li:before{
These footnotes are formatted separately, although they are also just ordered list in the page content.
    counter-increment:section;
    content:counter(section) ". ";/*content:"Section " counter(section) ". ";*/
    float: left;
    margin-right: 0.4em;
}
article ol li ol li:before {
    counter-increment:subsection;
    content:counter(section) "." counter(subsection) " ";
}
article ol li ol li ol li:before {
    counter-increment:subsubsection;
    content:counter(section) "." counter(subsection) "." counter(subsubsection) "" ;
}
</syntaxhighlight>
[[Category:Customization]]
[[Category:Customization]]
[[en:{{FULLPAGENAME}}]]
[[de:Aufzählungslisten_nummerieren]]
[[de:Aufzählungslisten_nummerieren]]

Latest revision as of 13:18, 17 July 2024

To number bullets in the page text consecutively, you can add the following CSS to the page MediaWiki:Common.css. Please note that this custom styling may not work if it is incompatible with CSS declarations from other stylesheets in the wiki.

Important!This styling does NOT apply in the PDF export.

Example for separately numbered footnotes.[1] [2]

/* Styles for formatting sub-ordered-list-items with 1.1., 1.1.1., etc.)*/
	
/* First, set all numbered lists to use counter-reset */
#mw-content-text ol, ol.ve-ce-branchNode {
      counter-reset: item;
       margin: 0.3em 0 0 2.2em;
}

/* Display all list items in a numbered list in block display */
#mw-content-text ol>li, ol.ve-ce-branchNode>li {
      display: block;
}
ol.ve-ce-branchNode>li > p {display:inline}

/* Use a counter that checks the number of items and adds a "." between them and ends with ". " */
#mw-content-text ol>li:before, ol.ve-ce-branchNode>li:before { 
      content: counters(item, ".") ". "; 
      counter-increment: item;
}

/*Number footnotes separately */
#mw-content-text  .references ::marker {
    content: " ";	
}
#mw-content-text  ol.references {
    counter-reset:ref; list-style-type:none;
}
#mw-content-text  ol.references li:before{
    counter-increment:ref;
    content:counter(ref) ". ";
    float: left;
    margin-right: 1em;
	}
#mw-content-text  ol > li li {
    margin-left:-0.3em;
}

Output:

  1. Step 1
    1. Substep 1
    2. Substep 2
      1. SubSubstep 1
      2. SubSubstep 2
      3. SubSubstep 3
  2. Step 2
  3. Step 2
  4. Step 2

Bulleted lists that are not numbered are not affected by the CSS declarations:

  • List item
    • List item level 2
      • List item level 3

Numbering in a new "ordered list" starts back at 1:

  1. Step 1
    1. Substep 1
    2. Substep 2
      1. SubSubstep 1
      2. SubSubstep 2
      3. SubSubstep 3
  2. Step 2
  3. Step 2
  4. Step 2

Example for footnote numbering

These footnotes are formatted separately, although they are also just ordered list in the page content.

  1. Footnote 1
  2. Footnote 2



To submit feedback about this documentation, visit our community forum.