Jump to content

Template:Page range/doc

From Wikipedia, the free encyclopedia

This is a convenience template for those with difficulty remembering which character to use between page-number ranges, or who have accessibility or other issues getting to the correct character, en dash .

  • It will take two page numbers (including roman numerals and such) and create a range from them: {{subst:page range|vi|ix}} → vi–ix
  • It can also take copy-pastes of existing ranges in any sensible format as a single parameter and create ranges from them: {{subst:page range|vi-ix}} or {{subst:page range|vi - ix}} → vi–ix

This template should always be substituted with {{subst:page range|...}}, except inside a <ref>...</ref> citation (where substitution does not work); in that case, just use {{page range|...}} and a bot will replace it later. This substitution/replacement is so that wikicode junk is not retained where unnecessary or where it "pollutes" the citation metadata.

Because is trims out unnecessary whitespace, it cannot be used for complex cases that contain spaces, such as "plate 7 – plate 9", though this information can be done more concisely using this template as plates {{subst:page range|7|9}} → plates 7–9. Because of the white-space stripping, it is also not appropriate for date (or other complex) ranges. For a sophisticated date-range handler, see {{date range}}.

Usage[edit]

Two parameters:

{{subst:page range|23|25}}

  • The first parameter is the first page number of the range.
  • The second parameter is the ending page number of the range.

One parameter:

{{subst:page range|23-25}}, {{subst:page range|23 – 25}}, etc.

  • The single parameter is the entire page range, with the first and last pages separated by any dash/hyphen sort of character that is apt to be found in Western languages (plus a few East Asian ones).

All of these characters are detected: -, , , , , , , , , , , . This should handle copy-pasted page ranges from source material in just about any format, especially since it automatically handles any whitespacing.

Trims whitespace[edit]

  • {{page range|48|49}} → 48–49
  • {{page range| 50| 51}} → 50–51
  • {{page range|52 |53 }} → 52–53
  • {{page range| 54 | 55 }} → 54–55
  • {{page range|60-61}} → 60–61
  • {{page range| 62-63}} → 62–63
  • {{page range| 64-65 }} → 64–65
  • {{page range|66 - 67}} → 66–67
  • {{page range|  68  -  69  }} → 68–69

Consequently, you cannot do something like Yang (2024), pp.{{subst:page range| 70|71}}; it needs to be Yang (2024), pp. {{subst:page range|70|71}}

Substitution does not work inside ref tags![edit]

Doing <ref>Yang (2024), pp. {{subst:page range|70|71}}</ref> will not actually work to substitute the template, due to a limitation of the MediaWiki parser. What will happen is the {{subst:page range|70|71}} wikicode itself will display in the citation instead of the template's intended output.

Instead, just do <ref>Yang (2024), pp. {{page range|70|71}}</ref>, and a bot that looks for "This template should always be substituted" templates like this one will fix it later.

Complex cases[edit]

This template is not "magic" and is not doing complicated parsing of three of more parameters.

  • If you have something like "pp. vi–ix, 23-25, 27, 92, 120–121, appendix 2" to mark up, use one of:
    • pp. {{subst:page range|vi|ix}}, {{subst:page range|23|25}}, 27, 92, {{subst:page range|120|121}}, appendix 2
    • pp. {{subst:page range|vi-ix}}, {{subst:page range|23-25}}, 27, 92, {{subst:page range|120-121}}, appendix 2

See also[edit]