This is a documentation subpage for 模板:SfnRef. It may contain usage information, categories and other content that is not part of the original 模板 page. |
This template is used on approximately 136,000 pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
This template uses Lua: |
Generate an identifier suitable as an anchor for a Harvard citation. This template, which can be used with either the name {{SfnRef}}
or the alias {{harvid}}
, is intended to be paired with Harvard citation templates such as {{Sfnp}}
, {{Sfn}}
, {{Harvp}}
, and {{模板:Harvard citation no brackets}}
. This template uses the same arguments as the other citation templates. As explained below, this template is needed only in some cases when the Harvard citation templates are used.
Usage
{{SfnRef|Surname of author|Year}}
{{SfnRef|Surname of author 1|Surname of author 2|Surname of author 3|Surname of author 4|Year}}
The first parameter is the first author's last name. Up to four authors can be given as parameters; if there are more than four authors, list only the first four. The last parameter is the year of publication, possibly with a letter suffixed to avoid ambiguity if there are multiple citations by the same set of authors in the same year.
All named parameters such as |p=
are ignored.
Purpose
This template creates the proper value for the |ref=
parameter of Citation Style 1 templates ({{Cite journal}}
, {{Cite book}}
, {{Citation}}
) and the generic Citation Style 2 template {{Citation}}
(as well as {{Vcite journal}}
, {{Vcite journal}}
, {{Vcite book}}
and other templates that generate Vancouver system references). It is intended to be paired with {{Sfnp}}
, {{Sfn}}
, {{Harvp}}
, {{模板:Harvard citation no brackets}}
, and related templates, and uses the same arguments. As explained below, {{SfnRef}}
is only necessary in a subset of the cases where those are used.
{{Sfnp}}
and its variants create a short footnote that is linked to a full footnote. The templates create the link automatically, but the full footnote must be assigned the proper ID value to be a valid target for that link. This usually happens automatically using the full-citation template's author/editor and date/year parameters, but some cases need a custom anchor, and that is what {{SfnRef}}
is for.
When using the Citation Style 1 and 2 family of citation templates, a default ID is generated from the last names of the first four authors (or editors if there are no authors specified). However, if none of |last=
, |editor-last=
, or their equivalents are present, use {{SfnRef}}
inside the CS1/CS2 template's |ref=
parameter to create a link anchor (perhaps using the publisher name or work title or an abbreviation thereof) without having to know the rules for how {{Sfnp}}
, etc., interpret the anchor ID string which is normally auto-generated.
The {{Vcite journal}}
etc. templates (with Vcite
, not Cite
names) require the use of {{SfnRef}}
to work with {{Sfn}}
, {{Harvnb}}
, and related templates.
Consistent output: For use with CS1/CS2 templates, {{Sfnp}}
and its {{Harvp}}
companion produce the most consistent citation formatting. For use with Vancouver citation templates (and any other citation styles that do not put dates in parentheses/round-brackets), the matching short-footnote templates are {{Sfn}}
and {{模板:Harvard citation no brackets}}
.
Examples
With the shortened footnote template
When citing an article published in the December 2004 edition of Rolling Stone where the author is unknown, you might create a short footnote as follows:
{{Sfn|Rolling Stone|2004}}
|ref=harv
will not work in this case because "Rolling Stone" is not the name of the author. You may code the value for the |ref=
parameter manually, or you can use {{SfnRef}}
and specify the same parameters as used with {{Sfn}}
:
{{SfnRef|Rolling Stone|2004}}
The full footnote:
{{Cite news |work=[[Rolling Stone]] |title=The RS 500 Greatest Songs of All Time |ref={{SfnRef|Rolling Stone|2004}} |date=December 2004}}
You can copy and paste the {{Sfn}}
template code and change the name of the template from "Sfn" to "SfnRef". If your short footnote includes page numbers such as {{Sfn|Rolling Stone|2004|p=48}}
, you can copy and paste it to create {{SfnRef|Rolling Stone|2004|p=48}}
; the |p=48
parameter is not necessary but will do no harm.
With other Harvard templates
For example, a References section might contain the following markup:
{{Vcite journal |author=Peh WC, Ng KH |title=Preparing the references |journal=Singapore Medical Journal |volume=50 |issue=7 |pages=659–661 |date=2009 |pmid=19644619 |url=http://smj.sma.org.sg/5007/5007emw1.pdf |format=PDF |ref={{SfnRef|Peh|Ng|2009}} }}
This markup uses {{SfnRef|Peh|Ng|2009}}
to generate the anchor identifier "CITEREFPehNg2009", used internally to link Harvard references to citations. (This identifier is not visible to the article's reader.) The generated citation looks like this:
Deprecated inline use
Running text can link to this citation with markup like the following:
{{harv|<Peh>|<Ng>|<2009>}}
which generates the following:
To see how it works, click on the "(Peh & Ng 2009)".
Note: Use of inline parenthetical referencing of that sort within articles has been deprecated by the Wikipedia community since 2022. This usage has not been deprecated within internal pages such as Wikipedia documentation, user pages, or wikiprojects, though there is rarely a practical use for it instead of just using normal citation footnotes.
See also
{{sfnref inline}}
– aspan>>
-based version for use with manually formatted, non-templated citations{{citeref}}
– a wrapper for{{SfnRef}}
to create wikilinks with either superscript [n] or plain-text labels to other citations from inside a citation