summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/chemformula/chemformula-manual.tex
blob: 6ceb89003d8ea85575e83bb818c74f2aa2b68fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
% !arara: pdflatex
% !arara: biber
% arara: pdflatex
% arara: pdflatex
% --------------------------------------------------------------------------
% the CHEMFORMULA package
%
%   typeset chemical compounds and reactions
%
% --------------------------------------------------------------------------
% Clemens Niederberger
% --------------------------------------------------------------------------
% https://github.com/cgnieder/chemformula/
% contact@mychemistry.eu
% --------------------------------------------------------------------------
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
% Copyright 2011--2020 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\documentclass{chemformula-manual}

\addbibresource{cnltx.bib}

\chemsetup{
  greek = newtx ,
  modules = {redox,reactions,units} ,
  formula = chemformula ,
  chemformula/format = \libertineLF
}

\usepackage[accsupp]{acro}
\acsetup{
  long-format  = \scshape ,
  short-format = \scshape
}
\DeclareAcronym{iupac}{
  short     = iupac ,
  long      = International Union of Pure and Applied Chemistry ,
  pdfstring = IUPAC ,
  accsupp   = IUPAC
}

\sisetup{
  detect-mode=false,
  mode=text,
  text-rm=\libertineLF
}

\usepackage{filecontents}

\defbibheading{bibliography}{\section{References}}
\addbibresource{\jobname.bib}
\begin{filecontents*}{\jobname.bib}
@book{iupac:greenbook,
  author    = {E. Richard Cohan and Tomislav Cvita\v{s} and Jeremy G. Frey and
    Bertil Holmstr\"om and Kozo Kuchitsu and Roberto Marquardt and Ian Mills and
    Franco Pavese and Martin Quack and J\"urgen Stohner and Herbert L. Strauss and
    Michio Takami and Anders J Thor} ,
  title     = {``Quantities, Symbols and Units in Physical Chemistry'', \acs{iupac}
    Green Book} ,
  sorttitle = {Quantities, Symbols and Units in Physical Chemistry} ,
  indexsorttitle = {Quantities, Symbols and Units in Physical Chemistry} ,
  edition   = {3rd Edition. 2nd Printing} ,
  year      = {2008} ,
  publisher = {\acs{iupac} \&\ RSC Publishing, Cambridge}
}
\end{filecontents*}

\DeclareInstance{xfrac}{chemformula-text-frac}{text}
  {
    scale-factor        = 1 ,
    denominator-bot-sep = -.2ex ,
    denominator-format  = \scriptsize #1 ,
    numerator-top-sep   = -.2ex ,
    numerator-format    = \scriptsize #1 ,
    slash-right-kern    = .05em ,
    slash-left-kern     = .05em
  }

\newpackagename\chemmacros{chemmacros}

\newidxcmd\manual{\textsf{#1}}[\ (manual)]
\newidxcmd\arrowtype{\code{#1}}[\ (arrow type)]

\makeatletter
\newcommand*\cf@arrow{%
  \@ifstar
    {\cf@arrow@star}
    {\cf@arrow@nostar}%
}
\newrobustcmd*\cf@arrow@star[1]{%
  \@ifnextchar[
    {\cf@arrow@star@opt{#1}}
    {\cf@arrow@star@opt{#1}[]}%
}
\newrobustcmd*\cf@arrow@nostar[1]{%
  \@ifnextchar[
    {\cf@arrow@nostar@opt{#1}}
    {\cf@arrow@nostar@opt{#1}[]}%
}
\def\cf@arrow@star@opt#1[#2]{%
  \ifblank{#2}
    {\item\arrowtype*{#1}}
    {\item\arrowtype*{#1}#2}%
  \cnltx@checkdefault{\hfill\newline}%
}
\def\cf@arrow@nostar@opt#1[#2]{%
  \ifblank{#2}
    {\item\arrowtype{#1}}
    {\item\arrowtype{#1}#2}%
  \cnltx@checkdefault{\hfill\newline}%
}

\newenvironment{codedesc}
  {%
    \def\Code##1{\item\code{##1}\hfill\newline}%
    \cnltxlist
  }
  {\endcnltxlist}

\newenvironment{arrows}
  {%
    \let\arrow\cf@arrow
    \cnltxlist
  }
  {\endcnltxlist}
\makeatother

\renewcommand*\AmS{\hologo{AmS}}

\newcommand*\TikZ{Ti\textit{k}Z}

\newname\hensel{Martin Hensel}

\begin{document}

\section{Introduction}
Probably every chemist using \LaTeXe\ is aware of the great \pkg{mhchem}
package by \hensel.  There have always been some difficulties intertwining it
with the \chemmacros\ package, though.  Also, some other minor points in
\pkg{mhchem} always bothered me, but they hardly seemed enough for a new
package.  They weren't even enough for a feature request to the \pkg{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 \pkg{mhchem} but is more strict as to how
compounds, stoichiometric factors and arrows are input.  In the same time
\chemformula\ offers \emph{many} possibilities to customize the output.

\section{Licence and Requirements}
\license

The \chemformula\ package needs and thus loads the packages
\bnd{l3kernel}~\cite{bnd:l3kernel}, \pkg{xparse}, \pkg{l3keys2e} and
\pkg{xfrac} (all three are part of the \bnd{l3packages}
bundle~\cite{bnd:l3packages}),
\pkg{tikz}\footnote{\CTANurl[graphics]{pgf}}~\cite{pkg:pgf},
\pkg{amstext}~\cite{pkg:amstext}, \pkg{nicefrac}~\cite{pkg:nicefrac} and
\pkg{scrlfile} (from the \KOMAScript\footnote{\CTANurl{koma-script}}
bundle~\cite{bnd:koma-script}).

\section{Setup}

If you're using \chemformula\ as a standalone package options are set up with
the following command:
\begin{commands}
  \command{setchemformula}[\marg{options}]
    Set up \chemformula.
\end{commands}

\chemformula\ is tightly intertwined with the \chemmacros\ package.  If both
packages are loaded together, \chemformula\ is integrated into the
\chemmacros\ package.  Then all of \chemformula's options belong to
\chemmacros' module \module{chemformula}.  This means if you load it via
\chemmacros\ or in addition to \chemmacros\ they can be setup with
\begin{commands}
  \command{chemsetup}[\Oarg{chemformula}\marg{options}]
    Set up options for \chemformula\ exclusively, or
  \command{chemsetup}[\Marg{chemformula/\meta{option1},chemformula/\meta{option2}}]
    Set up options for \chemformula\ together with others of \chemmacros'
    options.
\end{commands}

\section{The Basic Principle}
\chemformula\ offers one main command.
\begin{commands}
  \command{ch}[\oarg{options}\marg{input}]
    \chemformula's main command.
\end{commands}
The usage will seem very familiar to you if you're familiar with \pkg{mhchem}:
\begin{example}[side-by-side]
  \ch{H2O} \par
  \ch{Sb2O3} \par
  \ch{H+} \par
  \ch{CrO4^2-} \par
  \ch{AgCl2-} \par
  \ch{[AgCl2]-} \par
  \ch{Y^{99}+} \par
  \ch{Y^{99+}} \par
  \ch{H2_{(aq)}} \par
  \ch{NO3-} \par
  \ch{(NH4)2S} \par
  \ch{^{227}_{90}Th+} \par
  $V_{\ch{H2O}}$ \par
  \ch{Ce^{IV}} \par
  \ch{KCr(SO4)2 * 12 H2O}
\end{example}

However, there are differences.  The most notable one: \chemformula\
distinguishes between different types of input.  These different parts
\emph{have} to be separated with blanks:
\begin{commands}
  \command{ch}[\Marg{part1 part2 part3 part4}]
\end{commands}
A blank in the input \emph{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.

The most visible differences regard spacing and the shapes of the default
arrows:
\begin{example}[side-by-side]
  \ch{A + B ->[a] C} \par
  \ce{A + B ->[a] C}
\end{example}

This means that \cs{ch}\Marg{2H2O} is recognized as a \emph{single} part,
which in this case is recognized as a compound.
\begin{example}[side-by-side]
  \ch{2H2O} \par
  \ch{2 H2O}
\end{example}
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 \verbcode+~+ or \cs*{~}.  However, since commands
in most cases gobble a space after them a input like
\cs{ch}\Marg{\cs*{command} ABC} will be treated as a single part.  If you want
or need to divide them you need to add an empty group:
\cs{ch}\Marg{\cs*{command}\marg{} ABC}.  The different input types are
described in the following sections.

\section{Stoichiometric Factors}
A stoichiometric factor may only contain of numbers and the signs
\verbcode+.,_/()+
\begin{example}[side-by-side]
  \ch{2} \par
  \ch{12}

  % decimals:
  \ch{.5} \par
  \ch{5,75}

  % fractions:
  \ch{3/2} \par
  \ch{1_1/2}
 
  % ``iupac'':
  \ch{(1/2)}
\end{example}

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.
\begin{sourcecode}
  this won't work but will result in an error: \ch{1/1_1}
\end{sourcecode}

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.
\begin{example}
  \ch{(1/2) H2O} \ch{1/2 H2O} \ch{0.5 H2O}
\end{example}
You can find many examples like the following for stoichiometric factors in
parentheses in the \acs{iupac} Green Book~\cite{iupac:greenbook}:
\begin{reaction*}
 (1/5) K "\ox{7,Mn}" O4 + (8/5) HCl == (1/5) "\ox{2,Mn}" Cl2 + (1/2) Cl2 + (1/5) KCl + (4/5) H2O
\end{reaction*}

There are a few possibilities to customize the output.
\begin{options}
  \keyval{decimal-marker}{marker}\Default{.}
    The symbol to indicate the decimal.
  \keychoice{frac-style}{math,xfrac,nicefrac}\Default{math}
    Determines how fractions are displayed.
  \keyval{frac-math-cmd}{command sequence}\Default{\cs*{frac}}
    \sinceversion{4.1}Allows you to choose which command is used with
    \keyis{frac-style}{math}.  This needs to be a command sequence that takes
    two arguments that are set in math mode.
  \keyval{stoich-space}{skip}\Default{.1667em plus .0333em minus .0117em}
    The space that is placed after the stoichiometric factor.  A rubber
    length.
  \keybool{stoich-paren-parse}\Default{false}
    If set to true stoichiometric factors enclosed by parentheses also are
    parsed.
  \keyval{stoich-print}{cs}\Default{\cs{chstoich}}
    This option allows to redefine the macro that prints the stoichiometric
    factors.  \meta{cs} should be a macro that takes one mandatory argument.
    \emph{Please note that using this option will disable \chemformula's
      stoichiometric parsing as that is done by the default command
      \cs{chstoich}.}
\end{options}

\begin{example}
  \ch[decimal-marker={,}]{3.5} \ch[decimal-marker={$\cdot$}]{3,5} 
\end{example}

The option \keyis{frac-style}{xfrac} uses the \cs*{sfrac} command of the
\pkg{xfrac} package.  The output strongly depends on the font you use.
\begin{example}
  \ch[frac-style=xfrac]{3/2} \ch[frac-style=xfrac]{1_1/2}
\end{example}
\chemformula\ defines the instance \code{chemformula-text-frac} which you can
redefine to your needs.  See the \pkg{xfrac} documentation for further
information.  The default definition is this:
\begin{sourcecode}
  \DeclareInstance{xfrac}{chemformula-text-frac}{text}
   {
     slash-left-kern  = -.15em ,
     slash-right-kern = -.15em
   }
\end{sourcecode}
This document uses the font Linux Libertine~O and the following definition:
\begin{sourcecode}
  \DeclareInstance{xfrac}{chemformula-text-frac}{text}
   {
     scale-factor        = 1 ,
     denominator-bot-sep = -.2ex ,
     denominator-format  = \scriptsize #1 ,
     numerator-top-sep   = -.2ex ,
     numerator-format    = \scriptsize #1 ,
     slash-right-kern    = .05em ,
     slash-left-kern     = .05em
   }
\end{sourcecode}

The option \keyis{frac-style}{nicefrac} uses the \cs*{nicefrac} command of the
\pkg{nicefrac} package.
\begin{example}
  \ch[frac-style=nicefrac]{3/2} \ch[frac-style=nicefrac]{1_1/2}
\end{example}

The option \option{stoich-space} allows you to customize the space between
stoichiometric factor and the group following after it.
\begin{example}[side-by-side]
  \ch{2 H2O} \par
  \ch[stoich-space=.3em]{2 H2O}
\end{example}

\section{Compounds}\label{ssec: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.
\begin{example}[side-by-side]
  \ch{H2SO4} \par
  \ch{[Cu(NH3)4]^2+}
\end{example}

\subsection{Adducts}
\chemformula\ has two identifiers which will create adducts.
\begin{commands}
  \command{ch}[\Marg{A.B}] \ch{A.B}
  \command{ch}[\Marg{A*B}] \ch{A*B}
\end{commands}
\begin{example}[side-by-side]
  \ch{CaSO4.H2O} \par
  \ch{CaSO4*H2O}
\end{example}
Since numbers in a compound always are treated as subscripts (see
section~\ref{ssec:subscripts}) you sometimes need to introduce stoichiometric
factors for the right output:
\begin{example}[side-by-side]
  \ch{Na3PO4*12H2O} \par
  \ch{Na3PO4* 12 H2O} \par
  \ch{Na3PO4 * 12 H2O}
\end{example}

\subsection{Subscripts}\label{ssec:subscripts}
\emph{All} numbers in a compound are treated as subscripts.
\begin{example}[side-by-side]
  \ch{H2SO4}
\end{example}
If you want a letter to be a subscript you can use the math syntax:
\begin{example}[side-by-side]
  \ch{A_nB_m}
\end{example}
The subscript recognizes groups. You can also use math inside it.
\begin{example}[side-by-side]
  \ch{A_{$n$}B_{$m$}} \par
  \ch{NaCl_{(aq)}}
\end{example}

\subsection{Commands}
Commands are allowed in a compound:
\begin{example}[side-by-side]
  \ch{\textbf{A2}B3} \ch{A2\color{red}B3}
\end{example}

However, if the commands demand numbers as argument, \eg, space commands or
\chemmacros' \verbcode+\ox+ command the direct use will fail.  This is
because the numbers are treated as subscripts \emph{before} the command
expands.
\begin{sourcecode}
  \ch{A\hspace{2mm}B} will raise an error because \hspace sees something like
  this: \hspace{$_2$mm}. Actually not at all like this but equally bad\ldots
\end{sourcecode}
See section~\ref{ssec:text} for a way around this.

Please also note that formulas are placed inside a group!
\begin{example}[side-by-side]
  \ch{A2\color{red}B3 C4}
\end{example}

\subsection{Charges and Other Superscripts}
\paragraph{Basics}
If a compound \emph{ends} with a plus or minus sign it will be treated as
charge sign and typeset as superscript.  In other places a plus is treated as
a triple bond and a dash will be used as a single bond, see
section~\ref{ssec:bonds}.
\begin{example}[side-by-side]
  \ch{A+B} \ch{AB+} \par
  \ch{A-B} \ch{AB-}
\end{example}

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 \code{+} nor \code{-} are treated as bonds.  If a dot \code{.} is
inside a superscript it is treated as indicator for a radical.  A \code{*}
gives the excited state.
\begin{example}[side-by-side]
  \ch{A^{x-}} \par
  \ch{A^x-} \par
  \ch{A^{x}-} \par
  \ch{A^{$x-$}} \par
  \ch{RNO2^{-.}} \par
  \ch{^31H} \par
  \ch{^{14}6C} \par
  \ch{^{58}_{26}Fe} \par
  \ch{NO^*}
\end{example}

Actually\changedversion{4.5a} a dot \code{.} is not always treated as
indicator for a radical: if the dot in the superscript is followed by a number
it is interpreted as a decimal sign.  It is typeset according to the option
\option{decimal-marker}.  This may be a good place to mention that a comma
\code{,} in a superscript is also typeset according to
\option{decimal-marker}.

\begin{example}[side-by-side]
  \ch{^{22,98}_{11}Na}
  \ch{^{22.98}_{11}Na}\par
  \setchemformula{decimal-marker={,}}
  \ch{^{22,98}_{11}Na}
  \ch{^{22.98}_{11}Na}
\end{example}

Ions and ion composites with more than one charge can be typeset quite as
easy:
\begin{example}[side-by-side]
  \ch{SO4^2-} \ch{Ca^2+ SO4^2-}
\end{example}

\paragraph{Charge Commands}
You don't need to use \cs{mch} and related commands inside \cs{ch}.  Indeed,
you \emph{shouldn't} use them as they might mess with the subscript and
superscript alignment.  The \chemmacros\ option \code{circled} is obeyed by
\cs{ch}.
\begin{example}
  \chemsetup[charges]{circled=all}
  \ch{H+ + OH- <=> H2O}
\end{example}

\chemformula\ knows the options \option{circled} and \option{circletype} also
on its own.

\begin{example}
  \setchemformula{circled=all}
  \ch{H+ + OH- <=> H2O}
\end{example}

These options are coupled with \chemmacros\ options, \ie, setting \chemmacros'
options will also set \chemformula's equivalents.  The other way around the
options act independently: setting \chemformula's options will \emph{not} set
\chemmacros' options.
\begin{options}
  \keychoice{circled}{formal,\default{all},none}\Default{formal}
    \chemformula\ uses two different kinds of charges which indicate the usage
    of real ($+/-$) and formal (\fplus/\fminus) charges.  The choice
    \code{formal} distinguishes between them, choice \code{none} displays them
    all without circle, choice \code{all} circles all.
  % circletype
  \keychoice{circletype}{\default{chem},math}\Default{chem}
    This option switches between two kinds of circled charge symbols:
    \cs{fplus} \fplus\ and \verbcode+$\oplus$+ $\oplus$.
\end{options}

\paragraph{Behaviour}
The supercripts behave differently depending on their position in a compound,
if there are super- and subscripts following each other directly.
\begin{example}
  \ch{^33B} \ch{{}^33B} \ch{3^3B} \ch{B^3} \ch{B3^3} \par
  \ch{^{23}_{123}B} \ch{{}^{23}_{123}B} \ch{_{123}^{23}B}
  \ch{B^{23}} \ch{B_{123}^{23}} \par
  \ch{^{123}_{23}B} \ch{{}^{123}_{23}B} \ch{_{23}^{123}B}
  \ch{B^{123}} \ch{B23^{123}}
\end{example}
\begin{itemize}
  \item If a compound \emph{starts} with a sub- or superscript both sub- and
    superscript are aligned to the \emph{right} else to the \emph{left}.
  \item If a compound \emph{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
    \key{charge-hshift}{dim}, also see page~\pageref{desc:charge-hshift}f.
\end{itemize}
The second point follows \ac{iupac}'s recommendations:
\begin{cnltxquote}[{\acs{iupac} Green Book {\cite[][p.\,51]{iupac:greenbook}}}]
  In writing the formula for a complex ion, spacing for charge number can be
  added (staggered arrangement), as well as parentheses:
  \ch[charge-hshift=full]{SO4^2-}, \ch{(SO4)^2-}.  The staggered arrangement
  is now recommended.
\end{cnltxquote}

\subsection{Bonds}\label{ssec:bonds}
\subsubsection{Native Bonds}
There are three kinds of what I will call ``native bonds'':
\begin{example}[side-by-side]
  single: \ch{CH3-CH3} \par
  double: \ch{CH2=CH2} \par
  triple: \ch{CH+CH}
\end{example}

\subsubsection{Flexible Bonds}
\paragraph{Predefined Bonds}
In addition to the three native bonds there are a few more which can be called
by
\begin{commands}
  \command{bond}[\marg{bond name}]
    Prints the bond type specified by \meta{bond name}.
\end{commands}
The predefined bond types are shown in table~\vref{tab:bond_types}.

\begin{table}
  \centering
  \caption{Bonds available with \cs*{bond}.}
  \label{tab:bond_types}
  \begin{tabular}{lcl}
    \toprule
      \bfseries name & \bfseries appearance & \bfseries aliases \\
    \midrule
      \code{single}  & \bond{single}        & \code{normal}, \code{sb} \\
      \code{double}  & \bond{double}        & \code{db} \\
      \code{triple}  & \bond{triple}        & \code{tp} \\
      \code{dotted}  & \bond{dotted}        & \code{semisingle} \\
      \code{deloc}   & \bond{deloc}         & \code{semidouble} \\
      \code{tdeloc}  & \bond{tdeloc}        & \code{semitriple} \\
      \code{co>}     & \bond{co>}           & \code{coordright} \\
      \code{<co}     & \bond{<co}           & \code{coordleft} \\
    \bottomrule
  \end{tabular}
\end{table}

\begin{example}
  \ch{C\bond{sb}C\bond{db}C\bond{tp}C\bond{deloc}C\bond{tdeloc}C\bond{co>}C\bond{<co}C}
\end{example}

\paragraph{Own Bonds}
\chemformula{} offers commands to define own bond types:
\begin{commands}
  \command{NewChemBond}[\marg{name}\marg{code}]
    \sinceversion{4.3}Define the new bond type \meta{name}.  Issue an error if
    a bond \meta{name} already exists.
  \command{DeclareChemBond}[\marg{name}\marg{code}]
    Define the new bond type \meta{name} or overwrite it if it already
    exists.
  \command{RenewChemBond}[\marg{name}\marg{code}]
    Redefine the existing bond type \meta{name}.  Issue an error if a bond
    \meta{name} doesn't exist.
  \command{ProvideChemBond}[\marg{name}\marg{code}]
    \sinceversion{4.12a}Define the new bond type \meta{name} only if it
    doesn't exist yet.
  \command{NewChemBondAlias}[\marg{new name}\marg{old name}]
    \sinceversion{4.3}Declare the bond type \meta{new name} to be an alias of
    \meta{old name}.  Issue an error if a bond \meta{new name} already
    exists.
  \command{DeclareChemBondAlias}[\marg{new name}\marg{old name}]
    Declare the bond type \meta{new name} to be an alias of \meta{old name}.
  \command{ShowChemBond}[\marg{name}]
    Print the definition of bond type \meta{name}.
\end{commands}
The usage is best described with an example.  So let's see how the
\code{single} bond and the \code{co>} bond are defined:
\begin{sourcecode}
  \NewChemBond{single}
    { \draw[chembond] (chemformula-bond-start) -- (chemformula-bond-end) ; }
  \NewChemBond{coordright}
    {
      \draw[chembond,butt cap->]
        (chemformula-bond-start) -- (chemformula-bond-end) ;
    }
  \NewChemBondAlias{co>}{coordright}
\end{sourcecode}
Two points are important: the names of the starting and the ending
coordinates, \code{chemformula-bond-start} and \code{chemformula-bond-end},
and the \TikZ\ style of the bonds \code{chembond}.

So, let's say you want to define a special kind of dashed bond.  You could do
this:
\begin{example}
  \usetikzlibrary{decorations.pathreplacing}
  \makeatletter
  \NewChemBond{dashed}
    {
      \draw[
        chembond,
        decorate,
        decoration={
          ticks,
          segment length=\chemformula@bondlength/10,amplitude=1.5pt
        }]
        (chemformula-bond-start) -- (chemformula-bond-end) ;
    }
  \makeatother
  \setchemformula{bond-length=2ex}
  \ch{C\bond{dashed}C}
\end{example}

The last example showed you another macro: \verbcode+\chemformula@bondlength+.
It only exists so you can use it to access the bond length as set with
\option{bond-length} directly.

\subsection{Customization}\label{ssec:compounds:customization}
These options allow you to customize the ouptut of the compounds:
\begin{options}
  \keyval{subscript-vshift}{dim}\Default{0pt}
    Extra vertical shift of the subscripts.
  \keychoice{subscript-style}{text,math}\Default{text}
    Style that is used to typeset the subscripts.
  \keyval{charge-hshift}{dim}\Default{.25em}
    Shift of superscripts when following a subscript.\label{desc:charge-hshift}
  \keyval{charge-vshift}{dim}\Default{0pt}
    Extra vertical shift of the superscripts.
  \keychoice{charge-style}{text,math}\Default{text}
    Style that is used to typeset the superscripts.
  \keychoice{circled}{formal,\default{all},none}\Default{formal}
    \sinceversion{4.6}Like \chemmacros' package option but local to
    \chemformula's \cs{ch}.  That is: since \chemmacros' macros use
    \chemformula's mechanism this is effectively an alias.
  \keychoice{circletype}{\default{chem},math}\Default{chem}
    \sinceversion{4.6}Like \chemmacros' package option but local to
    \chemformula's \cs{ch}.  That is: since \chemmacros' macros use
    \chemformula's mechanism this is effectively an alias.
  \keyval{adduct-space}{dim}\Default{.1333em}
    Space to the left and the right of the adduct point.
  \keyval{adduct-penalty}{num}\Default{300}
    The\sinceversion{4.14} penalty inserted after the adduct point for
    (dis-)allowing line breaks.
  \keyval{bond-length}{dim}\Default{.5833em}
    The length of the bonds.
  \keyval{bond-offset}{dim}\Default{.07em}
    Space between bond and atoms.
  \keyval{bond-style}{\TikZ}\Default
    \TikZ\ options for the bonds.
  \keyval{bond-penalty}{num}\Default{10000}
    \sinceversion{4.0a}The penalty that is inserted after a bond for
    (dis-)allowing line breaks.
  \keyval{radical-style}{\TikZ}\Default
    \TikZ\ options for the radical point.
  \keyval{radical-radius}{dim}\Default{.2ex}
    The radius of the radical point.
  \keyval{radical-hshift}{dim}\Default{.15em}
    Horizontal shift before the radical point is drawn.
  \keyval{radical-vshift}{dim}\Default{.5ex}
    Vertical shift relative to the current baseline.
  \keyval{radical-space}{dim}\Default{.15em}
    Horizontal shift after the radical point is drawn.
\end{options}

Maybe you have noticed that charges of certain ions are shifted to the
right.
\begin{example}[side-by-side]
  \ch{SO4^2-} \ch{NH4+} \ch{Na+}
\end{example}
They are shifted if they \emph{follow} a subscript which follows \ac{iupac}
recommendations~\cite[][p.\,51]{iupac:greenbook}.  The amount of the shift can
be set with the option \option{charge-hshift}.
\begin{example}
  \ch{SO4^2-} \ch{NH4+} \ch{Na+} \par
  \setchemformula{charge-hshift=.5ex}
  \ch{SO4^2-} \ch{NH4+} \ch{Na+} \par
  \setchemformula{charge-hshift=.5pt}
  \ch{SO4^2-} \ch{NH4+} \ch{Na+}
\end{example}

Despite \ac{iupac}'s recommendation \chemformula\ does not make fully staggered
arrangements 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
\keyis{charge-hshift}{full}.
\begin{example}
  \ch[charge-hshift=0pt]{C5H11+} \ch[charge-hshift=0pt]{SO4^2-} \par
  \ch{C5H11+} \ch{SO4^2-} \par
  \ch[charge-hshift=1ex]{C5H11+} \ch[charge-hshift=1ex]{SO4^2-} \par
  \ch[charge-hshift=full]{C5H11+} \ch[charge-hshift=full]{SO4^2-}
\end{example}

If you don't want the charges to be typeset in text mode you can switch to
math mode:
\begin{example}
  \ch{M^x+} \ch{SO4^2-} \par
  \setchemformula{charge-style = math}
  \ch{M^x+} \ch{SO4^2-}
\end{example}

The option \option{subscript-vshift} can be used to adjust the vertical shift
of the subscripts:
\begin{example}
  \ch{H2SO4} \ch{Na3PO4} \par
  \setchemformula{subscript-vshift=.5ex}
  \ch{H2SO4} \ch{Na3PO4} \par
  \setchemformula{subscript-vshift=-.2ex}
  \ch{H2SO4} \ch{Na3PO4}
\end{example}

You can choose the mode subscripts are typeset in the same way as it is
possible for the charges:
\begin{example}
  \ch{A_nB_m} \ch{H2SO4} \par
  \setchemformula{subscript-style = math}
  \ch{A_nB_m} \ch{H2SO4}
\end{example}

The option \option{adduct-space} sets the space left and right to the adduct
symbol $\cdot$.
\begin{example}
  \ch{Na3PO3*H2O} \par
  \setchemformula{adduct-space=.2em}
  \ch{Na3PO3*H2O}
\end{example}

Changing the length of the bonds:
\begin{example}
  \setchemformula{bond-length=4mm}%
  single: \ch{CH3-CH3} \par
  double: \ch{CH2=CH2} \par
  triple: \ch{CH+CH}
\end{example}

You can change the distance between bond and atom, too:
\begin{example}
  \ch{H-H + N+N + O=O} \par
  \ch[bond-offset=1pt]{H-H + N+N + O=O}
\end{example}

\subsection{Standalone Formulae}
\chemformula\sinceversion{4.0} offers a command that \emph{only accepts} the
\enquote{compound} input type:
\begin{commands}
  \command{chcpd}[\oarg{options}\marg{compound}]
    Typeset single compounds.
\end{commands}

\subsection{Extend Compound Properties}\label{sec:extend-comp-prop}

It\sinceversion{4.10} is possible to extend the range of special input symbols
within compounds.  In the default setting those are \verbcode|*.-=+'| and
arabic numerals.  Others can be added or the existing ones be changed with one
of the following commmands:
\begin{commands}
  \command{NewChemCompoundProperty}[\marg{token}\marg{replacement}]
    \meta{token} will be replaced by \meta{replacement} within compounds.  The
    property is only added if \meta{token} is not yet part the compounds'
    property list. Otherwise an error is issued.
  \command{ProvideChemCompoundProperty}[\marg{token}\marg{replacement}]
    \meta{token}\sinceversion{4.12a} will be replaced by \meta{replacement}
    within compounds.  The property is only added if \meta{token} is not yet
    part the compounds' property list.
  \command{RenewChemCompoundProperty}[\marg{token}\marg{replacement}]
    \meta{token} will be replaced by \meta{replacement} within compounds.  The
    property is only added if \meta{token} is already part the compounds'
    property list. Otherwise an error is issued.
  \command{DeclareChemCompoundProperty}[\marg{token}\marg{replacement}]
    \meta{token} will be replaced by \meta{replacement} within compounds.  The
    property silently overwrites any previously set \meta{replacement} for
    \meta{token} if \meta{token} is already part the compounds' property
    list.
  \command{RemoveChemCompoundProperty}[\marg{token}]
    Removes \meta{token} from the compounds' property list.
\end{commands}

For example you can use
\begin{sourcecode}
  \NewChemCompoundProperty{\}{\slash}
\end{sourcecode}
to allow line breaks after slashes in compounds.

\section{Special Input Types}
There are some \enquote{special type} input groups.

\subsection{Single Token Groups}
The first kind are groups which consist of only one token.  They are again
divided into two groups, \enquote{addition symbols} and \enquote{symbols}.

\subsubsection{Addition Symbols}\label{sec:addition-symbols}
\begin{commands}
  \command{ch}[\Marg{ + } \ch{ + }]
    Creates the plus sign between compounds with space around it:\\
    \cs{ch}\Marg{2 Na + Cl2} \ch{2 Na + Cl2}
  \command{ch}[\Marg{ - } \ch{ - }]
    \sinceversion{4.3a}Creates the minus sign between compounds with space
    around it:\\
    \cs{ch}\Marg{M - H} \ch{M - H}
\end{commands}
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:
\begin{commands}
  \command{NewChemAdditionSymbol}[\marg{name}\marg{input}\marg{output}]
    Defines\sinceversion{4.11} the addition symbol \meta{name} with input
    symbol \meta{input} and output \meta{output}.
  \command{ProvideChemAdditionSymbol}[\marg{name}\marg{input}\marg{output}]
    Defines\sinceversion{4.12a} the addition symbol \meta{name} with input
    symbol \meta{input} and output \meta{output} only no addition symbol with
    then name \meta{name} doesn't exist.
  \command{RenewChemAdditionSymbol}[\marg{name}\marg{input}\marg{output}]
    Redefines\sinceversion{4.11} the addition symbol \meta{name} with input
    symbol \meta{input} and output \meta{output}.
  \command{DeclareChemAdditionSymbol}[\marg{name}\marg{input}\marg{output}]
    (Re-)Defines\sinceversion{4.11} the addition symbol \meta{name} with input
    symbol \meta{input} and output \meta{output} without checking if the
    symbol exists or not.
\end{commands}

The space left and right of the plus and the minus sign and the signs
themselves can be set with the following options:
\begin{options}
  \keyval{plus-space}{skip}\Default{.3em plus .1em minus .1em}
    A rubber length.
  \keyval{plus-penalty}{num}\Default{700}
    \sinceversion{4.0a}The penalty that is inserted after the plus sign for
    (dis-)allowing line breaks.
  \keyval{plus-output-symbol}{code}\Default{+}
    \sinceversion{4.9}The \meta{code} that is used for the plus sign.
  \keyval{minus-space}{skip}\Default{.3em plus .1em minus .1em}
    \sinceversion{4.9}A rubber length.
  \keyval{minus-penalty}{num}\Default{700}
    \sinceversion{4.9}The penalty that is inserted after the minus sign for
    (dis-)allowing line breaks.
  \keyval{minus-output-symbol}{code}\Default{\$-\$}
    \sinceversion{4.9}The \meta{code} that is used for the minus sign.
\end{options}
The corresponding three options are defined when \cs{NewChemAdditionSymbol}
or one of the variants is used, \code{\meta{name}-space} and
\code{\meta{name}-penalty} both with the same defaults as above, and
\code{\meta{name}-output-symbol}.

\begin{example}[side-by-side]
  \ch{A + B}\par
  \ch[plus-space=4pt]{A + B}
\end{example}

\subsubsection{Symbols}\label{sec:symbols}
\begin{commands}
    \command{ch}[\Marg{ v } \ch{ v }]
    Sign for precipitate: \cs{ch}\Marg{BaSO4 v} \ch{BaSO4 v}
  \command{ch}[\Marg{ \textasciicircum\ } \ch{ ^ }]
    Sign for escaping gas\footnotemark: \cs{ch}\Marg{H2 \textasciicircum}
    \ch{H2 ^}
\end{commands}
\footnotetext{Is this the correct English term? Please correct me if it isn't.}

You can define/redefine your own symbols:
\begin{commands}
  \command{NewChemSymbol}[\marg{input}\marg{output}]
    Defines\sinceversion{4.11} the addition symbol with input \meta{input} and
    output \meta{output}.
  \command{ProvideChemSymbol}[\marg{input}\marg{output}]
    Defines\sinceversion{4.12a} the addition symbol with input \meta{input} and
    output \meta{output} only if no symbol with input \meta{input} exists.
  \command{RenewChemSymbol}[\marg{input}\marg{output}]
    Redefines\sinceversion{4.11} the addition symbol with input \meta{input}
    and output \meta{output}.
  \command{DeclareChemSymbol}[\marg{input}\marg{output}]
    (Re-)Defines\sinceversion{4.11} the addition symbol with input
    \meta{input} and output \meta{output} without checking if the symbol
    exists or not.
\end{commands}

\subsection{Option Input}
Sometimes you might want to apply an option only to a part of a, say,
reaction.  Of course you have the possibility to use \cs{ch} several times.
\begin{example}
  \ch{H2O +}\textcolor{red}{\ch{H2SO4}}\ch{-> H3O+ + HSO4-} \par
  \ch{H2O +}\ch[subscript-vshift=2pt]{H2SO4}\ch{-> H3O+ + HSO4-}
\end{example}
This, however, interrupts the input in your source and \emph{may} mess with
the spacing. That's why there is an alternative:
\begin{commands}
  \command{ch}[\Marg{ @\marg{options} }]
    The options specified this way will be valid \emph{only} until the next
    compound is set.
\end{commands}
\begin{example}
  \ch{H2O +}\textcolor{red}{\ch{H2SO4}}\ch{-> H3O+ + HSO4-} \par
  \ch{H2O + @{format=\color{red}} H2SO4 -> H3O+ + HSO4-} \par
  or of course:\par
  \ch{H2O + \textcolor{red}{H2SO4} -> H3O+ + HSO4-}\par\bigskip
  \ch{H2O +}\ch[subscript-vshift=2pt]{H2SO4}\ch{-> H3O+ + HSO4-} \par
  \ch{H2O + @{subscript-vshift=2pt} H2SO4 -> H3O+ + HSO4-}
\end{example}

\section{Escaped Input}
In some cases it may be desirable to prevent \chemformula\ from parsing the
input.  This can be done in two ways.

\subsection{Text}\label{ssec:text}
If you put something between \verbcode+" "+ or \verbcode+' '+ then the input
will be treated as normal text, except that spaces are not allowed and have to
be input with \verbcode+~+.
\begin{commands}
  \command{ch}[\Marg{ "\meta{escaped text}" }]
    One of two possibilities to \emph{escape} \chemformula's parsing.
  \command{ch}[\Marg{ \textquotesingle\meta{escaped text}\textquotesingle\ }]
    The second of two possibilities to \emph{escape} \chemformula's parsing.
\end{commands}
\begin{example}[add-sourcecode-options={literate=}]
  \ch{"\ox{2,Ca}" O} \par
  \ch{"\ldots\," Na + "\ldots\," Cl2 -> "\ldots\," NaCl} \par
  \ch{'A~->~B'}
\end{example}
In many cases you won't need to escape the input.  But when you get into
trouble when using a command inside \cs{ch} try hiding it.

\subsection{Math}
If you especially want to input math you just enclose it with \verbcode+$ $+.
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.
\begin{commands}
 \command{ch}[\Marg{ \string$\meta{escaped math}\string$ }]
   One of two possibilities to \emph{escape} \chemformula's parsing into math
   mode.
 \command{ch}[\Marg{ \string\(\meta{escaped math}\string\) }]
   The second of two possibilities to \emph{escape} \chemformula's parsing
   into math mode.
\end{commands}
\begin{example}[side-by-side]
  escaped text: \ch{"$x$" H2O} \par
  escaped math: \ch{$x$ H2O} \par
  also escaped math: \ch{\(x\) H2O} \par
  \ch{$2n$ Na + $n$ Cl2 -> $2n$ NaCl}
\end{example}

The space that is inserted after a math group can be edited:
\begin{options}
  \keyval{math-space}{skip}\Default{.1667em plus .0333em minus .0117em}
   A rubber length.
\end{options}
\begin{example}
  \ch{$2n$ Na + $n$ Cl2 -> $2n$ NaCl} \par
  \setchemformula{math-space=.25em}
  \ch{$2n$ Na + $n$ Cl2 -> $2n$ NaCl} \par
  \ch{$A->B$}
\end{example}

\section{Arrows}\label{sec:arrows}
\subsection{Arrow types}
Arrows are input in the same intuitive way they are with \pkg{mhchem}.
There are various different types:
\begin{arrows}
  \arrow{->}[ \charrow{->}]
    standard right arrow
  \arrow{<-}[ \charrow{<-}]
    standard left arrow
  \arrow{-/>}[ \charrow{-/>}]
    does not react (right)
  \arrow{</-}[ \charrow{</-}]
    does not react (left)
  \arrow{<->}[ \charrow{<->}]
    resonance arrow
  \arrow{<>}[ \charrow{<>}]
    reaction in both directions
  \arrow{==}[ \charrow{==}]
    stoichiometric equation
  \arrow{<=>}[ \charrow{<=>}]
    equilibrium arrow
  \arrow{>=<}[ \charrow{>=<}]
    \sinceversion{4.5}reversed equilibrium arrow
  \arrow{<=>{}>}[ \charrow{<=>>}]
    unbalanced equilibrium arrow to the right
  \arrow{>=<{}<}[ \charrow{>=<<}]
    \sinceversion{4.5}reversed unbalanced equilibrium arrow to the right
  \arrow{<{}<=>}[ \charrow{<<=>}]
    unbalanced equilibrium arrow to the left
  \arrow{>{}>=<}[ \charrow{>>=<}]
    \sinceversion{4.5}reversed unbalanced equilibrium arrow to the left
  \arrow{<=o>}[ \charrow{<=o>}]
    \sinceversion{4.15}quasi equilibrium arrow
  \arrow{<=o>{}>}[ \charrow{<=o>>}]
    \sinceversion{4.15}unbalanced quasi equilibrium arrow to the right
  \arrow{<{}<=o>}[ \charrow{<<=o>}]
    \sinceversion{4.15}unbalanced quasi equilibrium arrow to the left
  \arrow{<o>}[ \charrow{<o>}]
    isolobal arrow
  \arrow{<==>}[ \charrow{<==>}]
    \sinceversion{4.5}I've seen this one used. I'm not sure it actually has a
    meaning in chemical equations.  If you have some official reference for
    this arrow type please feel free to contact me.
\end{arrows}
All these arrows are drawn with \TikZ.
\begin{example}
  \ch{H2 + Cl2 -> 2 HCl} \par
  \ch{H2O + CO3^2- <=> OH- + HCO3-} \par
  \ch{A <- B} \par
  \ch{\{[CH2=CH-CH2]- <-> {}[CH2-CH=CH2]- \}} \par
  \ch{A <> B} \par
  \ch{H+ + OH- <=>> H2O} \par
  \ch{2 NO2 <<=> N2O4}
\end{example}

\subsection{Labels}
The arrows take two optional arguments to label them.
\begin{arrows}
  \arrow*{->\oarg{above}\oarg{below}}
    Add text above or under an arrow.
\end{arrows}
\begin{example}[side-by-side]
  \ch{A ->[a] B} \par
  \ch{A ->[a][b] B} \par
  \ch{A ->[\SI{100}{\celsius}] B}
\end{example}
The label text can be parsed seperately from the arrow. The recipe is easy:
leave blanks.
\begin{example}[side-by-side]
  \ch{A ->[H2O] B} \par
  \ch{A ->[ H2O ] B} \par
  \ch{A ->[ "\ox{2,Ca}" F2 ] B} \par
  \ch{A ->[ $\Delta$,~ [ H+ ]] B}
\end{example}

If you leave the blanks \chemformula\ treats the groups inside the square
brackets as seperated input types.  The arrow reads its arguments
\emph{afterwards}.  As you can see the arrows \enquote{grow} with the length
of the labels.  What stays constant is the part that protrudes the labels.
\begin{example}
  \ch{A ->[a] B} \par
  \ch{A ->[ab] B} \par
  \ch{A ->[abc] B} \par
  \ch{A ->[abc~abc] B} \par
  % needs the `chemfig' package:
  \setchemfig{atom sep =15pt}
  \ch{A ->[ "\chemfig{-[:30]-[:-30]OH}" ] B} \par
\end{example}

\subsection{Customization}
These are the options which enable you to customize the arrows:
\begin{options}
  \keyval{arrow-offset}{dim}\Default{.75em}
    This is the length that an arrow protrudes a label on both sides.  This
    means an empty arrow's length is two times \code{arrow-offset}.
  \keyval{arrow-min-length}{dim}\Default{0pt}
    \sinceversion{3.6b}The minimal length an error must have unless two times
    \option{arrow-offset} plus the width of the label is larger.
  \keyval{arrow-yshift}{dim}\Default{0pt}
    Shifts an arrow up (positive value) or down (negative value).
  \keyval{arrow-ratio}{<factor>}\Default{.6}
    The ratio of the arrow lengths of the unbalanced equilibrium.  \code{.4}
    would mean that the length of the shorter arrow is $0.4\times$ the length
    of the longer arrow.
  \keyval{compound-sep}{dim}\Default{.5em}
    The space between compounds and the arrows.
  \keyval{label-offset}{dim}\Default{2pt}
    The space between the labels and the arrows.
  \keyval{label-style}{font command}\Default{\cs*{footnotesize}}
    The relative font size of the labels.
  \keyval{arrow-penalty}{num}\Default{0}
    \sinceversion{4.0a}The penalty that is inserted after an arrow for
    (dis-)allowing line breaks.
  \keyval{arrow-style}{\TikZ}\Default
    \sinceversion{4.1a}Additonal \TikZ\ keys for formatting the arrows.
\end{options}

The following code shows the effect of the different options on the \verbcode+<=>>+
arrow:
\begin{example}
  standard: \ch{A <=>>[x][y] B} \par
  longer: \ch[arrow-offset=12pt]{A <=>>[x][y] B} \par
  higher: \ch[arrow-yshift=2pt]{A <=>>[x][y] B} \par
  more balanced: \ch[arrow-ratio=.8]{A <=>>[x][y] B} \par
  labels further away: \ch[label-offset=4pt]{A <=>>[x][y] B} \par
  larger distance to compounds: \ch[compound-sep=2ex]{A <=>>[x][y] B} \par
  smaller labels: \ch[label-style=\tiny]{A <=>[x][y] B}
\end{example}

If you want to have different arrow tips\sinceversion{4.7} there is an easy
way to use existing arrow tips (as defined by \TikZ).  \chemformula\ uses
three different arrow tips: \code{cf}, \code{left cf} and \code{right cf}.  If
you want them to match those of \pkg{chemfig}~\cite{pkg:chemfig} for example
you could do:
\begin{sourcecode}
  \pgfkeys{
    cf /.tip = {CF@full} ,
    left cf /.tip = {CF@half}
  }
\end{sourcecode}
\pkg{chemfig} has no equivalent of \code{right cf}.  This mechanism relies on
\TikZ\ version~3.0.0 and the new \code{arrows.meta} library.

\subsection{Modify Arrow Types}\label{sec:arrows_modify}
The arrows are defined with the commands
\begin{commands}
  \command{NewChemArrow}[\marg{type}\marg{\TikZ}]
    Define the new arrow type \meta{type}.  Issue an error if an arrow type
    \meta{type} already exists.
  \command{ProvideChemArrow}[\marg{type}\marg{\TikZ}]
    Define\sinceversion{4.12a} the new arrow type \meta{type} only if it
    doesn't exist, yet.
  \command{DeclareChemArrow}[\marg{type}\marg{\TikZ}]
    Define the new arrow type \meta{type} or overwrite it if it already
    exists.
  \command{RenewChemArrow}[\marg{type}\marg{\TikZ}]
    Redefine the arrow type \meta{type}.  Issue an error if an arrow type
    \meta{type} doesn't exist.
  \command{ShowChemArrow}[\marg{type}]
    Print out the current definition of the arrow type \meta{type}.
\end{commands}
\meta{type} is the sequence of tokens that is replaced with the actual arrow
code.  For example the basic arrow is defined via
\begin{sourcecode}
  \NewChemArrow{->}{
    \draw[chemarrow,-cf] (cf_arrow_start) -- (cf_arrow_end) ;
  }
\end{sourcecode}
In order to define arrows yourself you need to know the basics of
\TikZ\footnote{Please see the \manual{pgfmanual} for details.}.  The
predefined arrows use the arrow tips \code{cf}, \code{left cf} and \code{right
  cf}.  They also all except the net reaction arrow \code{==} use the
\TikZ-style \code{chemarrow} that you should use, too, if you want the option
\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:
\begin{codedesc}
  \Code{(cf\_arrow\_start)}
    The beginning of the arrow.
  \Code{(cf\_arrow\_end)}
    The end of the arrow.
  \Code{(cf\_arrow\_mid)}
    The mid of the arrow.
  \Code{(cf\_arrow\_mid\_start)}
    The beginning of the shorter arrow in types like \verbcode+<=>>+.
  \Code{(cf\_arrow\_mid\_end)}
    The end of the shorter arrow in types like \verbcode+<=>>+.
  \Code{cf}
    A double-sided arrow tip.
  \Code{left cf}
    A left-sided arrow tip.
  \Code{right cf}
    A right-sided arrow tip.
  \Code{chemarrow}
    \chemformula's \TikZ-style that is applied to the arrows and set with
    \option{arrow-style}
\end{codedesc}
\begin{example}
  \NewChemArrow{.>}{
    \draw[chemarrow,-cf,dotted,red] (cf_arrow_start) -- (cf_arrow_end);
  }
  \NewChemArrow{n>}{
    \draw[chemarrow,-cf]
      (cf_arrow_start)
        .. controls ([yshift=3ex]cf_arrow_mid) ..
      (cf_arrow_end);
  }
  \ch{A .> B} \ch{A .>[a][b] B} \ch{A n> B}
\end{example}

\begin{example}
  \texttt{\ShowChemArrow{->}} \par
  \RenewChemArrow{->}{\draw[chemarrow,->,red] (cf_arrow_start) -- (cf_arrow_end) ;}
  \texttt{\ShowChemArrow{->}} \par
  \ch{A -> B}
\end{example}

\subsection{Standalone Arrows}
\chemformula\ offers\sinceversion{4.0} a command that \emph{only accepts} the
\enquote{arrow} input type:
\begin{commands}
  \command{charrow}[\marg{type}\oarg{above}\oarg{below}]
    Print the arrow type \meta{type}.
\end{commands}
This command is internally used for the arrows, too, when \cs{ch} is parsed.

\section{Names}
\subsection{Syntax}
\chemformula\ has a built-in syntax to write text under a compound.  In a way
it works very similar to the arrows.
\begin{commands}
  \command{ch}[\Marg{ !(\meta{text})( \meta{formula} ) }]
    Writes \meta{text} below \meta{formula}.
\end{commands}
If an exclamation mark is followed by a pair of parentheses \chemformula\ will
parse it this way:
\begin{example}
  \ch{!(ethanol)( CH3CH2OH )}
\end{example}
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.
\begin{example}
  \ch{!(water)(H2O)} \quad
  \ch{!( "\textcolor{blue}{water}" )( H2O )} \quad
  \ch{!( $2n-1$ )( H2O )} \quad
  \ch{!( H2O )( H2O )} \quad
  \ch{!(oxonium)( H3O+ )}
\end{example}
If for some reason you want to insert an exclamation mark \emph{without} it
creating a name you only have to make sure it isn't followed by parentheses.
\begin{example}[side-by-side]
  \ch{H2O~(!)} \par
  \ch{A!{}()}
\end{example}

\subsection{Customization}
\chemformula\ provides two options to customize the output of the names:
\begin{options}
 \keyval{name-format}{commands}\Default{\cs*{scriptsize}\cs*{centering}}
   The format of the name.  This can be arbitrary input.
 \keychoice{name-width}{\meta{dim},auto}\Default{auto}
   The width of the box where the label is put into.  \code{auto} will detect
   the width of the name and set the box to this width.
\end{options}
\begin{example}
  \ch{!(acid)( H2SO4 ) -> B} \par
  \ch[name-format=\sffamily\small]{!(acid)( H2SO4 ) -> B} \par
  \ch[name-format=\scriptsize N:~]{!(acid)( H2SO4 ) -> B} \par
  \ch[name-width=3em,name-format=\scriptsize\raggedright]{!(acid)( H2SO4 ) -> B}
\end{example}

\subsection{Standalone Names}
\chemformula\ offers a command\sinceversion{4.0} that allows the usage of the
\enquote{name} syntax in normal text.  This is the command that a bang is
replaced with in \chemformula's formulas, actually.  Both arguments are
mandatory.
\begin{commands}
  \command{chname}[\darg{text~1}\darg{text~2}]
    The command that is useed internally for placing  \meta{text~1} below of
    \meta{text~2}.
\end{commands}

\section{Format and Font}\label{sec:format}
In the standard setting \chemformula\ doesn't make any default changes to the
font of the formula output.  Let's take a look at a nonsense input which shows
all features:
\begin{example}[pre-output={\biolinumLF\libertineLF\setchemformula{format=}}]
  \newcommand*\sample{%
    \ch{H2C-C+C-CH=CH+ + CrO4^2-
        <=>[x][y]
      2.5 Cl^{-.} + 3_1/2 Na*OH_{(aq)} + !(name)( A^n ) "\LaTeXe"}
  }
  \sample
\end{example}
\newcommand*\sample{%
  \ch{H2C-C+C-CH=CH+ + CrO4^2-
      <=>[x][y]
    2.5 Cl^{-.} + 3_1/2 Na*OH_{(aq)} + !(name)( A^n ) "\LaTeXe"}
}

Now we're going to change different aspects of the font a look what happens:
\begin{example}[pre-output={\biolinumLF\libertineLF\setchemformula{format=}}]
  \sffamily Hallo \sample \\
  \ttfamily Hallo \sample \normalfont \\
  \bfseries Hallo \sample \normalfont \\
  \itshape Hallo \sample
\end{example}
As you can see most features adapt to the surrounding font.

If you want to change the default format you need to use this option:
\begin{options}
  \keyval{format}{code}\Default
    Adds \meta{code} before the output of \cs{ch}.
  \keyval{atom-format}{code}\Default
    This\sinceversion{4.13} adds \meta{code} before each formula. This
    allows to specify a format for the chemical formulas only and have a
    different format for the rest of the chemical equation.
\end{options}
\begin{example}[pre-output={\biolinumLF\libertineLF\setchemformula{format=}}]
  \definecolor{newblue}{rgb}{.1,.1,.5}
  \setchemformula{format=\color{newblue}\sffamily}
  \sffamily Hallo \sample \\
  \ttfamily Hallo \sample \normalfont \\
  \bfseries Hallo \sample \normalfont \\
  \itshape Hallo \sample
\end{example}

You can also specifically change the fontfamily, fontseries and fontshape of
the output.
\begin{options}
  \keyval{font-family}{family}\Default
    Changes the fontfamily of the output with \cs*{fontfamily}\marg{family}.
  \keyval{font-series}{series}\Default
    Changes the fontseries of the output with \cs*{fontseries}\marg{series}.
  \keyval{font-shape}{shape}\Default
    Changes the fontshape of the output with \cs*{fontshape}\marg{shape}.
\end{options}
\begin{example}[pre-output={\biolinumLF\libertineLF\setchemformula{format=}}]
  \setchemformula{font-series=bx}
  Hallo \sample \par
  \sffamily Hallo \sample \normalfont \par
  \setchemformula{font-family=lmss,font-series=m} Hallo \sample
    \normalfont \par
  \itshape Hallo \sample
\end{example}

If you're using \XeLaTeX\ or \LuaLaTeX\ and have loaded \pkg{fontspec} you
have the possibilty to set the font with it:
\begin{options}
  \keyval{font-spec}{font}\Default
    Use font \meta{font} for \chemformula's formulas.
\end{options}
or with options
\begin{options}
  \keychoice{font-spec}{\Marg{[\meta{options}]\meta{font}}}
    Use font \meta{font} with options \meta{options} for \chemformula's
    formulas.
\end{options}
Since this document is typeset with \pdfLaTeX\ the option cannot be
demonstrated here.

\section{Usage In Math Equations}
The \cs{ch} command can be used inside math equations.  It recognizes
\verbcode+\\+ and \verbcode+&+ and passes them on.  However, you can't use the
optional arguments of \verbcode+\\+ inside \cs{ch}.
\begin{example}
  \begin{align}
   \ch{
     H2O & ->[a] H2SO4 \\
     Cl2 & ->[x][y] CH4
   }
  \end{align}
  \begin{align*}
  \ch{
    RNO2      &<=>[ + e- ] RNO2^{-.} \\
    RNO2^{-.} &<=>[ + e- ] RNO2^2-
  }
  \end{align*}
\end{example}

\section{Usage with \TikZ\ or \pkg*{pgfplots} and externalization}
Since \chemformula\ uses\sinceversion{4.1} \TikZ\ to draw reaction arrows
and bonds they would be externalized, too, if you use that facility with
\TikZ\ or \needpackage{pgfplots}~\cite{pkg:pgfplots}.  This may not be
desirable since they are very small pictures maybe containing of a single
line.  This is why \chemformula's default behaviour is to disable
externalization for it's bonds and arrows.  This can be turned on and off
through the following option:
\begin{options}
  \keybool{tikz-external-disable}\Default{true}
    dis- or enable \TikZ' externalization mechanism for \chemformula's arrows
    and bonds.
\end{options}

If you should be using a formula that contains bonds or arrows inside of a
\code{tikzpicture} that is externalized you should locally enable it for
\chemformula, too:

\begin{sourcecode}
  \begin{tikzpicture}
    \setchemformula{tikz-external-disable=false}
    \begin{axis}[xlabel={\ch{2 H+ + 2 e- -> H2}}]
      \addplot ... ;
    \end{axis}
  \end{tikzpicture}
\end{sourcecode}

\section{Lewis Formulae}\label{sec:lewis-formulae}
\chemformula\ offers\sinceversion{4.2} a command to typeset Lewis formulae.
This does not mean Lewis structures!  Those can be achieved using the
\pkg{chemfig} package~\cite{pkg:chemfig}.  \chemformula\ provides the
possibility to draw electrons as dots and pairs of dots or a line around an
atom.

\begin{commands}
  \command{chlewis}[\oarg{options}\marg{electron spec}\marg{atom}]
    Draws electrons around the \meta{atom} according to \meta{electron spec}.
\end{commands}

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 \meta{angle}\meta{separator}.  \meta{angle} is a positiv or negativ
integer denoting the angle counter clockwise to the horizontal where the
electrons should be drawn.  \meta{separator} is either a dot (\code{.}, single
electron), a colon (\code{:}, electron pair), a vertical line (\code{|},
electron pair), an o (\code{o}, empty pair), or a comma (\code{,} default
spec).

\begin{commands}
  \command{chlewis}[\Marg{\meta{angle1}\meta{type1}\meta{angle2}\meta{type2}}%
    \marg{atom}]
    For example: \cs{chlewis}\Marg{0,180}\Marg{O} gives \chlewis{0,180}{O} and
    \cs{chlewis}\Marg{0.90.180.270.}\Marg{C} gives
    \chlewis{0.90.180.270.}{C}.
\end{commands}

The appearance can be influenced by a number of options:
\begin{options}
  \keychoice{lewis-default}{.,:,|,o,single,pair,pair (dotted),pair
    (line),empty}\Default{pair}
    Sets the default type that is used when no type is given in \meta{electron
      spec}.
  \keyval{lewis-distance}{dim}\Default{1ex}
    The distance of two electrons in a pair.
  \keyval{lewis-line-length}{dim}\Default{1.5ex}
    The length of the line representing an electron pair.
  \keyval{lewis-line-width}{dim}\Default{1pt}
    The thickness of a line representing an electron pair.
  \keyval{lewis-offset}{dim}\Default{.5ex}
    The distance of the symbols from the atom.
\end{options}
The dots are drawn according to the \option{radical-radius} option mentioned
in section~\ref{ssec:compounds:customization}.

The basic usage should be more or less self-explaining:
\begin{example}[side-by-side]
  \chlewis{0:90|180.270}{O}
  \quad
  \chlewis{45,135}{O}
  \quad
  \chlewis{0o}{Na}
\end{example}

The next example shows the effect of some of the options:
\begin{example}
  \chlewis[lewis-default=.]{23,68,113,158,203,248,293,338}{X}
  \quad
  \chlewis{0,90,180,270}{X}
  \quad
  \chlewis[lewis-distance=1.25ex]{0,90,180,270}{X}
  \quad
  \chlewis[lewis-distance=.75ex,radical-radius=.5pt]{0,90,180,270}{X}
  \quad
  \chlewis[
    radical-radius=.5pt,
    lewis-default=.
  ]{23,68,113,158,203,248,293,338}{X}
\end{example}

\begin{example}
  \ch{
    !($1s^22s^1$)( "\chlewis{180.}{Li}" ) +
    !($1s^22s^22p^5$)( "\chlewis{0.90,180,270}{F}" )
     ->
    !($1s^2$)( Li+ ) + !($1s^22s^22p^6$)( "\chlewis{0,90,180,270}{F}" {}- )
  }
\end{example}

\section{Kröger-Vink Notation}\label{sec:kroger-vink-notation}

\chemformula\ also supports the Kröger-Vink notation\sinceversion{4.5}.
\begin{options}
  \keybool{kroeger-vink}\Default{false}
    Enable the Kröger-Vink notation. As most options this can be enabled
    globally via the setup command or locally as option to \cs{ch}.
\end{options}

With this option enabled several changes come into effect: \verbcode|'|
produces a prime, a \code{x} in a superscript produces $\times$, and both a
\code{.} and a \code{*} 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.

\begin{example}[side-by-side,add-sourcecode-options={literate=}]
  \setchemformula{kroeger-vink=true}
  \ch{Al_{Al}^'}
  \ch{Al_{Al}'}\par
  \ch{Ni_{Cu}^{x}}\par
  \ch{V_{Cl}^.}
  \ch{V_{Cl}^*}\par
  \ch{Ca_i^{..}}\par
  \ch{e^'}\par
  \ch{Cl_i^'}
  \ch{Cl_i'}\par
  \ch{O_i^{''}}
  \ch{O_i''}
\end{example}

There are a number of options for customizations:
\begin{options}
  \keyval{kv-positive-style}{\TikZ}\Default
    \TikZ\ code for positive charge dot.
  \keyval{kv-positive-radius}{dim}\Default{.3ex}
    Radius of positive charge dot
  \keyval{kv-positive-hshift}{dim}\Default{.15em}
    Horizontal shift of positive charge dot
  \keyval{kv-positive-vshift}{dim}\Default{.5ex}
    Vertical shift positive charge dot
  \keyval{kv-positive-offset}{dim}\Default{.4em}
    The offset of two consecutive positive charge dots
  \keyval{kv-neutral-symbol}{\TeX\ code}\Default{\$\cs*{times}\$}
    Symbol for neutral particles.
\end{options}

\appendix
\newenvironment{changes}[2][]{%
  \subsection*{Version #2\ifblank{#1}{}{ (#1)}}
  \itemize\let\change\item
}{\enditemize}

\section{History Since Version~4.0}

\begin{changes}{4.0}
  \change Since version 4.0\sinceversion{4.0}, the \chemformula\ package is
    distributed independently from \chemmacros.
\end{changes}

\begin{changes}{4.1}
  \change New option \option{tikz-external-disable}.
  \change New option \option{frac-math-cmd}.
\end{changes}

\begin{changes}{4.2}
  \change New option \option{arrow-style}.
  \change New command \cs{chlewis} that allows to add Lewis electrons to an
    atom, see section~\ref{sec:lewis-formulae}.
\end{changes}

\begin{changes}{4.3}
  \change New option \option{stoich-print}.
  \change New command \cs{chstoich}.
  \change The commands \cs*{DeclareChem\meta{...}} now don't give an error any
    more if the command already exists.  This is more consistent with \LaTeX's
    \cs*{DeclareRobustCommand}.  For all those commands a version
    \cs*{NewChem\meta{...}} is introduced that \emph{does} give an error if
    the new command is already defined.
\end{changes}
  
\begin{changes}{4.4}
  \change A single dash \code{-} in \cs{ch} is now treated as a minus sign.
    This is consistent with the behaviour of a \code{+}.
\end{changes}

\begin{changes}{4.5}
  \change New arrow types \arrowtype{>=<}, \arrowtype{>=<{}<}, \arrowtype{>{}>=<}
    and \arrowtype{<==>}.
  \change Internal changes to \cs{ch} allow usage of optional arguments of
    \cs*{\textbackslash} and \cs*{label} in \chemmacros' \env*{reactions}
    environment.
\end{changes}
  
\begin{changes}{4.6}
  \change New options \option{circled} and \option{circletype}.  this allows to
    set the behaviour as described on \chemmacros' manual for a specific usage
    of \cs{ch}.
\end{changes}

\begin{changes}{4.7}
  \change Dependency change: \chemformula\ now requires the \TikZ\ library
    \code{arrows.meta} instead of the library \code{arrows}.  This requires
    \TikZ\ version~3.0.0.
\end{changes}

\begin{changes}{4.8}
  \change The \chemformula\ package now is no longer part of the \chemmacros\
    bundle but is distributed as a package of it's own.
\end{changes}

\begin{changes}{4.9}
  \change New options \option{minus-space} and \option{minus-penalty} equivalent
    to the existing \option{plus-space} and \option{plus-penalty}
  \change New options \option{plus-output-symbol} and
    \option{minus-output-symbol} for customizing the plus and minus signs in
    the output.
\end{changes}

\begin{changes}{4.10}
  \change New macro set \cs{NewChemCompoundProperty},  see
    section~\ref{sec:extend-comp-prop} for a description.
\end{changes}

\begin{changes}{4.11}
  \change New macro set \cs{NewChemAdditionSymbol}, see
  section~\ref{sec:addition-symbols}.
  \change New macro set \cs{NewChemSymbol}, see section~\ref{sec:symbols}.
\end{changes}

\begin{changes}{4.12}
  \change Change package requirement: \chemformula\ now not loads complete
    \pkg{amsmath} but only \pkg{amstext}.
\end{changes}

\begin{changes}{4.13}
  \change Check for blank input parts and don't process them.
  \change Drop support for \cs*{[} and \cs*{]} as replacement for \code{[} and
    \code{]} inside arrow captions.
  \change New option \option{atom-format}.
\end{changes}

\begin{changes}{4.14}
  \change New option \option{adduct-penalty}.
\end{changes}

\begin{changes}{4.15}
  \change The order of arrow definitions doesn't matter any more.
  \change New quasi equilibria arrows.
  \change Require \pkg{amsmath}.
  \change Allow \option{name-format} to end with a macro that takes an
    argument.
  \change Various bug fixes.
\end{changes}

\end{document}