Template:Refn/sandbox
This is the template sandbox page for Template:Refn (diff). See also the companion subpage for test cases. |
This template is used on approximately 36,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
Purpose
[edit]This template is used to create footnotes in Wikipedia, as an alternative and complement to the <ref>
. Because of a technical limitation, some of the standard Wikipedia markup elements that are often used in the article prose do not work within a set of <ref>...</ref>
tags, including but not limited to the pipe trick, template substitution and another "nested" set of <ref>...</ref>
tags. For example, the following does not work as expected:
<ref>[[Help:Footnotes|]]</ref>
(Generates: [[Help:Footnotes|]] instead of a wikilink)<ref>{{SUBST:TODAY}}</ref>
(Generates: {{SUBST:TODAY}} instead of the date that the edit was made)<ref>Explanatory footnote<ref>Citation</ref></ref>
(Generates: Cite error: A <ref> tag is missing the closing </ref> (see the help page). </ref>)
Replacing the outermost <ref>...</ref>
set with {{Refn}} allows for the use of the markup elements listed above.
Usage
[edit]{{refn|group=groupname|name=name|Contents of the footnote}}
- groupname: Groupname per WP:REFGROUP; if not specified, then the main and nested references will be rendered into the same reference list
- name: Reference name per WP:REFNAME
Names for footnotes and groups must follow these rules:
- Names are case-sensitive. Please do not use raNdOM capitalization.
- Names must not be purely numeric; the software will accept something like
":31337"
(which is punctuation plus a number), but it will ignore"31337"
(purely numeric). - Names should have semantic value, so that they can be more easily distinguished from each other by human editors who are looking at the wikitext. This means that ref names like
"Nguyen 2010"
are preferred to names like":31337"
. - Names must be unique. You may not use the same name to define different groups or footnotes. Try to avoid picking a name that someone else is likely to choose for a new citation, such as
":0"
or"NYT"
. - Please consider keeping reference names short, simple, and restricted to the standard English alphabet and numerals. If spaces are used, the following technical restrictions become relevant:
- Quotation marks are preferred but optional if the only characters used are letters
A–Z
,a–z
, digits0–9
, and the symbols!$%&()*,-.:;<@[]^_`{|}~
. That is, all printable ASCII characters except#"'/=<>?\
and space. - Inclusion of any other characters, including spaces, requires that the reference name be enclosed in quotes; for example,
name="John Smith"
. But quote-enclosed reference names may not include a less-than sign (<
) or a double straight quote symbol ("
), which may however be included by escaping as<
and"
respectively. - The quote marks must be the standard, straight, double quotation marks (
"
); curly or other quotes will be parsed as part of the reference name.
- Quotation marks are preferred but optional if the only characters used are letters
- You may optionally provide reference names even when the reference name is not required. This makes later re-use of the sourced reference easier.
Examples
[edit]Footnotes with citations
[edit]Markup | Renders as |
---|---|
|
|
Other forms of citations
[edit]Markup | Renders as |
---|---|
|
|
Substitution
[edit]The first example shows that substitution does not work in a regular <ref>...</ref>
tag (the |access-date=
does not appear correctly). The second example shows that the |access-date=
is substituted correctly within {{refn}}.
Markup | Renders as |
---|---|
|
|
|
|
Errors
[edit]If the reference or note content is missing, then Cite error: Invalid <ref> tag; refs with no name must have content. will be displayed.
If the note content contains an equals sign (=
), the equals sign will be interpreted as setting off a named parameter and cause an error. This can be worked around by using a numbered parameter, for example:
Markup | Renders as |
---|---|
{{refn|1+1=2}} |
Cite error: There are <ref> tags on this page without content in them (see the help page). |
{{refn|1= 1+1=2}} |
|
There are several predefined groups that can have a reference list styled so that the label (a superscripted character within square brackets, e.g., [1]) of an explanatory note or citation (a.k.a. footnote, reference) matches and links to the note marker label located in the main text and the label in front of the note's text in the appropriate group's list. There can be more than one of these groups' lists in the Notes, References and other similarly purposed sections.
These predefined note and citation groups have templates that make the wikitext markup simpler. These templates also allow a standard reference to be inserted, so that an explanatory note can have a reference, or citations can be nested.
Note: If the note's text has a reference name that is used more than once, the labels will still match, but the clickable alpha characters (superscript lowercase letters like a b c) that toggle the note's display[vague] will be next to the note's label, with links to the multiple locations of its marker in the main text. See WP:REFNAME and the first point below in § Issues.
Template use by reference group type
[edit]Group type | Footnote marker template or markup |
Reference list template |
Sample labels |
---|---|---|---|
none by default, but optionally any |
<ref>...</ref>
|
{{reflist}}
|
1 2 3 4 5 6 7 8 9 10 |
{{r}} (for nested references)
| |||
{{refn}} (for nested references)
| |||
lower-alpha | {{efn}} {{efn-la}} |
{{notelist}} {{notelist-la}} |
a b c d e f g h i j |
upper-alpha | {{efn-ua}} |
{{notelist-ua}} |
A B C D E F G H I J |
lower-roman | {{efn-lr}} |
{{notelist-lr}} |
i ii iii iv v vi vii viii ix x |
upper-roman | {{efn-ur}} |
{{notelist-ur}} |
I II III IV V VI VII VIII IX X |
lower-greek | {{efn-lg}} |
{{notelist-lg}} |
α β γ δ ε ζ η θ ι κ |
note | {{NoteTag}} |
{{NoteFoot}} |
note 1 note 2 note 3 |
{{efn}}
supports|name=
and|group=
, which work the same as the parameters in<ref>
(see, for instance, the 3rd and 4th examples below). Do not enclose values in quotes.{{notelist}}
supports the|colwidth=
,|refs=
, and|group=
parameters, which work the same as the parameters in{{reflist}}
. Do not enclose values in quotes.
In these examples, the footnote labels match between the footnote marker and the reference list:
Markup | Renders as |
---|---|
Lorem ipsum dolor sit amet.{{efn|Footnote 1}} Consectetur adipisicing elit.{{efn|Footnote 2}} Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.{{efn|Footnote 3}} {{notelist}} |
|
Markup | Renders as |
---|---|
Lorem ipsum dolor sit amet.{{efn-lr|Footnote 1}} Consectetur adipisicing elit.{{efn-lr|Footnote 2}} Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.{{efn-lr|Footnote 3}} {{notelist-lr}} |
|
Markup | Renders as |
---|---|
Lorem ipsum dolor sit amet.{{efn|name=fn1|Footnote 1}} Consectetur adipisicing elit.{{efn|Footnote 2}} Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.{{efn|name=fn1}} {{notelist}} |
|
Note: With named references you only need to add the details once. For each use after the first you just need to re-use the reference name. Doing this will not cause the inline superscript to display a custom name.
Markup | Renders as |
---|---|
Lorem ipsum dolor sit amet.{{efn|name=fn1}} Consectetur adipisicing elit.{{efn|name=fn2}} Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.{{efn|name=fn1}} {{notelist|refs= {{efn|name=fn1|Very long footnote 1}} {{efn|name=fn2|Very long footnote 2}} }} |
|
Note: Due to limitations in the MediaWiki software, do not use list-defined footnotes that contain references.
Issues
[edit]- Multiple backlink labels (see WP:REFNAME) are always styled as lower-alpha. This can be confusing when
{{efn}}
is used. See the note in the introduction of this section, above. - The entries in the reference list will show the default decimal styling if:
- The value for
|group=
in{{reflist}}
or<references />
does not exactly match one of the predefined values; use{{efn}}
or variant as|group=
will not be needed. - The value for
|group=
in{{reflist}}
or<references />
is enclosed by quotes; use{{efn}}
or variant as|group=
will not be needed. {{reflist}}
is indented with the:
markup.<references />
is used instead of{{reflist}}
- The value for
- The entries in the reference list will have no styling if:
- A reference is included in
{{navbox}}
or one of the variants and the style is set tobodyclass=hlist
; to resolve this, replace the style withlistclass=hlist
.
- A reference is included in
See also
[edit]- {{r}} (another template supporting nested footnotes)
- {{citeref}} (a different method to create nested links working on citation template anchor level rather than <ref></ref> markup level)
TemplateData
[edit]TemplateData for Refn
This template is used to create footnotes in Wikipedia, as an alternative and complement to the <ref> tag.
Parameter | Description | Type | Status | |
---|---|---|---|---|
content | 1 refn | The content of the footnote. | Content | required |
name | name | The name of the footnote. Corresponds to the "name" attribute of the <ref> tag. | String | optional |
group | group | The reference group. Corresponds to the "group" attribute on the <ref> tag. | String | optional |