Template:H/doc

From Wikisource
Jump to navigation Jump to search

{{h}}, {{sh}}, and {{ssh}} are still experimental templates for managing chapter headings in texts. Their philosophy are to be as simple as possible, to mirror well the use of direct formatting (like {{c}} and {{xl}}), so that they can be second nature for 90% of texts. For the remainder there probably is no general solution, instead of trying to kinda sorta half-way make something, these templates simply do not even try.

The templates provide some simple basic styling that roughly corresponds to typical styling that is common in books, but you are expected to create a work-specific stylesheet to tweak the headings so they match the actual style of the book. The stylesheet can do anything that CSS permits (well, what MediaWiki's more limited Sanitized CSS subset permits), but if you do much more than tweak alignment, font size, and font style (bold, italic, underline, etc.) you should probably reconsider. That you can do arbitrarily complex things doesn't mean it's a good idea to do so.

Usage[edit]

If your text contains a single chapter heading then just slap a {{h}} around it.

Example

{{h|Chapter 1}}

{{di|T}}here once was a man from Nantucket…

Chapter 1

There once was a man from Nantucket…

If there are two levels, then add a subheading too:

Example

{{h|Chapter 1}}
{{sh|The Man from Nantucket}}

{{di|T}}here once was a man from Nantucket…

Chapter 1

The Man from Nantucket

There once was a man from Nantucket…

And for texts with parts, chapters, and sections you can use a subsubheading:

{{h|Chapter 1}}
{{sh|The Man from Nantucket}}
{{ssh|a. Why Nantucket?}}

{{di|T}}here once was a man from Nantucket…

Example

{{h|Chapter 1}}
{{sh|The Man from Nantucket}}
{{ssh|a. Why Nantucket?}}

{{di|T}}here once was a man from Nantucket…

Chapter 1

The Man from Nantucket

a. Why Nantucket?

There once was a man from Nantucket…

Styling[edit]

Styling is done using page styles, targeting the three classes: wst-heading, wst-subheading, and wst-subsubheading. The basic style for the three headings is:

/* Basic default styling */
.wst-heading {
	margin-left: auto;
	margin-right: auto;
	font-size: 144%;
	text-align: center;
}
.wst-subheading {
	margin-left: auto;
	margin-right: auto;
	font-size: 120%;
	text-align: center;
}
.wst-subsubheading {
	margin-left: auto;
	margin-right: auto;
	font-size: 100%;
	text-align: center;
	font-style: italic;
}

(The sizes correspond to the sizes used for regular text, {{larger}}, and {{x-larger}} respectively).

To override these you could use something like this:

/* Basic default styling */
.wst-heading, .wst-subheading {
	font-size: 144%;
	font-style: bold;
}
.wst-subsubheading {
	font-size: 120%;
	text-align: left;
}

This would make both {{h}} and {{sh}} extra large (144%, or {{xl}}) and bold; and the {{ssh}} merely large but aligned to the left instead of the center.

Multiple heading styles in one work[edit]

Some texts use multiple heading styles within a single published unit (i.e. the thing for which an Index: is created, and for which there is only one stylesheet in effect). In these instances you can call the templates with a custom class name.

Example

{{h|divergent|Chapter 1}}

Chapter 1

If the template gets two arguments instead of one, the first one is treated as a custom class and added to the output. In the example above that would be _divergent (the underscore is to avoid collisions with other templates).