Editing Wikitext/Headings

From Wikibooks, open books for an open world
Jump to: navigation, search
 

Text Headings

Formal heading styles are used in nearly all WikiBooks pages and for that matter, for all of the sister projects' pages as well. They clearly show a degree of organization in the work, and they are absolutely essential if the user intends to take advantage of the automatically generated table of contents, (TOC).

The following notes explain how to make wiki headings, and introduces the table of contents. Notes are provided on moving the TOC around, and constraining its behavior. For those who intend to put the TOC into a table cell at the top of a page, refer to Images in Containers, and Templates Ready to Use.
CourierWC.png

 

Heading levels

There are six levels of heading styles and all of them are made by surrounding the heading text with an appropriate number of equals signs. The HTML heading styles are equivalent and so optionally, the heading text can be surrounded by the HTML tags instead. As an example; to make a level two heading, the largest practical heading, write either of the following at the left margin:

==Heading Text==

or;

<h2>Heading Text</h2>


To make smaller headings just increase the number of equals signs, or use larger numbers in the HTML tags. It was stated above that there are six levels but the first level is usually reserved for the page heading, and making a table of contents with more that three levels can be messy. As a result it is most common to stick to levels two, three and four, or to use the HTML equivalent, h2, h3 and h4. By insuring that smaller headings come below larger headings in the text, the TOC will indent the sub-levels accordingly, and automatically insert the required links.

At times a heading is needed for text in a table. Wikitext heading codes can have an adverse effect on tables and templates. When this happens, changing to the HTML versions of the heading will often solve the problem.

The level two heading style inserts a line across the page whether it is needed or not, but to add a similar line with the other headings, just type four hyphens at the left margin as follows:

----


 

Summary of Headings

The following table contains a summary of the headings that can be made.

Summary of Wikitext and HTML Heading Codes
Wikitext Result HTML Description
=Text= Text <h1>Text</h1> h1 is mostly for page headings
==Text== Text <h2>Text</h2> h2 heads a section
===Text=== Text <h3>Text</h3> h3 heads a subsection of h2
====Text==== Text <h4>Text</h4> h4 heads a subsection of h3
=====Text===== Text <h5>Text</h5> h5 is rarely used
======Text====== Text <h6>Text</h6> h6 is rarely used



Hiding Headings

As was mentioned above, the headings are used to make the table of contents, (TOC). Sometimes, when the TOC is looking a bit full, or when a heading does not seem to warrant listing, it would be useful to have the benefits of the heading's formats, but to miss it out on the TOC.

A set of templates has been made to do this. They are the six templates Hiddenh1 through Hiddenh6. The way to use say, a level three heading style without a TOC listing is just:

{{hiddenh3|Hidden Heading Here}}

Just choose a different template for other heading sizes.


Numbered Headings

Numbered headings are made only by typing them yourself, and the nested heading sizes are made in usual way.

The conventional numbering method is to assign a separate number sequence to each level of heading. Although an automatic method purports to exist in the user's preferences, it affects only the local view and will not be seen by others. A fairly standard approach for numbered headings is seen below, but the indentation that is preferred for numbered sub-sections cannot be obtained with a simple use of tags or wiki code. Templates could be made to indent the sub-sections properly, setting left margins for the paragraphs accordingly, and for those who might attempt it, the existing CSS styles for headings have been provided below.

1 Some Flowering Plants
1.1 Monocots
1.1.1 Orchids
1.1.2 Onions
2 Trees

etc.


Drop Capitals

Drop capitals are used for work where heading styles are intrusive, though the rules for their use are by no means clear.

T

here is no drop capital code in Wikitext at this time, but a template exists. The drop capital at the start of this paragraph was added using the Drop template. Users who need a different drop capital can find the basic coding on the template's editing window. The code used to call this template into use was just:

{{Drop|T}}here is no drop capital...

Notice that only the first character of the paragraph was included within the double curly brackets, and that the remainder of the text was dressed tightly to the left.


 

The Table of Contents

The table of contents habitually resides at the top-left of the page. In fact, it will position itself at the left margin and just above the first heading that is made. The TOC lists all of the headings and makes links to their positions in the page. Selecting a link causes the page to shift so that the selected heading is at the top of the screen. A table of contents will not be generated unless at least four headings are made.

The width and length of the TOC adjusts as more heading text is added. The width adjusts to the longest heading and the box extends downward as more headings are added. At some point the text is wrapped rather than continuously widening the box. The automatic behavior of the TOC is not always welcome, and various methods to constrain it have been devised. See the comments below.

It is possible to remove the TOC by typing;

__NOTOC__

anywhere on the page. (Note that there are two underscores on each side). The usual Wiki page includes a table of contents, but it is unclear how strict the convention is. Note the section above on Hiding Headings to avoid headings being added to the TOC.

To include the TOC in a place that it would not normally appear, for example, in a table cell at say the top of the page, just type the following code in the cell as if it were text;

__TOC__

Such a method can be used to position the TOC with some accuracy, as well as running text or images level with it in the top section. The __TOC__ word overrides a previous __NOTOC__ instruction though only one TOC can appear on a page.

The template Tocright can be used to place a table of contents at the right side of the WikiBooks page. The TOC will appear adjacent to the position on the page that the template is called. To call the template into use just type;

{{tocright}}

Other templates , that display the TOC with images and text at the top of a page include Imageontop, Textontop, and a number of similar templates. Another table-based template for top-sections is Thetop, and the table of contents is easily be added to it, as can be seen in the top section of this page.

The colors of the TOC are fixed; in fact they are set by the Toccolours class. So far, the TOC itself has resisted any modification.


 

CSS Heading Styles

At times, for example for templates, users need to know the details of certain wiki styles. These can be found in the wikibooks style sheets. An example of these styles for the main wiki headings can be found in the drop-box below.

Heading style extract
CSS Heading Styles from main.css
h1, h2, h3, h4, h5, h6 {
        color: black;
        background: none;
        font-weight: normal;
        margin: 0;
        padding-top: .5em;
        padding-bottom: .17em;
        border-bottom: 1px solid #aaa;
}
h1 { font-size: 188%; }
h1 .editsection { font-size: 53%; }
h2 { font-size: 150%; }
h2 .editsection { font-size: 67%; }
h3, h4, h5, h6 {
        border-bottom: none;
        font-weight: bold;
}
h3 { font-size: 132%; }
h3 .editsection { font-size: 76%; font-weight: normal; }
h4 { font-size: 116%; }
h4 .editsection { font-size: 86%; font-weight: normal; }
h5 { font-size: 100%; }
h5 .editsection { font-weight: normal; }
h6 { font-size: 80%;  }
h6 .editsection { font-size: 125%; font-weight: normal; }

Other Pages