Template:Harvard citation documentation

The harvard citation templates create an author-date citation with a one-directional link to the first matching citation template on the same page.

Templates that create Harvard citations in text:
 * Harvard citation or harv for a basic Harvard citation
 * Harvard citation no brackets or harvnb for a Harvard citation with no brackets
 * Harvard citation text or harvtxt for a Harvard citation with the name outside the brackets
 * Harvcol for a harvard citation with a colon before page numbers
 * Harvcolnb ditto, without brackets
 * Harvcoltxt ditto, with the name outside the brackets
 * Harvard citations or harvs for multiple Harvard citations and other more complicated features.

Template that create a Harvard citation in a footnote:
 * Sfn (shortened footnote template)

All of these templates have the same parameters and basic functionality. This page describes the first six in detail; for the others see their documentation pages. Editors editing one of these templates are requested to make parallel changes to the other versions.

Usage
In the body of the article:
 *  

In the references section (or in an earlier footnote):
 *  

Up to four authors can be given as parameters. (If there are more than 4 authors only the first 4 should be listed. See, below.) The last parameter is the year of publication.
 * Parameters

(All these examples have links which operate. Click on highlighted text "".)

The optional parameters p, pp and loc can be used to indicate the location in the source. All of the harvard citation templates use the same parameters to indicate page numbers or other locations in the text.

The parameter Ref is used to specify the reference value that links the short citation to the full citation. This parameter is optional and is usually not necessary. If you specify none no hyperlink is created. (See the examples. Not available in sfn.)

The links in the harvard citation templates can find anchors in most of Wikipedia's citation templates, such as Citation, Cite book, Cite journal or Cite web (or any of several others). To make the anchor, parameter harv must be set. This is not necessary for, but is normally necessary for the others.
 * Reference section

Harvard citation: harv

 * See also: 

Template harv creates a parenthetical reference with a link to the full citation in the references section at the bottom of the article.

{| class="wikitable" ! width=400 | Markup !! width = 300 | Result
 * Article text.
 * Article text.

Shortened footnote: sfn or harvnb

 * See also: 

Template harvnb inside a span can be used to create an author-date citation in footnote that is linked to the full citation at the bottom of the article. Template sfn has the same effect and it also combines identical footnotes automatically.

{{Wikitext example| Article text.{{sfn|Smith|2007|p=25}} More article text.{{sfn|Smith|2007|p=25}} Still more article text.{{sfn|Smith|2007|p=26}}

In text attribution: harvtxt

 * See also 

Template harvtxt can be used to link an in-text attribution to the full citation at the bottom of the page. {| class="wikitable" ! width=400 | Markup !! width = 300 | Result


 * According to ...
 * According to ...

Bundled citation: harvnb

 * See also: 

Template harvnb can be used to bundle citations.

{| class="wikitable" ! width=400 | Markup !! width = 300 | Result
 *  Article text.
 * Article text.
 * Article text.
 * Article text.
 * Article text.

More than one work in a year
For authors who have published more than one work in the same year, the standard way to differentiate such works is to put a lowercase letter after the year (e.g. place 2006a and 2006b in the citation templates and use  and  in the article body).

{| class="wikitable" ! width=400 | Markup !! width = 300 | Result More text.
 * Article text.
 * Article text.
 * Article text.

Large numbers of authors
Only the first four authors are required by the template. Listing more is not supported. It also possible to use the harvid in the citation template, which allows a more concise citation in the article text. {| class="wikitable" ! width=400 | Markup !! width = 300 | Result .
 * Article text
 * Article text

No author name in citation template
Some sources do not have a single author with a last name, such as a magazine article or a report from a government institution. There is no consensus (in Wikipedia or among citation styles) about how to format author-date citations to works that do not have a specific author. Several choices are: An article should adopt one of these styles consistently. Using harvid in the citation template can handle these cases.
 * 1) For a newspaper or periodical you may use the name of the paper and the date.
 * 2) For a publication by an institution, use either:
 * 3) The initials of the institution
 * 4) The name of the institution
 * 5) Alternatively, some style guides recommend using the title of the article.
 * 6) Other style guides recommend using "Anonymous" or "Anon."

{| class="wikitable" ! width=400 | Markup !! width = 300 | Result
 * Article text.
 * Article text.

Citation has date and no year
Either the year or date of a citation template can be matched – the template logic can extract the year of from a full date. If the date parameter is not a full date, then the extraction will fail. If the link does not seem to work, it also possible to set both date and year parameters. The template will display the date and use the year for the anchor. If only the year is known the year field must be used in the citation for the link to work correctly (i.e. 2005 may not work correctly). These two examples show a year being successfully extracted from full date.

{| class="wikitable" ! width=400 | Markup !! width = 300 | Result
 * Article text.
 * Article text.

Citation template does not support harv
The   family of templates use parameter harvid to create an anchor for the harvard citation templates. This must be set to a concatenation of the parameters passed to the harvard citation template.

{| class="wikitable" ! width=400 | Markup !! width = 300 | Result
 * Article text.
 * Article text.

Citation format does not support anchors: wikicite
In a few very rare cases, it may be impossible for the citation templates to create an anchor. Either (1) the citation is formatted with a template that does not support the ref parameter (such as cite report) or (2) the source can't be described using our citation templates at all. In these cases, it is possible to use wikicite to make the anchor. (As of November 2010, there are only approximately 100 articles that require this technique.) It is also possible that (3) local editors would prefer not to use citation templates. In this case, it is important to discuss what the local editors would like to do about the bad links. It is always possible to simply remove harv or sfn.

{| class="wikitable" ! width=400 | Markup !! width = 300 | Result


 * Article text.
 * Article text.

Recommended style
The recommended Harvard referencing style potentially uses all four templates. Each automatically generates a hypertext link based on the name(s) and date. Here is an example
 * Markup
 *  Some works on gravitation are so massive they warp spacetime themselves ; yet presented essential equations with notable brevity. The essential ingredients are the curvature tensor and the stress-energy tensor . 
 * Result
 * Some works on gravitation are so massive they warp spacetime themselves ; yet presented essential equations with notable brevity. The two ingredients are the curvature tensor and the stress-energy tensor.



In short:
 * 1) For a single work with no author in the text (the most common case), use Harv.
 * 2) For a single work with the author named in the text, use Harvtxt.
 * 3) For multiple works at the same point, use explicit parentheses and Harvnb separated by semicolons.
 * 4) For anything more complicated use Harvs.

Implementation notes
These templates use two elements: a wikilink in the body of the article, and an anchor in the reference section of the article. Clicking on the wikilink repositions the page at the anchor.

Citation template anchor
The most common citation templates use citation/core to format the citation, including cite book, cite journal, cite news, cite web and citation. If harv is set, then Citation/core creates an anchor  followed by the concatenation of the following parameters: Template Citation sets harv as the default.
 * last or last1 or surname or surname1 or author or author1 or authors,
 * last2 or surname2 or author2,
 * last3 or surname3 or author3,
 * last4 or surname4 or author4,
 * editor-last or editor-surname or editor1-last or editor1-surname or editor or editors,
 * editor2-last or editor2-surname,
 * editor3-last or editor3-surname,
 * editor4-last or editor4-surname,
 * year.

This covers the most common templates. Information about all the templates is available at User:Gadget850/Citation templates— anchors.

Please note that the above list does not include the coauthor parameter, which is ignored in generating the citation's CITEREF anchor. It is recommended that, when used with the harv family templates, citation templates always use the numbered last parameters instead of coauthor so that a more accurate CITEREF anchor may be generated. If coauthor is used, it will not be possible to generate a Harvard citation that displays the authors' names correctly and that generates a link to the correct CITEREF anchor.

Use of the date parameter in place of the year parameter in citation templates is preferred when full dates are known. The date parameter should not be used to simply encode a year, as this can fail to generate a viable  link.

Harvard citation wikilink
The harvard citation templates create a wikilink to the anchor. For example   produces a link   and produces an anchor.

Using CITEREF directly
A few articles create a custom ID using, either in place of the harvard citation template (e.g.  ) or as a value for ref in the citation template. Note that a custom ID must follow these rules:
 * Must begin with a letter A-Z or a-z
 * Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
 * If CITEREF is used Spaces in the ref field must be replaced with underscores
 * Case-sensitive

Where cite_name is a name such as the publisher.

sfn's ref name
Template sfn creates a named footnote, so that identical footnotes are combined automatically. The footnote name begins with  followed by a concatenation of the arguments to sfn. E.g.: this template call should have exactly the same functionality as which, in turn, has the same functionality as

The call to harvnb has been subst'ed for quicker load times.