Template:Reflist

From Wikibooks, open books for an open world
Jump to: navigation, search
Template documentation[edit] [history] [purge]

This template encapsulates the <references /> tag to show the list of references defined by <ref>...</ref> tags, with some formatting. It reduces the font size and has options for columns and groups. References can be defined within the body of the article or within the reference list.

The <ref>...</ref> and <references /> tags are part of the Cite.php MediaWiki extension.

{{Reflist}} may be used with {{Refbegin}} and {{Refend}} to format different styles of references.

Usage

Using only footnote-style references
== Content ==
Lorem ipsum.<ref>Source name, access date, etc.</ref>

Lorem ipsum dolor sit amet.<ref>Source name, access date, etc.</ref>

== References ==
{{Reflist}}
Using only bibliographical style references
== Content ==
Lorem ipsum.

Lorem ipsum dolor sit amet.

== References ==
{{refbegin}}
* reference 1
* reference 2
{{refend}}
Using both footnote-style and bibliography-style references
== Content ==
Lorem ipsum.<ref>Source name, access date, etc.</ref>

Lorem ipsum dolor sit amet.<ref>Source name, access date, etc.</ref>

Lorem ipsum.

Lorem ipsum dolor sit amet.

== References ==
{{Reflist}}

{{Refbegin}}
* reference 1
* reference 2
{{Refend}}

Font size

The font size should reduce to 90% for most browsers. Note that there is no consensus that a small font size should always be used for references; when normal-sized font is more appropriate on a page, use <references /> instead.

Columns

Columns are currently supported only by Gecko-based browsers (such as Mozilla Firefox). See below for more information.

Using {{Reflist|2}} will create a two-column reference list, and {{Reflist|3}} will create a three-column list. Three-column lists may be inaccessible to users with smaller/laptop monitors and should be avoided.

Using {{Reflist|30em}} will allow the browser to automatically choose the number of columns based on the width of the web browser. Choose a column width that is appropriate for the average width of the references on the page.

Multiple uses

If {{Reflist}} is used multiple times without a parameter, each instance will include all of the previously defined references. To force the parser to close previous references, each use of {{Reflist}} must be forced as a new instance by the use of any parameter. Even an undefined parameter such as {{Reflist|close=1}} will force the references to close.

Grouped references

The footnotes system supports the separation of references into groups. This allows groups for explanatory notes, table references and the like.

The general format for the reference tag would be:

<ref group="groupname">

And for the reflist:

{{Reflist|group="groupname"}}
Where groupname would be a group identifier such as "note", "nb" or "label".

List-defined references

References may be defined within {{reflist}} using |refs= and invoked within the content. There are new error messages associated with this update, documented at Help:Editing#References. As usual, groups can be used. Defined references must be used within the body; unused references will show an error message.

Example

This is reference 1.<ref name="refname1" group="groupname"/>
This is reference 2.<ref name="refname2" group="groupname"/>
This is reference 3.<ref name="refname3" group="groupname"/>

{{Reflist|group="groupname"|refs=
<ref name="refname1" group="groupname">content1</ref>
<ref name="refname2" group="groupname">content2</ref>
<ref name="refname3" group="groupname">content3</ref>
}}

Result

This is reference 1.[groupname 1] This is reference 2.[groupname 2] This is reference 3.[groupname 3]

  1. content1
  2. content2
  3. content3

Technical details

Browser support for columns

Multiple columns are generated by using CSS3, which is still in development; thus only browsers that properly support the multi-column property will show multiple columns with {{Reflist}}.[1][2]

Supports columns

These browsers support CSS3 columns:

  • Gecko-based browsers such as Mozilla Firefox; earlier versions had a bug that created broken links in multiple columns
  • WebKit-based browsers such as Safari and Google Chrome; Webkit versions earlier than 533 have a link positioning bug; Safari 5.x (7533.17) and Chrome 5.0 or higher resolve this issue
No column support

These browsers do not support CSS3 columns:

Supporting CSS

{{Reflist}} uses a CSS rule in MediaWiki:Common.css/References.css to set the font size:

  • div.references { font-size: 90%; }

One of the the following classes is assigned by the template when either column count or column width is set:

  • .references-column-count and .references-column-count-n (where n is the numer of columns)
  • .references-column-width

The following CSS properties are utilized using the {{column-count}} and {{column-width}} templates:

  • column-count CSS3 standard
  • column-width CSS3 standard
  • -moz-column-count Mozilla CSS extension
  • -moz-column-width Mozilla CSS extension
  • -webkit-column-count Webkit CSS extension
  • -webkit-column-width Webkit CSS extension

Customizing the view

By editing your CSS, the personal appearance of the reference list can be customized. From Preferences, select the Appearance tab, then on the selected skin select Custom CSS. After editing and saving, follow the instructions at the top of the page to purge.

Font size

The font size defaults to 90% of the standard size. To change it, add:

div.references { font-size: 90%; }

Change 90% to the desired size.

Columns

To disable columns, add:

.references-column-count, .references-column-width {
    column-count: 1 !important;
    column-width: auto !important;
    -moz-column-count: 1 !important;
    -moz-column-width: auto !important;
    -webkit-column-count: 1 !important;
    -webkit-column-width: auto !important;
}

Similarly, to force all reference lists to a number of columns, change the number.

Column dividers

To add dividers (rules) between columns, add:

.references-column-count, .references-column-width {
    column-rule: 1px solid #aaa;
    -moz-column-rule: 1px solid #aaa;
    -webkit-column-rule: 1px solid #aaa;
}

You can alter the appearance of the dividers by changing the values.

Collapsing and scrolling

There have been a number of requests to add functionality for a collapsible or scrolling reference list. These requests have not been fulfilled to due to issues with readability, accessibility, and printing.

The links between the inline cite and the reference list do not work when the reference list is enclosed in a collapsed box.

See also

References