Template:Chem2/doc

From Telupedia
Revision as of 23:15, 17 July 2026 by Wikipedia>Scyrme (mentioning MOS:CHEMINDENT as this guideline is followed by chemistry articles but differs from the general guidance at MOS:INDENT)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

__EXPECTED_UNCONNECTED_PAGE__

{{chem2}} is a template used to format a chemical formula or equation.

When displaying a chemical equation on its own line, it should be indented using a colon (:) and not centered. (For further information, see MOS:CHEMINDENT.)

Use

Formula punctuation

Symbol Gives Example Output
\s {{chem2|CH3\sCH3}} CH3−CH3
\d = {{chem2|CH2\dCH2}} CH2=CH2
\t {{chem2|HC\tCH}} HC≡CH
\q {{chem2|[Cl4Re\qReCl4](2−)}} [Cl4Re≣ReCl4]2−
\- - <syntaxhighlight lang="tex" inline>A-B</syntaxhighlight> A-B
\\ \ <syntaxhighlight lang="tex" inline>C\D</syntaxhighlight> C\D
\h η <syntaxhighlight lang="tex" inline>η</syntaxhighlight> η
\h{1} η1- <syntaxhighlight lang="tex" inline>η1-</syntaxhighlight> η1-
\m{1} μ1- <syntaxhighlight lang="tex" inline>μ1-</syntaxhighlight> μ1-
-> {{chem2|2H2 + O2 -> 2H2O}} 2H2 + O2 → 2H2O
<-> {{chem2|K<->L}} K ⇌ L
* · {{chem2|CoCl2*6H2O}} CoCl2·6H2O
\* * <syntaxhighlight lang="tex" inline>Cp*2Fe</syntaxhighlight> Cp*2Fe
_{} subscript <syntaxhighlight lang="wikitext" inline>CnH2n+2</syntaxhighlight> CnH2n+2
^{} superscript {{chem2|^{13}CH4}} 13CH4
&nabla; <syntaxhighlight lang="wikitext" inline></syntaxhighlight>
( ) ( ) {{chem2|R\sCH(OH)CN}} R−CH(OH)CN

End }-bracket issue

When input ends correctly with a }-bracket, like with A_{x}H_{1-x}, the final }-brackets are technically mixed up:

{{chem2|A_{x}H_{1-x}}}AxH_{1x} Red XN

The closing bracket <syntaxhighlight lang="text" class="" style="" inline="1">}</syntaxhighlight> of input and end of template brackets <syntaxhighlight lang="text" class="" style="" inline="1">}}</syntaxhighlight> are interpreted by Wikipedia software in reversed order.

  • Solutions:
Empty pipe: {{chem2|...{...}|}} (empty parameter #2)
Parameters numbers 1 and 2 (empty): {{chem2|1=...{...}|2=}}
Space: {{chem2|...{...} }}
Nowiki tag: {{chem2|...{...}<nowiki/>}}
Escape the last set of brackets: {{chem2|A_{x}H_{{(}}1-x{{)}}}}
Result: {{chem2|A_{x}H_{1-x}|}}AxH1−x Green tickY

Formulas, charges, and equations

Formulas (without charge) are just written:

  • {{chem2|CH3(CH2)5CH3}}CH3(CH2)5CH3
  • {{chem2|Fe3S2(CO)9}}Fe3S2(CO)9
  • {{chem2|C_{''n''}H_{2''n''+2}|}}CnH2n+2

Charges are written inside parentheses:

  • {{chem2|SO4(2-)}}SO2−4
  • {{chem2|S19(2+)}}S2+19

Charges +1 and −1 can be written plain:

  • {{chem2|Na+}}Na+
  • {{chem2|O2-}}O2
same as {{chem2|O2(-)}}O2

Chemical equations:

  • {{chem2|2 S + 3 O2 + 2 H2O -> 2 H2SO4}}2 S + 3 O2 + 2 H2O → 2 H2SO4
  • {{chem2|2S + 3O2 + 2H2O -> 2H2SO4}}2S + 3O2 + 2H2O → 2H2SO4

The arrows can be written as -> or just . All characters (and unicode markup) are valid input except \, = (Mediawiki use it), _ and - (endash etc.)

  • {{chem2|2 H2(g) + O2(g) -> 2H2O(g)|}}2 H2(g) + O2(g) → 2H2O(g)
  • {{chem2|NH2RCHCO2H <-> NH3+RCHCO2-}}NH2RCHCO2H ⇌ NH+3RCHCO2

Hapticity and bridging ligands:

  • {{chem2|(\h{5}Cp)FeCO(\m{2}CO)FeCO(\h{5}Cp)}}5-Cp)FeCO(μ2-CO)FeCO(η5-Cp)
  • {{chem2|(\h{5}Cp)FeCO(\m{2}CO)FeCO(\h{5}Cp)|auto=yes}}(η5-Cp)FeCO2-CO)FeCO(η5-Cp)

Wikilinks

As of March 2023, {{chem2}} should not be used inside wikilinks; this can cause erratic failures to properly render sub/superscripts in other invocations on the same page. Instead, use the following options.

Whole formula link

Link the whole formula with <syntaxhighlight lang="wikitext" inline style="display: none;" />|link=<wiki pagename>:

  • {{chem2|FeCl3|link=Iron(III) chloride}}FeCl3

Or use wikilink brackets in input like [[ammonia|NH3]]:

  • <syntaxhighlight inline="1" lang="wikitext">{{chem2|3H2 + 2N2 <-> 2NH3}}</syntaxhighlight> → 3H2 + 2N2 ⇌ 2NH3

Link each element (C, Hg) and generic element code (R, X)

Use <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes to link from the first occurrence of each element symbol, and some functional-group symbols such as Ph

  • {{chem2|CH3CH2CH3CBrFCIClCH3|auto=yes}}CH3CH2CH3CBrFCIClCH3

Link functional groups

Some common groups are recognized and linked if you wikilink them using [[ ]]

  • <syntaxhighlight inline="1" lang="wikitext">{{chem2|R\-COOH}}</syntaxhighlight> → R-COOH
  • <syntaxhighlight inline="1" lang="wikitext">{{chem2|CH3CR2I}}</syntaxhighlight> → CH3CR2I
  • In particular H2O links to water of crystallization in <syntaxhighlight inline="1" lang="wikitext">{{chem2|CuSO4 * 5 H2O}}</syntaxhighlight> → CuSO4 · 5 H2O, because a link to water is generally unnecessary.

You can link to any article even if chem2 is unaware of it:

To change the default link:

  • {{chem2|[[water|H2O]]}}H2O

All recognised symbols and codes

Examples and tests

(The first "→" in each example is not part of the output; it separates the example from its output.)

  • {{chem2|[Cl4Re\qReCl4](2-)|}}[Cl4Re≣ReCl4]2−
  • {{chem2|NH2RCHCO2H <-> NH3+RCHCO2−}}NH2RCHCO2H ⇌ NH+3RCHCO2

  • {{chem2|\\hallo}}\hallo
  • {{chem2|H3CC\tCH <-> H2C\dC\dCH2}}H3CC≡CH ⇌ H2C=C=CH2
  • {{chem2|4 NH3 + 5 O2 -> 4 NO + 6 H2O}}4 NH3 + 5 O2 → 4 NO + 6 H2O

  • {{chem2|H2O &#8594; H2O}}H2O → H2O
  • {{chem2|H2O(l) -> H2O(g)}}H2O(l) → H2O(g)

  • {{chem2|4 NH3 + 5 O2 → 4 NO + 6 H2O}}4 NH3 + 5 O2 → 4 NO + 6 H2O
  • {{chem2|4NH3 + 5O2 → 4NO + 6H2O}}4NH3 + 5O2 → 4NO + 6H2O
  • {{chem2|2Mn2(+)}}2Mn+2
  • {{chem2|2Mn2(+) + 3H2O}}2Mn+2 + 3H2O
  • {{chem2|Mn–}}Mn

  • {{chem2|Mn2(2-)}}Mn2−2
  • {{chem2|Mn2☃+}}Mn2+;
  • {{chem2|Mn2(2☃–)}}Mn2(2)
  • {{chem2|Mn2(+)}}Mn+2
  • {{chem2|Mn2+}}Mn+2
  • {{chem2|Mn2(-)}}Mn2
  • {{chem2|Mn2-}}Mn2

  • <syntaxhighlight inline="1" lang="wikitext">{{chem2|C_{n}H_{2n + 2}|}}</syntaxhighlight> → CnH2n + 2
  • (chem: <syntaxhighlight inline="1" lang="wikitext">{{chem|C|n|H|2n + 2}}</syntaxhighlight> → C
    n
    H
    2n + 2
  • {{chem2|C_{abc}|}}Cabc
  • {{chem2|CoCl2*1.5H2O}}CoCl2·1.5H2O
  • {{chem2|Cu2C2*H2O}}Cu2C2·H2O

Special

  • {{chem2|[Me2Al(\m{2}Me)]2}}[Me2Al(μ2-Me)]2
  • {{chem2|^{13}CO2}}13CO2
  • {{chem2|^{13}CO2|auto=yes}}13CO2
  • {{chem2|\h{5}(C5H5)2TiCl2}}η5-(C5H5)2TiCl2
  • (bad) {{chem2|\h{5}\s(C5H5)2TiCl2}}η5-−(C5H5)2TiCl2
  • {{chem2|CH2\dCH2\sCH2\sC\tCH\qMn}}CH2=CH2−CH2−C≡CH≣Mn

  • {{chem2|RC(OR')3}}RC(OR')3
  • {{chem2|C\\C}}C\C
  • {{chem2|C2*NH3}}C2·NH3
  • {{chem2|C2*2NH3}}C2·2NH3
  • {{chem2|C1.2H3.5}}C1.2H3.5

  • {{chem2|\b\bAbC\e\e}}AbC
  • {{chem2|C2(μ\-C)}}C2(μ-C)

  • {{chem2|SO4(2-)}}SO2−4
  • {{chem2|2Mn2(2+)}}2Mn2+2
  • {{chem2|CH3-CH2-OH}}CH3CH2OH
  • {{chem2|[ZnCl4]-}}[ZnCl4]
  • {{chem2|[ZnCl4](2-)}}[ZnCl4]2−
  • {{chem2|((H2O)5{CoCl2})2|auto=yes}}((H2O)5{CoCl2})2
  • {{chem2|Si(OH)4}}Si(OH)4

  • {{chem2|Cu2C2*H2O|auto=yes}}Cu2C2·H2O
  • {{chem2|Cu2C2*2H2O}}Cu2C2·2H2O
  • {{chem2|CuSO*2H2O}}CuSO·2H2O
  • {{chem2|CuSO4*15H2O}}CuSO4·15H2O
  • {{chem2|CuSO4(H2O)5}}CuSO4(H2O)5
  • {{chem2|H+ + OH- → H2O}}H+ + OH → H2O
  • {{chem2|H → O}}H → O

  • {{chem2|ZxPo4}}ZxPo4     Unknown element.
  • {{chem2|((Na)Cl}}((Na)Cl     Too many "(".
  • {{chem2|Si(OH))4}}Si(OH))4     Too many ")".
  • {{chem2|Si&[[☃]]Si}}Si&Si
  • {{chem2|1=CH2=CH2}}CH2=CH2

More

  • {{chem2|Cl2O6|link=dichlorine hexoxide}}Cl2O6
  • {{chem2|[Fe(Phen)(Phen)3](2+)}}[Fe(Phen)(Phen)3]2+
  • {{chem2|[Fe(Phen)(Phen)3](2+)|auto=yes}}[Fe(Phen)(Phen)3]2+
  • {{chem2|[C2O2](2+)}}[C2O2]2+
  • {{chem2|SI4|link=Tomato}}SI4
  • {{chem2|H2SO4+}}H2SO+4
  • {{chem2|Mn-}}Mn
  • {{chem2|Mn22+}}Mn+22, {{chem2|Mn22-}}Mn22
  • {{chem2|Mn(2+)}}Mn2+
  • {{chem2|Mn2(+)}}Mn+2
  • {{chem2|Mn(22-)}}Mn22−
  • {{chem2|Mn3(22-)}}Mn22−3
  • {{chem2|Mn(22+)}}Mn22+
  • {{chem2|Mn2(22+)}}Mn22+2
  • {{chem2|Mn2(2+)}}Mn2+2
  • {{chem2|Mn22(2+)}}Mn2+22

Chem vs. chem2

  • {{chem|(CH|3|)|2|CO}}(CH
    3
    )
    2
    CO
  • {{chem2|(CH3)2CO}}(CH3)2CO
  • {{chem|H|2|+}}H+
    2
  • {{chem2|H2+}}H+2

Predefined codes (groups etc.)

Predefined codes
code target article {{chem2|code}} type note
A. Groups etc with element-like names
Bz Benzoyl group Bz A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
Et Ethyl group Et A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
Ln Lanthanide Ln A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
Nu Nucleophile Nu A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
Ph Phenyl group Ph A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
R Substituent R A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
T Tritium T A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
Tf Trifluoromethylsulfonyl group Tf A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
X Halogen X A: wl <syntaxhighlight lang="wikitext" inline style="display: none;" />|auto=yes
B. Groups which are redirected from their normal target if wikilinked; never autolinked.
CH3 Methyl group CH3 B: wl |..[[code]]..
CO3 Carbonate CO3 B: wl |..[[code]]..
COOH Carboxyl group COOH B: wl |..[[code]]..
ClO Hypochlorite ClO B: wl |..[[code]]..
ClO2 Chlorite ClO2 B: wl |..[[code]]..
ClO3 Chlorate ClO3 B: wl |..[[code]]..
ClO4 Perchlorate ClO4 B: wl |..[[code]]..
H2O Water of crystallization H2O B: wl |..[[code]]..
H3O Hydronium H3O B: wl |..[[code]]..
NH2 Amine group NH2 B: wl |..[[code]]..
NH4 Ammonium NH4 B: wl |..[[code]]..
NO3 Nitrate NO3 B: wl |..[[code]]..
PO3 Phosphite PO3 B: wl |..[[code]]..
PO4 Phosphate PO4 B: wl |..[[code]]..
SH Thiol group SH B: wl |..[[code]]..
SO3 Sulfite SO3 B: wl |..[[code]]..
SO4 Sulfate SO4 B: wl |..[[code]]..
SeH Selenol group SeH B: wl |..[[code]]..

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Chem2 in articles based on its TemplateData.

TemplateData for Chem2

Formats a chemical formula or equation using mhchem code. See template documentation for details on how it works.

Template parameters

ParameterDescriptionTypeStatus
Formula1

The chemical formula or equation in mhchem, which can also be hyperlinked manually. See template documentation for how this works.

Example
5HS- + 8NO3- + 3H+ -> 5SO4(2-) + 4N2 + 4H2O + 40e-
Stringsuggested
Autolinked?auto

Hyperlink every first instance of chemical elements, functional groups, and other generic element codes.

Default
no
Booleanoptional
Whole formula linklink

Hyperlink the entire formula or equation to a given article page.

Page nameoptional

Tracking

See also