Template:SubSup
This template employs intricate features of template syntax.
You are encouraged to familiarise yourself with its setup andparser functionsbefore editing the template. If your edit causes unexpected problems, pleaseundoit quickly, as this template may appear on a large number of pages. You can conduct experiments, and should test all major changes, in eitherthis template's sandbox,thegeneral template sandbox,or your user space before changing anything here. |
This template provides a simple means of coding inline mathematical material that has subscripts and superscripts, for display in the same typeface as the surrounding text. The rendering is always done inHTML;this offers an alternative to using theTeXpreprocessor via the<math>...</math>
tags, which display the material in a serif typeface regardless of the typeface of the running text. Unlike with TeX/HTML rendering, the type size of the subscripts and superscripts is always reduced, in keeping with common practice in mathematics.
Usage
{{SubSup|[<symbol>]|<subscript>[|s=0]}}
{{SubSup|[<symbol>]||<superscript>[|s=0]}}
{{SubSup|[<symbol>]|<subscript>|<superscript>[|s=0]}}
The first argument is assumed to be a quantity symbol, and is set in the oblique ( “italic” )[1] font of the typeface for the surrounding text. To have the base symbol in upright font, give the symbol before the template and give a blank first argument.
The subscripts and superscripts are set in upright font, in keeping with normal practice for numerals and descriptive subscripts. To set the superscript or subscript in oblique font, as for a subscript that itself is a variable, use the HTML<var>...</var>
or<i>...</i>
tags, or the wikimarkup for italics (''
).
Note that to get only a superscript, a blank second argument must be given.
By default, a space of approximately 1/6 em is added after the symbol to prevent the oblique symbol from overlapping the upright superscript or subscript. To suppress this spacing, give the optionals=0
parameter (any value other than zero is ignored); thesparameter is ignored if the first argument (for the base symbol) is blank. Thesparameter may be given at any point in the argument list; the other arguments must be given in the order shown.
Examples
Subscript only:
{{SubSup|x|a}}
givesxa
Subscript only without spacing:
{{SubSup|x|s=0|a}}
givesxa
Superscript only:
{{SubSup|x||3}}
givesx3
Subscript and superscript:
{{SubSup|x|a|3}}
givesx3
a
Subscript and superscript with base symbol in upright font:
X{{SubSup||a|3}}
gives X3
a
Superscript with variables:
{{SubSup|e||''u'' ln ''a''}}
giveseulna
To obtain a more mathematical font, the{{math}}template may be wrapped around any of these. E.g.
{{math|{{SubSup|x|a}}}}
givesxa{{math|{{SubSup|x|s=0|a}}}}
givesxa{{math|{{SubSup|x||3}}}}
givesx3{{math|{{SubSup|e||''u'' ln ''a''}}}}
giveseulna
Compatibility
The template has been tested under Windows XP SP3 using Firefox 3, Internet Explorer 7, Opera 9.5, and Safari 3.1. Combined subscripts and superscripts do not display properly when zooming the text with Internet Explorer 7.
Notes
- ^ A trueitalicfontis bothobliqueandcursive,i.e., the type is slanted and theglyphsare different from the upright font, resembling handwriting. This is the case with mostseriftypefaces.But mostsans-seriftypefaces simply slant the upright font, so that its “italic” font is properly just oblique. The distinction between oblique and true italic type is commonly ignored, so that “italic” is usually taken to mean simply the oblique font of the primary typeface. This template follows that convention.