|
Cookbook /
NumberedHeadersSummary: Display numbered headers, indented paragraphs and table of contents
Version: 0.7
Status: Stable
Prerequisites: pmwiki-2
Maintainer: PRZ
Categories: TOC
Votes:
Goal
1/ Setting numbered headers, like
1 - Header
1.1 - Subheader
1.2 - Subheader
2 - Another Header
2.1 - Subheader
2.2 - Subheader
2/ Indenting the text following the header level
3/ Set a table of contents of said headers
Answer
Load the file numtoc.zipΔ Copy the file numtoc.php in the cookbook directory Set in the local/config.php file the line : include_once('cookbook/numtoc.php');
Documentation page PmWiki.NumberedHeaders will go in /wikilib.d directory. You should make a reference to this page in the PmWiki.Documentation Index and probably also in a page describing the particularities of your own wiki. Notes and comments
Usage
Use it with the usual headers - Numbering To have numbered headers, set the directive
- Table of Contents To have a page table of contents, set the directive directive The table and indentation will work on 4 levels maximum. - Indentation To have text indented following the header level, set the directive
The browsers default headers being way too large, if they are not redefined in your skin, you may want to set in your config.php the below text, which give more reasonnable sizes.
$HTMLStylesFmt['numheader'] = "
h1 {font-size:132%; margin:20px 0px;}
h2 {font-size:124%; margin:16px 0px;}
h3 {font-size:116%; margin:12px 0px;}
h4 {font-size:108%; margin:12px 0px;}
";
Note that if css files are defined in the /pub/css directory, they will override the hereabove settings. Site example : Options
You can define the numbering type with a parameter in the directive A) Header
A-1) SubHeader
A-1.a.1) ...
B) ...
B-2.c.4) ...
You always should define 4 numbering characters, 3 separators and ending chars. The separators are defined with only one character, but the final ending can have multiple character, like (:num 1.1.1.1/ - :). More than one blank chars are only displayed as one blank.
You can change the default value '1.1.1.1. ' by setting the variable $DefNum = 'your desc'; in your local/config.php file, e.g.
$DefNum = 'A 1-a.1/ ';
Styling
You can override the default styling which are as follows. The table of contents is in a container with the class .tocstyle . Default content of the class : empty. The indentation of the table of contents is defined by the following classes :
$HTMLStylesFmt['nmhtoc']= "
.toc1 {margin-left:1em;}
.toc2 {margin-left:2em;}
.toc3 {margin-left:3em;}
.toc4 {margin-left:4em;}
";
The indentation of the text blocks is defined by the following classes :
$HTMLStylesFmt['nmhindent']= "
.indent1 {margin-left:1.25em;}
.indent2 {margin-left:2.5em;}
.indent3 {margin-left:3.75em;}
.indent4 {margin-left:5em;}
";
And the header have a negative indentation compared to the hereabove. This is defined in a variable : $HdrIndStyle = 'text-indent:-1em;'; Restrictions
You should deactivate the recipe PageTableOfContents of John Rankin. Instead of the recipe of John Rankin, there is no parameter for The History
Discussion
Is there any way to make it so if my second header is longer than one line it will indent that line as well? Right now my second header is indented on the first line, but it spills over to a second line in the TOC that is not indented. Looks very sloppy, any ideas? Thanks, Bryan. I am trying to include a TOC on every page, I have put the TOC code in Main.GlobalHeader and inserted thise file in my theme. However unless I use the TOC code in the page itself it does not show up, and then of course I have two :) How might I get a TOC on top of every page? Take a look at Cookbook.AllGroupHeader
I would like to see a option for horizontal line before each header (level 1). I doesn't work with indent, because the line starts at the last subheader indent. I have tried noindent, ---- and then indent but after some headers there are strange effects. I've increased the maximum level of headings from 4 to 6 (the maximum recognized by PmWiki). You can download it here: numtoc_max.zipΔ if you are interested. //Aidin Bugs
2.feb.2008 Manne 6.jan.2008, Petr 31. May 2007, Markus 24.May 2007, Lars: A second issue is that special characters (e.g. á) appear in their markup in the TOC (as á), not as the special character. In the heading/subheading they are displayed correctly. Thanks for your help. 7.Apr.2006 Is it possible to add number restarting? so it's possible to start from number other than 1. Very useful for pages included in other pages, to keep virtual numbering. You can define a numbering style like (: num 2.1.1.1 :) and it will start numbering at 2, instead of 1. Joshua Kugler
9.feb.2006, a.l.e:
27.jan.2006, Tom: I dunno how my configuration is set, but I was getting "
$title = preg_replace ("/(%.*?%)([^%]*)/", "\\2", $title);
This may not be the most elegant solution, but it works for me, and I think it behaves correctly (did some minor testing). If you have any suggestions for improvement, I'd be happy to acquiesce. As soon styles are used for the heading e.g. Ok, tom patch added on V0.7 - I was willing to use section edit, so discovering the problem... PRZ See also
Contributors
|