NumberedSections

Summary: Add section numbers on a page
Version: 1.2
Prerequisites: None
Status: stable
Maintainer: Andrei Radulescu-Banu
Categories: TOC
Users: +1 (view / edit)

Description

This recipe allows users to number the sections on the page.

It is a slight modification of the NumberedHeaders recipe, to allow for better control as to which header level gets numbered.

Install

Download and install numberedsections.phpΔ under the cookbook folder, and add the next line to your local/config.php

include_once("$FarmD/cookbook/numberedsections.php");

Configuration

To start section numbering, include the directive (:numbered-sections:). To stop section numbering, include (:nonumbered-sections:). The (:numbered-sections:) directive takes an optional format parameter

(:numbered-sections format=format_string:)

where format_string is of the following form:

a.b.c.d.e.f

where a, b, c, d, e, f can be the digits 0 or 1 or the characters a or A. If a digit is set to 0 at level L, then level L section headers don't get counted. If a digit is set to 1, a or A at level L, then level L section headers get counted starting respectively with 1, a or A.

The inner separator can be controlled as well: 1X1Y1Z1U1V1 will result in X, Y, Z, ... being separator characters between numbers.

The default value for $DDNumFmt is 1.1.1.1.1.1.

For example, assume your sectioning is

h1
 h2
 h2
 h2
  h3
   h4
    h5
     h6
     h6
     h6

Then format 1.1.1.1.1.a yields the following section numbering:

1 h1
 1.1 h2
 1.2 h2
 1.3 h2
  1.3.1 h3
   1.3.1.1 h4
    1.3.1.1.1 h5
     1.3.1.1.1.a h6
     1.3.1.1.1.b h6
     1.3.1.1.1.c h6

Format 0.0.0.0.1-a yields the following section numbering:

h1
 h2
 h2
 h2
  h3
   h4
    1 h5
     1-a h6
     1-b h6
     1-c h6

You may also define $DDNumFmt="a.b.c.d.e.f"; in your config.php, to specify a site-specific default.

The NumberedSections recipe can be combined with the 'numtoc', 'sectionedit' and other section-related recipes.

Release notes

Version 1.1 - Fixed handling of GroupHeader and GroupFooter

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

Contributors

Andrei Radulescu-Banu

See Also

PmWiki /
TableOfContents  Basic automatic table of contents and numbered headings
Cookbook /
Accordion  lightweight Accordion javascript requiring no framework (stable)
AutoTOC  Unobtrusive Automatic Table of Contents links (stable)
HandyTableOfContents  Handy Client-side Table of Contents (stable)
NumberedHeaders  Display numbered headers, indented paragraphs and table of contents (Stable)
PageTableOfContents  Adds a clickable table of contents to a page (Stable)
QuickPageTableOfContents  Adds a dropdown clickable table of contents to a page - client side processing (Stable)
SlimTableOfContents  Simple or Numbered Table of Contents, Compatible with SectionEdit Recipe (not working with php5.5)
PmWiki /
TableOfContents-Talk  

Comments

See discussion at NumberedSections-Talk?

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.