Difference between revisions of "Template:Chem/sandbox"
imported>DePiep |
imported>DePiep (sync full source code) |
||
| Line 1: | Line 1: | ||
| − | + | <span class="chemf" style="white-space:nowrap;">{{chem/link | |
| − | | | + | |link={{{link|}}} |
| − | | | + | |{{#if:{{{2|}}}{{{3|}}} |
| − | | | + | |{{#ifeq:{{lc:{{{1}}}}}|{{#switch:{{{1|}}}|(|)|[|]|=X|{{{1}}}}} |
| − | | | + | |{{#ifeq:{{lc:{{{2}}}}}|{{#switch:{{{2|}}}|(|)|[|]|=X|{{{2}}}}} |
| − | | | + | |{{#ifexpr:{{#iferror:{{#expr:{{{1}}}}} |
| − | | | + | |1 |
| − | | | + | |{{#iferror:{{#expr:{{{2}}}}} |
| − | }}< | + | |0 |
| − | {{ | + | |{{{1}}}>{{{2}}} |
| − | + | }} | |
| − | < | + | }} |
| − | | | + | |{{su|w=70%|a=r|p={{{1}}}|b={{{2}}}}} |
| − | | | + | |{{su|w=70%|a=r|p={{{2}}}|b={{{1}}}}} |
| − | | | + | }}<!-- end #ifexpr:{{{1}}}>{{{2}}} --> |
| − | | | + | |{{su|w=70%|p={{{1}}}}}{{chem/atom|{{{2|}}}|{{{3|}}}|{{{4|}}}}} |
| − | </ | + | }}<!-- end #ifeq:{{lc:{{{2}}}}}|{{#switch:{{{2|}}}|(|)|[|]|=X|{{{2}}}}} --> |
| − | + | |{{chem/atom|{{{1|}}}|{{{2|}}}|{{{3|}}}}}{{chem/atom|{{{2|}}}|{{{3|}}}|{{{4|}}}}} | |
| − | + | }}{{#if: {{{3|}}} {{{4|}}}|{{chem/atom|{{{3|}}}|{{{4|}}}|{{{5|}}}}}<!-- | |
| − | + | -->{{#if: {{{4|}}} {{{5|}}}|{{chem/atom|{{{4|}}}|{{{5|}}}|{{{6|}}}}}<!-- | |
| − | :: | + | -->{{#if: {{{5|}}} {{{6|}}}|{{chem/atom|{{{5|}}}|{{{6|}}}|{{{7|}}}}}<!-- |
| − | + | -->{{#if: {{{6|}}} {{{7|}}}|{{chem/atom|{{{6|}}}|{{{7|}}}|{{{8|}}}}}<!-- | |
| − | }}</noinclude> | + | -->{{#if: {{{7|}}} {{{8|}}}|{{chem/atom|{{{7|}}}|{{{8|}}}|{{{9|}}}}}<!-- |
| + | -->{{#if: {{{8|}}} {{{9|}}}|{{chem/atom|{{{8|}}}|{{{9|}}}|{{{10|}}}}}<!-- | ||
| + | -->{{#if: {{{9|}}}{{{10|}}}|{{chem/atom|{{{9|}}}|{{{10|}}}|{{{11|}}}}}<!-- | ||
| + | -->{{#if:{{{10|}}}{{{11|}}}|{{chem/atom|{{{10|}}}|{{{11|}}}|{{{12|}}}}}<!-- | ||
| + | -->{{#if:{{{11|}}}{{{12|}}}|{{chem/atom|{{{11|}}}|{{{12|}}}|{{{13|}}}}}<!-- | ||
| + | -->{{#if:{{{12|}}}{{{13|}}}|{{chem/atom|{{{12|}}}|{{{13|}}}|{{{14|}}}}}<!-- | ||
| + | -->{{#if:{{{13|}}}{{{14|}}}|{{chem/atom|{{{13|}}}|{{{14|}}}|{{{15|}}}}}<!-- | ||
| + | -->{{#if:{{{14|}}}{{{15|}}}|{{chem/atom|{{{14|}}}|{{{15|}}}|{{{16|}}}}}<!-- | ||
| + | -->{{#if:{{{15|}}}{{{16|}}}|{{chem/atom|{{{15|}}}|{{{16|}}}|{{{17|}}}}}<!-- | ||
| + | -->{{#if:{{{16|}}}{{{17|}}}|{{chem/atom|{{{16|}}}|{{{17|}}}|{{{18|}}}}}<!-- | ||
| + | -->{{#if:{{{17|}}}{{{18|}}}|{{chem/atom|{{{17|}}}|{{{18|}}}|{{{19|}}}}}<!-- | ||
| + | -->{{#if:{{{18|}}}{{{19|}}}|{{chem/atom|{{{18|}}}|{{{19|}}}|{{{20|}}}}}<!-- | ||
| + | -->{{#if:{{{19|}}}{{{20|}}}|{{chem/atom|{{{19|}}}|{{{20|}}}|{{{21|}}}}}<!-- | ||
| + | -->{{#if:{{{20|}}}{{{21|}}}|{{chem/atom|{{{20|}}}|{{{21|}}}|{{{22|}}}}}<!-- | ||
| + | -->{{#if:{{{21|}}}{{{22|}}}|{{chem/atom|{{{21|}}}|{{{22|}}}|{{{23|}}}}}<!-- | ||
| + | -->{{#if:{{{22|}}}{{{23|}}}|{{chem/atom|{{{22|}}}|{{{23|}}}|{{{24|}}}}}<!-- | ||
| + | -->}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||
| + | |{{{1|}}} | ||
| + | }} | ||
| + | }}</span><noinclude>{{documentation}}</noinclude> | ||
Revision as of 14:37, 16 May 2015
| 50px | This is the template sandbox page for Template:Chem (diff). See also the companion subpage for test cases. |
| 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 allows you to render chemical formulas using HTML. Alternatively, you can use <chem>...</chem>, using mhchem LaTeX notation to generate formulas.
Contents
Template instructions
This template, {{chem}}, serves to simplify the writing of chemical formulas. For example,
{{chem|H|2|O}}
will yield:
- H
2O
Algebraic expression as subscript
Algebraic expressions are rendered as subscripts (but must not contain upper case letters).
{{chem|C|''n''|H|2''n'' + 2}}
gives
- C
nH
2n + 2
Charge
Ion charge superscripts (for: +/-) are also supported:
{{chem|H|3|O|+}}
yields a "+" as superscript:
- H
3O+
Simultaneous subscripts/superscripts are automatically handled (use a hyphen for the minus sign):
{{chem|SO|4|2-}}
gives "2-" as superscript:
- SO2−
4
The hyphen is converted to a true minus sign.
Atomic number and mass number
The first parameter can be used for mass number.
{{chem|4|He}}
gives:
- 4
He
The first two parameters can be used for mass number and atomic number.
{{chem|4|2|He}}
gives:
- 4
2He
- Note
- Only the first two parameters can handle two consecutive plain numbers (i.e. without a plus sign or a hyphen (
+or-) following). Otherwise the template will loop.
- See also {{Nuclide2}}
Linking
The optional parameter link changes the formula into a link. For example:
{{chem|link=water|H|2|O}}
will yield:
Individual elements can be linked in the following manner:
{{chem|[[Hydrogen|H]]|2|[[Oxygen|O]]}}
gives
Notes
- To include "=" in the formula, use "=" For example, "{{chem|CH|2|=CH|2}}" yields CH
2=CH
2.- Or, don't use this template. For example, "CH<sub>2</sub>=CH<sub>2</sub>" yields CH2=CH2.
- To include "≡" in the formula, use "≡" For example, "{{chem|HC≡CH}}" yields HC≡CH.
- The template accepts up to twenty parameters in addition to
link. - This template uses {{su}}.
See also
- {{Chemical formula}}, which auto-links elements and common compounds
- {{Chem2}}
- {{Chem molar mass}}
TemplateData
TemplateData for Chem
Template data
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Render chemical formulas using HTML. Alternatively, you can use <chem>...</chem>, using mhchem LaTeX notation to generate formulas. Up to 25 unnamed ordered parameters can be used with automatic detection of subscripts and superscripts.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The above documentation is transcluded from Template:Chem/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. Please add categories to the /doc subpage. Subpages of this template. |