Chemformula: Typeset Chemical Compounds and Reactions Clemens Niederberger
Chemformula: Typeset Chemical Compounds and Reactions Clemens Niederberger
v4.15e           2017/03/23
                       typeset chemical compounds and reactions
Clemens Niederberger
http://www.mychemistry.eu/forums/forum/chemformula/
contact@mychemistry.eu
                                             –
                                      − 2e
                                0     0              I       −I
                                                         +        –
                              2 Na + Cl2         2 Na + 2 Cl
                                                         –
                                                 + 2e
Table of Contents
1. Introduction                              2 7. Special Input Types                                  18
                                                  7.1. Single Token Groups . .             .   .   .   18
2. Licence and Requirements                  2         7.1.1. Addition Symbols             .   .   .   18
                                                       7.1.2. Symbols . . . . .            .   .   .   20
3. Setup                                     2    7.2. Option Input . . . . . . .          .   .   .   20
6. Compounds                                 7 9. Arrows                                               22
   6.1. Adducts . . . . . . . . . . . . .    7     9.1. Arrow types . . . . .      .   .   .   .   .   22
   6.2. Subscripts . . . . . . . . . . .     7     9.2. Labels . . . . . . . . .   .   .   .   .   .   24
   6.3. Commands . . . . . . . . . . .       8     9.3. Customization . . . .      .   .   .   .   .   25
   6.4. Charges and Other Superscripts       9     9.4. Modify Arrow Types         .   .   .   .   .   27
   6.5. Bonds . . . . . . . . . . . . . .   11     9.5. Standalone Arrows .        .   .   .   .   .   29
        6.5.1. Native Bonds . . . . .       11
        6.5.2. Flexible Bonds . . . . .     11 10. Names                                               29
   6.6. Customization . . . . . . . . .     13     10.1. Syntax . . . . . . . .    . . . . .           29
   6.7. Standalone Formulae . . . . .       17     10.2. Customization . . . .     . . . . .           30
   6.8. Extend Compound Properties          17     10.3. Standalone Names . .      . . . . .           30
                                                 1
                                           1. Introduction
  1. Introduction
  Probably every chemist using LATEX 2ε is aware of the great mhchem package by Martin Hensel.
  There have always been some difficulties intertwining it with the chemmacros package,
  though. Also, some other minor points in mhchem always bothered me, but they hardly
  seemed enough for a new package. They weren’t even enough for a feature request to the
  mhchem author. The challenge and the fun of creating a new package and the wish for a highly
  customizable alternative led to chemformula after all.
     chemformula works very similar to mhchem but is more strict as to how compounds,
  stoichiometric factors and arrows are input. In the same time chemformula offers many
  possibilities to customize the output.
  3. Setup
  If you’re using chemformula as a standalone package options are set up with the following
  command:
\setchemformula{ hoptionsi }
  Set up chemformula.
                                                  2
                                      4. The Basic Principle
\chemsetup[chemformula]{ hoptionsi }
  Set up options for chemformula exclusively, or
\chemsetup{chemformula/ hoption1i ,chemformula/ hoption2i }
  Set up options for chemformula together with others of chemmacros’ options.
                                                    H2O
   1   \ch{H2O} \par                                Sb2O3
   2   \ch{Sb2O3} \par                              H+
   3   \ch{H+} \par                                 CrO42–
       \ch{CrO4^2-} \par
   4
                                                    AgCl2–
   5   \ch{AgCl2-} \par
   6   \ch{[AgCl2]-} \par
                                                    [AgCl2]–
   7   \ch{Y^{99}+} \par                            Y99+
   8   \ch{Y^{99+}} \par                            Y99+
   9   \ch{H2_{(aq)}} \par                          H2(aq)
  10   \ch{NO3-} \par                               NO3–
  11   \ch{(NH4)2S} \par                            (NH4)2S
  12   \ch{^{227}_{90}Th+} \par                     227   +
                                                     90Th
  13   $V_{\ch{H2O}}$ \par
                                                    VH2O
  14   \ch{Ce^{IV}} \par
  15   \ch{KCr(SO4)2 * 12 H2O}
                                                    CeIV
                                                    KCr(SO4)2 · 12 H2O
     However, there are differences. The most notable one: chemformula distinguishes between
  different types of input. These different parts have to be separated with blanks:
\ch{part1 part2 part3 part4}
  A blank in the input never is a blank in the output. This role of the blank strictly holds and
  disregarding it can have unexpected results and even lead to errors.
     Another notable difference: chemformula tries to avoid math mode whenever possible:
                                                               a
   1   \ch{A + B ->[a] C} \par                      A+B         C
                                                            a
   2   \ce{A + B ->[a] C}                           A + B −−−→ C
                                                3
                                        5. Stoichiometric Factors
   This means that \ch{2H2O} is recognized as a single part, which in this case is recognized as
a compound.
This also means, that a part cannot contain a blank since this will automatically divide it into two
parts. If you need an extra blank in the output you need to use ~. However, since commands in
most cases gobble a space after them a input like \ch{\command ABC} will be treated as a single
part. If you want or need to divide them you need to add an empty group: \ch{\command{}
ABC}. The different input types are described in the following sections.
5. Stoichiometric Factors
A stoichiometric factor may only contain of numbers and the signs .,_/()
 1   \ch{2} \par
 2   \ch{12}
 3
                                                        2
 4   % decimals:
 5   \ch{.5} \par
                                                        12
 6   \ch{5,75}                                          0.5
 7                                                      5.75
                                                        3
 8   % fractions:                                       2
 9   \ch{3/2} \par                                      1 12
10   \ch{1_1/2}                                         (1/2)
11
12   % ``iupac'':
13   \ch{(1/2)}
     As you can see if you input decimal numbers a missing leading zero is added.
     You have to be a little bit careful with the right syntax but I believe it is rather intuitive.
  If stoichiometric factors are enclosed with parentheses the fractions are not recognized and
missing leading zeros are not added. What’s inside the parentheses is typeset as is.
                                                    4
                                                     5. Stoichiometric Factors
                  You can find many examples like the following for stoichiometric factors in parentheses in the
                  IUPAC Green Book [Coh+08]:
(1/5) KMnVII O4 + (8/5) HCl = (1/5) MnII Cl2 + (1/2) Cl2 + (1/5) KCl + (4/5) H2O
1 \ch[decimal-marker={,}]{3.5} \ch[decimal-marker={$\cdot$}]{3,5}
3,5 3·5
                    The option frac-style = {xfrac} uses the \sfrac command of the xfrac package. The
                  output strongly depends on the font you use.
                                                                 5
                                  5. Stoichiometric Factors
1 \ch[frac-style=xfrac]{3/2} \ch[frac-style=xfrac]{1_1/2}
3⁄2 11 ⁄ 2
chemformula defines the instance chemformula-text-frac which you can redefine to your
needs. See the xfrac documentation for further information. The default definition is this:
  1   \DeclareInstance{xfrac}{chemformula-text-frac}{text}
  2    {
  3      slash-left-kern = -.15em ,
  4      slash-right-kern = -.15em
  5    }
This document uses the font Linux Libertine O and the following definition:
  1   \DeclareInstance{xfrac}{chemformula-text-frac}{text}
  2    {
  3      scale-factor        = 1 ,
  4      denominator-bot-sep = -.2ex ,
  5      denominator-format = \scriptsize #1 ,
  6      numerator-top-sep   = -.2ex ,
  7      numerator-format    = \scriptsize #1 ,
  8      slash-right-kern    = .05em ,
  9      slash-left-kern     = .05em
 10    }
The option frac-style = {nicefrac} uses the \nicefrac command of the nicefrac package.
1 \ch[frac-style=nicefrac]{3/2} \ch[frac-style=nicefrac]{1_1/2}
3/2 11/2
  The option stoich-space allows you to customize the space between stoichiometric factor
and the group following after it.
                                             6
                                        6. Compounds
  6. Compounds
  chemformula determines compounds as the type that “doesn’t fit in anywhere else.” This
  point will become more clear when you know what the other types are.
  6.1. Adducts
  chemformula has two identifiers which will create adducts.
\ch{A.B}
  A·B
\ch{A*B}
  A·B
  Since numbers in a compound always are treated as subscripts (see section 6.2) you sometimes
  need to introduce stoichiometric factors for the right output:
  6.2. Subscripts
 All numbers in a compound are treated as subscripts.
                                               7
                                        6. Compounds
1 \ch{H2SO4} H2SO4
If you want a letter to be a subscript you can use the math syntax:
1 \ch{A_nB_m} AnBm
The subscript recognizes groups. You can also use math inside it.
1   \ch{A_{$n$}B_{$m$}} \par                      An Bm
2   \ch{NaCl_{(aq)}}                              NaCl(aq)
6.3. Commands
Commands are allowed in a compound:
    \ch{\textbf{A2}B3} \ch{A2\color{red}B
1
                                                  A2B3 A2B3
      3}
  However, if the commands demand numbers as argument, e. g., space commands or chem-
macros’ \ox command the direct use will fail. This is because the numbers are treated as
subscripts before the command expands.
                                              8
                                                          6. Compounds
                 For longer charge groups or other superscripts you can use the math syntax. It recognizes
               groups and you can use math inside them. Inside these groups neither + nor - are treated as
               bonds. If a dot . is inside a superscript it is treated as indicator for a radical. A * gives the
               excited state.
                                                                     Ax–
               1   \ch{A^{x-}} \par
               2   \ch{A^x-} \par
                                                                     Ax–
               3   \ch{A^{x}-} \par                                  Ax–
               4   \ch{A^{$x-$}} \par                                Ax –
               5   \ch{RNO2^{-.}} \par                               RNO2–
                                                                     3
               6   \ch{^31H} \par                                    1H
                   \ch{^{14}6C} \par                                 14
                                                                      6C
               7
               8   \ch{^{58}_{26}Fe} \par                            58
                                                                     26Fe
               9   \ch{NO^*}
                                                                     NO*
Changed in        Actually a dot . is not always treated as indicator for a radical: if the dot in the superscript is
version 4.5a   followed by a number it is interpreted as a decimal sign. It is typeset according to the option
               decimal-marker. This may be a good place to mention that a comma , in a superscript is also
               typeset according to decimal-marker.
               1   \ch{^{22,98}_{11}Na}
               2   \ch{^{22.98}_{11}Na}\par                          22.98  22.98
                                                                        11Na 11Na
               3   \setchemformula{decimal-marker={,}}               22,98  22,98
               4   \ch{^{22,98}_{11}Na}                                 11Na 11Na
               5   \ch{^{22.98}_{11}Na}
Ions and ion composites with more than one charge can be typeset quite as easy:
                                                                 9
                                           6. Compounds
  Charge Commands You don’t need to use \mch and related commands inside \ch. Indeed,
  you shouldn’t use them as they might mess with the subscript and superscript alignment. The
  chemmacros option circled is obeyed by \ch.
    1   \chemsetup[charges]{circled=all}
    2   \ch{H+ + OH- <=> H2O}
        H
         +
           + OH 
                –
                        H2O
chemformula knows the options circled and circletype also on its own.
    1   \setchemformula{circled=all}
    2   \ch{H+ + OH- <=> H2O}
        H
         +
           + OH 
                –
                        H2O
     These options are coupled with chemmacros options, i. e., setting chemmacros’ options
  will also set chemformula’s equivalents. The other way around the options act independently:
  setting chemformula’s options will not set chemmacros’ options.
circled = formal|all|none                                                   Default: formal
  chemformula uses two different kinds of charges which indicate the usage of real (+/−) and
  formal (
/
           + 
)
             – charges. The choice formal distinguishes between them, choice none displays
  them all without circle, choice all circles all.
                                                10
                                                 6. Compounds
          3 3 3       3 3
          3B 3 B 3B B B3
           23 23     23   23 23
          123B 123B 123B B B123
          123 123 123      123 123
           23B 23 B 23B B     B23
          • If a compound starts with a sub- or superscript both sub- and superscript are aligned to
            the right else to the left.
          • If a compound does not start with a sub- or superscript and there is both a sub- and a
            superscript, the superscript is shifted additionally by a length determined from the option
            charge-hshift = { hdimi }, also see page 13f.
  6.5. Bonds
  6.5.1. Native Bonds
  There are three kinds of what I will call “native bonds”:
The predefined bond types are shown in table 1 on the following page.
      1   \ch{C\bond{sb}C\bond{db}C\bond{tp}C\bond{deloc}C\bond{tdeloc}C\bond{co>}C\bond
            {<co}C}
                                                        11
                                                          6. Compounds
C C C C C C C C
                    1   \NewChemBond{single}
                    2     { \draw[chembond] (chemformula-bond-start) -- (chemformula-bond-end) ; }
                    3   \NewChemBond{coordright}
                                                                12
                                            6. Compounds
    4      {
    5          \draw[chembond,butt cap->]
    6            (chemformula-bond-start) -- (chemformula-bond-end) ;
    7      }
    8    \NewChemBondAlias{co>}{coordright}
  Two points are important: the names of the starting and the ending coordinates, chemformula-bond-start
  and chemformula-bond-end, and the TikZ style of the bonds chembond.
    So, let’s say you want to define a special kind of dashed bond. You could do this:
    1    \usetikzlibrary{decorations.pathreplacing}
    2    \makeatletter
    3    \NewChemBond{dashed}
    4      {
    5        \draw[
    6          chembond,
    7          decorate,
    8          decoration={
    9             ticks,
    10            segment length=\chemformula@bondlength/10,amplitude=1.5pt
    11         }]
    12         (chemformula-bond-start) -- (chemformula-bond-end) ;
    13     }
    14   \makeatother
    15   \setchemformula{bond-length=2ex}
    16   \ch{C\bond{dashed}C}
C C
    The last example showed you another macro: \chemformula@bondlength. It only exists so
  you can use it to access the bond length as set with bond-length directly.
  6.6. Customization
  These options allow you to customize the ouptut of the compounds:
subscript-vshift = { hdimi }                                                      Default: 0pt
  Extra vertical shift of the subscripts.
subscript-style = text|math                                                      Default: text
  Style that is used to typeset the subscripts.
charge-hshift = { hdimi }                                                       Default: .25em
  Shift of superscripts when following a subscript.
                                                  13
                                                              6. Compounds
Maybe you have noticed that charges of certain ions are shifted to the right.
                                                                     14
                                         6. Compounds
They are shifted if they follow a subscript which follows IUPAC recommendations [Coh+08,
p. 51]. The amount of the shift can be set with the option charge-hshift.
   Despite IUPAC’s recommendation chemformula does not make fully staggered arrange-
ments in the default setting as I find it hard to read in some cases and ugly in others. Since this
is a subjective decision chemformula not only let’s you define the absolute amount of the
shift but also provides a possibility for full staggered arrangements. For this you have to use
charge-hshift = {full}.
        C5H+11 SO2–
                 4
        C5H11+ SO42–
        C5H11+ SO4 2–
        C5H11+ SO42–
If you don’t want the charges to be typeset in text mode you can switch to math mode:
                                                15
                                       6. Compounds
      Mx+ SO42–
      Mx + SO42−
The option subscript-vshift can be used to adjust the vertical shift of the subscripts:
      H2SO4 Na3PO4
      H2SO4 Na3PO4
      H2SO4 Na3PO4
  You can choose the mode subscripts are typeset in the same way as it is possible for the
charges:
      AnBm H2SO4
      An Bm H2SO4
The option adduct-space sets the space left and right to the adduct symbol ·.
  1   \ch{Na3PO3*H2O} \par
  2   \setchemformula{adduct-space=.2em}
                                             16
                                                        6. Compounds
3 \ch{Na3PO3*H2O}
                        Na3PO3 · H2O
                        Na3PO3 · H2O
                    1   \setchemformula{bond-length=4mm}%
                    2   single: \ch{CH3-CH3} \par
                    3   double: \ch{CH2=CH2} \par
                    4   triple: \ch{CH+CH}
You can change the distance between bond and atom, too:
                        H H+N N+O O
                        H H+N N+O O
                                                                17
                                                      7. Special Input Types
                \RemoveChemCompoundProperty{ htokeni }
                  Removes htokeni from the compounds’ property list.
                    For example you can use
1 \NewChemCompoundProperty{\}{\slash}
                \ch{ - }  −
Introduced in     Creates the minus sign between compounds with space around it:
version 4.3a      \ch{M - H} M − H
                                                                18
                                                       7. Special Input Types
                  Addition symbols are surrounded with space which can be customized according to options
                  explained in a bit. There is also some penalty prohibiting a line break after them which also can
                  be customized with an option.
                    You can define/redefine your own addition symbols:
                    The space left and right of the plus and the minus sign and the signs themselves can be set
                  with the following options:
                                                                  19
                                                                7. Special Input Types
                  7.1.2. Symbols
                \ch{ v } ↓
                  Sign for precipitate: \ch{BaSO4 v} BaSO4↓
                \ch{ ^ } ↑
                  Sign for escaping gas3: \ch{H2 ^} H2↑
                  This, however, interrupts the input in your source and may mess with the spacing. That’s why
                  there is an alternative:
                \ch{ @{ hoptionsi } }
                  The options specified this way will be valid only until the next compound is set.
                                                                             20
                                            8. Escaped Input
  8. Escaped Input
  In some cases it may be desirable to prevent chemformula from parsing the input. This can
  be done in two ways.
  8.1. Text
  If you put something between " " or ' ' then the input will be treated as normal text, except
  that spaces are not allowed and have to be input with ~.
    1   \ch{"\ox{2,Ca}" O} \par
    2   \ch{"\ldots\," Na + "\ldots\," Cl2 -> "\ldots\," NaCl} \par
    3   \ch{'A~->~B'}
        CaII O
        . . . Na + . . . Cl2   . . . NaCl
        A -> B
                                                  21
                                               9. Arrows
  In many cases you won’t need to escape the input. But when you get into trouble when using a
  command inside \ch try hiding it.
  8.2. Math
  If you especially want to input math you just enclose it with $ $. This output is different from
  the escaped text as it is followed by a space. The reasoning behind this is that I assume math
  will mostly be used to replace stoichiometric factors.
\ch{ $ hescapedmathi $ }
  One of two possibilities to escape chemformula’s parsing into math mode.
\ch{ \( hescapedmathi \) }
  The second of two possibilities to escape chemformula’s parsing into math mode.
           2n Na + n Cl2     2n NaCl
           2n Na + n Cl2     2n NaCl
           A− > B
  9. Arrows
  9.1. Arrow types
  Arrows are input in the same intuitive way they are with mhchem. There are various different
  types:
                                                  22
                                                                9. Arrows
                ->
                     standard right arrow
                <-
                     standard left arrow
                -/>
                     does not react (right)
                </-
                     does not react (left)
                <->
                     resonance arrow
                <>
                     reaction in both directions
                ==      =
                     stoichiometric equation
                <=>
                     equilibrium arrow
                >=<
Introduced in        reversed equilibrium arrow
version 4.5
                <=>>
                     unbalanced equilibrium arrow to the right
                >=<<
Introduced in        reversed unbalanced equilibrium arrow to the right
version 4.5
                <<=>
                     unbalanced equilibrium arrow to the left
                >>=<
Introduced in        reversed unbalanced equilibrium arrow to the left
version 4.5
                <=o>
Introduced in        quasi equilibrium arrow
version 4.15
                <=o>>
Introduced in        unbalanced quasi equilibrium arrow to the right
version 4.15
                <<=o>
Introduced in        unbalanced quasi equilibrium arrow to the left
version 4.15
                <o>
                     isolobal arrow
                                                                   23
                                                              9. Arrows
                <==>
Introduced in     I’ve seen this one used. I’m not sure it actually has a meaning in chemical equations. If you
version 4.5       have some official reference for this arrow type please feel free to contact me.
                  All these arrows are drawn with TikZ.
                           H2 + Cl2    2 HCl
                                    2–
                           H2O + CO3       OH– + HCO3–
                           A      B
                           {[CH2 CH CH2]–       [CH2 CH CH2]–}
                           A      B
                           H+ + OH–      H2O
                           2 NO2     N2O4
                  9.2. Labels
                  The arrows take two optional arguments to label them.
                ->[ habovei ][ hbelowi ]
                  Add text above or under an arrow.
                                                                          a
                   1   \ch{A ->[a] B} \par                            A         B
                                                                          a
                   2   \ch{A ->[a][b] B} \par                         A   b ◦
                                                                              B
                   3   \ch{A ->[\SI{100}{\celsius}] B}                    100 C
                                                                      A             B
The label text can be parsed seperately from the arrow. The recipe is easy: leave blanks.
                                                                          H2O
                   1   \ch{A   ->[H2O] B} \par
                                                                      A             B
                                                                          H2O
                   2   \ch{A   ->[ H2O ] B} \par                      A             B
                   3   \ch{A   ->[ "\ox{2,Ca}" F2 ] B} \par
                                                                          CaII F2
                                                                      A             B
                   4   \ch{A   ->[ $\Delta$,~ [ H+ ]] B}                  ∆, [H+]
                                                                      A              B
                                                                 24
                                                             9. Arrows
                     If you leave the blanks chemformula treats the groups inside the square brackets as
                  seperated input types. The arrow reads its arguments afterwards. As you can see the arrows
                  “grow” with the length of the labels. What stays constant is the part that protrudes the labels.
                            a
                        A       B
                            ab
                        A        B
                            abc
                        A         B
                            abc abc
                        A             B
                                 OH
                        A                 B
                  9.3. Customization
                  These are the options which enable you to customize the arrows:
                                                                 25
                                                              9. Arrows
                                        x
                        standard: A y       B
                                    x
                        longer: A   y       B
                                    x
                        higher: A y B
                                                x
                        more balanced: A        y   B
                                                    x
                        labels further away: A      y     B
                                                              x
                        larger distance to compounds: A       y   B
                                             x
                        smaller labels: A y B
Introduced in        If you want to have different arrow tips there is an easy way to use existing arrow tips (as
version 4.7       defined by TikZ). chemformula uses three different arrow tips: cf, left cf and right cf.
                  If you want them to match those of chemfig [Tel15] for example you could do:
                    1   \pgfkeys{
                    2     cf /.tip = {CF@full} ,
                    3     left cf /.tip = {CF@half}
                    4   }
                  chemfig has no equivalent of right cf. This mechanism relies on TikZ version 3.0.0 and the
                  new arrows.meta library.
                                                                  26
                                                               9. Arrows
                \ShowChemArrow{ htypei }
                  Print out the current definition of the arrow type htypei.
                  htypei is the sequence of tokens that is replaced with the actual arrow code. For example the
                  basic arrow is defined via
                    1   \NewChemArrow{->}{
                    2     \draw[chemarrow,-cf] (cf_arrow_start) -- (cf_arrow_end) ;
                    3   }
                  In order to define arrows yourself you need to know the basics of TikZ.4 The predefined arrows
                  use the arrow tips cf, left cf and right cf. They also all except the net reaction arrow ==
                  use the TikZ-style chemarrow that you should use, too, if you want the option arrow-style to
                  have an effect.
                     There are some predefined coordinates you can and should use. For completeness’ sake the
                  arrow tips and the TikZ-style are also listed:
                (cf_arrow_start)
                  The beginning of the arrow.
                (cf_arrow_end)
                  The end of the arrow.
                (cf_arrow_mid)
                  The mid of the arrow.
                (cf_arrow_mid_start)
                  The beginning of the shorter arrow in types like <=>>.
                    4. Please see the pgfmanual for details.
                                                                  27
                                             9. Arrows
(cf_arrow_mid_end)
 The end of the shorter arrow in types like <=>>.
cf
 A double-sided arrow tip.
left cf
 A left-sided arrow tip.
right cf
 A right-sided arrow tip.
chemarrow
     chemformula’s TikZ-style that is applied to the arrows and set with arrow-style
       1   \NewChemArrow{.>}{
       2     \draw[chemarrow,-cf,dotted,red] (cf_arrow_start) -- (cf_arrow_end);
       3   }
       4   \NewChemArrow{n>}{
       5     \draw[chemarrow,-cf]
       6       (cf_arrow_start)
       7         .. controls ([yshift=3ex]cf_arrow_mid) ..
       8       (cf_arrow_end);
       9   }
      10   \ch{A .> B} \ch{A .>[a][b] B} \ch{A n> B}
                         a
           A      BA     b
                             BA       B
       1   \texttt{\ShowChemArrow{->}} \par
       2   \RenewChemArrow{->}{\draw[chemarrow,->,red] (cf_arrow_start) -- (cf_arrow_end)
             ;}
       3   \texttt{\ShowChemArrow{->}} \par
       4   \ch{A -> B}
           \draw [chemarrow,-cf](cf_arrow_start)--(cf_arrow_end);
           \draw [chemarrow,->,red] (cf_arrow_start) -- (cf_arrow_end) ;
           A      B
                                                 28
                                                              10. Names
This command is internally used for the arrows, too, when \ch is parsed.
                  10. Names
                  10.1. Syntax
                  chemformula has a built-in syntax to write text under a compound. In a way it works very
                  similar to the arrows.
1 \ch{!(ethanol)( CH3CH2OH )}
                         CH3CH2OH
                            ethanol
                  The same what’s true for the arrows arguments holds for these arguments: if you leave blanks
                  the different parts will be treated according to their input type before the text is set below the
                  formula.
                     1   \ch{!(water)(H2O)} \quad
                     2   \ch{!( "\textcolor{blue}{water}" )( H2O )} \quad
                     3   \ch{!( $2n-1$ )( H2O )} \quad
                     4   \ch{!( H2O )( H2O )} \quad
                     5   \ch{!(oxonium)( H3O+ )}
                                                                  29
                                                             10. Names
                  If for some reason you want to insert an exclamation mark without it creating a name you only
                  have to make sure it isn’t followed by parentheses.
                  10.2. Customization
                  chemformula provides two options to customize the output of the names:
                           H2SO4       B
                             acid
                           H2SO4       B
                            acid
                           H2SO4       B
                            N: acid
                            H2SO4       B
                           acid
                           1i )( htext 2i )
                \chname( htext
                  The command that is useed internally for placing htext 1i below of htext 2i.
                                                                 30
                                                        11. Format and Font
                     1   \newcommand*\sample{%
                     2     \ch{H2C-C+C-CH=CH+ + CrO4^2-
                     3         <=>[x][y]
                     4       2.5 Cl^{-.} + 3_1/2 Na*OH_{(aq)} + !(name)( A^n ) "\LaTeXe"}
                     5   }
                     6   \sample
                                                            x
                         H2C C C CH CH+ + CrO42–            y       2.5 Cl– + 3 21 Na · OH(aq) + An LATEX 2ε
                                                                                                    name
Now we’re going to change different aspects of the font a look what happens:
                                                                      x
                         Hallo H2C C C CH CH+ + CrO42–                y   2.5 Cl– + 3 21 Na · OH(aq) + An LATEX 2ε
                                                                                                               name
                                                            x
                    Hallo H2C C C CH CH+ + CrO42-           y   2.5 Cl- + 3 21 Na · OH(aq) + An LATEX 2ε
                                                                                                   name
                                                                      x
                    Hallo H2C C C CH CH+ + CrO42–                     y   2.5 Cl– + 3 12 Na · OH(aq) + An LATEX 2ε
                                                                                                             name
                                               +                x
                    Hallo H2C C C CH CH +          CrO42–       y
                                                                           –
                                                                      2.5 Cl +   3 21   Na · OH(aq) +    n A
                                                                                                        A L T X 2ε
                                                                                                                E
                                                                                                        name
                                                                     31
                                           11. Format and Font
     1   \definecolor{newblue}{rgb}{.1,.1,.5}
     2   \setchemformula{format=\color{newblue}\sffamily}
     3   \sffamily Hallo \sample \\
     4   \ttfamily Hallo \sample \normalfont \\
     5   \bfseries Hallo \sample \normalfont \\
     6   \itshape Hallo \sample
                                                         x
         Hallo H2C C C CH CH+ + CrO42–                   y    2.5 Cl– + 3 21 Na · OH(aq) + An LATEX 2ε
                                                                                                  name
                                                     x
    Hallo    H2C C C CH CH+ + CrO42–                 y       2.5 Cl– + 3 21 Na · OH(aq) + An LATEX 2ε
                                                                                              name
                                    +                x
    Hallo H2C C C CH CH +                 CrO42–     y
                                                                    –
                                                             2.5 Cl +       3 21   Na · OH(aq) + An LATEX 2ε
                                                                                               name
                                +                x
    Hallo H2C C C CH CH +               CrO42–   y
                                                                –
                                                         2.5 Cl +   3 12   Na · OH(aq) +    n A
                                                                                           A L T X 2ε
                                                                                                   E
                                                                                           name
You can also specifically change the fontfamily, fontseries and fontshape of the output.
     1   \setchemformula{font-series=bx}
     2   Hallo \sample \par
     3   \sffamily Hallo \sample \normalfont \par
     4   \setchemformula{font-family=lmss,font-series=m} Hallo \sample
     5     \normalfont \par
     6   \itshape Hallo \sample
                                                         x
         Hallo H2C C C CH CH+ + CrO42–                   y     2.5 Cl– + 3 12 Na · OH(aq) + An LATEX 2ε
                                                                                                   name
                                                         x
         Hallo H2C C C CH CH+ + CrO42–                   y     2.5 Cl– + 3 12 Na · OH(aq) + An LATEX 2ε
                                                                                                   name
                                                         x
         Hallo H2C C C CH CH+ + CrO42–                   y    2.5 Cl– + 3 12 Na · OH(aq) + An LATEX 2ε
                                                                                                    name
                                                     32
                                      12. Usage In Math Equations
                                                   x
         Hallo H2C C C CH CH+ + CrO42–             y      2.5 Cl– + 3 12 Na · OH(aq) + An LATEX 2ε
                                                                                      name
    If you’re using XELATEX or LuaLATEX and have loaded fontspec you have the possibilty to set
  the font with it:
or with options
Since this document is typeset with pdfLATEX the option cannot be demonstrated here.
     1   \begin{align}
     2     \ch{
     3        H2O & ->[a] H2SO4 \\
     4        Cl2 & ->[x][y] CH4
     5     }
     6   \end{align}
     7   \begin{align*}
     8   \ch{
     9       RNO2      &<=>[ + e- ] RNO2^{-.} \\
    10       RNO2^{-.} &<=>[ + e- ] RNO2^2-
    11   }
    12   \end{align*}
                                                   a
                                          H2O             H2SO4                                (1)
                                                   x
                                            Cl2    y      CH4                                  (2)
                                                   + e–
                                        RNO2                RNO2–
                                                   + e–
                                       RNO2–                RNO22–
                                                   33
                                         13. Usage with TikZ or pgfplots and externalization
                     If you should be using a formula that contains bonds or arrows inside of a tikzpicture that
                  is externalized you should locally enable it for chemformula, too:
                     1   \begin{tikzpicture}
                     2     \setchemformula{tikz-external-disable=false}
                     3     \begin{axis}[xlabel={\ch{2 H+ + 2 e- -> H2}}]
                     4       \addplot ... ;
                     5     \end{axis}
                     6   \end{tikzpicture}
                                             speci }{ hatomi }
                \chlewis[ hoptionsi ]{ helectron
                  Draws electrons around the hatomi according to helectron speci.
                     Electrons are specified by the angle to the horizontal in the couter-clockwise direction. The
                  default appearance is a pair of electrons drawn as a pair of dots. Other specifications can be
                  chosen. The specification follows the pattern hangleihseparatori. hanglei is a positiv or negativ
                  integer denoting the angle counter clockwise to the horizontal where the electrons should be
                  drawn. hseparatori is either a dot (., single electron), a colon (:, electron pair), a vertical line (|,
                  electron pair), an o (o, empty pair), or a comma (, default spec).
                                                                    34
                                          14. Lewis Formulae
   1   \chlewis{0:90|180.270}{O}
   2   \quad
   3   \chlewis{45,135}{O}                             O       O   Na
   4   \quad
   5   \chlewis{0o}{Na}
       1    \chlewis[lewis-default=.]{23,68,113,158,203,248,293,338}{X}
       2    \quad
       3    \chlewis{0,90,180,270}{X}
       4    \quad
       5    \chlewis[lewis-distance=1.25ex]{0,90,180,270}{X}
       6    \quad
       7    \chlewis[lewis-distance=.75ex,radical-radius=.5pt]{0,90,180,270}{X}
       8    \quad
       9    \chlewis[
       10     radical-radius=.5pt,
       11     lewis-default=.
       12   ]{23,68,113,158,203,248,293,338}{X}
X X X X X
                                                  35
                                                                    15. Kröger-Vink Notation
                       1   \ch{
                       2     !($1s^22s^1$)( "\chlewis{180.}{Li}" ) +
                       3     !($1s^22s^22p^5$)( "\chlewis{0.90,180,270}{F}" )
                       4      ->
                       5     !($1s^2$)( Li+ ) + !($1s^22s^22p^6$)( "\chlewis{0,90,180,270}{F}" {}- )
                       6   }
Li + F Li+ + F –
1s 2 2s 1 1s 2 2s 2 2p 5 1s 2 1s 2 2s 2 2p 6
                    With this option enabled several changes come into effect: ' produces a prime, a x in a
                  superscript produces ×, and both a . and a * produce a little filled circle. In the Kröger-Vink
                  notation a prime denotes a negative relative charge, the circle a positive relative charge, and
                  the cross denotes a neutral relative charge.
                   1   \setchemformula{kroeger-vink=true}
                   2   \ch{Al_{Al}^'}
                                                                                         0      0
                   3   \ch{Al_{Al}'}\par                                              AlAl  AlAl
                   4   \ch{Ni_{Cu}^{x}}\par                                           Ni×Cu
                   5   \ch{V_{Cl}^.}                                                  VCl VCl
                   6   \ch{V_{Cl}^*}\par
                                                                                      Cai
                   7   \ch{Ca_i^{..}}\par
                                                                                      e0
                   8   \ch{e^'}\par
                   9   \ch{Cl_i^'}
                                                                                      Cli0 Cli0
                  10   \ch{Cl_i'}\par                                                 Oi00 Oi00
                  11   \ch{O_i^{''}}
                  12   \ch{O_i''}
                                                                                 36
                                                       A. History Since Version 4.0
                  Version 4.1
                      • New option tikz-external-disable.
                      • New option frac-math-cmd.
                  Version 4.2
                      • New option arrow-style.
                      • New command \chlewis that allows to add Lewis electrons to an atom, see section 14.
                  Version 4.3
                      • New option stoich-print.
                      • New command \chstoich.
                      • The commands \DeclareChem h...i now don’t give an error any more if the command
                        already exists. This is more consistent with LATEX’s \DeclareRobustCommand. For all
                        those commands a version \NewChem h...i is introduced that does give an error if the new
                        command is already defined.
                  Version 4.4
                      • A single dash - in \ch is now treated as a minus sign. This is consistent with the behaviour
                        of a +.
                                                                   37
                               A. History Since Version 4.0
Version 4.5
   • New arrow types >=<, >=<<, >>=< and <==>.
   • Internal changes to \ch allow usage of optional arguments of \\ and \label in chem-
     macros’ reactions environment.
Version 4.6
   • New options circled and circletype. this allows to set the behaviour as described on
     chemmacros’ manual for a specific usage of \ch.
Version 4.7
   • Dependency change: chemformula now requires the TikZ library arrows.meta instead
     of the library arrows. This requires TikZ version 3.0.0.
Version 4.8
   • The chemformula package now is no longer part of the chemmacros bundle but is
     distributed as a package of it’s own.
Version 4.9
   • New options minus-space and minus-penalty equivalent to the existing plus-space
     and plus-penalty
Version 4.10
   • New macro set \NewChemCompoundProperty, see section 6.8 for a description.
Version 4.11
   • New macro set \NewChemAdditionSymbol, see section 7.1.1.
Version 4.12
   • Change package requirement: chemformula now not loads complete amsmath but
     only amstext.
                                           38
Version 4.13
       • Check for blank input parts and don’t process them.
• Drop support for \[ and \] as replacement for [ and ] inside arrow captions.
Version 4.14
       • New option adduct-penalty.
B. References
[Coh+08]             E. Richard Cohan et al.
                    “Quantities, Symbols and Units in Physical Chemistry”, IUPAC Green Book.
                    3rd Edition. 2nd Printing. IUPAC & RSC Publishing, Cambridge, 2008.
[Feu13]              Christian Feuersänger. pgfplots. version 1.9, Oct. 4, 2013 (or newer).
                     url: http://mirror.ctan.org/graphics/pgf/contrib/pgfplots/.
[Koh15]              Markus Kohm. KOMA - Script. version 3.18, July 2, 2015 (or newer).
                     url: http://mirror.ctan.org/macros/latex/contrib/koma-script/.
[L3Pa]               The LATEX3 Project Team. l3kernel. version SVN 6377, Jan. 19, 2016 (or newer).
                     url: http://mirror.ctan.org/macros/latex/contrib/l3kernel/.
[L3Pb]               The LATEX3 Project Team.
                     l3packages. version SVN 6377, Jan. 19, 2016 (or newer).
                     url: http://mirror.ctan.org/macros/latex/contrib/l3packages/.
[MS00]               Frank Mittelbach and Rainer Schöpf.
                     amstext. version 2.01, June 29, 2000 (or newer).
                     url: http://mirror.ctan.org/macros/latex/required/amstext/.
[Rei98]              Axel Reichert. nicefrac. version 0.9b, Aug. 4, 1998 (or newer).
                     url: http://mirror.ctan.org/macros/latex/contrib/units/.
[Tan13]              Till Tantau. TikZ/pgf. version 3.0.0, Dec. 13, 2013 (or newer).
                     url: http://mirror.ctan.org/graphics/pgf/.
[Tel15]              Christian Tellechea. chemfig. version 1.2c, Nov. 20, 2015 (or newer).
                     url: http://mirror.ctan.org/macros/generic/chemfig/.
C. Index
                                                                               39
                                                                                        INDEX
                                                                                             40
                                                                               INDEX
41