Template:Su/sandbox
This is the template sandbox page for Template:Su (diff). See also the companion subpage for test cases. |
This template is used on approximately 4,400 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. |
This template should not be used in citation templates such as Citation Style 1 and Citation Style 2, because it includes markup that will pollute the COinS metadata they produce; see Wikipedia:COinS. |
This template uses Lua: |
Purpose
[edit]Template for creating two smaller lines of text on one actual line, this can be used for scientific notations of uncertainty and physics symbols, such as nuclides and particles.
It was named after the <sup>
and <sub>
HTML tags, which share the first two letters of their name with this template. This template uses the third letter of the name of these tags, p
and b
, as the name of the argument that drives the output of the top and bottom line, respectively.
Arguments
[edit]|p= |
The contents of the top line. |
|b= |
The contents of the bottom line. |
|a= |
The alignment of both lines (|a=r : right-aligned; |a=c : center-aligned; default is left-aligned).
|
|w= |
The size of the characters (|w=f : fixed-width (monospace), otherwise template inherits the current font and context by default).
|
|lh= |
The line height or distance from top to bottom (including top character). Default is 1.2em. |
Note on fractions
[edit]Usually, when using vulgar fractions it is MOS habit to use ⁄ (⁄
) (MOS:FRAC) and {{frac}}.
However, in <sub> or <sup> tags, best use the keyboard slash /
for readability in most browsers:
- X1⁄2
7⁄8 (fraction slash)
and
- X1/2
7/8 (keyboard slash)
Examples
[edit]Simple
[edit]X{{su|p=a}} X{{su|b=b}} X{{su|p=a|b=b}} {{su|p=a|b=b}}X {{su|p=a|b=b}}X{{su|p=c|b=d}}
- Xa
X
b Xa
b a
bX a
bXc
d
Left-aligned (default)
[edit]X{{su|p=aaaaa|b=b}} X{{su|p=aaaaa|b=b}}Y X{{su|p=a|b=bbbbb}} {{su|p=a|b=bbbbb}}X
- Xaaaaa
b Xaaaaa
bY Xa
bbbbb a
bbbbbX
Right-aligned
[edit]X{{su|a=r|p=aaaaa|b=b}}X{{su|a=r|p=a|b=bbbbb}}X
- Xaaaaa
bXa
bbbbbX
Center-aligned
[edit]X{{su|a=c|p=aaaaa|b=b}}X{{su|a=c|p=a|b=bbbbb}}X
- Xaaaaa
bXa
bbbbbX
Smaller font
[edit]{{small|X{{su|p=a}}X{{su|b=b}}X{{su|p=a|b=b}}X}}
- Xa
X
bXa
bX
Larger font
[edit]{{big|X{{su|p=a}}X{{su|b=b}}X{{su|p=a|b=b}}X}}
- Xa
X
bXa
bX
Fixed-width
[edit]X{{su|p=...|b=www}}X{{su|w=f|p=...|b=www}}X
- X...
wwwX...
wwwX
Close-spacing
[edit]{{su|p=4|b=4}} {{su|lh=0.8em|p=4|b=4}}
- 4
4 4
4
Line breaks
[edit]Unlike the <sup>
and <sub>
tags, this template does not always prevent line breaks between the two small lines and the text preceding or following it. Thus, if this template is used to supply a subscript and superscript over a base symbol, the whole structure has to be enclosed in a {{nowrap}}, or this template should be invoked through another template that takes care of the wrapping in an appropriate way.
Note: Without the suggested {{nowrap}}, this is not consistent across all browsers: in Chrome, this is true, whereas in Firefox and Safari line breaks will generally be suppressed after preceding text.
Example: {{nowrap|X{{su|p=a|b=b}}}}
→ Xa
b