summaryrefslogtreecommitdiff
path: root/macros/generic/chemfig/chemfig-en.tex
blob: 3c6797732b0620c19fc6b6688dffd357b7071858 (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
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,margin=2.5cm,head=17pt,headsep=3mm,footskip=10mm]{geometry}
\usepackage[bottom]{footmisc}
\usepackage{libertine,amsmath,array,longtable,xspace,fancybox,boites,textcomp,enumitem,chemfig,fancyhdr}
\usepackage[scaled=0.8]{luximono}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{matrix}
\usepackage[protrusion=true,expansion,final,babel=true]{microtype}
\fancypagestyle{plain}{%
	\fancyhead[L]{}
	\fancyhead[C]{}
	\fancyhead[R]{}
	\fancyfoot[l]{\tiny Compiled the \today.}
	\fancyfoot[c]{}
	\fancyfoot[r]{\thepage}}
\renewcommand\headrulewidth{0pt}

\makeatletter
\newcommand\make@car@active[1]{%
	\catcode`#1\active
	\begingroup
		\lccode`\~`#1\relax
		\lowercase{\endgroup\def~}%
}

\newif\if@exstar

\newcommand\exemple{%
	\begingroup
	\parskip\z@
	\@makeother\;\@makeother\!\@makeother\?\@makeother\:% neutralise frenchb
	\@ifstar{\@exstartrue\exemple@}{\@exstarfalse\exemple@}}

\newcommand\exemple@[2][65]{%
	\medbreak\noindent
	\begingroup
		\let\do\@makeother\dospecials
		\make@car@active\ { {}}%
		\make@car@active\^^M{\par\leavevmode}%
		\make@car@active\^^I{\space\space}%
		\make@car@active\,{\leavevmode\kern\z@\string,}%
		\make@car@active\-{\leavevmode\kern\z@\string-}%
		\make@car@active\>{\leavevmode\kern\z@\string>}%
		\make@car@active\<{\leavevmode\kern\z@\string<}%
		\exemple@@{#1}{#2}%
}

\newcommand\exemple@@[3]{%
	\def\@tempa##1#3{\exemple@@@{#1}{#2}{##1}}%
	\@tempa
}

\newcommand\exemple@@@[3]{%
	\xdef\the@code{#3}%
	\endgroup
	\if@exstar
		\begingroup
			\fboxrule0.4pt
			\let\breakboxparindent\z@
			\def\bkvz@bottom{\hrule\@height\fboxrule}%
			\let\bkvz@before@breakbox\relax
			\def\bkvz@set@linewidth{\advance\linewidth\dimexpr-2\fboxrule-2\fboxsep}%
			\def\bkvz@left{\vrule\@width\fboxrule\hskip\fboxsep}%
			\def\bkvz@right{\hskip\fboxsep\vrule\@width\fboxrule}%
			\def\bkvz@top{\hbox to \hsize{%
				\vrule\@width\fboxrule\@height\fboxrule
				\leaders\bkvz@bottom\hfill
				\sffamily
				\fboxsep\z@
				\colorbox{black}{\kern0.25em\color{white}\footnotesize\lower0.5ex\hbox{\strut#2}\kern0.25em}%
				\leaders\bkvz@bottom\hfill
				\vrule\@width\fboxrule\@height\fboxrule}}%
			\breakbox
				\kern.5ex\relax
				\ttfamily\footnotesize\the@code\par
				\normalfont
				\kern3pt
				\hrule height0.1pt width\linewidth depth0.1pt
				\vskip5pt
				\rightskip0pt plus 1fill
				\everypar{{\color{lightgray}\rlap{\vrule height0.1pt width\linewidth depth0.1pt}}\hskip0pt plus 1fill}%
				\newlinechar`\^^M\everyeof{\noexpand}\scantokens{#3}\par
			\endbreakbox
		\endgroup
	\else
		\vskip0.5ex
		\boxput*(0,1)
			{\fboxsep\z@
			\hbox{\sffamily\colorbox{black}{\leavevmode\kern0.25em{\color{white}\footnotesize\strut#2}\kern0.25em}}%
			}%
			{\fboxsep5pt
			\fbox{%
				$\vcenter{\hsize\dimexpr0.#1\linewidth-\fboxsep-\fboxrule\relax
					\kern5pt\parskip0pt \ttfamily\footnotesize\the@code}%
				\vcenter{\kern5pt\hsize\dimexpr\linewidth-0.#1\linewidth-\fboxsep-\fboxrule\relax
					\everypar{{\color{lightgray}\rlap{\vrule height0.1pt width\dimexpr\linewidth-0.#1\linewidth-\fboxsep-\fboxrule depth0.1pt}}}%
					\footnotesize\newlinechar`\^^M\everyeof{\noexpand}\scantokens{#3}}$%
				}%
			}%
	\fi
	\medbreak
	\endgroup
}

\begingroup
	\catcode`\<13 \catcode`\>13
	\gdef\Verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
		\bgroup
			\verb@eol@error \let\do\@makeother \dospecials
			\verbatim@font\@noligs
			\catcode`\<13 \catcode`\>13 \def<{\begingroup$\langle$\itshape}\def>{\/$\rangle$\endgroup}%
			\@ifstar\@sverb\@verb}
\endgroup

\newcommand\falseverb[1]{{\ttfamily\detokenize\expandafter{\string#1}}}

\def\CFengdate@i#1/#2/#3\@nil{\number#3\relax\ifnum#3=1 \ier{}\fi\space \ifcase#2 \or january\or february\or march\or april\or may\or june\or july\or august\or september\or october\or november\or december\fi\space#1}
\edef\CFengdate{\expandafter\CFengdate@i\CFdate\@nil}

\DeclareRobustCommand\CF{%
	\textsf{%
		chem%
		\if\string b\detokenize\expandafter{\f@series}%
			\lower0.01em\hbox{\itshape f}\kern-0.06em
		\else
			\lower0.048em\hbox{\kern-0.04em \itshape f}\kern0.03em
		\fi ig%
		}%
		\xspace
}
\makeatother

\usepackage[english]{babel}
\def\degres{\ensuremath{{}^\circ}}
\newcommand\TIKZ{ti\textit kz\xspace}
\newcommand\molht[1]{\begingroup\parskip3.5pt\par\hfill\chemfig{#1}\hfill\null\par\endgroup}
\newcommand\boxednode[2]{\fbox{$\mathrm{#1}\vphantom{M_1}$}_{#2}}
\newcommand\boxedfalseverb[1]{{\fboxsep0pt\fbox{\vphantom|\falseverb{#1}}}}
\newcommand*\chevrons[1]{\textlangle\textit{#1}\textrangle}
\newcommand*\CFkey[1]{{\color{teal}\texttt{\detokenize{#1}}}}
\newcommand*\CFval[1]{{\color{teal}\textlangle\textit{#1}\textrangle}}
\newcommand*\CFkv[2]{\CFkey{#1}{\color{teal}${}={}$}\CFval{#2}}
\newcommand*\CFparam[1]{\CFkey{#1}&\ifcat\relax\detokenize\expandafter\expandafter\expandafter{\useKV[chemfig]{#1}}\relax \textlangle\textit{empty}\textrangle\else\texttt{\detokenize\expandafter\expandafter\expandafter{\useKV[chemfig]{#1}}}\fi\\}
\newcommand*\Chargeparam[1]{\CFkey{#1}&\ifcat\relax\detokenize\expandafter\expandafter\expandafter{\useKV[charge]{#1}}\relax \textlangle\textit{vide}\textrangle\else\texttt{\detokenize\expandafter\expandafter\expandafter{\useKV[charge]{#1}}}\fi}
\newcommand*\CFdelimparam[1]{\CFkey{#1}&\ifcat\relax\detokenize\expandafter\expandafter\expandafter{\useKV[CFdelimiters]{#1}}\relax \textlangle\textit{vide}\textrangle\else\texttt{\detokenize\expandafter\expandafter\expandafter{\useKV[CFdelimiters]{#1}}}\fi}

\usepackage[plainpages=false,pdfpagelabels,bookmarks=true,bookmarksopen=true,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,pdfauthor={Christian TELLECHEA},pdftitle={ChemFig},pdfsubject={Draw 2D molecule with LaTeX},pdfkeywords={ChemFig},pdfcreator={LaTeX}]{hyperref}

\csname @addtoreset\endcsname{section}{part}
\usepackage{titlesec}
\titleformat{\part}[display]{\normalfont\filcenter\sffamily\bfseries}{}{0pt}{\Huge}

\begin{document}
\topsep=3pt plus5pt minus2pt\relax
\begin{titlepage}
	\catcode`!12
	\begin{tikzpicture}[remember picture,overlay]
		\shade [left color=blue,right color=white]([yshift=2cm]current page.west) rectangle ([xshift=-1cm]current page.south);
		\shade [left color=white,right color=blue] ([xshift=1cm]current page.south) rectangle ([yshift=2cm]current page.east);
		\filldraw[black](current page.north west) rectangle ([yshift=7cm]current page.east);
		\shade[top color=black,bottom color=blue]([yshift=7cm]current page.east)rectangle([yshift=2.5cm]current page.west);
		\filldraw[black!55!blue!100]([yshift=2.5cm]current page.east)rectangle([yshift=2cm]current page.west);
	\end{tikzpicture}
	\begin{center}
		\color{white}\sffamily\fontsize{50pt}{50pt}\selectfont\CF\par
		\Large v\CFver\par
		\CFengdate\par\bigbreak
		\normalsize Christian Tellechea\smallbreak
		\href{mailto:unbonpetit@netc.fr}{\texttt{unbonpetit@netc.fr}}\par\vskip1.5cm
		\huge A \TeX{} package for drawing molecules%
	\end{center}
	\vskip4cm
	\begin{center}
		\scriptsize
		\setchemfig{atom sep=3em}%
		\chemfig{-[::-30](-[5])(-[7])-[::+60]-[::-60]O-[::+60](=[::-45]O)-[::+90]HN>:[::-60](-[::+60]**6(------))-[::-30](<:[2]OH)-[::-60](=[6]O)-[::+60]O>:[::-60]*7(---?(<[::-120]OH)-(<|[1]CH_3)(<:[::-90]CH_3)-(-[1](<[::+80]HO)-[0](=[::+60]O)-[7](<|[::+130]CH_3)(-[::+75](<|[2]OH)-[::-60]-[::-60](<[::+30]O-[::-90])-[::-60](<[::+90])(<:[::+30]O-[7](-[6]CH_3)=[0]O)-[::-60])-[6]-[5,1.3]?(<:[7]O-[5](=[::-60]O)-[6]**6(------)))=(-[2]CH_3)-)}%
		\par
		{\sffamily\small Taxotere}%
	\end{center}
	\vskip1.5cm
	\hfill
	\hbox to 0pt{\hss\scriptsize
		\setchemfig{bond offset=1pt,atom sep=2.5em,compound sep=5em,arrow offset=6pt}
		\schemestart
		  \chemfig{(-[:-150]R')(-[:-30]R)=[2]N-[:30]OH}
		  \arrow{<=>[\chemfig{H^\oplus}]}
		  \chemfig{(-[@{a0}:-150]R')(-[:-30]R)=[2]@{a1}N-[@{b0}:30]@{b1}\chemabove{O}{\scriptstyle\oplus}H_2}
		  \chemmove[red,-stealth,red,shorten <=2pt]{
		      \draw(a0)..controls +(135:2mm) and +(215:4mm).. (a1);
		      \draw(b0)..controls +(120:2mm) and +(180:3mm).. ([yshift=7pt]b1.180);}
		  \arrow{<=>[\chemfig{{-}H_2O}]}[,1.1]
		  \chemleft[{\subscheme[90]{%
		    \chemfig{R'-\chemabove{N}{\scriptstyle\oplus}~C-R}
		    \arrow{<->}[,0.75]
		    \chemfig{R'-\charge{90=\:}{N}=@{a1}\chemabove{C}{\scriptstyle\oplus}-R}}}\chemright]
		  \arrow{<=>[\chemfig{H_2@{a0}\charge{0=\:,90=\:}{O}}]}[,1.1]
		  \chemmove[red,-stealth,red,shorten <=3pt]{
		      \draw(a0)..controls+(90:10mm)and+(45:10mm)..([yshift=6pt]a1.45);}
		  \chemfig{*6(R\rlap{$'$}-N=(-R)-\chemabove{O}{\scriptstyle\oplus} H_2)}
		  \arrow{<=>[\chemfig{{-}H^\oplus}]}
		  \chemfig{*6(R\rlap{$'$}-N=(-R)-OH)}
		  \arrow
		  \chemfig{*6(R\rlap{$'$}-\chembelow{N}{H}-(-R)(=[2]O))}
		\schemestop\hss}\hfill\null
	\begin{center}
		\sffamily\small The Beckmann rearrangement%
	\end{center}
\end{titlepage}
\parindent0pt\pagestyle{plain}
\tableofcontents
\parskip\medskipamount
\newpage

\setitemize{leftmargin=3em,topsep=0pt,parsep=0pt,itemsep=0pt}
\part{Introduction}
\section{New in v1.5}
\subsection{The primitive \texttt{\protect\textbackslash expanded}}
As of version 1.54, \CF requires a \TeX{} engine that provides the \verb|\expanded| primitive. If this is not available, \CF will not be loaded. It is strongly recommended that you update your \LaTeX{} distribution in order to take advantage of the newer engine that provide for the use of this new primitive.

\subsection{The macro \texttt{\protect\textbackslash charge}}
Version 1.5 implements the macros \verb|\charge| and \verb|\Charge| (see page~\pageref{charge}) whose purpose is to place arbitrary elements around an atom that can be placed with great precision. These macros will replace the \verb|\lewis| and \verb|\Lewis| macros because they are much more powerful and configurable, even if more verbose. It is therefore important to note that the macros \verb|\lewis| and \verb|\Lewis| \textcolor{red}{\bfseries are no longer documented and will be removed from the \CF package}.

\exemple{La macro \string\charge}/Simple charges around A :
\Charge{0=\:,
        0:3pt[anchor=180]=$\color{red}\scriptstyle\delta^+$,
        120={\"["width=2pt,"style={draw=green,fill=gray}]},
        210=\|
        }{A}
\par
Complex charges aroud "B" :
\Charge{%
	30:10pt={\chemfig[atom sep=6pt,double bond sep=1.5pt]{[:20]*6(=-=-=-)}},
	120:5pt[scale=0.4,rotate=30,anchor=center]=\chemfig{CH_2=CH_2},
	-45[anchor=west,rotate=\chargeangle]={%
		\begin{tikzpicture}
			\node[anchor=mid west](a){$\oplus$};\draw[-stealth](a)--(-.5,0);
		\end{tikzpicture}}%
	}{B}/

\subsection{Consecutive bonds}
As of version 1.5, two bonds are joined if the atom between them has all its dimensions equal to zero (i.e. width, height and depth in the sense of \TeX). Previously, two bonds were joined if the atom was \emph{empty}, which was more restrictive.

Together with the use of the macro \verb|\charge|, this new feature makes it possible to place charges in a chain without using invisible bonds.
\exemple{Consecutive bonds}/\chemfig{[:30]-\charge{90=\:}{}
-[:-30]\charge{-90=\"}{}-\charge{90:2pt=$\delta^+$}{}-[:-30]}/

\subsection{Manual Update}
More detailed explanations are given on:
\begin{itemize}
	\item the role played by the first atom encountered in the placement of the whole molecule (page~\pageref{premieratome1} and \pageref{premieratome});
	\item how \CF places the atoms in a group of atoms (page~\pageref{placementatomes});
	\item how a bond joins two atoms (page~\pageref{liaisonatomes}).
\end{itemize}

\section{Presenting \protect\CF}
To use this package, start by adding the following code to the preamble:
\begin{itemize}
	\item {\color{blue}\verb-\input chemfig.tex-} with $\varepsilon$\TeX;
	\item {\color{blue}\verb-\usepackage{chemfig}-} with \LaTeX;
	\item {\color{blue}\verb-\usemodule[chemfig]-} with Con\TeX t\falseverb*{ConTeXt@Con\protect\TeX{}t}.
\end{itemize}

In all cases, the \TIKZ package, if not loaded before, is loaded by \CF.

The most important command for drawing molecules is \Verb|\chemfig{<code>}|. The argument \verb|code| is a set of characters describing the structure of the molecule according to the rules which are described in this manual.

Care has been taken to make it possible to draw the greatest possible number of molecular configurations, while maintaining a simple, flexible, and intuitive syntax. Despite this, the \Verb-<code>- which describes the 2D structure of the molecule increases in complexity in proportion to that of the molecule being drawn.

The command \verb|\chemfig| draws a molecule using the commands provided by the \TIKZ package, placed inside a \verb|tikzpicture| environment. The choice of \TIKZ implies that:
\begin{itemize}
\item the user has a choice of compilation method: pdf\LaTeX{} can be used equally well in \falseverb{dvi mode} (tex $\longrightarrow$ dvi $\longrightarrow$ ps $\longrightarrow$ pdf) or in \falseverb{pdf mode} (tex $\longrightarrow$ pdf). In effect \TIKZ, via the underlying \falseverb{pgf}, gives identical graphical results in the two modes;
\item the \falseverb{bounding box} is automatically calculated by \TIKZ and the user need not worry about any overlap with the text. However, care must be taken with alignment when the molecule is drawn in a paragraph. In the following example, we have drawn the \falseverb{bounding box} for the molecule: {\fboxsep0pt \fbox{\chemfig{H_3C-C(-[:-30]OH)=[:30]O}}}.
\end{itemize}

\section{Acknowledgment}
This package has seen the light of day thanks to the assistance of Christophe \textsc{Casseau}, who had the idea. I thank him for his help before writing the code and for the tests he carried out.
\medbreak
I also want to warmly thank Theo \textsc{Hopman} for offering to translate this manual into English.
\newpage

\part{Operation of \protect\CF}
This part is devoted to describing the most common features of \CF. The user will find here explanations sufficient to draw most molecules. The presentation of features is done from a theoretical angle, and the goal of this part is not to draw real molecules but to give the user a formal description of the functionality of \CF. The ``Advanced usage'', page~\pageref{utilisation.avancee}, will be more practical and will illustrate advanced features for the most demanding uses. It will also highlight methods of building real molecules, page~\pageref{exemples.commentes}. Finally, the last part will give examples of molecules and the code used to draw them.

\section{The \texttt{\textbackslash chemfig} macro}
The macro \verb|\chemfig| has the following syntax
\begin{center}
	\Verb|\chemfig[list of <keys>=<values>]{<molecule code>}|
\end{center}
The optional argument in square brackets sets the parameters used for this molecule. It should be noted that the parameters are only modified for the current molecule and will be restored to their previous values after the macro has been executed. To permanently modify parameters, the macro \Verb|\setchemfig{<key>=<values>}| should be used.

Here is the complete list of parameters as well as their default values\label{listeparametres}. It should be noted that the \chevrons{keys} from \CFkey{scheme debug} included to the end of the list concern reaction schemes and make no sense in the optional argument of the macro \verb|\chefig| where they are simply ignored:\par
\leavevmode\hfill
\begin{minipage}[t]{.45\linewidth}
	\begin{longtable}{rl}\hline
		\chevrons{keys} & default \chevrons{values}\\\hline\endhead
		\CFparam{chemfig style}
		\CFparam{atom style}
		\CFparam{bond join}
		\CFparam{fixed length}
		\CFparam{cram rectangle}
		\CFparam{cram width}
		\CFparam{cram dash width}
		\CFparam{cram dash sep}
		\CFparam{atom sep}
		\CFparam{bond offset}
		\CFparam{double bond sep}
		\CFparam{angle increment}
		\CFparam{node style}
		\CFparam{bond style}
		\CFparam{lewis | width}
		\CFparam{lewis sep}
		\CFparam{lewis length}
		\CFparam{lewis style}
		\CFparam{lewis dist}\hline
	\end{longtable}
\end{minipage}\hfill
\begin{minipage}[t]{.45\linewidth}
	\begin{longtable}{rl}\hline
		\chevrons{keys} & default \chevrons{values}\\\hline\endhead
		\CFparam{lewis radius}
		\CFparam{lewis diag coeff}
		\CFparam{cycle radius coeff}
		\CFparam{stack sep}
		\CFparam{scheme debug}
		\CFparam{compound style}
		\CFparam{compound sep}
		\CFparam{arrow offset}
		\CFparam{arrow angle}
		\CFparam{arrow coeff}
		\CFparam{arrow style}
		\CFparam{arrow double sep}
		\CFparam{arrow double coeff}
		\CFparam{arrow double harpoon}
		\CFparam{arrow label sep}
		\CFparam{arrow head}
		\CFparam{+ sep left}
		\CFparam{+ sep right}
		\CFparam{+ vshift}\hline
	\end{longtable}
\end{minipage}\hfill\null\bigbreak

The \Verb|<molecule code>| contains instructions for drawing the molecule according to a syntax that will be explained in this document. There are no restrictions on the characters accepted in the code:
\begin{itemize}
	\item all catcode 11 or 12 characters, i. e. upper and lower-case letters, numbers, mathematical operators (\texttt+ \texttt- \texttt* \texttt/ \texttt=), punctuation marks whether active or not (\verb|.| \verb|,| \verb|;| \verb|:| \verb|!| \verb|?| \verb|'| \verb|`| \verb|"| \verb-|-), parenthesis and brackets;
	\item more special characters such as "\verb|~|", "\verb|#|"\footnote{To avoid that \texttt\# is doubled when the macro \texttt{\textbackslash chemfig} is in the argument of a macro, instead of \texttt\#, the macro \texttt{\textbackslash\#} or the macro \texttt{\textbackslash CFhash} can be used.} as well as "\verb|^|" and "\verb|_|" which have their normal mathematical mode properties;
	\item spaces, but these are ignored by default because the atoms are composed in mathematical mode;
	\item the "\verb|{|" and "\verb|}|" braces that have their normal behavior as group markers or macro argument delimiters;
	\item macros.
\end{itemize}

\section{Groups of atoms}
Drawing a molecule consists inherently of connecting groups of atoms with lines. Thus, in the molecule \chemfig{O=O}, there are two groups of atoms, each consisting of a single atom ``O''.

{\fboxsep1pt
However, in this molecule
\molht{H_3C-C(-[:-30]OH)=[:30]O}
there are four groups of atoms: ``$\mathrm{H_3C}$'', ``C'', ``O'' and ``OH''. For reasons which we shall see later, \CF splits each group into single atoms. Each atom extends up to the next capital letter or one of these special characters: {\ttfamily \boxedfalseverb{-} \boxedfalseverb{=} \boxedfalseverb{~} \boxedfalseverb{(} \boxedfalseverb{!} \boxedfalseverb{*} \boxedfalseverb{<} \boxedfalseverb{>} \boxedfalseverb{@}}. \CF ignores all characters inside braces when splitting groups into atoms.

Therefore the first group of atoms ``$\mathrm{H_3C}$'' is split into two atoms: $\boxednode{H_3}{}$ and $\boxednode C{}$. In terms of chemistry, of course, these are not real atoms; $\mathrm{H_3}$, for example, consists of three hydrogen atoms. In what follows the word atom refers to \CF's definition. Thus \CF sees the preceding molecule as follows:
\renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
\molht{H_3C-C(=[:30]O)(-[:-30]OH)}}

A space is ignored when at the beginning of a group of atoms.

\section{First atom's role}\label{premieratome1}
It is important to understand that the placement of the entire molecule depends on the first atom placed, i.e. the first atom of the first group of atoms. For this first atom, its \TIKZ anchor "\verb|base east|" is placed on the baseline of the current line (drawn in gray in the examples of this manual).

\exemple{Influence of the first atom}/\chemfig{A-B}\qquad
\chemfig{-B}\qquad
\chemfig{A^1-B}/

\section{Different types of bonds}
For \CF, bonds between two atoms are one of nine types, represented by the characters \boxedfalseverb-, \boxedfalseverb=, \boxedfalseverb~, \boxedfalseverb>, \boxedfalseverb<, \boxedfalseverb{>:}, \boxedfalseverb{<:}, \boxedfalseverb{>|} and \boxedfalseverb{<|} :\label{types.liaisons}
\begin{center}
\begin{tabular}{>{\centering\arraybackslash}m{1.7cm}>{\centering\arraybackslash}m{3cm}>{\centering\arraybackslash}m{2cm}m{4cm}}
\hline
Bond \#&Code                 &Result      &Bond type\\\hline
1            &\verb+\chemfig{A-B}+ &\chemfig{A-B} &Single\\
2            &\verb+\chemfig{A=B}+ &\chemfig{A=B} &Double\\
3            &\verb+\chemfig{A~B}+ &\chemfig{A~B} &Triple\\
4            &\verb+\chemfig{A>B}+ &\chemfig{A>B} &right Cram, plain\\
5            &\verb+\chemfig{A<B}+ &\chemfig{A<B} &left Cram, plain\\
6            &\verb+\chemfig{A>:B}+&\chemfig{A>:B}&right Cram, dashed\\
7            &\verb+\chemfig{A<:B}+&\chemfig{A<:B}&left Cram, dashed\\
8            &\verb+\chemfig{A>|B}+&\chemfig{A>|B}&right Cram, hollow\\
9            &\verb+\chemfig{A<|B}+&\chemfig{A<|B}&left Cram, hollow\\\hline
\end{tabular}
\end{center}
\label{double bond sep}The \chevrons{key} \Verb-double bond sep=<dim>- adjusts the spacing between the lines in double or triple bonds. This spacing is 2pt by default.

\label{longueur.liaison}We must understand that when a bond is made between two atoms, these atoms are contained within invisible rectangular boxes. The centers of these two rectangles are separated by an adjustable distance $\Delta$ called the ``interatomic distance''. Furthermore, bonds do not connect to the exact edges of the rectangles: a length $\delta$, also adjustable, separates the edges of the rectangles and the beginning and end of the bond line. The rectangular boxes are made visible in the diagram below to help understanding.
\begin{center}
\begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline]
	\node[draw] at(0,0)(aa){\huge A};
	\node[draw]at(4,0)(bb){\huge B};
	\path[shorten <=10pt,shorten >=10pt,draw](aa)--(bb)coordinate[pos=0](al) coordinate[pos=1](bl);
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(al){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=10pt]al){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(bl){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=-10pt]bl){};
	\draw[blue,dash pattern=on 1pt off 1pt](bl)--([yshift=0.7cm]bl);
	\draw[blue,dash pattern=on 1pt off 1pt]([xshift=-10pt]bl)--([xshift=-10pt,yshift=0.7cm]bl);
	\draw[stealth-stealth]([yshift=0.6cm]bl.center)--([xshift=-10pt,yshift=0.6cm]bl.center) node [midway,above,draw=none]{$\delta$};
	\draw[blue,dash pattern=on 1pt off 1pt](al)--([yshift=0.7cm]al);
	\draw[blue,dash pattern=on 1pt off 1pt]([xshift=10pt]al)--([xshift=10pt,yshift=0.7cm]al);
	\draw[stealth-stealth]([yshift=0.6cm]al.center)--([xshift=10pt,yshift=0.6cm]al.center) node [midway,above,draw=none]{$\delta$};
	\node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(aa){};
	\node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(bb){};
	\draw[stealth-stealth]([yshift=1cm]aa.center)--([yshift=1cm]bb.center) node [midway,above,draw=none] {$\Delta$} ;
	\draw[red,dash pattern=on 2pt off2pt](aa.center)--([yshift=1.1cm]aa.center);
	\draw[red,dash pattern=on 2pt off2pt](bb.center)--([yshift=1.1cm]bb.center);
\end{tikzpicture}
\end{center}

\label{atom sep}The \chevrons{key} \CFkv{atom sep}{dim} adjusts the interatomic distance $\Delta$. This setting, like all other settings, affects all the following molecules.

\exemple{Interatomic distance}|\chemfig[atom sep=2em]{A-B}\par
\chemfig[atom sep=50pt]{A-B}|

\label{bond offset}The \chevrons{key} \CFkv{bond offset}{dim} sets the spacing $\delta$ between the bond line and the atom. Its default value is 2pt.
\exemple{Trimming bonds}|\chemfig[bond offset=0pt]{A-B}\par
\chemfig[bond offset=5pt]{A-B}|

If one bond is followed immediately by another, then \CF inserts an empty group \verb-{}-. Around this empty group the separation $\delta$ is zero:
\exemple{Empty groups}/\chemfig{A-B=-=C}/

\label{bond style}The \chevrons{key} \CFkv{bond style}{tikz code} sets the style for all the bonds drawn thereafter. The \CFval{tikz code} is empty by default. To custom a single bond, see page~\pageref{perso-liaisons}.
\exemple{Style of bonds}/\chemfig[bond style={line width=1pt,red}]{A-B=C>|D<E>:F}/

\label{modif.retrait} The spacing $\delta$ for just one bond can be specified with the character \verb-#-. This character must be placed \emph{immediately} after the bond symbol and has one required argument between parentheses of the form ``\Verb-#(<dim1>,<dim2>)-'', where \Verb-<dim1>- is the spacing $\delta$ at the beginning of the bond and \Verb-<dim2>- is the that at the end. If \Verb-<dim2>- is omitted, the spacing at the end of the bond takes the value of $\delta$ in effect at that time. One can see in the example how the shortening, set to 4pt to be more visible, is nullified for the bond arriving at ``B'', then for the one leaving ``B'', and finally for both:
\begingroup
\catcode`\#12
\exemple{Fine adjustment of bond shortening}/\setchemfig{bond offset=4pt}
\chemfig{A-B-C}\par
\chemfig{A-#(,0pt)B-C}\par
\chemfig{A-B-#(0pt)C}\par
\chemfig{A-#(,0pt)B-#(0pt)C}/
\endgroup

By default, all atoms within groups of atoms are typeset in \falseverb{math mode} (spaces are ignored). They may therefore contain math mode specific commands such as subscripts or superscripts\footnote{There is a problem with the placement of groups of atoms containing exponents or subscripts. See page~\pageref{alignement.vertical}.}:
\exemple{Math mode}|\chemfig{A_1B^2-C _ 3 ^ 4}|

There are settings specifically for Cram bonds:
\begin{itemize}
	\item \CFkv{cram width}{dim} is the size of the base of the triangle, and is 1.5pt by default;
	\item \CFkv{cram dash width}{dim} is the thickness of the dots, and is 1pt by default;
	\item \CFkv{cram dash sep}{dim} is the spacing between the dots, and is 2pt by default.
\end{itemize}

Here is an example where the three dimensions are changed:

\exemple{Modified Cram bonds}-\chemfig[cram width=10pt,
         cram dash width=0.4pt,
         cram dash sep=1pt]{A>B>:C>|D}-

\section{Bond angle}
Each bond takes an optional argument in brackets. This optional argument can adjust every aspect of a bond, and consists of five optional fields separated by commas. The first of these fields defines the bond angle. Angles increase counterclockwise, and are relative to the horizontal. If the angle field is empty, the angle takes its default value of 0\degres. We will see later how to change this default.

There are several ways of specifying the bond angle.
\subsection{Predefined angles}
When the angle field contains an integer, this represents the angle the bond makes relative to the horizontal, in multiples of 45\degres. For example, \verb-[0]- specifies an angle of 0\degres, \verb-[1]- is 45\degres, and so on.

\exemple{Predefined angles}|\chemfig{A-B-[1]C-[3]-D-[7]E-[6]F}|

These angles remain valid if the atoms are empty, and this is the case for all the features we will see below:
\exemple{Predefined angles with empty groups}|\chemfig{--[1]-[3]--[7]-[6]}|

For those who find this "ugly\footnote{See \texttt{\detokenize{http://tex.stackexchange.com/questions/161796/ugly-bond-joints-in-chemfig detokenize}}}", it is now possible connect the single bonds with a slightly increased compilation time. The boolean \chevrons{key} \CFkv{bond join}{boolean} macro enables this feature when \CFval{true} and disables it when \CFval{false}, which is the better behavior, set by default.

\exemple{Connecting bonds}/\setchemfig{bond style={line width=3pt}}
\chemfig{-[1]-[7]} et
\chemfig[bond join=true]{-[1]-[7]}/

\label{angle increment}The \chevrons{key} \CFkv{angle increment}{angle} sets the default angle used to calculate the angle of a bond:

\exemple{Set the predefined angle}/Default (45) : \chemfig{-[1]-[-1]-[1]-[-1]}

Angle of 30 : \chemfig[angle increment=30]{-[1]-[-1]-[1]-[-1]}/

\subsection{Absolute angles}
If one wishes to specify an angle in degrees relative to the horizontal, then the optional angle field must take this form: \Verb-[:<absolute angle>]-. If necessary, the \Verb-<absolute angle>- is reduced to the interval $[0,360)$:
\exemple{Absolute angles}/\chemfig{A-[:30]B=[:-75]C-[:10]D-[:90]>|[:60]-[:-20]E-[:0]~[:-75]F}/

\subsection{Relative angles}\label{angle.relatif}
It is often useful to specify a bond angle relative to the preceding bond. This syntax must be then be used: \Verb-[::<relative angle>]-. The sign of the \Verb-<relative angle>- can be omitted if it is a \verb-+-.

Here is a molecule where the first bond has an absolute angle of $-5\degres$, and the rest of the bond angles are incremented by 20\degres:
\exemple{Result of relative angles}|\chemfig{A-[:-5]-[::+20]-[::20]B-[::+20]-[::20]C-[::20]}|

One can ``break'' a chain of relative angles by putting an absolute or predefined angle where desired. Here, atom ``B'' is followed by a bond at  an absolute angle of 315\degres.
\exemple{Result of relative angles followed by absolute}|\chemfig{A-[:-5]-[::20]-[::20]B-[7]-[::20]C-[::20]}|

\section{Length of a bond}
Rather than speaking of length of a bond, we should use the term interatomic spacing. If effect, only the interatomic spacing is adjustable with \falseverb{atom sep} as we have seen on page~\pageref{longueur.liaison}. Once this parameter is set, the length of a bond depends on the content of atoms and, to a lesser extent, the angle the bond makes with the horizontal. It should be obvious that two ``slimmer'' atoms will have larger edge separations than two which are larger. This can be seen easily in the following example where an ``I'' atom is narrower than an ``M'' atom, which means that the bond between the ``I'' atoms is longer than that between the ``M'' atoms:
\exemple{Influence of the size of atoms}|\chemfig{I-I}\par
\chemfig{M-M}|

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts. In this example, the bond is extremely short, to the point of confusion with a negative sign $-$:
\exemple{Too-short bond}|\chemfig{A^{++}_{2}-B^{-}_3}|

It is important to note that the exponent \verb+-+ is \emph{put inside braces}. If this were not done, \CF would stop the atom on this character, which is a bond character. The atom would then be ``\verb-B^-'', which would lead to unexpected results.

It is possible to change the behavior of \CF about the interatomic spacing. Indeed, when the \verb+\chemfig+ macro is immediately followed by a star, the \chevrons{key} \CFkey{atom sep}no longer defines the distance between the centers of atoms, denoted $\Delta$, but \emph{length of the bonds}. Consequently, the bonds have fixed lengths while the distance between the centers of the atoms is variable and depends on their size. Here is the diagram on page~\pageref{longueur.liaison} and what becomes with the two boolean values of key \CFkey{fixed length}:

\begin{center}
\begin{tabular}{c@{\kern2cm}c}
	\CFkv{fixed length}{false}&\CFkv{fixed length}{true}\\[2ex]
	\begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline]
	\node[draw] at(0,0)(aa){\huge A};
	\node[draw]at(4,0)(bb){\huge B};
	\path[shorten <=10pt,shorten >=10pt,draw](aa)--(bb)coordinate[pos=0](al) coordinate[pos=1](bl);
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(al){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=10pt]al){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(bl){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=-10pt]bl){};
	\draw[blue,dash pattern=on 1pt off 1pt](bl)--([yshift=0.7cm]bl);
	\draw[blue,dash pattern=on 1pt off 1pt]([xshift=-10pt]bl)--([xshift=-10pt,yshift=0.7cm]bl);
	\draw[stealth-stealth]([yshift=0.6cm]bl.center)--([xshift=-10pt,yshift=0.6cm]bl.center) node [midway,above,draw=none]{$\delta$};
	\draw[blue,dash pattern=on 1pt off 1pt](al)--([yshift=0.7cm]al);
	\draw[blue,dash pattern=on 1pt off 1pt]([xshift=10pt]al)--([xshift=10pt,yshift=0.7cm]al);
	\draw[stealth-stealth]([yshift=0.6cm]al.center)--([xshift=10pt,yshift=0.6cm]al.center) node [midway,above,draw=none]{$\delta$};
	\node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(aa){};
	\node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(bb){};
	\draw[stealth-stealth]([yshift=1cm]aa.center)--([yshift=1cm]bb.center) node [midway,above,draw=none] {$\Delta$} ;
	\draw[red,dash pattern=on 2pt off2pt](aa.center)--([yshift=1.1cm]aa.center);
	\draw[red,dash pattern=on 2pt off2pt](bb.center)--([yshift=1.1cm]bb.center);
	\end{tikzpicture}
	&
	\begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline]
	\node[draw] at(0,0)(aa){\huge A};
	\node[draw]at(5,0)(bb){\huge B};
	\path[shorten <=10pt,shorten >=10pt,draw](aa)--(bb)coordinate[pos=0](al) coordinate[pos=1](bl);
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(al){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=10pt]al){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(bl){};
	\node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=-10pt]bl){};
	\draw[blue,dash pattern=on 1pt off 1pt](bl)--([yshift=0.7cm]bl);
	\draw[blue,dash pattern=on 1pt off 1pt]([xshift=-10pt]bl)--([xshift=-10pt,yshift=0.7cm]bl);
	\draw[stealth-stealth]([yshift=0.6cm]bl.center)--([xshift=-10pt,yshift=0.6cm]bl.center) node [midway,above,draw=none]{$\delta$};
	\draw[blue,dash pattern=on 1pt off 1pt](al)--([yshift=0.7cm]al);
	\draw[blue,dash pattern=on 1pt off 1pt]([xshift=10pt]al)--([xshift=10pt,yshift=0.7cm]al);
	\draw[stealth-stealth]([yshift=0.6cm]al.center)--([xshift=10pt,yshift=0.6cm]al.center) node [midway,above,draw=none]{$\delta$};
	\draw[stealth-stealth]([yshift=1cm]al)--([yshift=1cm]bl) node [midway,above,draw=none] {$\Delta$} ;
	\draw[red,dash pattern=on 2pt off2pt](al)--([yshift=1.1cm]al);
	\draw[red,dash pattern=on 2pt off2pt](bl)--([yshift=1.1cm]bl);
	\end{tikzpicture}
\end{tabular}
\end{center}

In rings, even when \CFkv{fixed length}{true}, the default behavior is restored for the bonds of the cycle, in order to draw regular polygons.

\exemple{Fixed length bonds}/\chemfig{Cl-Cl}\par
\chemfig[fixed length=true]{Cl-Cl}/

Especially with the default behavior, to avoid too short bonds, it is sometimes necessary to increase (or perhaps reduce) the interatomic distance. For this, the optional argument to bonds is actually made up of several comma-separated fields. As we have seen, the first field specifies the angle. The second field, if it is not empty, is a coefficient which multiplies the default interatomic distance $\Delta$. Thus, writing \verb+-[,2]+ asks that this bond have the default angle (first field is empty) and that the atoms it connects be separated by twice the default distance.
\exemple{Modified bond length}/\chemfig{A^{++}_{2}-[,2]B^{-}_3}\par
\chemfig{A-B-[,2]C=[,0.5]D}\par
\chemfig{-=[,1.5]-[,0.75]=[:-20,2]}/

We can change the \falseverb{size of molecules} by altering the font size or the \chevrons{key} \CFkey{atom sep}, possibly on both, being careful to confine these changes within a group if we want to limit the scope:
\exemple{How to modify the size of molecule}/\normalsize       \chemfig{H-[:30]O-[:-30]H}\par
\setchemfig{atom sep=2.5em}
\chemfig{H-[:30]O-[:-30]H}\par
\small            \chemfig{H-[:30]O-[:-30]H}\par
\footnotesize     \chemfig{H-[:30]O-[:-30]H}\par
\scriptsize       \chemfig{H-[:30]O-[:-30]H}\par
\tiny             \chemfig{H-[:30]O-[:-30]H}/

\section{Departure and arrival atoms}
A group of atoms can contain several atoms. Suppose we want to connect the group ``ABCD'' to the group ``EFG'' with a bond. \CF calculates which atom of the first group and which of the second group are to be connected by looking at the angle of bond relative to the horizontal. If the angle is between (but not including) $-90\degres$ and 90\degres{} (modulo 360\degres) then the bond is made between the last atom of the first group and the first atom of the second group. In all other cases, the bond is made between the first atom of the first group and the last atom of the second group.

Here are some examples where the bond is in the interval $(-90,90)$, and where the bond is made between D and E:
\exemple{Default atom connections}|\chemfig{ABCD-[:75]EFG}\quad
	\chemfig{ABCD-[:-85]EFG}\quad
	\chemfig{ABCD-[1]EFG}|

In the  following examples, the angles are in the interval $[90,270]$ and so the bond is made between A and G:
\exemple[60]{Default atom connections}|\chemfig{ABCD-[:100]EFG}\quad
	\chemfig{ABCD-[:-110]EFG}\quad
	\chemfig{ABCD-[5]EFG}|

One may sometimes want the bond partners to be atoms other than those determined by \CF. The departure and arrival atoms can be set with the optional bond argument by writing:
\begin{center}
	\Verb/[,,<integer 1>,<integer 2>]/
\end{center}
where \Verb-<integer 1>- and \Verb-<integer 2>- are the numbers of the desired departure and arrival atoms. These atoms must exist, otherwise an error message will be given.
\exemple{Specified atom connections}|\chemfig{ABCD-[:75,,2,3]EFG}\qquad
	\chemfig{ABCD-[:75,,,2]EFG}\qquad
	\chemfig{ABCD-[:75,,3,2]EFG}|

\section{Customization of bonds}\label{perso-liaisons}
There is a fifth and last optional argument for bonds which is found after the fourth comma:
\begin{center}
	\Verb/[,,,,<tikz code>]/
\end{center}

This \Verb-<tikz code>- is passed directly to \TIKZ when the bond is drawn. There one can put characteristics such as colour (\verb-red-), dash type (\verb-dash pattern=on 2pt off 2pt-), thickness (\verb-line width=2pt-), or even decoration if the \TIKZ decoration library has been loaded. A bond can be made invisible by writing ``\verb-draw=none-''. To set several attributes, the syntax of \TIKZ is used, separating them by a comma:
\exemple{Passing tikz code}|\chemfig{A-[,,,,red]B}\par
\chemfig{A-[,,,,dash pattern=on 2pt off 2pt]B}\par
\chemfig{A-[,,,,line width=2pt]B}\par
\chemfig{A-[,,,,red,line width=2pt]B}|

Numerous \TIKZ decoration libraries are available. For example, one can use the ``\verb-pathmorphing-'' library by putting \verb-\usetikzlibrary{decorations.pathmorphing}- in the preamble in order to draw wavy bonds:
\exemple{Wavy bonds}|\chemfig{A-[,3,,,decorate,decoration=snake]B}|

Cram bonds ignore thickness and dash settings.

\section{Default values}
At the beginning of each molecule, the default values for the optional arguments are initialized. They are:
\begin{itemize}
	\item 0\degres{} for the bond angle;
	\item 1 for the length multiplication coefficient;
	\item \Verb-<empty>- for the numbers of the departure and arrival atoms, which lets \CF calculate these based on the bond angle;
	\item \Verb-<empty>- for the parameters passed to \TIKZ.
\end{itemize}

These default values can be changed for the whole molecule by beginning the molecule code with
\begin{center}
	\Verb/[<angle>,<coeff>,<n1>,<n2>,<code tikz>]/
\end{center}

Thus, if the code of a molecule begins with \verb-[:20,1.5]-, then all the bonds will be at angle of 20\degres{} by default, and the interatomic distances will have a length 1.5 times the default length. These default values can be overridden at any time by giving an optional argument, such as for the bond which follows atom ``C'' in this example:
\exemple{Overriding default values}|\chemfig{[:20,1.5]A-B-C-[:-80,0.7]D-E-F}|

If something odd like \verb-[1,1.5,2,2,red,thick]- is written, then unless otherwise indicated all the bonds will have an angle of 45\degres{}, the interatomic distances will be 1.5 times the default distance, the bonds will begin and end on the second atom of each group, and the bonds will be red and thick:
\exemple{Default values}|\chemfig{[1,1.5,2,2,red,thick]ABC-DEF=GHI}|

\section{Branches}
\subsection{Principle}
Up to now, all the molecules have been linear, which is rare. A sub-molecule can be attached to an atom by following the atom with \Verb-<code>- in parentheses. This \Verb-<code>- is the code of the sub-molecule which will be attached to the atom.

In this example, the sub-molecule ``\verb/-[1]W-X/'' will be attached to atom ``B'': 
\exemple{A branch}|\chemfig{A-B(-[1]W-X)-C}|

There can be several sub-molecules which are to be attached to the same atom. Just have several parentheses containing the code for each sub-molecule:
\exemple{Multiple branches}|\chemfig{A-B(-[1]W-X)(-[6]Y-[7]Z)-C}|

The code of each sub-molecule can define its own default values, which will be valid throughout the whole sub-molecule. Here a sub-molecule ``\verb/[:60]-D-E/'' is attached to atom ``B'', with a default angle of 60\degres{} absolute. A second sub-molecule ``\verb/[::-60,1.5]-X-Y/'' is attached to ``B'' with a default bond angle 60\degres{} less than that of the preceding bond (which will be the one between ``A'' and ``B'') and with an interatomic distance 1.5 times the default value:
\exemple{Default values in branches}|\chemfig{A-B([:60]-D-E)([::-30,1.5]-X-Y)-C}|

Observe what happens if, at the beginning of the main molecule, one writes ``\verb/[:-45]/'':
\exemple{Effect of the default bond angle}|\chemfig{[:-45]A-B([:60]-D-E)([::-30,1.5]-X-Y)-C}|

We see that the angle between the bond \verb/B-C/ and the bond \verb/B-X/ stays at 30\degres{} because it is a relative angle for the sub-molecule ``\verb/-X-Y/''. By contrast, the branch ``\verb/-D-E/'' stays inclined at 60\degres{} to the horizontal, and does not follow the rotation given by the $-45\degres$ angle at the beginning; this is expected because ``\verb/-D-E/'' has an absolute angle. It is essential that all the angles be relative in order to rotate the whole molecule.

\subsection{Nesting}
Sub-molecules may be nested, and the rules seen in the preceding paragraphs stay in force:
\exemple{Nested branches}|\chemfig{A-B([1]-X([2]-Z)-Y)(-[7]D)-C}|

\subsection{Method}
Suppose now that we want to draw an acid anhydride molecule:
\chemfig{R-C(=[::+60]O)-[::-60]O-[::-60]C(=[::+60]O)-[::-60]R}

The best way to get this is to find the longest chain. Here, for example, we can draw the chain \verb/R-C-O-C-R/ taking into account angles and using only relative angles:
\exemple{Acid anhydride structure}|\chemfig{R-C-[::-60]O-[::-60]C-[::-60]R}|

To this structure we just have to add two ``\verb/=O/'' sub-molecules to each of the carbon atoms:
\exemple{Acid anhydride}|\chemfig{R-C(=[::+60]O)-[::-60]O-[::-60]C(=[::+60]O)-[::-60]R}|

Because we used only relative angles, we can rotate this molecule by giving a default angle of e.g. 75\degres:
\exemple[70]{Rotation of a molecule}|\chemfig{[:75]R-C(=[::+60]O)-[::-60]O-[::-60]C(=[::+60]O)-[::-60]R}|

\section{Connecting distant atoms}
We have seen how to connect atoms \emph{which are adjacent in the code}. It is often necessary to connect atoms which are not next to each other in the code. Let's call these particular bonds ``distant bonds''.

Let's take this molecule:
\exemple{Branched structure}|\chemfig{A-B(-[1]W-X)(-[7]Y-Z)-C}|

and suppose that we want to connect the atoms \verb/X/ and \verb/C/. In this case, \CF allows a ``hook'' to be placed \emph{immediately} after the atom of interest. The character used for a hook is ``\verb-?-'' because of its similarity to a hook. So, if one writes \verb/X?/ then the atom \verb/X/ will have a hook. Later in the code, all atoms followed by a \verb-?- will be connected to \verb/X/:
\exemple{Distant bond}|\chemfig{A-B(-[1]W-X?)(-[7]Y-Z)-C?}|

We could connect other atoms to X by following them with \verb-?-. Here it's the atoms \verb-C- and \verb-Z-:
\exemple{Several distant bonds}|\chemfig{A-B(-[1]W-X?)(-[7]Y-Z?)-C?}|

Now imagine if we were to leave the distant bonds \verb/X-C/ and \verb/X-Z/while adding another: \verb/A-W/. We must therefore ask for two \emph{different} hooks, one on \verb/A/ and the other on \verb/X/. Fortunately the character \verb/?/ has an optional argument:
\begin{center}
	\Verb/?[<name>,<bond>,<tikz>]/
\end{center}
where each field takes its default value if it is empty:
\begin{itemize}
	\item The \Verb-<name>- is the name of the hook: all alphanumeric characters (a\dots z, A\dots Z, 0\dots 9) are allowed\footnote{This is not exactly right. Actually all the characters that can be put between \texttt{\string\csname...\string\endcsname} are allowed.}. The name is \verb-a- by default. In the first occurrence of the hook with this name, only this field is used.
	\item \Verb-<bond>- specifies how the atom with the current occurrence of the named hook is to be bonded to the atom with the first occurrence of the hook. There are two ways this can be done. First, this field can be an integer representing the desired bond type: 1=single bond, 2=double bond, etc. (See the table on page~\pageref{types.liaisons} for the bond codes.)

		Second, the field can be one of the bond character codes, provided that this character is \emph{between braces}.
	\item \Verb-<tikz>- will be passed directly to \TIKZ as we have seen with regular bonds.
\end{itemize}

Here is our molecule with the required distant bonds, then with the bond \verb/A-W/ and \verb/X-C/ customized:
\exemple{Multiple distant bonds}|\chemfig{A?[a]-B(-[1]W?[a]-X?[b])(-[7]Y-Z?[b])-C?[b]}\par\medskip
	\chemfig{A?[a]-B(-[1]W?[a,2,red]-X?[b])(-[7]Y-
	Z?[b,1,{line width=2pt}])-C?[b,{>},blue]}|

Several different hooks can be written after an atom. Suppose that in this unfinished pentagon, we wish to connect \verb/A-E/, \verb/A-C/ and \verb/E-C/:
\exemple{An incomplete ring}|\chemfig{A-[:-72]B-C-[:72]D-[:144]E}|

Then we must do this:
\exemple{Multiple distant bonds}|\chemfig{A?[a]-[:-72]B-C?[a]?[b]-[:72]D-[:144]E?[a]?[b]}|

\section{Rings}
The preceding example shows how to draw a regular polygon, but the method used is tedious because the angles depend on the number of sides of the polygon.

\subsection{Syntax}
\CF can easily draw regular polygons. The idea is to attach a ring to an \Verb/<atom>/ outside the ring with this syntax:
\begin{center}
	\Verb/<atom>*<n>(<code>)/
\end{center}
\Verb/<n>/ is the number of sides of the polygon and the \Verb/<code>/ describes the bonds and groups of atoms which make up its edges and vertices. This code \emph{must} begin with a bond because the atom is outside the ring.

Here is a 5-ring, attached to the atom ``\verb/A/'':
\exemple{5-ring}|\chemfig{A*5(-B=C-D-E=)}|

A ring can also be drawn with one, several, or all the groups of atoms empty, as is the case for diagrams outside rings:
\exemple{5-ring with empty groups}|\chemfig{*5(-=--=)}|

A ring can be incomplete:
\exemple{Incomplete 5-ring}|\chemfig{*5(-B=C-D)}|
If a ring has a code which contains too many bonds and atom groups for the given number of vertices, all the bonds and groups over the maximum allowed are ignored:
\exemple{Truncated 5-ring}|\chemfig{A*5(-B=C-D-E=F-G=H-I)}|

It is possible to draw a circle or an arc in the inside of a ring. To do so, the following syntax is used:
\begin{center}
	\Verb/<atom>**[<angle 1>,<angle 2>,<tikz>]<n>(<code>)/
\end{center}
where each field of the optional argument takes its default value if it is empty:
\begin{itemize}
	\item \Verb/<angle 1>/ and \Verb/<angle 2>/ are the absolute angles of the start and finish of the arc. These default to 0\degres{} and 360\degres{} respectively so that a circle is drawn by default;
	\item \Verb/<tikz>/ is the code that will be passed to \TIKZ for drawing the arc.
\end{itemize}

\exemple{Rings and arcs}|\chemfig{**6(------)}\quad
	\chemfig{**[30,330]5(-----)}\quad
	\chemfig{**[0,270,dash pattern=on 2pt off 2pt]4(----)}|

\subsection{Angular position}
\subsubsection{At the start}
As can be seen in the examples above, the rule is that the attachment atom ``\verb/A/'' is always at the south-west of the ring. Furthermore, the ring is always constructed counterclockwise, and the last bond descends vertically onto the attachment atom:
\exemple{Angular position of rings}|\chemfig{A*4(-B-C-D-)}\qquad\chemfig{A*6(------)}|

If this angular position is not convenient, it is possible to specify another angle using the optional argument at the beginning of the molecule. Here is a 6-cycle which has been rotated by $+30\degres$, by $-30\degres$, and lastly by $+60\degres$:
\exemple[55]{Rotation of rings}|\chemfig{[:30]A*6(------)}\qquad
	\chemfig{[:-30]A*6(------)}\qquad
	\chemfig{[:60]A*6(------)}|

\subsubsection{After a bond}
When a ring does not begin a molecule and one or more bonds have already been drawn, the default angular position changes: the ring is drawn is such a way that the bond ending on the attachment atom bisects the angle formed by the first and last sides of the ring.

Here is a simple case:
\exemple{Bond ending on a ring}|\chemfig{A-B*5(-C-D-E-F-)}|

The rule remains valid, whatever the angle of the preceding bond:
\exemple{Bonds ending on a ring}|\chemfig{A-[:25]B*4(----)}\vskip5pt
	\chemfig{A=[:-30]*6(=-=-=-)}|

\subsection{Branches on a ring}
To have branches attached to the vertices of a ring, we use the syntax we have already seen:
\begin{center}
	\Verb/<atom>(<code>)/
\end{center}
where the \Verb/<code>/ is that of the sub-molecule and the \Verb-<atom>- is at the vertex. Unique to rings, the default angle of the sub-molecule is not 0\degres{} but is calculated so that it will bisect the sides leaving the vertex:
\exemple{Branch on a ring}|\chemfig{X*6(-=-(-A-B=C)=-=-)}|

A sub-molecule can be attached to the first vertex of a ring, just like the other vertices:
\exemple{Ring and branches}|\chemfig{*5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)}|

If one wants the bond leaving a vertex not to be the bisector of its sides, one can tinker with the optional global parameter or the optional bond parameter:
\exemple[50]{Branches at specified angles}|\chemfig{*5(---([:90]-A-B)--)}\qquad
	\chemfig{*5(---(-[:90]A-B)--)}\qquad
	\chemfig{*5(---([::+0]-A-B)--)}|

It is worth noting that in the third example, where a relative angle of 0\degres{} was given, the bonds of the branch are drawn in line with the preceding bond in the ring. This is the rule on page~\pageref{angle.relatif} which specified that the reference angle was that of the bond last drawn.

We can now connect together rings with bonds:
\exemple{Connected rings}|\chemfig{*6(--(-*5(----(-*4(----))-))----)}|

\subsection{Nested rings}
To ``glue'' two rings together, the syntax is only slightly different: the vertex is specified where the other ring is going to start. Simply follow this vertex by the usual syntax for a ring. Here for example is a 5-ring which is attached to the second vertex of a 6-ring:
\exemple{Nested rings}|\chemfig{A*6(-B*5(----)=-=-=)}|

Note that the ring which is going to be attached to the main ring has an angular position such that two of the rings' sides coincide. In addition, the 5-ring has only four bonds ``\verb/----/''. In effect, the fifth will be useless because it is the second side of the 6-ring, which has already been drawn.

It is quite possible to glue multiple rings together:
\exemple{Multiple nested rings}|\chemfig{*5(--*6(-*4(-*5(----)--)----)---)}|

There is a case where a trick must be used. It can be seen in this example that the fourth side of the second 5-ring just passes through the center of atom ``\verb-E-''.
\exemple{Flawed drawing}|\chemfig{A-B*5(-C-D*5(-X-Y-Z-)-E-F-)}|

This is normal because the second 5-ring (which is attached to atom ``\verb-D-'') is drawn \emph{before} \CF knows about atom ``\verb-E-''. In this case, it is necessary to use two hooks to draw the bond \verb/Z-E/:
\exemple{Distant bond and ring}|\chemfig{A-B*5(-C-D*5(-X-Y-Z?)-E?-F-)}|

We could also use a \verb-\phantom{E}- at the last vertex of the 5-ring:
\exemple{Using \string\phantom}/\chemfig{A-B*5(-C-D*5(-X-Y-Z-\phantom{E})-E-F-)}/

\subsection{Rings and groups of atoms}
Some care must be taken with rings when one or more vertices are made up of groups of atoms:
\exemple{Ring and groups of atoms}|\chemfig{AB*5(-CDE-F-GH-I-)}|

In order for the ring to have a regular shape, it is necessary to override the \CF mechanism which automatically calculates the departure and arrival atoms of bonds. Here, \verb/C-F/ and \verb/F-G/ must be connected by using the optional argument of these bonds:
\exemple{Forced departure and arrival atoms}|\chemfig{AB*5(-CDE-[,,1]F-[,,,1]GH-I-)}|

\section{Representing electron movements}\label{mecanismes-reactionnels}
Starting with \CF version 0.3, we can represent the movement of electrons in mesomeric effects or reaction mechanisms. This is done by marking the departure and arrival points of the electron movement arrow using the syntax ``\Verb-@{<argument>}-''. This syntax allows a \TIKZ node to be placed and makes this node accessible outside the argument of the \verb-\chemfig- command thanks to the ``\texttt{remember picture}'' option which is passed to all the ``\falseverb{tikzpicture}'' environments. It is assumed that the viewer supports ``\falseverb{picture remembering}'' and that the compilation is done twice.

Two types of diagrams can arise, so we can ask for:
\begin{itemize}
	\item a zero size node on a bond using the syntax ``\Verb-@{<name>,<coeff>}-'' placed at the beginning of the optional argument of the relevant bond, without being followed by a comma if there is a first optional argument. In this case, the node takes the name ``\Verb-<name>-'' and the \Verb-<coeff>-, which must be between 0 and 1, determines where the node is located on the bond. If ``\Verb-@{<name>}-'' is used, the \Verb-<coeff>- is set to 0.5 by default, which means that the node is placed halfway along the bond;
	\item a node on an atom using the syntax ``\Verb-@{<name>}-'' immediately before the relevant atom. In this case, the node has exactly the same footprint as the atom, but may be empty and therefore have zero dimensions.
\end{itemize}
Once the \falseverb{\chemfig} command has drawn the molecule(s) and has placed the nodes with the syntax described above, we can connect these nodes to each other with \TIKZ instructions. These instructions are placed in the argument of the command \verb-\chemmove-\footnote{Actually, the \texttt{\string\chemmove} command puts its argument in a ``\falseverb{tikzpicture}'' environment with the options ``\texttt{remember picture, overlay}''.} and has the following syntax if (for example) we need to connect a node named ``\Verb-<name1>-'' to the node named ``\Verb-<name2>-'':
\begin{center}
	\Verb|\chemmove[<opt>]{\draw[<tikz opt>](<name1>)<tikz link>(<name2>);}|
\end{center}

The optional argument \Verb-<opt>- of the \verb-\chemmove- command will be added to the argument of the \falseverb{tikzpicture} environment in which the links between the nodes will be drawn. The \Verb-<tikz opt>- and \Verb-<tikz link>- instructions are describe in detail in the documentation of the \TIKZ package.

\subsection{Mesomeric effects}
To make these concepts concrete, let's take the example of a mesomeric effect involving a double bond and non-bonding lone pair conjugate. Let's begin with the possible delocalization of electrons from the double bond. We will place a node named ``db'' (double bond) in the middle of the double bond and a node named ``a1'' on the end of the double bond.

The macros \verb|\schemestart|, \verb|\schemestop|, \verb|\arrow| and \verb|\+| are explained in the chapter \ref{schemas}, starting on page \pageref{schemas}.

\exemple{Mesomeric effect 1}/\schemestart
	\chemfig{@{a1}=_[@{db}::30]-[::-60]\charge{90=\|}{X}}
	\arrow{<->}
	\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
	\chemabove{X}{\scriptstyle\oplus}}
\schemestop
	\chemmove{\draw(db).. controls +(100:5mm) and +(145:5mm).. (a1);}/

As noted above, there is no comma after the node placed in the optional arguments of a bond; we write ``\verb|=_[@{db}::30]|'' and not ``\verb|=_[@{db},::30]|'' as one might be tempted to do.

To link the nodes ``db'' and ``a1'' we have used the following syntax:
\begin{center}
	\Verb|\chemmove{\draw(db)..controls +(80:8mm) and +(145:8mm)..(a1);}|
\end{center}

For arrows in \verb|\chemmove|, the default tip is ``CF''.In this example we ask for an arrow (\verb/[->]/) and we use two \falseverb{control points}\footnote{To find all the ways of connecting two nodes with \TIKZ, read the documentation for that package.}. These will be located using polar coordinates at 80\degres{} and 8~mm from ``db'' for the first and at 145\degres{} and 8~mm from ``a1'' for the second. Though this syntax may seem complicated at first reading, one need not be alarmed because its use will usually be a matter of copying and pasting. Only the names and coordinates of the control points need be changed, as can be verified from the example below, where an arrow has been added from the lone pair (node ``dnl'' to the single bond (node ``sb'').
\exemple{Mesomeric effect 2}/\schemestart
	\chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\charge{90=\|}{X}}
	\arrow{<->}
	\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
	\chemabove{X}{\scriptstyle\oplus}}
\schemestop
\chemmove{
    \draw(db)..controls +(100:5mm) and +(145:5mm)..(a1);
    \draw(dnl)..controls +(90:4mm) and +(45:4mm)..(sb);}/

For our new arrow we have set the \falseverb{control points} as follows: 4~mm at an angle of 90\degres{} from ``dnl'' and 4~mm at an angle of 45\degres{} from ``sb''. But we are not completely satisfied, since we would like the arrow not to touch the line segment representing the lone pair. To do this we will add some options to our arrow.
\exemple{Mesomeric effect 3}/\schemestart
	\chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\charge{90=\|}{X}}
	\arrow{<->}
	\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
	\chemabove{X}{\scriptstyle\oplus}}
\schemestop
\chemmove[->]{% change the tip style
    \draw(db).. controls +(100:5mm) and +(145:5mm).. (a1);
    \draw[shorten <=3pt,shorten >=1pt](dnl) .. controls +(90:4mm)
          and +(45:4mm) .. (sb);}/

The option ``\verb|shorten <=3pt|'' indicates that the tail of the arrow is to be shortened by 3~pt just as ``\verb|shorten >=2pt|'' means that the head of the arrow is shortened by 2~pt.

We can use all the power of \TIKZ instructions to modify the style of the arrow. Here we change the head of the arrow leaving the double bound and set it to ``\verb|-stealth|'', and we draw the arrow with a fine dashed red line. We also add the letter $\pi$ above the middle of the arrow:
\exemple{Mesomeric effect 4}/\schemestart
	\chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\charge{90=\|}{X}}
	\arrow{<->}
	\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
	\chemabove{X}{\scriptstyle\oplus}}
\schemestop
\chemmove{
    \draw[-stealth,thin,dash pattern= on 2pt off 2pt,red]
        (db).. controls +(100:5mm) and +(145:5mm)..
        node[sloped,above] {$\pi$} (a1);
    \draw[shorten <=3pt, shorten >= 1pt]
        (dnl).. controls +(90:4mm) and +(45:4mm).. (sb);}/

In the following example, we'll see how to indicate the position of the departure or arrival anchor points of the arrow. If we write
\exemple{Departure or arrival anchor point 1}/\chemfig{@{x1}\charge{45=\:}{X}}
\hspace{2cm}
\chemfig{@{x2}\charge{90=\|}{X}}
\chemmove{
    \draw[shorten >=4pt](x1).. controls +(90:1cm) and +(90:1cm).. (x2);}/

Note that the tail of the arrow does not leave correctly from our electrons; it leaves from the middle of the upper edge of the node. Indeed, we chose a departure angle of 90~\degres{} and so \TIKZ makes the arrow leave from the anchor ``x1.90'' which corresponds to the intersection of the ray leaving from the center of node ``x1'' at a 90\degres{} angle relative to the horizontal and of the edge of the rectangular node. To get the arrow departure angle that we want, we must specify its position. After some trial and error, it is ``x1.57'':
\exemple{Departure or arrival anchor point 2}/\chemfig{@{x1}\charge{45=\:}{X}}
\hspace{2cm}
\chemfig{@{x2}\charge{90=\|}{X}}
\chemmove[shorten <=4pt,shorten >=4pt]{
    \draw(x1.57).. controls +(60:1cm) and +(120:1cm).. (x2.90);}/

In some cases it will be easier to use Cartesian coordinated for the \falseverb{control points}. Here we use just one control point placed 1~cm to the right of and 1.5~cm above ``x1'':
\exemple{A single control point}/\chemfig{@{x1}\charge{45=\:}{X}}
\hspace{2cm}
\chemfig{@{x2}\charge{90=\|}{X}}
\chemmove[shorten <=4pt,shorten >=4pt]{
    \draw(x1.57).. controls +(1cm,.8cm).. (x2.90);}/

All the graphics drawn by means of the command \verb|\chemmove| are superimposed and will not be included in the bounding boxes. We can see this in the preceding example.

\subsection{Reaction mechanisms}
Thanks to the option \verb|remenber picture| which is passed to all the ``tikzpicture'' environments we can easily draw arrows indicating reaction mechanisms. Let's take for example the first step of the esterification reaction.
\exemple{Esterification: step 1}/\setchemfig{atom sep=7mm}
\schemestart
	\chemfig{R-@{dnl}\charge{90=\|,-90=\|}{O}-H}
	\+
	\chemfig{R-@{atoc}C([6]-OH)=[@{db}]O}
	\arrow(.mid east--){<->[\chemfig{@{atoh}\chemabove{H}{\scriptstyle\oplus}}]}
\schemestop
\chemmove[shorten <=2pt]{
	\draw(dnl)..controls +(90:1cm)and+(north:1cm)..(atoc);
	\draw[shorten >=6pt](db)..controls +(north:5mm)and+(100:1cm)..(atoh);}/

The use of the \Verb|\chemabove{<code>}{<materiel>}| command does not change the dimensions of the \falseverb{bounding box} of \Verb|<code>|. For this reason we can run into some difficulty in pointing to the symbol representing the charge carried ($\oplus$ or $\ominus$). In the example above the solution is to create a control point with an angle of 110\degres{} at 1~cm from ``atoh'' and to shorten the arrow by 6pt. In the following example, the second step of the esterification reaction, we can see that the arrow can take more complicated forms without complicating the code.
\exemple{Esterification: step 2}/\setchemfig{atom sep=7mm}
\chemfig{R-O-C(-[2]R)(-[6]OH)-@{dnl}\charge{90=\|,-90=\|}{O}H}\hspace{1cm}
\chemfig{@{atoh}\chemabove{H}{\scriptstyle\oplus}}
\chemmove{
    \draw[shorten <=2pt, shorten >=7pt]
        (dnl).. controls +(south:1cm) and +(north:1.5cm).. (atoh);}/

The rest is left as an exercise to the reader\dots.

\section{Writing a name under a molecule}\label{chemname}
For convenience, \CF can write the name of a molecule underneath it with the command
\begin{center}
	\Verb/\chemname[<dim>]{\chemfig{<code of the molecule>}}{<name>}/
\end{center}

The \Verb-<dim>-, which is 1.5ex by default, will be inserted between the \falseverb{baseline} of the molecule and the top of the letters of the \Verb-<name>-. The \Verb-<name>- will be centered relative to the molecule, but the \Verb-<name>- may not contain multiple paragraphs. As we see in this example: \chemname{\chemfig{H-O-H}}{\scriptsize\bfseries The water molecule: $\mathrm{\mathbf{H_2O}}$}, the \Verb-<name>- which is displayed under the molecule is taken into account only for the vertical size of the bounding box. The horizontal size of \Verb-<name>- is always zero.

Here is a reaction with the names under the molecules:
\exemple*{Displaying names of molecules}/\schemestart
	\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Acide carboxylique}
	\+
	\chemname{\chemfig{R'OH}}{Alcool}
	\arrow(.mid east--.mid west)
	\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
	\+
	\chemname{\chemfig{H_2O}}{Water}
\schemestop
\chemnameinit{}/

There are some limitations to this command. Suppose we switch the acid and the alcohol on the left side:
\exemple*{Name alignment 1}/\schemestart
	\chemname{\chemfig{R'OH}}{Alcohol}
	\+
	\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Carboxylic acid}
	\arrow(.mid east--.mid west)
	\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
	\+
	\chemname{\chemfig{H_2O}}{Water}
\schemestop
\chemnameinit{}/

In fact, to draw the \Verb-<name>- the command \falseverb{\chemname} inserts 1.5ex${}+{}$\emph{the largest of the depths\footnote{In \TeX{} terms, the depth is the dimension which extends vertically below the baseline.} of the molecules thus far} below the baseline of each molecule (light gray for the examples in this manual). The command \falseverb{\chenameinit}\Verb-{<stuff>}- initializes this largest depth with the \Verb-<stuff>-. Therefore one should:
\begin{itemize}
	\item write \Verb-\chemnameinit{<deepest molecule>}- before using the \verb-\chemname- command in a reaction, unless the reaction begins with the deepest molecule;
	\item write \verb-\chemnameinit{}- after having written all the names in a chemical reaction lest the greatest depth in this reaction interfere with a future reaction.
\end{itemize}

Thus the correct code uses \falseverb{\chemnameinit} before and after the reaction:
\exemple*{Name alignment 2}/\chemnameinit{\chemfig{R-C(-[:-30]OH)=[:30]O}}
\schemestart
	\chemname{\chemfig{R'OH}}{Alcohol}
	\+
	\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Carboxylic acid}
	\arrow(.mid east--.mid west)
	\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
	\+
	\chemname{\chemfig{H_2O}}{Water}
\schemestop
\chemnameinit{}/

Finally, to write a name on multiple lines, the command \verb-\\- encountered in a \Verb-<name>- causes a line break\footnote{Conversely, the command \texttt{\textbackslash par} is forbidden and causes a compilation error.}:
\exemple*{Name on 2 lines}/\schemestart
	\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Carboxilic\\Acid}
	\+
	\chemname{\chemfig{R'OH}}{Alcohol}
	\arrow(.mid east--.mid west)
	\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
	\+
	\chemname{\chemfig{H_2O}}{Water}
\schemestop
\chemnameinit{}/

If \Verb|\chemname*{<name>}| is written, the macro does not take into account the previous names.
\newpage

\part{Advanced usage}\label{utilisation.avancee}
\section{Separating atoms}\label{decoupage.atomes}
The \falseverb{separating atom mechanism} described previously extends each atom until the next capital letter or one of the characters {\ttfamily \boxedfalseverb{-} \boxedfalseverb{=} \boxedfalseverb{~} \boxedfalseverb{(} \boxedfalseverb{!} \boxedfalseverb{*} \boxedfalseverb{<} \boxedfalseverb{>} \boxedfalseverb{@}}

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagram. Consider this example molecule, noting that the ``\texttt('' character is placed between braces so that \CF doesn't incorrectly create a branch:

\exemple*{Alkene}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}/

We find that the bond which arrives at the carbon atom in the upper right is too short. This happens because, if we apply the \CF rules for separating atoms to the upper right group, the atoms are split in this way: ``\texttt{\detokenize{C{(}}}'', ``\texttt{\detokenize{C}}'', ``\texttt{\detokenize{H_3{)}_3}}''. We now realize that the first atom contains a parenthesis and thus has too great a depth in math mode; we can see this by making the bounding boxes visible:
\begin{center}
\fboxsep=0pt
\renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}%
\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}%
\end{center}
The character ``|'' forces splitting of the atom when it is encountered. Thus we can write \texttt{C\textcolor{red}{|}\detokenize{{(CH_3)_3}}} to ensure that \CF separates just two atoms here: ``\texttt{\detokenize{C}}'' and ``\texttt{\detokenize{{(CH_3)_3}}}''. The problem of the too-short bond is thus solved:

\exemple*{Alkene}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C|{(CH_3)_3}}/

\section{Displaying atoms}\label{perso.affichage}
Once a molecule has been split into atoms, the macro \falseverb{\printatom} is called internally by \CF in order to display each atom. Its sole argument is the code of the atom to be displayed (e.g. ``\verb-H_3-''). By default, this macro enters \falseverb{math mode} and displays its argument with the math font family ``rm''. It is defined by the following code:
\begin{itemize}
	\item \verb|\newcommand*\printatom[1]{\ensuremath{\mathrm{#1}}}|\qquad when compiling with \LaTeX{}
	\item \verb|\def\printatom#1{\ifmmode\rm#1\else$\rm#1$\fi}|\qquad when compiling with $\varepsilon$\TeX{} ou Con\TeX tX.
\end{itemize}

One can modify the code of this macro to customize how atoms are displayed. In the following example, we redefine \falseverb{\printatom} so that each atom will be enclosed in a rectangular box:
\exemple{Redefinition of \string\printatom}/\fboxsep=1pt
\renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
\chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}/

Here is how to redefine it to use the ``sf'' font family of math mode:
\exemple{Atoms displayed with ``sf'' font family}/\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}
\chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}/

\section{Arguments given to tikz}\label{arguments.optionnels}
The \chevrons{key} \CFkey{chemfig style}  contains \TIKZ instructions which will be passed to the \falseverb{tikzpicture} environment in which the molecule is drawn. On the other hand, the The \chevrons{key} \CFkey{atom style} contains \TIKZ instructions which will be executed when each node; these instructions are added to the end of \texttt{every node/.style\{<argument>\}}, i.e. after the fhe following instructions: ``{\ttfamily anchor=base,inner sep=0pt,outer sep=0pt,minimum size=0pt}''.

With the use of the first optional argument one can, for example, choose the global color or thickness of lines:
\exemple{Style choice}/\chemfig{A-B-[2]C}\par\medskip
\setchemfig{chemfig style={line width=1.5pt}}\chemfig{A-B-[2]C}\par\medskip
\setchemfig{chemfig style=red}\chemfig{A-B-[2]C}/

With \CFkey{node style}, one can choose the colour of nodes drawn by \TIKZ, change the angle of the drawing or its scale:
\exemple{Style choices}/\chemfig{A-B-[2]C}\par\medskip
\setchemfig{atom style=red}\chemfig{A-B-[2]C}\par\medskip
\setchemfig{atom style={rotate=20}}\chemfig{A-B-[2]C}\par\medskip
\setchemfig{atom style={scale=0.5}}\chemfig{A-B-[2]C}/


\section{Shifted double bonds}
All double bonds are made up of two line segments, and these segments are drawn on either side of the imaginary line along which a single bond would be drawn. It is possible to shift a double bond so that one of the line segments lies on the imaginary line. The other segment is then shifted above or below the bond. Actually, it is more correct to say ``left'' or ``right'' of the imaginary line, as the bond is traversed in the direction of drawing.

To shift the bond to the left, write ``\verb-=^-'' and to shift it to the right, write ``\verb-=_-'':
\exemple{Shifted double bonds}/\chemfig{A-=-B}\par
\chemfig{A-=^-B}\par
\chemfig{A-=_-B}/

In rings, double bonds are automatically shifted to the left. However, they can be shifted to the right by specifying it with ``\verb-=_-'':
\exemple{Shifted double bonds and rings}/\chemfig{*6(-=-=-=)}\qquad
\chemfig{*6(-=_-=_-=_)}/

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains with double bonds. They give a continuous zig-zag path, whereas the path will be broken with regular double bonds:
\exemple{Shifted bonds and skeleton diagrams}/\chemfig{-[:30]=[:-30]-[:30]=[:-30]-[:30]}\par
\chemfig{-[:30]=^[:-30]-[:30]=^[:-30]-[:30]}\par
\chemfig{-[:30]=_[:-30]-[:30]=_[:-30]-[:30]}/

\section{Delocalized double bonds}
It is sometimes necessary to draw a double bond so that one line would be full and the other dashed. This feature is not hard-coded in \CF since \TIKZ, with its ``decorations.markings'' library makes it possible.

\exemple*{Delocalized bonds}|\catcode`\_=11
\tikzset{
	ddbond/.style args={#1}{
		draw=none,
		decoration={%
			markings,
			mark=at position 0 with {
				\coordinate (CF@startdeloc) at (0,\dimexpr#1\CF_doublesep/2)
				coordinate (CF@startaxis) at (0,\dimexpr-#1\CF_doublesep/2);
				},
			mark=at position 1 with {
				\coordinate (CF@enddeloc) at (0,\dimexpr#1\CF_doublesep/2)
				coordinate (CF@endaxis) at (0,\dimexpr-#1\CF_doublesep/2);
				\draw[dash pattern=on 2pt off 1.5pt] (CF@startdeloc)--(CF@enddeloc);
				\draw (CF@startaxis)--(CF@endaxis);
				}
			},
		postaction={decorate}
	}
}
\catcode`\_=8
\chemfig{A-[,,,,ddbond={+}]B-[,,,,ddbond={-}]C}|

\section{Saving a sub-molecule}\label{definesubmol}
\CF is capable of saving a \Verb-<code>- as an alias for reuse in a more compact form in the code of a molecule. This is particularly useful when the \Verb-<code>- appears several times.

To do this, one gives the command
\begin{center}
	\Verb|\definesubmol{<name>}{<code>}|
\end{center}
which saves the \Verb/<code>/ for recall in the code of the molecule via the shortcut ``\verb/!{name}/''. This \Verb-<name>- can be:
\begin{itemize}
	\item a sequence of characters: all the alphanumeric characters able to be between \texttt{\string\csname} and \texttt{\string\endcsname} are accepted;
	\item a control sequence.
\end{itemize}

In all cases, if the alias is already defined you should not overwrite it with a new definition using \falseverb{\definesubmol}. A warning will be issued to the user that the old alias will be overwritten by the new one. To override the definition of an alias made previously, use:\label{redefinesubmol}
\begin{center}
	\Verb|\redefinesubmol{<name>}{<code>}|
\end{center}

Here is a code which draws the pentane molecule. An alias ``\verb/xy/'' was defined beforehand for the code \verb/CH_2/:
\exemple{Pentane}|\definesubmol{xy}{CH_2}
	\chemfig{H_3C-!{xy}-!{xy}-!{xy}-CH_3}|

In this case the technique is not very interesting because ``\verb/!{xy}/'' is just as long to type as the code it replaces.

But in certain cases, this feature saves a lot of space in the code of the molecule and increases readability. In the following example, we draw the complete structural diagram of butane. We will define an alias with the control sequence ``\verb/\xx/'' for the sub-molecule $\mathrm{CH_2}$. If we use only relative angles, it is possible to rotate the entire molecule to any given angle by using the optional global angle parameter which specifies the default bond angle of the main molecule. It is set to 15\degres{} here:
\exemple{Butane}|\definesubmol\xx{C(-[::+90]H)(-[::-90]H)}
\chemfig{[:15]H-!\xx-!\xx-!\xx-!\xx-H}|

The \falseverb{\definesubmol} command takes an optional argument; its syntax is as follows:
\begin{center}
	\Verb/\definesubmol{<name>}[<code1>]{code2}/
\end{center}

When the optional argument is present, the alias ``\Verb-!<name>-'' will be replaced by \Verb'<code1>' if the bond which arrives at the alias comes from the right, i.e., if the angle which the arriving bond makes is between but is not equal to 90\degres{} and 270\degres{}. For all the other cases where the bond arrives from the left of vertically, the alias will be replaced by \Verb-<code2>-.

We will define a control sequence \verb-\Me- pour ``methyl'' so that the alias ``\verb-!\Me-'' will be replaced by ``\verb-H_3C-'' when the bond arrives from the right and by ``\verb-CH_3-'' when it arrives from the left. We can observe in the example that with this alias we need no longer worry about the angle:
\exemple{Dual alias}/\definesubmol\Me[H_3C]{CH_3}
\chemfig{*6((-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-)}/

\label{definesubmolarg}The sub-molecule saved with a \Verb|<name>| does not admit an argument when it is called after "\verb|!||". To define a sub-molecule admitting one or more arguments, place this \Verb|<number>| of arguments just after the \Verb|<name>|. And the full syntax of \verb|\definesubmol| is:
\begin{center}
	\Verb/\definesubmol{<name>}<number>[<code1>]{<code2>}/
\end{center}

In the \Verb|<codes>|, the arguments must appear in their usual form "\Verb|#<n>|" where \Verb|<n>| is the argument number.

\exemple{\texttt{\string\definesubmol} with arguments}/\definesubmol\X1{-[,-0.2,,,draw=none]{\scriptstyle#1}}
\chemfig{*6((!\X A)-(!\X B)-(!\X C)-(!\X D)-(!\X E)-(!\X F)-)}

\definesubmol{foo}3[#3|\textcolor{#1}{#2}]{\textcolor{#1}{#2}|#3}
\chemfig{A(-[:135]!{foo}{red}XY)-B(-[:45]!{foo}{green}{W}{zoo})}/

It should be noted that if the \Verb|<number>| of arguments is incorrect (negative or greater than 9), an error message will be issued and \CF will consider that the sub molecule does not admit an argument.

Except in cases where the character "\verb|#|" is followed by a number between 1 and \Verb|<number>| in which case it represents an argument, "\verb|#|" are allowed in the sub-molecule codes.

\exemple{Use of \#}/\definesubmol\X2{#1-#2-#3-#(3pt,3pt)#4}
\chemfig{A-!\X{M}{N}-B}/

In this example, only \verb|#1| and \verb|#2| are understood as the arguments of the sub molecule \verb|\X|. The other "\verb|#|" are displayed as they are in the molecule (case of \verb|#3| and \verb|#4|) or understood as the character specifying the fine adjustment of the offset of the bonds.

\section{Placement of Atoms}
\subsection{First Atom}\label{premieratome}
As explained on page~\pageref{first atom}, the first atom encountered (whether empty or not) is the one that is placed on the baseline, represented in gray on the examples of this manual. The choice of this first atom thus conditions the placement of all the others and often influences the placement of the whole molecule.

\exemple{First atom}/\chemfig{H-[7]C(-[5]H)=C(-[1]H)-[7]H}\qquad
\chemfig{C(-[3]H)(-[5]H)=C(-[1]H)-[7]H}/

\subsection{Groups of atoms}\label{placementatomes}
In a group of atoms, the atoms are placed one after the other in a well-established order:
\begin{itemize}
	\item the first one which is placed (which we will call "reference atom") is the one on which the bond arrives; in the case of the beginning of the molecule, the atom on the left is the reference atom;
	\item the atoms to the right of the reference atom are then placed from left to right;
	\item atoms to the left of the reference atom are finally placed from right to left.
\end{itemize}

In the group of atoms thus formed, the baselines of each atom are on \emph{the same horizontal line}, in other words, the atoms are all aligned on the same horizontal line.

In the example below whose code would be "\verb|\chemfig{A[:-60,,,3]BCDEF}|" the reference atom of the 2nd{} group of atoms is "D" because the bond is requested to arrive on the 3rd{} atom. Below each atom of this group is the sequence number in which the atom is displayed:
\begin{center}
	\def\0#1#2{%
		\vtop{%
			\def\tempprintatom##1{\ensuremath{\mathrm{##1}}}%
			\setbox0\hbox{\tempprintatom{#1}}%
			\def\tempvrule{\vrule height.33ex width.4pt}%
			\offinterlineskip\copy0 \kern2pt
			\hbox to\wd0{\kern.5pt \tempvrule\hrulefill\tempvrule\kern.5pt}\kern2pt
			\hbox to\wd0{\hss$\scriptstyle#2$\hss}}}
	\chemfig{A-[:-60,,,3]\0{B}{5}|\0{C}{4}|\0{D}{1}|\0{E}{2}|\0{F}{3}}
\end{center}

\subsection{Bonds between atoms}\label{liaisonentreatomes}
A bond starting from an atom would, if extended, pass through the centre of its bounding box. The atom placed at the end of the bond has its center of its bounding box is in the extension of the bond. Therefore, a bond between two atoms extends through the centers of their bounding boxes, as shown in this example:
\begin{center}
\fboxsep=.25pt
\renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
\setchemfig{chemfig style={line width=1pt}}
\Large
\chemfig{A@ABC-[:65,,2,3]DE@BFG}
\chemmove{%
	\draw[red,fill=red]  (A.center)circle(.2ex);
	\draw[blue,fill=blue](B.center)circle(.2ex);
	\draw[gray,-,dashed,shorten <=-1.5em, shorten >=-1.5em](A.center)--(B.center);
}
\end{center}
This mechanism can create misalignments between groups of atoms that are particularly visible when the bonds are horizontal. Everything works well when the atoms have the same vertical dimensions; however, if a departure atom is high (with exponent) or deep (with subscript) and the arrival atom has a different vertical dimension, the alignment is broken.
\exemple*{Horizontal alignment}/\Huge\setchemfig{atom sep=2em}
\chemfig{A^1-B-C-D}\qquad
\chemfig{E_1-F-G-H}/

It is surprising that the second atom is correctly aligned when the last two are vertically shifted. This is because \CF adds in front of each arrival atom the \falseverb{\vphantom} of the departure atom, but without including it in the content of this arrival atom: this \falseverb{\vphantom} is thus not intended to be reflected on the following atoms. This phenomenon can be shown by making visible the bounding boxes of the atoms where it appears that the atoms "\verb-B-" and "\verb-F-" have bounding boxes whose height takes into account the heights of the preceding atom:
\exemple*{Horizontal placement and bounbding boxes}/\Huge\setchemfig{atom sep=2em}
\fboxsep=0pt
\renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm#1}}}
\chemfig{A^1-B-C-D}\qquad
\chemfig{E_1-F-G-H}/

Since no automatic solution is satisfactory, we can manually get around this problem by creating an departure atom being a "strut" equal to \verb|\vphantom{X}|: thus, the starting atom has a "normal" height and no shift will be reflected on the next group of atoms. A sub-molecule is used here for brevity.
\exemple*{Bypassing vertical placement}/\Huge\setchemfig{atom sep=2em}
\definesubmol\I{\vphantom{X}}
\chemfig{A^1|!\I-B-C-D}\qquad
\chemfig{E_1|!\I-F-G-H}/
The disadvantage is that the first bond is too long because the departure atom now has a zero horizontal dimension.

If we are \emph{really sure} to understand the consequences that this will have on the molecule and especially if it lends itself to it, we can redefine \verb|\printatom| so that it forces the atom's bounding box to have fixed vertical dimensions; for example that of "$\mathrm{X^1_1}$".
\exemple*{Redefinition of \string\printatom}/\Huge\setchemfig{atom sep=2em}
\let\oldprintatom\printatom
\renewcommand\printatom[1]{%
	\begingroup
		\setbox0\hbox{\oldprintatom{X^1_1}}%
		\edef\tmp{\ht0=\the\ht0\relax\dp0=\the\dp0\box0 }%
		\setbox0\hbox{\oldprintatom{#1}}%
		\ifnum1\ifdim\ht0=0pt0\fi\ifdim\dp0=0pt0\fi\ifdim\wd0=0pt0\fi<1000
			\tmp
		\fi
	\endgroup
}
\chemfig{A^1-B-C-D}\qquad
\chemfig{E_1-F-G-H}/

\subsection{La macro \texttt{\char`\\chemskipalign}}\label{chemskipalign}
For any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thus neutralize the \falseverb{\vphantom}. Simply place the \falseverb{\chemskipalign} command in the group of atoms; the alignment will resume in the following group of atoms as if the group of atoms containing \falseverb{\chemskipalign} had never existed. The following example shows the effects of this instruction: the reference point of the box containing the first atom is placed at the level of the bond which arrives from the left. The bounding boxes of the atoms are drawn in the second line.

\exemple[60]{Deactivation of the alignment mechanism}/\large
\chemfig{A-.-B}\quad
\chemfig{A-\chemskipalign.-B}\par\bigskip
\fboxsep=0pt
\renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
\chemfig{A-.-B}\quad
\chemfig{A-\chemskipalign.-B}/

This command is to be used with caution lest the alignment of atoms in the next group be disrupted. In general, all will be well if the group of atoms featuring \falseverb{\chemskipalign} contains \emph{a single atom} whose height and depth are \emph{less} than those of the preceding and following atoms, and if the preceding and following atoms have identical heights and depths. Here is an example of the mess that results when the group of atoms contains two atoms, here ``\verb-\chemskipalign.-'' and ``\verb-B-'':
\exemple{Consequence of the \string\chemskipalign command}/\large
\fboxsep=0pt
\renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
\chemfig{A-\chemskipalign.B-C}/

This feature can sometimes be useful. Suppose we want to draw the following molecule
\begin{center}
	\catcode`;12
	\def\emptydisk{\chemskipalign\tikz\draw(0,0)circle(2pt);}%
	\def\fulldisk{\chemskipalign\tikz\fill(0,0)circle(2pt);}%
	\chemfig{A-#(,0pt)\emptydisk-#(0pt,0pt)\fulldisk-#(0pt)B}%
\end{center}
We can define commands which will draw the empty and full disks with \TIKZ. To ensure that these disks are at the right height, namely the height of the bond arriving at them, we will use the command \falseverb{\chemskipalign}. In the second line below the bonds are ``stuck'' to the disks by using the ability to change the bond shortening with the ``\verb-#-'' character, a feature seen on page~\pageref{modif.retrait}.
\begingroup\catcode`;12 \catcode`#12
\exemple{Use of \string\chemskipalign\ and #}/\def\emptydisk{\chemskipalign\tikz\draw(0,0)circle(2pt);}
\def\fulldisk{\chemskipalign\tikz\fill(0,0)circle(2pt);}
\chemfig{A-\emptydisk-\fulldisk-B}\par
\chemfig{A-#(,0pt)\emptydisk-#(0pt,0pt)\fulldisk-#(0pt)B}
/\endgroup

\section{The macro \texttt{\char`\\charge}}\label{charge}
\subsection{Overview}
The macro \verb| load|, which requires two mandatory arguments, allows to arrange elements (called \chevrons{charges}) around an \chevrons{atome}; its syntax is
\begin{center}
	\Verb|\charge{[<general parameters>]<position>[<tikz code>]=<charge>}{<atom>}|
\end{center}
where:
\begin{itemize}
	\item the \chevrons{atom} is usually one or two letters, but it can also be empty;
	\item the \chevrons{charge} is an arbitrary content that will be placed around the atom. Few constraints exist on this content: it can be text (in math mode if needed), or even \TIKZ code or a molecule drawn with \verb|chemfig|;
	\item the \chevrons{general parameters} (optional) are a list of key/values specifying the options that this execution of the macro must satisfy. These keys/values are described below;
	\item the \chevrons{position} is "\chevrons{angle}\verb-:-\chevrons{shift}", but it is possible to specify only the \chevrons{angle}, in which case, the \chevrons{shift} will be equal to \verb|0pt|;
	\item the optionnal \chevrons{tikz code} sets the options given to the \TIKZ macro \verb|\node|, which places the \chevrons{charge}.
\end{itemize}

\subsection{Parameters}
The \chevrons{keys}${}={}$\chevrons{values} available in the \chevrons{general parameters} are:

\begin{longtable}{rlp{8.5cm}}\hline
	\chevrons{keys} & default \chevrons{values} & Description\\\hline\endhead
	\Chargeparam{debug} & boolean which, when \CFval{true}, draws the outlines of the nodes receiving the \chevrons{atoms} (in green), the \chevrons{loads} (in blue) and the \chevrons{charge} (in red).\\
	\Chargeparam{macro atom}&macro receiving the \chevrons{atom} as argument.\\
	\Chargeparam{circle} & boolean which, when \CFval{true}, puts the \chevrons{atom} in a circular node; otherwise, the node is rectangular.\\
	\Chargeparam{macro charge}&macro (e.g., \verb|\printatom| or  \verb|\ensuremath|) receiving each charge as an argument.\\
	\Chargeparam{extra sep} & node size increment of the \chevrons{atom} to put the \chevrons{charges}: it is the value passed to the \CFkey{inner sep} of \TIKZ.\\
	\Chargeparam{overlay} & boolean which, when \CFval{true}, draws the \chevrons{charges} "overlay", i.e. outside the final bounding box.\\
	\Chargeparam{shortcuts}&boolean which, when \CFval{true}, activates the shortcuts"\verb-\.-," "\verb-\:-," "\verb-\|- and "\verb-\"-" to draw Lewis formuas.\\
	\Chargeparam{lewisautorot}&booleann which, when \CFval{true}, automatically rotates "\verb-\:-," "\verb-\|- and "\verb-\"-".\\
	\Chargeparam{.radius}&radius of the point used to plot "\verb|\.|" and "\verb|\:|".\\
	\Chargeparam{:sep} & separation between the two dots of "\verb|\:|".\\
	\Chargeparam{.style}&\TIKZ style used to draw the "\verb|\.|" and "\verb|\:|" dots.\\
	\Chargeparam{"length}&length of the rectangle "\verb-\- "and the line "\verb-\|-".\\
	\Chargeparam{"width}&width of the rectangle \verb-\"-.\\
	\Chargeparam{"style}&\TIKZ style used to draw the rectangle \verb-\"-.\\
	\Chargeparam{|style}&TIKZ style used to draw the line \verb-\|-.\\\hline
\end{longtable}

It is possible to set some (or all) of these parameters by running the macro
\begin{center}
	\Verb|\setcharge{<keys>=<values>}|
\end{center}
and reset all parameters to their default values with
\begin{center}
	\verb|\resetcharge|
\end{center}
The \verb|\charge| macro places the \chevrons{charges} out of the bounding box (unless otherwise specified in the \chevrons{parameters}) while \verb|\Charge| places them into the bounding box.
\medbreak

The \chevrons{angle} is the location on the boundary of the node where the \chevrons{charge} is placed. This \chevrons{angle} can be expressed in degrees or it can be a boundary anchor in the sense of \TIKZ, like "south east." The \chevrons{shift} is a \TeX-dimension and represents an additional length between the boundary of the node containing the \chevrons{atom} and the place where the \chevrons{charge} is placed. Unless otherwise specified in the \chevrons{tikz code}, the \emph{center} anchor of \chevrons{charges}.
\medbreak

In the two following examples, \CFkey{debug} will be set to \CFval{true} in order to better perceive the changes induced by the modification of the parameters. In addition, the macro \verb|\Charge| will be used so that the bounding boxes take into account the charges. Here we see the influence of the node shape on the placement of the charges:
\exemple{Generic example}|\setcharge{debug}
Default then circle:
\Charge{30=\:,120=$\ominus$,210=$\delta^+$}{Fe}\qquad
\Charge{[circle]30=\:,120=$\ominus$,210=$\delta^+$}{Fe}|

To place the loads $\ominus$ and $\delta^+$ further away, we can play on the \chevrons{shift} or better, on the anchor: the \chevrons{angle} where the load is placed is stored in the macro \verb|\chargeangle|, so it is wise to choose the anchor \verb|180+\chargeangle|. It is also possible to specify a circular node to place the charge.

\exemple{Fine positioning}|\setcharge{debug}
\Charge{30=\:,120:3pt=$\ominus$,210:5pt=$\delta^+$}{Fe}\qquad
\Charge{[circle]30=\:,
        120[circle,anchor=180+\chargeangle]=$\ominus$,
        210[anchor=180+\chargeangle]=$\delta^+$}{Fe}|

It is important to note that circular nodes have dimensions \emph{sometimes very different} from the "classic" rectangular nodes, especially in terms of horizontal and vertical extent. It is therefore advisable to set \CFval{true} the boolean key \CFkey{circle} knowingly.

\exemple{Circular nodes}/\chemfig{\charge{90=\.}{N}H_3} : rectangle nodes\smallbreak
\chemfig{\charge{[circle]90=\.}{N}H_3} : circle node/

\subsection{Lewis formula}
When \CFkey{shortcut} is \CFval{true}, the shortcuts "\verb|\.|», "\verb|\:|», "\verb-\|- and "\verb-\"-» are actgive to draw Lewis formulas {\setcharge{extra sep=0pt}"\Charge{0=\.}{\vphantom{A}}», "\Charge{0=\:}{\vphantom{A}}», "\Charge{0=\|}{\vphantom{A}}» et "\Charge{0=\"}{\vphantom{A}}»}. You can deactivate them at any time with the \verb|\disableshortcuts| macro and reactivate them with \verb|\enableshortcuts|.

When the boolean \CFkey{shortcut} is \CFval{false} or the shortcuts have been disabled with \verb|\disableshortcuts|, shortcuts "\verb|\:|", "\verb-\|-" and "\verb-\"-" are no longer programmed to draw Lewis formulas, so the macros \verb|\chargedot|, \verb|\chargeddot|, \verb|\chargeline| and \verb|\chargerect| must be used instead.
\medbreak

The key \CFkey{lewisautorot}, which is \CFval{true} by default, acts on {\setcharge{extra sep=0pt}"\Charge{0=\:}{\vphantom{A}}", "\Charge{0=\|}{\vphantom{A}}" and "\Charge{0=\"}{\vphantom{A}}"} and rotates them.

\exemple{Autorot}/\Charge{60=\:,150=\"}{A} et
\Charge{[lewisautorot=false]60=\:,150=\"}{A}/

The \verb|lewis| and \verb|Lewis| macros are still functional, but are no longer maintained or documented, and \textcolor{red}{\bfseries will be removed in a future version}, so it is advisable to prefer the \verb|\charge| and \verb|\Charge| macros, which give comparable results as shown below, while being much more powerful and configurable:

\exemple{Comparison with \string\Lewis}/\Lewis{1:3.5|,X}\quad\Lewis{0:2.3|,X}\qquad(avec \string\Lewis)\par
\Charge{45=\:,135=\.,225=\"}{X}\quad\Charge{0=\:,90=\.,135=\"}{X}%
\qquad(avec \string\Charge)/

The customization of Lewis' formulas is done via the macro \verb|\setcharge| or via the optional argument of \verb|\charge| by acting on the keys \CFkey{.radius}, \CFkey{:sep}, \CFkey{.style}, \CFkey{|style}, \CFkey{"length}, \CFkey{"width} and \CFkey{"style}. It is also possible to modify these keys for each formula with their optional argument which receives a list of \CFkey{keys}${}={}$\chevrons{values}.

\exemple{Ccustomization}/\Charge{[.radius=1.5pt,.style={draw=gray}]
   45  =\.[{.style={draw=none,fill=red}}],
   135 =\.[{.style={draw=none,fill=blue}}],
   -45 =\.[{.style={draw=none,fill=green}}],
   -135=\.}{A}\quad
\Charge{
   45 =\"[{"style={draw=red,fill=gray}}],
   135=\"[{"width=3pt,"style={line width=.8pt,draw=blue,fill=cyan}}]}{A}/

\subsection{Integration in \CF}
A macro \verb|\charge| can take the place of an atom, just like it did with \verb|\lewis|.

\exemple{Charge in \CF}*\chemfig{H-\chemabove{\lewis{5|7,O}}{\quad\scriptstyle+}(-[2]H)-H}
\qquad
\chemfig{H-\charge{45:1.5pt=$\scriptstyle+$,-45=\|,-135=\"}{O}(-[2]H)-H}*

However, \CF has been modified so that the bonds are \emph{joined} when the dimensions of an atom is zero, that is, if its width, height and depth are all \verb|0pt|. This was previously only the case if the atom was empty. This new feature makes it easy to place charges in carbon chains.

\exemple{Charge in chain}/\chemfig{[:30]-\charge{90=\:}{}
-[:-30]\charge{-90=\"}{}-\charge{90:2pt=$\delta^+$}{}-[:-30]}/

\section{Stacking}
The macros\label{chemabove}
\begin{center}
	\Verb|\chemabove[<dim>]{<code>}{<stuff>}|
\end{center}
and
\begin{center}
	\Verb|\chembelow[<dim>]{<code>}{<stuff>}|
\end{center}
place the \Verb-<stuff>- above and below the \Verb-<code>- respectively at a vertical distance \Verb-<dim>-, without changing the \falseverb{bounding box} of \Verb-<code>-. The optional argument allows, if written, to specify this dimension at each call. If the optional argument is not used, a default size will be taken: its value is \CFval{1.5pt} but it can be modified with the \chevrons{key} \CFkv{stack sep}{dim}.

These commands are independent of the macro \verb-\chemfig- and can be used either inside or outside its argument.

They are especially useful in rings, if care is taken to put braces around the letters A, B, C and D in order to prevent \CF from starting a new atom on these letters:
\exemple{Staking in rings}|\chemfig{*5(-\chembelow{A}{B}--\chemabove{C}{D}--)}|

\label{Chemabove}The \falseverb{\Chemabove} and \falseverb{\Chembelow} commands work in the same way, except that the bounding box takes into account the \Verb-<stuff>- placed above or below.

What's the difference between \verb|\chemabove| and \verb|\charge| for placing one item above or below another?
\exemple{\string\chemabove\space or \string\charge}/\chemfig{*5(----\chemabove{A}{\oplus}-)}
\chemfig{*5(----\charge{90[anchor=-90]=$\oplus$}{A}-)}/

By default, the two macros give very similar results. However, there are differences in their use:
\begin{itemize}
	\item \verb|\chemabove| and \verb|\chemabelow| can only be used in the argument of \verb|chemfig|, which is not the case for \verb|\charge|;
	\item the \verb|\charge| macro requires \TIKZ, whereas \verb|\chemabove| and \verb|\chemabelow| use low-level \TeX{} primitives and are therefore fast and independent of any package.
\end{itemize}

\section{Using {\protect\ttfamily\protect\textbackslash chemfig} in the {\protect\ttfamily tikzpicture} environment}
It is possible to call the \falseverb{\chemfig} inside a {\ttfamily\falseverb{tikzpicture}} environment:
\exemple{\textbackslash chemfig inside tikzpicture}|\begin{tikzpicture}[help lines/.style={thin,draw=black!50}]
		\draw[help lines] (0,0) grid (4,4);
		\draw(0,0) -- (2,1);
		\draw(2,2) circle (0.5);
		\node at (1,3) {\chemfig{A=B-[:30]C}};
		\node[draw,red,anchor=base] at(3,2){\chemfig{X>[2,,,,blue]Y}};
	\end{tikzpicture}|

\section{Annotated examples}\label{exemples.commentes}
In this chapter, several molecules will be drawn, putting into use the methods previously described. The aim here is to show a logical order for putting together a molecule so that the user unfamiliar with \CF will learn how to construct complex molecules. The construction steps will be shown to help with this learning process.

In addition, several possibilities --- some intuitive and others less so --- will be shown which give the same graphical results, with the objective being to show that \CF allows some flexibility in encoding molecules. One can see how each is put together and adopt the methods with which one is most comfortable.

\subsection{Ethanal}
Here we will draw the ethanal (or acetaldehyde) molecule: \chemfig{H-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O}

The best method for non-cyclic molecules is to select the longest chain. Here one could take ``\verb|H-C-C=0|'' for example. The bond \verb|C=O| is tilted to 45\degres{} by using the predefined angle ``\verb-[1]-''. This give a ``backbone'' of the molecule to which the branches merely have to be added:
\exemple{Backbone of ethanal}|\chemfig{H-C-C=[1]O}|

The three hydrogen atoms still have to placed at the correct orientation with the help of predefined angles. The first is at 90\degres{} with the branch ``\verb/(-[2]H)/'', the second at 270\degres{} with ``\verb/(-[6H])/'', and the one on the right at 315\degres{} with ``\verb/(-[7]H)/'':
\exemple{Ethanal}|\chemfig{H-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O}|

\subsection{2-amino-4-oxohexanoic acid}
Here is the molecule to be drawn: \chemfig{-[::+30]-[::-60](=[:-90]O)-[::+60]-[::-60](-[:-90]NH_2)-[::+60](=[:90]O)-[::-60]OH}

As is often the case for most molecules, there are several methods and for each several different ways of getting the result. Here we will look at four different methods.

\subsubsection{Absolute angles}
We will first of all draw the central chain with absolute angles. We set the default angle to $+30\degres$ with the optional argument, and so only the descending bonds need to have their absolute angle set to $-30\degres$:
\exemple{Backbone (absolute angles)}|\chemfig{[:30]--[:-30]--[:-30]--[:-30]OH}|

The branches ``\verb/(=[6]O)/'', ``\verb/(-[6]NH_2)/'' and ``\verb/(=[2]O)/'' still have to be added to the correct vertices:
\exemple{Molecule (absolute angles)}|\chemfig{[:30]--[:-30](=[6]O)--[:-30](-[6]NH_2)-(=[2]O)-[:-30]OH}|

\subsubsection{Relative angles}
A more general approach uses only relative angles, in this way:
\exemple{Structure (relative angles)}|\chemfig{[:30]--[::-60]--[::-60]--[::-60]OH}|

then
\exemple{Molecule (relative angles)}|\chemfig{[:30]--[::-60](=[::-60]O)--[::-60](-[::-60]NH_2)
-(=[::60]O)-[::-60]OH}|

\subsubsection{Ring}
Since the angles between the bonds are 120\degres{}, it is possible to use a 6-ring, although this method is less natural. Here we take advantage of the fact that a ring can be left unfinished. The ring must be rotated 120\degres{} so that the first vertex is to the south-east of the ring:
\exemple{Backbone (ring)}|\chemfig{[:120]NH_2*6(---=O)}|

Now the branches must be added to the right vertices:
\exemple{Molecule (ring)}|\chemfig{[:120]NH_2*6(-(-(=[::60]O)-[::-60]OH)--(--[::60])=O)}|

\subsubsection{Nested rings}
Delving deeper into the ring method, we can also consider nesting incomplete 6-rings. We could start with this backbone:
\exemple{Backbone (nested rings)}|\chemfig{*6(--*6(--=O))}|

And then add the bonds which leave the vertices of these rings. There are no angles to worry about because the bonds leaving the rings are the bisectors of the sides of the ring, exactly what we want here:
\exemple{Molecule (nested rings)}|\chemfig{*6((-)-(=O)-*6(-(-NH_2)-(-OH)=O))}|

A close look shows that the second line segment of the double bond to the oxygen atom is \emph{inside} the incomplete 6-ring\footnote{This was also true for the preceding method with one ring.} Despite its brevity, this code does not give a perfect drawing. This can of course be corrected by adding a little to the code:
\exemple{Molecule (corrected nested rings)}|\chemfig{*6((-)-(=O)-*6(-(-NH_2)-(-OH)(=[::60]O)))}|

\subsection{Glucose}
The goal here is to represent the glucose molecule according to several different conventions.

\subsubsection{Skeleton diagram}
The code here looks like that of 2-amino-4-oxohexanoic acid. This gives almost the same structure with absolute angles, except here the default angle is $-30\degres$:
\exemple[60]{Backbone}|\chemfig{[:-30]HO--[:30]--[:30]--[:30]-H}|

Adding the branches is no problem. We use predefined absolute angles:
\exemple[60]{Glucose, skeleton diagram}|\chemfig{[:-30]HO--[:30](<[2]OH)-(<:[6]OH)
-[:30](<:[2]OH)-(<:[6]OH)-[:30](=[2]O)-H}|

\subsubsection{Fisher projection}
The goal is to get the molecule below:
\begin{center}
	\definesubmol{x}{(-[4]H)(-[0]OH)}
	\definesubmol{y}{(-[0]H)(-[4]OH)}
	\chemfig{[2]OH-[3]-!x-!x-!y-!x-=[1]O}
\end{center}
The idea is to begin to draw the longest chain vertically by giving a default angle of ``\verb-[2]-''. Here is the skeleton, where we have added lower case letters at the end of each vertical bond:
\exemple{Skeleton}|\chemfig{[2]OH-[3]-a-b-c-d-=[1]O}|

Next we define two aliases for the horizontal bonds and the atoms at their ends. Lets choose ``\verb-x-'' which we will put in place of the lower case a, c and d, and ``\verb-y-'' which will replace the letter c. Since these alias are just one character, we do not need braces and can write ``\verb-!x-'' instead of ``\verb-!{x}-'':
\exemple{Glucose (Fisher projection)}|\definesubmol{x}{(-[4]H)(-[0]OH)}
\definesubmol{y}{(-[0]H)(-[4]OH)}
\chemfig{[2]OH-[3]-!x-!x-!y-!x-=[1]O}|

\subsubsection{``Chair'' representation}
We will depict the $\alpha$-D-glucose molecule:
\chemfig{?(-[:190]OH)-[:-50](-[:170]OH)-[:10](-[:-55,0.7]OH)-[:-10](-[6,0.7]OH)-[:130]O-[:190]?(-[:150,0.7]-[2,0.7]OH)}

To do this, we will first of all draw five sides of the chair and link the first vertex to the last with a hook ``\verb-?-''. We will use the following absolute angles, running counterclockwise: $-50\degres$, $10\degres$, $-10\degres$, $130\degres$, $190\degres$.
\exemple{Structure}|
\chemfig{?-[:-50]-[:10]-[:-10]-[:130]O-[:190]?}|

Now we simply add the branches inside parentheses. The angles are chosen to give the best impression of perspective, and some bonds are shortened by a factor of 0.7:
\exemple{Chair representation}|\chemfig{?(-[:190]OH)-[:-50](-[:170]OH)-[:10](-[:-55,0.7]OH)
-[:-10](-[6,0.7]OH)-[:130]O-[:190]?(-[:150,0.7]-[2,0.7]OH)}|

\subsubsection{Haworth projection}
The goal is to depict this D-glucopyranose molecule:
\chemfig[cram width=2pt]{HO-[2,0.5,2]?<[7,0.7](-[2,0.5]OH)-[,,,,line width=2pt](-[6,0.5]OH)>[1,0.7](-[6,0.5]OH)-[3,0.7]O-[4]?(-[2,0.3]-[3,0.5]OH)}

First of all we will choose the longest chain, which starts at the ``HO'' group on the left and continues through fives sides of the ring. The ring will be closed with a hook. For the vertical bond which leaves from the first ``HO'' group, we need to specify that it will leave from the second atom using the optional argument. Furthermore, it will be shortened with a coefficient of 0.5. Its optional argument will thus be ``\verb/[2,0.5,2]/''.

Next, to give the impression of perspective to the ring, the diagonal bonds will be shortened by a coefficient of 0.7. For the bold diagonal lines we will use Cram bonds, having redefined the base of the triangles to be 2pt. The bold horizontal bond needs to be drawn with a thickness of 2pt, and so its optional argument will be ``\verb/[0,,,,line width=2pt]/''. Here is the skeleton of the molecule:
\exemple{Structure}|\chemfig[cram width=2pt]{HO-[2,0.5,2]?<[7,0.7]-[,,,,
line width=2pt]>[1,0.7]-[3,0.7]O-[4]?}|

All that needs to be done now is to add the branches at the correct places, giving the right absolute angles and sometimes reducing the length to better give the illusion of perspective:
\exemple{Projection de Haworth}|\chemfig[cram width=2pt]{HO-[2,0.5,2]?<[7,0.7](-[2,0.5]OH)-[,,,,
line width=2pt](-[6,0.5]OH)>[1,0.7](-[6,0.5]OH)-[3,0.7]
O-[4]?(-[2,0.3]-[3,0.5]OH)}|

\subsection{Adrenaline}
We want to draw the adrenaline molecule:
\chemfig{*6((-HO)-=-(-(<[::60]OH)-[::-60]-[::-60,,,2]HN-[::+60]CH_3)=-(-HO)=)}

We are going to use two different methods.

\subsubsection{Using one ring}
First of all, we start with a 6-ring and we draw the start of the branches which leave it:
\exemple[60]{Skeleton of adrenaline}|\chemfig{*6((-HO)-=-(-)=-(-HO)=)}|

The branch on the right still needs to be completed using, for example, relative angles:
\exemple[60]{Adrenaline, step two}|\chemfig{*6((-HO)-=-(--[::-60]-[::-60]
HN-[::+60]CH_3)=-(-HO)=)}|

Then we need to add a Cram-bonded \verb-OH- and indicate that the bond which arrives at ``\verb-HN-'' does so on the second atom, i.e., ``N''. We use the fourth optional argument of the bond:
\exemple[60]{Adrenaline}|\chemfig{*6((-HO)-=-(-(<[::60]OH)-[::-60]-[::-60,,,2]
HN-[::+60]CH_3)=-(-HO)=)}|

\subsubsection{Using two rings}
This method is less natural, but the goal is to show here how to make a bond invisible.

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-rings adjacent to each other:
\exemple[60]{Adrenaline, two-ring skeleton}|\chemfig{*6((-HO)-=*6(--HN---)-=-(-HO)=)}|

Now the first two bonds of the ring on the right need to be made invisible. To do this we use the argument that is passed to \TIKZ, specifying ``\verb-draw=none-''. These bonds will thus have this code: ``\verb/-[,,,,,draw=none]/''. To keep the code readable, we define an alias named ``\verb-&-'' for these bonds:
\exemple[60]{Adrenaline, step two}|\definesubmol{&}{-[,,,,draw=none]}
\chemfig{*6((-HO)-=*6(!&!&HN---)-=-(-HO)=)}|

The rest becomes easy; just add the branches to the right vertices:
\exemple[60]{Adrenaline, step three}|\definesubmol{&}{-[,,,,draw=none]}
\chemfig{*6((-HO)-=*6(!&!&HN(-CH_3)--(<OH)-)-=-(-HO)=)}|

To finish, we specify that the bonds that \emph{arrive at and leave from} ``\verb-HN-'' must do so at the second atom. We therefore define another alias for the invisible bond which arrives at ``\verb-HN-'':
\exemple[60]{Adrenaline}|\definesubmol{&}{-[,,,,draw=none]}
\definesubmol{&&}{-[,,,2,draw=none]}
\chemfig{*6((-HO)-=*6(!&!{&&}HN(-CH_3)-[,,2]-(<OH)-)-=-(-HO)=)}|

\subsection{Guanine}
We will draw the guanine molecule:
\chemfig{*6((-H_2N)=N-*6(-\chembelow{N}{H}-=N?)=?-(=O)-HN-[,,2])}\medskip

First of all, let's begin by drawing the nested rings, putting just the nitrogen atoms at the vertices:
\exemple{Guanine, skeleton}|\chemfig{*6(=N-*6(-N-=N)=--N-)}|

Then we can draw the horizontal bond in the right ring with a hook. We will also place a hydrogen atom under the nitrogen atom of the 5-ring with the command \verb-\chembelow{N}{H}-. We also need to write ``\verb-HN-'' instead of ``\verb-N-'' at the vertex at the upper left of the molecule:
\exemple{Guanine, step two}|\chemfig{*6(=N-*6(-\chembelow{N}{H}-=N?)=?--HN-)}|

We note that one bond leaves from the wrong atom\footnote{This seems illogical because the angle of the bond from the \texttt{HN} group toward the first vertex lies between $-90\degres$ and $90\degres$; \CF should therefore leave from the second atom. To explain this contradiction, one must know that in rings, the last bond always links the last vertex to the first, ignoring the \emph{calculated theoretical} angle of this bond (which here is $-90\degres$). \CF uses this theoretical angle to determine the departure and arrival atoms, but does not use it to draw the bond because the two ends are already defined. The departure atom for the last bond is thus the first atom.}! The automatic calculation mechanism must be corrected so that the bond leaves from the second atom ``\verb-N-'' instead of the first. To do this we give an optional argument for the last bond of the first 6-ring ``\verb-[,,2]-'':
\exemple{Guanine, step three}|\chemfig{*6(=N-*6(-\chembelow{N}{H}-=N?)=?--HN-[,,2])}|

Simply add the branches to the right vertices. Note especially the branch leaving the first vertex of the first 6-ring ``\verb/(-N_2N)/'':
\exemple{Guanine}|\chemfig{*6((-H_2N)=N-*6(-\chembelow{N}{H}-=N?)=?-(=O)-HN-[,,2])}|

We could also draw the same molecule with a regular 5-ring, as is sometimes done:
\exemple{Guanine with 5-ring}|\chemfig{*6((-H_2N)=N-*5(-\chembelow{N}{H}-=N-)=-(=O)-HN-[,,2])}|

\section{How to \protect\ldots}
\subsection{Write a colored atom}
Since the package \verb-xcolor- is loaded by \TIKZ, itself loaded by \CF, we can write color commands in the code of a molecule, mainly \falseverb{\color} and \falseverb\textcolor. The atoms are displayed in \TIKZ nodes which behaves like boxes of \TeX{} and it is as if these atoms were put in a group. Therefore, the color change remains local to the atom.

\exemple{Colors}/\chemfig{C\color{blue}H_3-C(=[1]O)-[7]O\color{red}H}/

This code does not work, because of the rule used to separate atoms: here, the first atom starts at ``\verb-C-'' and spreads to the next uppercase letter. Therefore, this atom is ``\verb-C\color{blue}-'' and the color change occurs at the end of atom and has no effect. We need to force \CF to cut the first atom just after ``\verb-C-'' with the character ``\verb-|-'' and then include \verb-\color{blue}H_3- between braces so that \CF does not stop the atom 2 before the uppercase ``\verb-H-'' which would leave the color change alone and therefore ineffective in an atom:

\exemple{Colors}/\chemfig{C|{\color{blue}H_3}-C(=[1]O)-[7]O|{\color{red}H}}/

The same effect can be obtained with \verb-\textcolor-:

\exemple{Colors}/\chemfig{C|\textcolor{blue}{H_3}-C(=[1]O)-[7]O|\textcolor{red}{H}}/

The main disadvantage is that we have to do the same for every atom that need to be colored, even if they are contiguous.

\subsection{Add a superscript without modifying a bond}
Adding a \falseverb{charge} to an atom with a mathematical exponent implies that the box (and therefore the \TIKZ node) containing the atom has its dimensions modified. It has no importance when the atom is trailing but the alignment may be compromised if a bond is attached to the atom. The first reaction is to put the charge in a box with no width and therefore use the command \falseverb\rlap\footnote{If you have to put the charge at the left of the atom, you must use the command \texttt{\string\llap.}}, which often gives good results. We see here that with \falseverb\rlap, the \falseverb{horizontal alignment} of atoms is preserved:
\exemple{Charge and bond}/\chemfig{A^+-[2]B}
\qquad
\chemfig{A\rlap{${}^+$}-[2]B}/

The macro \verb|\charge| allows this task to be performed simply and accurately.
\exemple{Placing charges}/\chemfig{\charge{[extra sep=0pt]45[anchor=180+\chargeangle]=%
$\scriptstyle\oplus$}{A}-[2]B}
\qquad
\chemfig{*5(---\charge{90:2pt=$\scriptstyle\oplus$}{}-%
\charge{135:2pt=$\scriptstyle-$}{}-)}/

\subsection{Draw a curve bond}
We have already seen that with the \TIKZ library ``\verb-decorations.pathmorphing-'', we can draw a wavy bond:

\exemple{Wavy bond}|\chemfig{A-[,3,,,decorate,decoration=snake]B}

\chemfig{A-[,3,,,decorate,decoration={snake,amplitude=1.5mm,
    segment length=2.5mm}]B}|

For more flexibility, you can also define nodes using the character ``\verb-@-'' and reuse these nodes after the molecule has been drawn to connect them with a curved line using \falseverb\chemmove:

\exemple{Curved bonds}/\chemfig{@{a}A-[,,,,draw=none]@{b}B}
\chemmove{\draw[-](a)..controls +(45:7mm) and +(225:7mm)..(b);}
\bigskip

\chemfig{*6(@{a}---@{b}---)}
\chemmove{\draw[-](a)..controls +(60:3em) and +(240:3em)..(b);}
\quad
\chemfig{*6(@{a}---@{b}---)}
\chemmove{\draw[-](a)..controls +(60:3em) and +(30:1em)..
    ++(20:2em) ..controls +(210:3em) and +(-120:4em) ..(b);}/

\subsection{Draw a polymer element}\label{polymerdelim}
The macro \verb|\polymerdelim|, until now undocumented and in the test phase, becomes officially released in \CF with version 1.33. Its syntax is as follows:
\begin{center}
	\Verb|\polymerdelim[<keys>=<values>]{<node1>}<node2>}|
\end{center}

The effect, after possibly \emph{two} compilations, is to place vertical delimiters at the specified nodes. The parameters are specified via the \chevrons{keys} and \chevrons{values}, which are listed below, default values and actions.
\begin{center}
\begin{tabular}{rlp{8cm}}\hline
	\chevrons{keys} & default \chevrons{values} & Action\\\hline
	\CFdelimparam{delimiters} & Defines the delimiters. If these delimiters are brackets, write \verb|delimiters={[]}|.\\
	\CFdelimparam{height} & Defines the height (above the node) of the delimiters.\\
	\CFdelimparam{depth}  & Defines the depth (below the node) of the delimiters. If the \chevrons{value} is empty, then the depth is equal to the height.\\
	\CFdelimparam{h align}&Boolean which, when \CFval{false}, places the 2nd delimiter on the 2nd node, at the risk that the delimiters are not on the same horizontal line.\\
	\CFdelimparam{auto rotate}&Boolean which, when \CFval{true} and \CFkv{h align}{false}, automatically turns the delimiters to be perpendicular to the line that connects the two nodes.\\
	\CFdelimparam{rotate}&When \CFkv{h align}{false} and \CFkv{auto rotate}{false}, sets the rotation angle of the two delimiters.\\
	\CFdelimparam{open xshift}& Defines the horizontal offset of the opening delimiter.\\
	\CFdelimparam{close xshift}& Defines the horizontal offset of the closing delimiter. If the \chevrons{value} is empty, then this offset becomes opposite to the offset of the opening delimiter.\\
	\CFdelimparam{indice} & Defines the indices that will be placed at the right bottom of the closing delimiter.\\\hline
\end{tabular}
\end{center}
\exemple*{Polymers}|Polyethylen:
\chemfig{\vphantom{CH_2}-[@{op,.75}]CH_2-CH_2-[@{cl,0.25}]}
\polymerdelim[height = 5pt, indice = \!\!n]{op}{cl}
\bigskip

Polyvinyl chloride:
\chemfig{\vphantom{CH_2}-[@{op,1}]CH_2-CH(-[6]Cl)-[@{cl,0}]}
\polymerdelim[height = 5pt, depth = 25pt, open xshift = -10pt, indice = \!\!n]{op}{cl}
\bigskip

Nylon 6:
\chemfig{\phantom{N}-[@{op,.75}]{N}(-[2]H)-C(=[2]O)-{(}CH_2{)_5}-[@{cl,0.25}]}
\polymerdelim[height = 30pt, depth = 5pt, indice = {}]{op}{cl}
\bigskip

Polycaprolactame
\chemfig[atom sep = 2em]{[:-30]-[@{left,.75}]N(-[6]H)-[:30](=[2]O)--[:30]--[:30]--[@{right,0.25}:30]}
\polymerdelim[height = 5pt, indice = \!\!n]{left}{right}
\bigskip

Polyphenyl sulfide:
\chemfig{\vphantom{S}-[@{op,.75}]S-(**6(---(-[@{cl,0.25}])---))}
\polymerdelim[delimiters = (), height = 15pt, indice = {}]{op}{cl}
\bigskip

\chemfig{-CH_2-CH([6]-CO-NH-CH_2-NH-CO-CH([4]-CH_2-)([0]-[@{downleft,0.8},2]CH_2
-CH([2]-CO-NH_2)-[@{downright,0.3},2]CH_2-[,1.5]C?H-))-[@{upleft,0.8},2]CH_2
-CH([6]-CO-NH_2)-[@{upright,0.3},2]CH_2-[,1.5]CH([6]-CO-NH-CH_2-NH-C?O)-}
\polymerdelim[delimiters ={[]}, height = 5pt, depth = 40pt, indice = n]{upleft}{upright}
\polymerdelim[delimiters ={[]}, height = 40pt, depth = 5pt, indice = n]{downleft}{downright}

\chemfig{-[@{op,.5}:-30]O-[::60](=[::60]O)-[::-60]*6(-=-(-(=[::-60]O)-[::60]O-[::-60]-[::60]-[@{cl,.5}::-60])=-=)}
\polymerdelim[height=6ex, indice=n, h align=false]{op}{cl}|

\subsection{Draw the symmetrical of a molecule}\label{retournement}
The two commands \falseverb{\hflipnext} and \falseverb{\vflipnext} allow to draw the symmetrical of the next molecule about a horizontal or vertical axis. If we want to draw more symmetrical molecules, we need to write these commands before each molecule involved.

\exemple{Symmetry}/\chemfig{H_3C-C(=[:30]O)-[:-30]OH}% original

\vflipnext
\chemfig{H_3C-C(=[:30]O)-[:-30]OH}\medskip

\chemfig{H_3C-C(=[:30]O)-[:-30]OH}% original
\hflipnext
\chemfig{H_3C-C(=[:30]O)-[:-30]OH}/

\subsection{Add text above bonds and arc to angles}
Once we have understood that the character ``\verb-@-'' can put a ``global'' \TIKZ node, that is to say a node accessible after the molecule has been drawn, everything that \TIKZ can do with nodes (that is to say a lot of things) becomes possible.

To write something above or below a bond, we can put two ``global'' nodes on the atoms at the ends of this bond and write midway of them a text, raised or lowered so that it falls to just above or below the bond. This is done by the macro \verb-\bondname- in the code below.

To draw an arc between two bonds, three atoms are involved on which we have to put three ``global'' nodes. The macro  \verb-\arcbetweennodes- calculates the angle between two lines drawn from a node. Then \verb-\arclabel- draws an arc between two bonds and writes a text next to the arc: the optional argument of this macro is the \TIKZ code used to custom the arc. The second argument is the radius of the arc and the following three arguments are the names of global nodes between which the arc must be drawn, the middle name needs to be the vertex of the angle. The last argument is the text to write.

\exemple*{Arcs and text on bonds}|\newcommand\angstrom{\mbox{\normalfont\AA}}
\newcommand\namebond[4][5pt]{\chemmove{\path(#2)--(#3)node[midway,sloped,yshift=#1]{#4};}}

\newcommand\arcbetweennodes[3]{%
  \pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}%
  \let#3\pgfmathresult}

\newcommand\arclabel[6][stealth-stealth,shorten <=1pt,shorten >=1pt]{%
  \chemmove{%
    \arcbetweennodes{#4}{#3}\anglestart \arcbetweennodes{#4}{#5}\angleend
    \draw[#1]([shift=(\anglestart:#2)]#4)arc(\anglestart:\angleend:#2);
    \pgfmathparse{(\anglestart+\angleend)/2}\let\anglestart\pgfmathresult
    \node[shift=(\anglestart:#2+1pt)#4,anchor=\anglestart+180,rotate=\anglestart+90,inner sep=0pt,
          outer sep=0pt]at(#4){#6};}}

\chemfig{@{a}A=[:30,1.5]@{b}B-[7,2]@{c}C-@{d}D}
\namebond{a}{b}{\scriptsize My text}
\namebond[-3.5pt]{b}{c}{\small\color{red}$\pi$}
\namebond{c}{d}{\small1 \angstrom}
\medskip

Horizontal water molecule: \chemfig{@{1}H-[::37.775,2]@{2}O-[::-75.55,2]@{3}H}.
\namebond{1}{2}{\footnotesize0.9584 \angstrom}
\namebond{2}{3}{\footnotesize0.9584 \angstrom}
\arclabel{0.5cm}{1}{2}{3}{\footnotesize104.45\textdegree}
\qquad
Water molecule rotated 30\textdegree: \chemfig{[:30]@1H-[::37.775,2]@2O-[::-75.55,2]@3H}
\namebond12{\footnotesize0.9584 \angstrom}
\namebond23{\footnotesize0.9584 \angstrom}
\arclabel{0.5cm}{1}{2}{3}{\footnotesize104.45\textdegree}|

\subsection{Dessiner des liaisons multiples}
Again, the ``decorations.markings'' library allows to draw multiple bonds:

\exemple*{Liaisons multiples}|\catcode`_=11
\tikzset{nbond/.style args={#1}{%
	draw=none,%
	decoration={%
		markings,%
		mark=at position 0 with {\coordinate (CFstart@) at (0,0);},
		mark=at position 1 with {%
		\foreach\CF_i in{0,1,...,\number\numexpr#1-1}{%
			\pgfmathsetmacro\CF_nbondcoeff{\CF_i-0.5*(#1-1)}%
			\draw ([yshift=\CF_nbondcoeff\CF_doublesep]CFstart@)--(0,\CF_nbondcoeff\CF_doublesep);
			}%
		}
		},
	postaction={decorate}
	}
}
\catcode`\_=8
\chemfig{A-[1,,,,nbond=4]B-[:-30,,,,nbond=5]C-[6,,,,nbond=6]D}|

\part{Reaction schemes}\label{schemas}
Following several requests from users, it had become evident that \CF had a weakness regarding the drawing of reaction schemes. The gap is now filled. Therefore, \CF has now reached version 1.0 since I consider that the main features sought are now available.

I thank Clemens \textsc {Niederberger} for his help and the tests he carried out on the new features presented in this part.
\section{Overview}\label{schemestart}
A reaction scheme must be contained between the commands ``\falseverb\schemestart'' and ``\falseverb\schemestop''. As shown in this example, \falseverb{debug information} is either hidden or displayed  with the \chevrons{key} \CFkey{scheme debug} and the value \CFval{true} ou \CFval{false}:
\exemple[50]{Example 1}/\setchemfig{scheme debug=false}
\schemestart
  \chemfig{*6(-=-=-=)}\arrow
  \chemfig{X=[1]Y}\arrow
  \chemfig{S>T}
\schemestop
\bigskip

\setchemfig{scheme debug=true}
\schemestart
  \chemfig{*6(-=-=-=)}\arrow
  \chemfig{X=[1]Y}\arrow
  \chemfig{S>T}
\schemestop/

Some comments:
\begin{itemize}
	\item the \falseverb{\arrow} commands draw the arrows;
	\item everything lying between two \falseverb{\arrow} commands is considered a \falseverb{compound}. It was decided that all possible settings, whether for arrows or compounds, are controlled by the arguments of the \falseverb{\arrow} command, whose syntax may become quite complex;
	\item arrows are plotted horizontally, this can obviously be modified;
	\item  arrows are plotted on the imaginary line connecting the center of the compounds' bounding boxes  (the red and blue squares are the anchoring points of arrows). This behavior can also be modified;
	\item debug information is displayed with the \CFkey{scheme debug} \chevrons{key}. It consists of:
	\begin{itemize}
		\item the green label above the bounding boxes is the default name assigned to compounds by \CF. It follows the series "c1", "c2", etc. Numbering is reset to 1 for every reaction scheme.
		\item display of the compounds bounding boxes;
		\item the arrows start and end points represented by red points and anchors by blue points;
	\end{itemize}
	\item the distance from edge to edge between two compounds is defined with the \chevrons{key} \CFkv{compound sep}{dim}\label{compound sep}. By default this \CFval{dim} is 5em;
	\item finally, the distance between the edges of the compounds and the beginning and end of the arrows is defined with the \chevrons{key} \CFkv{arrow offset}{dim}. By default, this \CFval{dim} is 4pt.\label{arrow offset}
\end{itemize}

\section{Arrow types}\label{arrow}
When the \falseverb{\arrow} command is followed by an optional argument in braces (which is not mandatory), the argument defines the type of arrow:
\exemple[50]{Arrow types}|\schemestart A\arrow{->}B\schemestop\par % by default
\schemestart A\arrow{-/>}B \schemestop\par
\schemestart A\arrow{<-}B \schemestop\par
\schemestart A\arrow{<->}B \schemestop\par
\schemestart A\arrow{<=>}B \schemestop\par
\schemestart A\arrow{<->>}B \schemestop\par
\schemestart A\arrow{<<->}B \schemestop\par
\schemestart A\arrow{0}B \schemestop\par
\schemestart A\arrow{-U>}B \schemestop|
The arrow ``\verb/-U>/'' is not fully drawn, an arc can be added tangent to the arrow center using  optional arguments on the command, see page~\pageref{fleche.arg.optionnel}. Here is a ``\verb/-U>/'' arrow with the arc on top of it: \schemestart A\arrow{-U>[$\scriptstyle x$][$\scriptstyle y$]}B\schemestop

For the sake of clarity, capital letters will be used throughout the documentation instead of chemical formulas made with the  \falseverb\chemfig command except for specific examples. Reaction schemes obviously work identically with letters and drawn molecules. Several examples are shown in the Gallery with proper reaction schemes.

\section{Arrows features}
Each \falseverb{arrow} is characterized by:
\begin{itemize}
	\item an angle expressed in degrees;
	\item a coefficient that specifies the arrow length through the multiplication of the compounds spacing value defined by \CFkey{compound sep};
	\item  a style with \TIKZ instructions to customize the color, the thickness or other graphical attribute of the arrow.
\end{itemize}

These features are defined with the \chevrons{keys}
\begin{itemize}
	\item \CFkv{arrow angle}{angle}, which default value is 0;
	\item \CFkv{arrow coeff}{decimal}, which default value is 1;
	\item \CFkv{arrow style}{code tikz}, empty by default.
\end{itemize}

\exemple[50]{Definition of default values}/\schemestart A\arrow B\arrow C\schemestop

\setchemfig{arrow angle=15,arrow coeff=1.5,
arrow style={red, thick}}
\schemestart A\arrow B\arrow C\schemestop

\setchemfig{arrow coeff=2.5,arrow style=dashed}
\schemestart A\arrow B\arrow C\schemestop

\setchemfig{arrow angle={},arrow coeff={},arrow style={}}
\schemestart A\arrow B\arrow C\schemestop/

In order to locally modify one or all of these default values, the \falseverb{\schemestart} command accepts an optional argument in the form \verb-[angle,coeff,style]- which changes the default arrow features within the sole reaction scheme:
\exemple[50]{Optional argument}/\setchemfig{arrow angle=5,arrow coeff=2.5,arrow style=blue}
\schemestart A\arrow B\arrow C\schemestop

\schemestart[0] A\arrow B\arrow C\schemestop

\schemestart[0,1] A\arrow B\arrow C\schemestop

\schemestart[0,1,thick] A\arrow B\arrow C\schemestop

\schemestart[0,1,black] A\arrow B\arrow C\schemestop/

Regarding style, the rule is: the style specified in the argument in brackets applies \emph{after} the default style, without overwriting it! This is why only the ``black'' color attribute is able to overwrite the `` blue'' default style.

Finally, the \falseverb{\arrow} command accepts an optional argument in brackets in  the form \verb-[angle,coeff,style]- to change the feature of that given arrow. As above, style applies \emph{after} the default style and \emph{after} the style possibly-specified in the optional argument of the \verb-\schemestart- command, again without overwrting them.
\exemple[50]{Arrows features}/\schemestart
  A\arrow[45]B\arrow[-20,2]C
\schemestop
\bigskip

\schemestart
  A\arrow[90,,thick]B\arrow[,2]C
  \arrow[-45,,dashed,red]D
\schemestop/

\section{Compounds names}
Automatic naming of compounds (``c1'', ``c2'', etc.) can be overridden. For this, the \falseverb{\arrow} command must be immediately followed by an argument in parentheses. The argument is of the form: \verb/(n1--n2)/. The compounds located at the beginning and at the end of the arrow are named ``\verb-n1-''  and ``\verb-n2-'', respectively. Any alphanumeric string can be used. The numbering of the names "c<n>" continues internally, so if a \falseverb{compound} has a different name than the default one, it does not affect the default name of the subsequent compounds.

Names are optional, and the argument can be either \verb/(n1--)/ and \verb/(--n2)/.

\exemple[50]{Compounds names}/\setchemfig{scheme debug=true}
\schemestart
  A\arrow(aa--bb)B\arrow(--cc)C\arrow(--dd)D\arrow E
\schemestop
\bigskip

\schemestart
  A\arrow(aa--)B\arrow(bb--)C\arrow(cc--dd)D\arrow E
\schemestop/
Note that both methods are equivalent. Therefore, compounds can either be named by arrows preceding or following them. However,  when a \falseverb{compound} is surrounded by two arrows specifying its name, the first name is ignored and a warning message is generated:
\exemple[50]{Overfull naming}/\setchemfig{scheme debug=true}
\schemestart
  A\arrow(--foo)B\arrow(bar--)C
\schemestop/
Here \falseverb{compound} ``B'' is called ``foo'' by the arrow pointing at it, and ``bar'' by the arrowing leaving from it. Thus \CF generates a warning mentioning that the name "foo" will be ignored:

\hfill\verb-Package chemfig Warning: two names for the same node, first name "foo" ignored-\hfill\null

\section{Anchoring}
As noted above, arrows lie on the line connecting the center of the compounds' bounding boxes. Default anchors are called ``center'' in the sense of \TIKZ. Non-default anchoring points can be user-specified as well with an argument between brackets:

\hfill\verb/(n1.a1--n2.a2)/\hfill\null

where the anchor ``\verb-a1-'' or ``\verb-a2-'' can be: north west, north, north east, west, center, east, mid west, mid, mid east, base west, base, base east, south west, south , south east, text, or any angle. Here is an example from the \TIKZ  manual where the anchors are located on the bounding box:
\exemple*{TikZ anchoring}|\Huge
\begin{tikzpicture}[baseline]
\node[anchor=base west,name=x,draw,inner sep=25pt] {\color{lightgray}Rectangle\vrule width 1pt height 2cm};
\foreach \anchor/\placement in
{north west/above left, north/above, north east/above right,west/left, center/above, east/right,
mid west/left, mid/above, mid east/right,base west/left, base/below, base east/right,
south west/below left, south/below, south east/below right,text/below,10/right,45/above,150/left}
\draw[shift=(x.\anchor)] plot[mark=x] coordinates{(0,0)}
node[\placement,inner sep=0pt,outer sep=2pt] {\scriptsize\texttt{(\anchor)}};
\end{tikzpicture}|
Like for names, arrival and departure anchoring points are independent and optional.

In this example, the default alignment  is not good because the two ``A'' are not aligned vertically.  Debug information show that the default ``center'' anchors are not suitable:
\exemple[50]{Alignment problems}/\setchemfig{scheme debug=true}
\schemestart
  \chemfig{A*5(-----)}
  \arrow
  \chemfig{A*5(---(-)--)}
\schemestop/
For the alignment to be correct, arrows will leave/arrive either from the anchor ``base east''/``base west'', or from anchor  ``mid east''/``mid west'':
\exemple[50]{Alignment problems}/\setchemfig{scheme debug=true}
\schemestart
  \chemfig{A*5(-----)}
  \arrow(.base east--.base west)
  \chemfig{A*5(---(-)--)}
\schemestop
\bigskip

\schemestart
  \chemfig{A*5(-----)}
  \arrow(foo.mid east--bar.mid west)
  \chemfig{A*5(---(-)--)}
\schemestop/

One last anchor need be specified: the anchor of the first \falseverb{compound} with respect to the \falseverb{baseline} of the text just before it. This is illustrated by the green point on the left-hand side of the scheme below:
\exemple[50]{Initial anchoring}/\setchemfig{scheme debug=true}
Preceding text:
\schemestart
  \chemfig{A*5(-----)}\arrow A
\schemestop/

The default position of this anchor on the first \falseverb{compound}'s bounding box is that given by  ``text''. This position can be controlled with the second optional argument of the \falseverb{\schemestart} command:
\exemple[50]{Adjusting the initial anchoring}/\setchemfig{scheme debug=true}
Preceding text:
\schemestart[][south]
  \chemfig{A*5(-----)}\arrow A
\schemestop
\bigskip

Preceding text:
\schemestart[][north west]
  \chemfig{A*5(-----)}\arrow A
\schemestop
\bigskip

Preceding text:
\schemestart[][west]
  \chemfig{A*5(-----)}\arrow A
\schemestop/

\section{Compounds style}
The \falseverb{\arrow} command can also include \TIKZ instructions to define the bounding box style ``\verb-s-'' of the reactant and the product of the reaction. This is done with the argument between parentheses. Always style through the argument in brackets of the \falseverb{\arrow}, we can specify with \TIKZ instructions the  style ``\verb-s-'' to bounding box of the \falseverb{compound}  of departure or of arrival. Therefore the complete syntax of the \falseverb{\arrow} command, with each specification being optional, is as follows:

\hfill\verb/\arrow(n1.a1[s1]--n2.a2[s2]){arrow type}[angle,coeff,arrow style]/\hfill\null

Like forn names, if  specific styles are given to one compound by arrows arriving on it and leaving from it, the first style will be ignored with a warning.

\exemple[60]{Compounds style}/\schemestart
  A
  \arrow([red]--[fill=blue,semitransparent,text opacity=1,
  inner sep=10pt,rounded corners=2mm])
  B
\schemestop
\bigskip

\schemestart
  A\arrow(--foo[yshift=5mm])B
\schemestop/

\label{setcompoundstyle}The macro \falseverb\setcompoundstyle\Verb-{<code tikz>}- allows  to globally define the style of compounds  displayed thereafter. Entering an empty argument results in the absence of style, which corresponds to the default case.

Here a style is defined with round corner-shaped boxes and semitransparent background:
\exemple[50]{Global styles}/\setchemfig{compound style={draw,line width=0.8pt,
semitransparent,text opacity=1,inner sep=8pt,
rounded corners=1mm}}
\schemestart
  A\arrow([fill=red]--[fill=blue])[90]
  B\arrow(--[fill=gray])
  C\arrow(--[fill=green])[-90]
  D\arrow(--[draw=none])[-180]
\schemestop/

\section{Branching}
So far, only linear reaction schemes have been treated. Branched schemes are also possible and this is where compound names play a key role. When a name is preceded by ``\verb-@-'' in the argument between brackets of the \falseverb{\arrow} command,  it means that the \falseverb{compound} already exists. Several scenarios are possible:
\begin{itemize}
	\item \verb/(@n1--n2)/: the arrow will leave from the existing compound ``\verb-n1-'' and the scheme will continue following the arrow, thus creating a branch;
	\item \verb/(@n1--@n2)/: the arrow is drawn between two existing compounds, no matter whether they are already defined or whether they will later in the reaction scheme: therefore this syntax can be placed \emph{anywhere} in the code of the reaction scheme;
	\item \verb/(n1--@n2)/: this syntax is not permitted;
\end{itemize}

In the following example, 3 branches are made, a first one from  ``B'', a second one from ``D'' and a last one from ``X''. Finally one more arrow connects two existing compounds: ``XX'' and ``D'':
\exemple[50]{Branching}/\schemestart
  A\arrow(aa--bb)B\arrow(--cc)C\arrow D
  \arrow(@bb--xx1)[-90]X\arrow[-90]Y% 1st branch
  \arrow(@c4--)[-90]Z\arrow W% 2nd branch
  \arrow(@xx1--xx2)[-45]XX% 3rd branch
  \arrow(@xx2--@c4)% XX-to-D arrow
\schemestop/

One may wish to have ``Y'' and ``XX'' on the same horizontal line. To achieve this, a horizontal invisible bond is drawn between ``Y'' and ``XX''; the scheme is completed with a final arrow between the two existing compounds ``XX'' and ``D'':
\exemple[50]{Branching}/\schemestart
  A\arrow(aa--bb)B\arrow(--cc)C\arrow D
  \arrow(@bb--xx1)[-90]X\arrow[-90]Y\arrow(--xx2){0}XX
  \arrow(@c4--)[-90]Z\arrow W
  \arrow(@xx1--@xx2)% X-to-XX arrow
  \arrow(@xx2--@c4)% XX-to-D arrow
\schemestop/

\section{Subscheme}\label{subscheme}
A fraction of the reaction scheme can be defined within a single bounding box, so that \CF treats it as a \falseverb{compound}. The reaction scheme fraction is defined inside the compulsory argument between braces of the  \falseverb{\subscheme} command so it is subsequently regarded as a single entity. When \falseverb{\subscheme} is located after an arrow, the command labels this subscheme as a \falseverb{compound} named ``c<n+1>'':
\exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
\schemestart
  A\arrow
  \subscheme{B\arrow[-90,2]C}
  \arrow
  D
\schemestop/
Although this is not clearly seen because of labels overlap, the box around the subscheme is called ``c2'', and name numbering continues inside the subscheme with B called ``c3'' and C called  ``c4''. Since the first \falseverb{compound} in the subscheme is  ``B'', the subscheme's baseline is that of ``B''. This can be pointed out by specifying the anchors:
\exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
\schemestart
  A\arrow(--.mid west)
  \subscheme{B\arrow[-90,2]C}
  \arrow
  D
\schemestop/
Note that since ``\falseverb\subscheme\Verb-{<scheme>}-'' is only a convenient shortcut for
\begin{center}
\falseverb\schemestart\Verb-<scheme>-\falseverb\schemestop
\end{center}
Consequently, it can be used with the same optional arguments as \falseverb\schemestart.

\label{chemleft}\CF provides the \falseverb{\chemleft} and \falseverb{\chemright} command pair. These allow to set expandable delimiters on either side of a material. The commands must be followed by delimiters, just like in the case of \TeX{} primitive commands \verb-\left- and \verb-\right-:
\begin{center}
	\Verb/\chemleft<car1><material>\chemright<car2>/
\end{center}
where \Verb-<car1>- and \Verb-<car2>- can be ``('' et ``)'' or ``['' and ``]'', or any other expandable delimiter consistent with the \verb-\left- et \verb-\right- commands.
\exemple{The \string\chemleft\ and \string\chemright macros}/\chemleft\lfloor\chemfig{A-[1]B}\chemright)

\chemleft\{\chemfig{A-[1,1.25]B-[6,1.25]C}\chemright|

\chemleft[\chemfig{H-[1]O-[7]H}\chemright]/
The code of the reaction scheme discussed above including \falseverb{\chemleft} and \falseverb{\chemright} is written:
\exemple{Reaction scheme with \string\chemleft\ and \string\chemright}/\schemestart
  A\arrow
  \chemleft[\subscheme{B\arrow[-90,2]C}\chemright]
  \arrow
  D
\schemestop/
\label{chemup}By analogy,  the macros \falseverb{\chemup} and \falseverb{\chemdown} can be used to draw expandable delimiters above and below the material, respectively:
\begin{center}
	\Verb/\chemup<car1><material>\chemdown<car2>/
\end{center}
For example:
\exemple{The \string\chemup\ and \string\chemdown macros}/\schemestart[-90]
X\arrow
\chemup\{\chemfig{A-[1]B-[7]C}\chemdown\}
\arrow Y
\schemestop
\qquad
\schemestart[-90]
X\arrow
\chemup[\chemfig{A-[1]B-[7]C}\chemdown]
\arrow Y
\schemestop/

Delimiters can can also be drawn through compounds' style and apply them to a random compound (and hereby to a subscheme). These expandable delimiters (parentheses, brackets, braces) can be used upon loading the ``matrix'' \TIKZ library in the document preamble:

\hfill\verb-\usetikzlibrary{matrix}-\hfill\null

Since the  \falseverb{\chemleft}, \falseverb{\chemright}, \falseverb{\chemup} and \falseverb{\chemdown} commands are available, the  \CF package  will \emph{not} automatically load the library. As long as the user want to access this special set of delimiters, the library must be explicitly loaded.

The same brackets-delimited subscheme as above is presented again:
\exemple[50]{The ``matrix'' library delimiters}/\schemestart
  A\arrow(--[left delimiter={[}, right delimiter={]}])
  \subscheme{B\arrow[-90,2]C}
  \arrow
  D
\schemestop/
Since the delimiters are drawn outside the bounding box, it is advisable to slightly shorten the incoming and outgoing arrows:
\exemple[50]{Subscheme}/\schemestart
  A\arrow(--[left delimiter={[},
  right delimiter={]}])[,,shorten >=6pt]
  \subscheme{B\arrow[-90,2]C}
  \arrow[,,shorten <=6pt]
  D
\schemestop/

Subschemes should be used with care, undesired results are sometimes observed. In this example, a subscheme is used to horizontally align 3 different compounds:
\exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
\schemestart
  A
  \arrow{0}[-90]
  \subscheme{%
    tagada\arrow{}
    tsoin\arrow{}
    fin}
  \arrow(xx--yy){}E
  \arrow(@c1--@c3){}
  \arrow(@c1--@c5){}
  \arrow(@c1--@c4){}
\schemestop/
The center of the subscheme is exactly located on the same vertical line as the center of compound "A". This is because the two entities are connected by an  invisible arrow with a $-90 $ angle. However, the arrow between the two pre-existing compounds ``A'' and ``tsoin'' is \emph{not}  vertical because ``tsoin'' is not on the center of the subscheme since "tagada" is wider than "end". If this arrow is to be vertical within the use of the \falseverb{\subscheme} command, one must find a correct angle  for the arrival anchor of the invisible arrow by try-and-error.

A much simpler method is to use a branch instead of a subscheme: draw a \emph{visible} arrow between ``A'' and ``tsoin'', and then draw horizontal arrows on both sides  of ``tsoin'', with a branch for the right-hand side arrows.
\exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
\schemestart
  A
  \arrow(--tsoin){->}[-90]
  tsoin
  \arrow{<-}[180]
  tagada
  \arrow(@tsoin--fin){}
  fin
  \arrow{}
  E
  \arrow(@c1--@c3){}
  \arrow(@c1--@fin){}
\schemestop/

\section{Arrows optional arguments}\label{fleche.arg.optionnel}
Within the argument in braces of the \falseverb\arrow command, the arrow name can be followed by optional arguments written between brackets. Here are the possible values for these optional arguments and their meaning, as defined by \CF:
\begin{itemize}
	\item the arrows ``\verb|->|'', ``\verb|<-|'', ``\verb|<->|'', ``\verb|<=>|'', ``\verb|<<->|'',``\verb|<->>|'', ``\verb|-/>|'' have three optional arguments:
	\begin{itemize}
		\item the first one contains the ``label'' to be placed above the arrow;
		\item the second one contains the ``label'' to be placed below the arrow. The orientation of these two labels is given by the same angle as the arrow. The perpendicular shift between the arrow and the label anchor can be adjusted  with the \chevrons{key} \CFkv{arrow label sep}{dim}\label{arrow label sep} which value is 3pt by default. Labels contained in the two optional arguments are \emph{not} typed in math mode.
		\item the third one is a dimension corresponding to a shift perpendicular to the arrow that can be applied to it: the dimension is positive for an upward shift of the arrow (and of its  labels, if any), and negative for a downward shift.
	\end{itemize}
	\item the ``\verb|-U>|'' arrow has 5 optional arguments:
	\begin{itemize}
		\item the first three are identical to those found in the other arrow types;
		\item the fourth one is a coefficient (which is 0.333 by default) which multiplies the length of the arrow to get the radius of the arc;
		\item the fifth one is the half-angle from the center of the arc path, it is 60 degrees by default.
	\end{itemize}
	\item the invisible arrow ``\verb-0-'' accepts two optional arguments of the same type as the first two listed above;
\end{itemize}
\exemple[50]{Arrows optional arguments}/\setchemfig{scheme debug=false}
\schemestart A\arrow{->[up][down]}B \schemestop
\qquad
\schemestart A\arrow{->[up][down][4pt]}B \schemestop
\qquad
\schemestart A\arrow{->[up][down][-4pt]}B \schemestop
\medskip

\schemestart A\arrow{<=>[up][down]}[30,1.5]B \schemestop
\medskip

\schemestart[-20]
  A\arrow{->}B\arrow{->[][][3pt]}C\arrow{->[][][-3pt]}D
\schemestop/
A problem arises for vertical  arrows:
\exemple[50]{Vertical arrows}/\schemestart
  A\arrow{->[up][down]}[-90]B
\schemestop/
For the sake of clarity, one may prefer to have the ``above'' and ``below'' labels written horizontally. Label angles can be specified, while default is the same angle as that of the arrow. To choose a specific angle, \Verb-*{<angle>}- can be written at the beginning of the optional arguments:
\exemple[55]{Choice of angles}/\setchemfig{scheme debug=true}
\schemestart A\arrow{->[*{0}up][*{0}down]}[90]B\schemestop
\qquad
\schemestart A\arrow{->[*{0}up][*{0}down]}[45]B\schemestop
\qquad
\schemestart A\arrow{->[*{0}up][*{0}down]}[-45]B\schemestop
\qquad
\schemestart A\arrow{->[*{0}up][*{0}down]}[-90]B\schemestop/
The default position of the label anchor can lead to undesired results:
\exemple[50]{Anchors}/\setchemfig{scheme debug=true}
\schemestart
  A\arrow{->[*{0}on top of][*{0}underneath]}[45,2]B
\schemestop/
To counter this, the anchoring position can be specified as well to override the one selected by \CF by default. The syntax for this is: \Verb-*{<angle>.<ancre>}-.
\exemple[50]{Anchors}/\setchemfig{scheme debug=true}
\schemestart
  A\arrow{->[*{0.0}on top of][*{0.180}underneath]}[45,2]B
\schemestop
\qquad
\schemestart
  A\arrow{->[*{0.south east}on top of]%
    [*{0.north west}underneath]}[45,2]B
\schemestop/

The ``\verb/-U>/'' arrow remains a particular case. If one of the two labels from the first two optional arguments is present, the corresponding arc is plotted:
\exemple[50]{The \texttt{-U>} arrow}/\schemestart A\arrow{-U>[123][456]}B\schemestop
\qquad
\schemestart A\arrow{-U>[123]}[30]B\schemestop
\qquad
\schemestart A\arrow{-U>[][456]}[-30]B\schemestop/

The fourth and fifth optional arguments modify the appearance of the arc: respectively the arrow length coefficient which sets the arc radius, and the angle that defines the half arc:
\exemple[50]{The \texttt{-U>} arrow}/\schemestart A\arrow{-U>[123][456][][0.25]}B\schemestop
\qquad
\schemestart A\arrow{-U>[123][456][][][90]}B\schemestop
\qquad
\schemestart A\arrow{-U>[123][456][][1][45]}B\schemestop/
With negative values for the radius and the angle, the arc is drawn below the arrow:
\exemple[50]{The \texttt{-U>} arrow}/\schemestart
  A\arrow{-U>[123][456][][-0.333][-60]}B
\schemestop/
Label angles and anchoring customization is controlled with the first two arguments, just like for other arrows:
\exemple[50]{The \texttt{-U>} arrow}/\schemestart
  A\arrow{-U>[123][456]}[-90]B
\schemestop
\qquad
\schemestart
  A\arrow{-U>[*{0.180}123][*{0.180}456]}[-90]B
\schemestop/

\section{Arrows customization}\label{definearrow}
This section is quite technical and requires some knowledge of \TIKZ. It is targeted at advanced users  only who need to define their own arrows.

The \falseverb{\definearrow} command allows to build custom arrows. Its syntax is:

\hfill\Verb-\definearrow{<number>}{<arrow name>}{<code>}-\hfill\null

where \Verb-<number>- is the number of optional arguments that will be used in the \Verb-<code>-, with the usual syntax \verb-#1-, \verb-#2-, etc. These optional arguments cannot accept default values; if no value is specified upon using the macro \verb-\arrow-, the arguments will remain empty.

Before going further, let's examine the available internal macros  when drawing arrows. Since these macros include the "\verb-@-" character in their name, they can only be accessed between \verb|\catcode`\_=11| and \verb|\catcode`\_=8| commands.
\begin{itemize}
	\item \falseverb{\CF_arrowstartname} and \falseverb{\CF_arrowendname} include the names of the compounds (considered as nodes by \TIKZ) between which the arrow is drawn;
	\item \falseverb{\CF_arrowstartnode} and \falseverb{\CF_arrowendnode} include the node names where arrow ends will be located. After these names, user-defined anchors can be specified in the argument between brackets of the \falseverb\arrow command, unless the field is left empty;
	\item \falseverb{\CF_arrowcurrentstyle} and \falseverb{\CF_arrowcurrentangle} contain the style and the angle of the arrow to be drawn;
	\item \falseverb{\CF_arrowshiftnodes}\Verb-{<dim>}- shifts the nodes ``\falseverb{\CF_arrowstartnode}'' and ``\falseverb{\CF_arrowendnode}'' perpendicularly relative to the arrow by a dimension specified in the argument;
	\item \falseverb{\CF_arrowdisplaylabel}\verb/{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}/ is the most complex one. It gives the labels position with the following arguments:
	\begin{itemize}
		\item \verb-#1- and \verb-#5- are the labels to be written;
		\item \verb-#2- and \verb-#6- are real numbers between 0 and 1. They specify the location  of the labels on the arrow. 0 is the beginning of the arrow and 1 is its end, assuming a \emph{straight} arrow; 
		\item \verb-#3- and \verb-#7- are the ``+'' or ``-'' characters. ``+'' displays the  label above the arrow, while  ``-'' does it below it;
		\item \verb-#4- and \verb-#8- are the names of the nodes corresponding to the beginning and the end of the arrow.
	\end{itemize}
	\item arrow heads are based on ``\verb-CF-'' for a full arrow and have the ``harpoon'' option for half arrows.
\end{itemize}

\subsection{First arrow}
As an example, assume we want to make an arrow with a circle on its center. Let's call it ``\verb/-.>/''. This arrow will accept four optional arguments. Like for previously-defined arrows, the first and second arguments will be the labels to be located above and below the arrow. The third one will define the perpendicular shift relative to the arrow direction. Finally, the 4th argument will define the circle size. If this last argument is absent the default circle size will be equal to 2pt.

Let's start with \verb/\definearrow{4}{-.>}/ to declare that the arrow will have 4 optional arguments and that it will be called \verb/-.>/. First, the position of the nodes between which the arrow is to be drawn must be modified in order to take the third-argument shift into account. This is made with the  macro \falseverb{\CF_arrowshiftnodes}, so the code of the arrow will start with: \falseverb{\CF_arrowshiftnodes}\verb-{#3}%-. Then, one must plot the arrow itself, while taking the opportunity to set a node on the center of the segment, which will be called  "\verb-mid@point-". Finally, the circle is defined with its center on that node. The whole \TIKZ code is:

{\hskip2em\verb-\edef\pt_radius{\ifx\empty#4\empty 2pt\else #4\fi}% circle radius-\par\parskip0pt
\hskip2em\verb/\expandafter\draw\expandafter[\CF_arrowcurrentstyle,-CF]/\par
\hskip4em\verb/(\CF_arrowstartnode)--(\CF_arrowendnode)coordinate[midway](mid@point);/\par
\hskip2em\verb-\filldraw(mid@point)circle(\pt_radius);%-}

The last step is to enter the labels, if any, with the folwing line:

\hskip2em\verb/\CF_arrowdisplaylabel{#1}{0.5}{+}{\CF_arrowstartnode}{#2}{0.5}{-}{\CF_arrowendnode}/

Here is the completed arrow:
\exemple*{Arrow ``-.>''}/\catcode`\_11
\definearrow4{-.>}{%
  \edef\pt_radius{\ifx\empty#4\empty 2pt\else #4\fi}% dot radius
  \CF_arrowshiftnodes{#3}%
  \expandafter\draw\expandafter[\CF_arrowcurrentstyle,-CF](\CF_arrowstartnode)--(\CF_arrowendnode)
    coordinate[midway](mid@point);
  \filldraw(mid@point)circle(\pt_radius);%
  \CF_arrowdisplaylabel{#1}{0.5}{+}{\CF_arrowstartnode}{#2}{0.5}{-}{\CF_arrowendnode}
  }
\catcode`\_8
\schemestart
A \arrow{-.>} B \arrow{-.>[above][below][][1pt]} C \arrow{-.>[][below]}[30] D \arrow{-.>[above][][5pt][1.5pt]} E
\schemestop/

\subsection{Curved arrow}
How about a curved arrow? To make things as simple as possible, assume it will have one single optional argument with the  \TIKZ  code that will specify the point(s) of control. If this argument is empty, a ``\verb/-CF/'' type arrow will be plotted.

If \verb-#1- is not empty, attention should not be drawn to ``\falseverb{\CF_arrowstartnode}'' and ``\falseverb{\CF_arrowendnode}'' which contain the node names of arrow ends positions, because the location of these nodes is already determined by the anchors calculated for \emph{straight} arrows! Instead we will use \falseverb{\CF_arrowstartname} and \falseverb{\CF_arrowendname} which contain the names of the compound (which are nodes for \TIKZ), since the arrow must be plotted between them. Here's the \TIKZ code to draw the curved arrow between the two compounds:

{\verb/\draw[shorten <=\CF_arrowoffset,shorten >=\CF_arrowoffset,\CF_arrowcurrentstyle,-CF,/\par\parskip0pt
\verb/(\CF_arrowstartname).. controls #1 ..(\CF_arrowendname);%/}

One must add a  \TIKZ code to shorten the arrow by an amount \falseverb{\CF_arrowoffset} defined by  \falseverb{\setarrowoffset}. Indeed, the nodes ar not the same as those  for straight arrows (\falseverb{\CF_arrowstartnode} and \falseverb{\CF_arrowendnode}). So before \falseverb{\CF_arrowcurrentstyle}, the following code must be added:
\begin{center}
	\verb/shorten <=\CF_arrowoffset, shorten >=\CF_arrowoffset/
\end{center}
this is the role the two lines after \verb-\else-.

So here is our curved arrow:
\exemple*{Curved arrow}/\catcode`\_11
\definearrow1{s>}{%
\ifx\empty#1\empty
  \expandafter\draw\expandafter[\CF_arrowcurrentstyle,-CF](\CF_arrowstartnode)--(\CF_arrowendnode);%
\else
  \def\curvedarrow_style{shorten <=\CF_arrowoffset,shorten >=\CF_arrowoffset,}%
  \CF_eaddtomacro\curvedarrow_style\CF_arrowcurrentstyle
  \expandafter\draw\expandafter[\curvedarrow_style,-CF](\CF_arrowstartname)..controls#1..(\CF_arrowendname);
\fi
}
\catcode`\_8
\schemestart
A\arrow{s>}
B\arrow{s>[+(0.5cm,0.5cm)]}
C\arrow{s>[+(45:1cm)]}
D\arrow(.60--.120){s>[+(60:1cm) and +(-120:1cm)]}
E\arrow{s>[+(45:1) and +(-135:1)]}
F\arrow{s>[+(-30:1) and +(150:1)]}[,1.5]
G\arrow(.90--.90){s>[+(60:1)and+(120:1)]}[,2]
H
\schemestop

\schemestart
A\arrow(.90--.180){s>[+(90:0.8) and +(180:0.8)]}[45]B
\arrow(.0--.90){s>[+(0:0.8) and +(90:0.8)]}[-45]C
\arrow(.-90--.0){s>[+(-90:0.8) and +(0:0.8)]}[-135]D
\arrow(.180--.-90){s>[+(180:0.8) and +(-90:0.8)]}[135]
\schemestop/

\section{The \protect\texttt{\textbackslash merge} command}
The \falseverb{\merge} command allows to draw arrows coming from several existing compounds that merge into one single arrow that arrive to one single compounds.

Just after the  \falseverb{\merge} command, the direction that follows up must be specified. For this, 4 different direction characters can be used: ``\verb->-'' (the default direction if no character is entered), ``\verb-<-'', ``\verb-^-'' and ``\verb-v-''.

The syntax follows with:

\hfill\verb/\merge{dir}(n1.a1)(n2.a2)(...)(ni.ai)--(n.a[s])/\hfill\null

where the  ``\verb-ni-'' names before the double dash are those already-defined compounds from which out coming arrows will merge into a single one. One can also specify the  ``\verb-ai-'' anchor, when the default one is not convenient. Like for the \falseverb\arrow command, the command ``\verb-n.a[s]-'' includes  the name, the anchor and the style of the target compound.

\exemple[50]{The \string\merge command}/\schemestart
ABC\arrow[30]EFGHIJ\arrow[45]KLM\arrow[60]NO
\merge>(c1)(c2)(c3)--()series 1
\arrow series 2
\schemestop
\bigskip

\schemestart
Foooo\arrow(foo--bar){<=>}Bar\arrow(--baz){<=>}Bz
\merge^(foo)(bar)(baz)--()series
\schemestop
\bigskip

\setchemfig{scheme debug=true}
\schemestart
A\arrow{<->}[90]B
\merge<(c1.120)(c2)--(foobar.45[circle,blue])CCC
\schemestop/

Regarding the geometry of the  \falseverb{\merge} arrow, it consists of $n$ segments leaving from  $n$ compounds up to the perpendicular line that connects them: the default length of the shortest of these segments is worth half of the compound-spacing  distance defined by \falseverb\setcompoundsep. The arrow drawn from the connecting line to the target compound has the same default length, its origin is on the middle of the connecting line. These three geometric features can be customized with the optional argument immediately after the target compound:

\hfill\verb/\merge{dir}(n1.a1)(n2.a2)(...)(ni.ai)--(n.a[s])[c1,c2,c,style]/\hfill\null

where:
\begin{itemize}
	\item the shortest segment distance between reactants and the connecting line is controlled through the multiplication of the \falseverb{\setcompoundsep} distance by a coefficient \verb-c1-, whose default value is 0.5;
	\item the length of the arrow between the connecting line and the product compound is controlled through the multiplication of the \falseverb{\setcompoundsep} distance by a coefficient \verb-c2-, whose default value is 0.5;
	\item the origin of the arrow between the connecting line and the product compound is determined by the coefficient \verb-c-, a value of 0 involves a departure from the the left of the connect line (or from its top if the direction is \verb-v- or \verb-^-);
	\item the style of the \falseverb{\merge}  arrow is  defined with the last argument: \verb-style-.
\end{itemize}

\exemple*{Geometrical parameters of \string\merge}/\schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()C\schemestop\qquad
\schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[1]C\schemestop\qquad
\schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[,1]C\schemestop\qquad
\schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[,,0.2]C\schemestop\qquad
\schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[,,0.9,red,thick]C\schemestop
\bigskip

\schemestart A\arrow{<=>}B\merge^(c1)(c2)--()C\schemestop\qquad
\schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[1]C\schemestop\qquad
\schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[,1]C\schemestop\qquad
\schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[,,0.2]C\schemestop\qquad
\schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[,,0.9,red,thick]C\schemestop/

Finally, it is possible to write labels above or below the merged arrow. For this, the direction character accepts two optional arguments in brackets, a first one for the label above the arrow and a second one for the label below it. Therefore, the full syntax of the \falseverb{merge} command is:

\hfill\verb/\merge{dir}[labelup][labeldow](n1.a1)(n2.a2)(...)(ni.ai)--(n.a[s])[c1,c2,c,style]/\hfill\null

All the features introduced before for arrow labeling can be implemented here as well, i.e. rotation angle and anchoring with the syntax \verb-*{angle.anchor}- entered just before the content of the label.

\exemple*{Labels of the \string\merge command}/\schemestart
ABC\arrow{<=>}[90]DEF\merge>[above][below](c1)(c2)--()[0.25,1,0.75]GHIJ
\schemestop\qquad
\schemestart
ABC\arrow{<=>}[90]DEF\merge>[*{45.south west}above][*{45.north east}below](c1)(c2)--()[0.25,1,0.75]GHIJ
\schemestop\qquad
\schemestart
ABC\arrow{<=>}[90]DEF\merge>[*{90}above][*{90}below](c1)(c2)--()[0.25,1,0.75]GHIJ
\schemestop
\bigskip

\schemestart
ABC\arrow{<=>}DEF\merge v[above][below](c1)(c2)--()[0.25,1,0.75]GHIJ
\schemestop\qquad
\schemestart
ABC\arrow{<=>}DEF\merge v[*{45.north west}above][*{45.south east}below](c1)(c2)--()[0.25,1,0.75]GHIJ
\schemestop\qquad
\schemestart
ABC\arrow{<=>}DEF\merge v[*{0}above][*{0}below](c1)(c2)--()[0.25,1,0.75]GHIJ
\schemestop/

\section{The + sign}\label{signe+}
The use of a  ``\falseverb\+'' macro that displays a ${}+{}$ sign is available between the commands  \falseverb{\schemestart} and \falseverb{\schemestop}. This macro accepts an optional argument in braces with  3 dimensions in the  form \Verb-{<dim1>,<dim2>,<dim3>}-, where:
\begin{itemize}
	\item \Verb-<dim1>- and \Verb-<dim2>- are the dimensions to be inserted before and after the ${}+{}$ sign;
	\item \Verb-<dim3>- is the vertical offset of the sign.
\end{itemize}

These dimensions can also be set, for all the following ${}+{}$ signs with the \chevrons{keys} \CFkv{+ sep left}{dim}, \CFkv{+ sep right}{dim} et \CFkv{+ vshift}{dim}. The default values are 0.5em for the two first and 0pt for the third.

\exemple[50]{The \string\+ command}/\schemestart
A\+B\+{2em,,5pt}C\+{0pt,0pt,-5pt}D\arrow E\+F
\schemestop

\setchemfig{+ sep left=1em,+ sep right=1em,+ vshift=0pt}
\schemestart
A\+B\+{2em,,5pt}C\+{0pt,0pt,-5pt}D\arrow E\+F
\schemestop/

As shown in the example below, it should be kept in mind that the ${}+{}$ sign inserted by the \falseverb{\+} command is part of the compound:
\exemple[50]{Compounds and \string\+}/\setchemfig{scheme debug=true}
\schemestart A\+ B\+{,,5pt}C\arrow D\+ E\schemestop/
This makes it difficult to draw a vertical arrow exactly below the letter ``A'' since  this letter is not a single compound for \CF. This issue can be solved with the use of  the \falseverb{\subscheme} command to uniquely define the letter ``A'' as a single compound (the same procedure can be applied to the ${}+{}$ sign itself) so that it can be referred to later on with its own name:
\exemple[50]{Subcompound and \string\+}/\setchemfig{scheme debug=true}
\schemestart
\subscheme{A}\+ B\arrow C
\arrow(@c2--)[-90]E
\schemestop
\medskip

\schemestart
A\subscheme{\+}BCDEF \arrow G
\arrow(@c2--)[-90]H
\schemestop/%

A common problem can be the misalignment of the ``+'' sign with the molecules before or after it. For example:
\exemple{+ sign alignment}/\setchemfig{scheme debug=true}
\schemestart
  \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
  \+
  \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
\schemestop/
Here, the ``+'' sign sits on the same baseline as the compound before it, and this baseline is that of the top carbon atom. One may shift the  ``+'' sign,  but this would not change the vertical position of ``\kern0.3333em\chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}\kern0.3333em''. In fact, the ``+'' sign does not prevent \CF from reading a compound, as shown in the example above where everything is included in the compound `` c1''. Therefore, one must stop the compound right after the first molecule with a \verb-\arrow{0}[,0]- that will draw an invisible, zero-length arrow. In order to vertically center the whole scheme, one must also set the  the anchor of the first compound as ``west'' (or ``180'', which is a synonym) with the second optional argument of the \verb-\schemestart- command:
\exemple{+ sign alignment}/\setchemfig{scheme debug=true}
\schemestart[][west]
  \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
  \arrow{0}[,0]\+
  \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
\schemestop/
Thus, the first compound `` c1'' consists of the first molecule and the second compound consists of everything else, i.e.  the  ``+'' sign and the second molecule. Alternatively, one can play with  anchors or styles via the  \verb-\arrow- command to move the second compound to another location. Here, for example, the second compound is shifted downwards by 10pt in the first case. In the second case, the ``south east'' anchor of the first compound matches the ``south west'' anchor of the second one:
\exemple{+ sign alignment}/\setchemfig{scheme debug=true}
\schemestart[][west]
  \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
  \arrow(--[yshift=-10pt]){0}[,0]\+
  \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
\schemestop
\medskip

\schemestart[][west]
  \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
  \arrow(.south east--.south west){0}[,0]\+
  \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
\schemestop/
\newpage

\part{List of commands}
The commands created by \CF are:
\begin{center}
\begin{longtable}{>\footnotesize l>\footnotesize p{9cm}}\\\hline
\hfill\normalsize Commands\hfill\null &\hfill\normalsize Description\hfill\null\\\hline
\Verb-\chemfig[<settings>]{<code>}-& draws the molecule whose design is described by the \Verb-<code>-\\
\Verb|\setchemfig{<settings>}|& sets the parameters with the syntax \chevrons{key}${}={}$\chevrons{value}. Here is the full list of keys with the default values:
\begin{itemize}
	\item \CFkv{chemfig style}       {{}}: style given to \TIKZ
	\item \CFkv{atom style}          {{}}: style of \TIKZ nodes (atoms)
	\item \CFkv{bond join}           {false}: boolean for bond joins
	\item \CFkv{fixed length}        {false}: boolean for fixed bond widths
	\item \CFkv{cram rectangle}      {false}: boolean to draw rectangle Cram bond
	\item \CFkv{cram width}          {1.5ex}: length of the base of the triangles Cram bonds
	\item \CFkv{cram dash width}     {1pt}: width of dash Cram bonds
	\item \CFkv{cram dash sep}       {2pt}: space between dash Cram bonds
	\item \CFkv{atom sep}            {3em}: space between atoms
	\item \CFkv{bond offset}         {2pt}: space between atom and bond
	\item \CFkv{double bond sep}     {2pt}: space between multiple bonds lines
	\item \CFkv{angle increment}     {45}: increment of the angle of bonds
	\item \CFkv{node style}          {{}}: style of atoms
	\item \CFkv{bond style}          {{}}: style of bonds
	\item \CFkv{lewis | width}       {0.3ex}: width of the rectangle Lewis "|"
	\item \CFkv{lewis sep}           {0.4ex}: space between atom and Lewis formulas
	\item \CFkv{lewis length}        {1.5ex}: length of Lewis formulas
	\item \CFkv{lewis style}         {{}}: style of Lewis formulas
	\item \CFkv{lewis dist}          {0.3em}: space between discs of the ":" Lewis formulas
	\item \CFkv{lewis radius}        {0.15ex}: radius of discs for Lewis formulas
	\item \CFkv{lewis diag coeff}    {1}: factor that multiplies the distance to Lewis formulas in odd directions
	\item \CFkv{cycle radius coeff}  {0.75}: shrinkage ratio of the circle or arc inside cycles
	\item \CFkv{stack sep}           {1.5pt}: vertical gap between arguments of \verb-\chemabove- and \verb-\chembelow- macros
	\item \CFkv{compound style}      {{}}: style of compounds
	\item \CFkv{compound sep}        {5em}: space between compounds
	\item \CFkv{arrow offset}        {4pt}: space between compound and arrow
	\item \CFkv{arrow angle}         {0}: angle of the reaction arrow
	\item \CFkv{arrow coeff}         {1}: length ratio of arrows
	\item \CFkv{arrow style}         {{}}: style of arrows
	\item \CFkv{arrow double sep}    {2pt}: space between double arrows
	\item \CFkv{arrow double coeff}  {0.6}: shrinkage ratio for the little arrow in "<->>" and "<<->"
	\item \CFkv{arrow double harpoon}{true}: boolean for double harpoon arrows
	\item \CFkv{arrow label sep}     {3pt}: space between arrow and its label
	\item \CFkv{arrow head}          {-CF}: style of arrow head
	\item \CFkv{+ sep left}          {0.5em}: space before the $+$ sign
	\item \CFkv{+ sep right}         {0.5em}: space after the $+$ sign
	\item \CFkv{+ vshift}            {0pt}: vertical shift of the $+$ sign
\end{itemize}
\\
\verb|\resetchemfig|&Reset the parameters to their default values\\
\falseverb\printatom& displays the atoms within the molecules. It can be redefined to customize the output. See page~\pageref{perso.affichage}\\
\falseverb\hflipnext&the next molecule will be horizontally flipped\\
\falseverb\vflipnext&the next molecule will be vertically flipped\\
\Verb-\definesubmol{<name>}<n>[<code1>]{<code2>}- & creates an alias \Verb-!<name>- which can be put in the code of molecules to be drawn, and which will be replaced with \Verb-<code1>- or \Verb-<code2>- depending on the angle of the last bond. See page~\pageref{definesubmol}\\
\falseverb\chemskipalign& tells the vertical alignment mechanism to ignore the current group of atoms. See page~\pageref{chemskipalign}.\\
\Verb-\redefinesubmol{<name>}<n>[<code1>]{<code2>}- & replaces a preexisting alias \Verb-!<name>- with the new \Verb-<code>-. See page~\pageref{redefinesubmol}\\[2ex]\hline
&\\
\Verb-\charge{[<parameters>]<pos>[<tikz>]}{<atom>}-& prints \Verb-<atome>- and places the charges according to their \Verb-<positions>-. The charges are places out of the bounding box of the \Verb-<atome>-. See page~\pageref{charge}\\
\Verb-\Charge{[<parameters>]<pos>[<tikz>]}{<atom>}-& Same behaviour as \verb|\charge|, but the final bounding box takes the charges into account.\\
\Verb-\chemmove[<tikz options>]<tikz code>-& Makes a \verb-tikzpicture- environment, adding to it the \verb-<tikz options>-. Uses the \Verb-<tikz code>- to join the nodes specified in the molecules with the help pf the ``\verb-@-'' character. See page~\pageref{mecanismes-reactionnels}.\\[2ex]\hline
&\\
\Verb-\chemabove[<dim>]{<txt1>}{txt2}- & writes \Verb-<txt1>- and places \Verb-<txt2>- above, leaving \Verb-<dim>- of vertical space. This command does not change the bounding box of \Verb-<txt1>-. See page~\pageref{chemabove}\\
\Verb-\chembelow[<dim>]{<txt1>}{txt2}- & writes \Verb-{txt1}- and places \Verb-<txt2>- below, leaving \Verb-<dim>- of vertical space. This command does not change the bounding box of \Verb-<txt1>-. See page~\pageref{chemabove}\\
\Verb-\Chemabove[<dim>]{<txt1>}{txt2}- & writes \Verb-<txt1>- and places \Verb-<txt2>- above, leaving \Verb-<dim>- of vertical space. See page~\pageref{chemabove}\\
\Verb-\Chembelow[<dim>]{<txt1>}{txt2}- & writes \Verb-{txt1}- and places \Verb-<txt2>- below, leaving \Verb-<dim>- of vertical space. See page~\pageref{chemabove}\\
\Verb-\chemname[<dim>]{<molecule>}{<name>}- & Places \Verb-<name>- under the \Verb-<molecule>-\\
\falseverb\chemnameinit & Initializes the greatest molecule depth to ensure correct alignment of the names of the following molecules.\\[2ex]\hline
&\\
\falseverb\schemestart\dots\falseverb\schemestop& commands between which a reaction scheme is drawn. See page~\pageref{schemestart}.\\
\falseverb\arrow& draws an arrow in a reaction scheme (this command is only defined inside a reaction scheme). See page~\pageref{arrow}.\\
\falseverb\+ & prints a $+$ sign in a reaction scheme (this command is only defined inside a reaction scheme). See page~\pageref{signe+}.\\
\falseverb\subscheme\Verb-{<code>}- & draws a subscheme (this command is only defined inside a reaction scheme). See~\pageref{subscheme}.\\
\falseverb\definearrow & defines an arrow. See page~\pageref{definearrow}.\\
\Verb-\chemleft<car1><stuff>-\falseverb\chemright\Verb-<car1>-& draws expandable delimiters defined with \Verb-<car1>- and \Verb-<car2>- on the left and on the right of the \Verb-<stuff>-, see page~\pageref{chemleft}.\\
\Verb-\chemup<car1><stuff>-\falseverb\chemdown\Verb-<car1>-& draws expandable delimiters defined with \Verb-<car1>- and \Verb-<car2>- above and below the \Verb-<stuff>-, see page~\pageref{chemup}.\\
\Verb|\polymerdelim[<settings]{<node1>}{node2>}|& draws delimiters at specified nodes, see page~\pageref{polymerdelim}\\\hline
\end{longtable}
\end{center}
\newpage

\part{Gallery}
This manual concludes with drawings of molecules of varying complexity.

The curious user can look at the \Verb-<code>- of each molecule, though it does become less attractive the more complex the molecule gets. Indeed, beyond a certain level of complexity, though it it is fairly easy to write \Verb-<code>-, it becomes much harder to read the \Verb-<code>- to analyze it afterwards. We quickly reached the limits of immediate readability of the code of a complex drawing.

Anyway, I hope that this package will help all \LaTeX{} users wishing to draw molecules. Although \CF has been thoroughly tested and although its version number is now greater than 1.0, I hope that you will be forgiving with bugs you encounter and send me an \href{mailto:unbonpetit@netc.fr}{\texttt{\textbf{email}}} to let me know of any malfunctions or suggestions for improvement.

\hfill Christian \textsc{Tellechea}
\bigskip

\begin{center}
\parskip0pt
$\star$\par
$\star\quad\star$
\end{center}
\bigskip

\exemple*{2-methylpentane}/\chemfig{[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3}/

\exemple*{3-ethyl-2-methylhexane}/\chemfig{H_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C}/

\exemple*{Stearine, condensed structural diagram}/\definesubmol{@}{([0,2]-O-[0,1]C(=[2,1]O)-C_{17}H_{33})}
\chemfig{[2,2]CH_2!@-CH_{\phantom 2}!@-CH_2!@}/

\exemple*{Stearine, skeleton diagram}/\definesubmol{x}{-[:+30,.6]-[:-30,.6]}
\definesubmol{y}{-O-(=[2,.6]O)-!x!x!x!x!x!x!x!x}
\chemfig{[2]([0]!y)-[,1.5]([0]!y)-[,1.5]([0]!y)}/

\exemple*{Methyl 2-methylpropanoate}/\chemfig{H_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3}/

\exemple*{Vanillin}/\chemfig{HC*6(-C(-OH)=C(-O-[::-60]CH_3)-CH=C(-[,,,2]HC=[::-60]O)-HC=[,,2])} \quad or \quad
\chemfig{*6(-(-OH)=(-OCH_3)-=(-=[::-60]O)-=)}/

\exemple*{Caffeine}/\chemfig{*6((=O)-N(-CH_3)-*5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)}/

\exemple*{Aspirin}/\chemfig{*6(-=-(-O-[::-60](=[::-60]O)-[::+60])=(-(=[::+60])-[::-60]OH)-=)}/Aspirin is a registered trademark of Bayer in many countries.

\exemple*{Phthalic anhydride}/\chemfig{*6(=*5(-(=O)-O-(=O)-)-=-=-)}/

\exemple*{Camphor}/\chemfig{*6(-(<:[::120](-[::-100,0.7])(-[::100,0.7]))--(=O)-(-)(<:[::120])--)}
\quad or \quad
\setchemfig{cram width=3pt}
\chemfig{<[:10](>[:85,1.8]?(-[:160,0.6])-[:20,0.6])
>[:-10]-[:60](=[:30,0.6]O)-[:170]?(-[:30,0.6])-[:190]-[:240]}/

\exemple*{Triphenylmethane}/\chemfig{*6(-=-*6(-(-*6(=-=-=-))-*6(=-=-=-))=-=)}
\quad or \quad
\definesubmol{@}{*6(=-=-=-)}
\chemfig{(-[:-30]!@)(-[:90]!@)(-[:210]!@)}/

\exemple*{Amygdalin}/\setchemfig{cram width=2pt}
\definesubmol{c1}{-[:200]-[:120]O-[:190]}
\definesubmol{c2}{-[:170](-[:200,0.7]HO)<[:300](-[:170,0.6]HO)
-[:10,,,,line width=2pt](-[:-40,0.6]OH)>[:-10]}
\definesubmol{csub}{-[:155,0.65]-[:90,0.65]}
\chemfig{O(!{c1}(!{csub}O(!{c1}(!{csub}OH)!{c2}))!{c2})-[:-30](-[:-90]CN)-[:30]*6(=-=-=-)}/

\exemple*{Adenosine triphosphate}/\setchemfig{cram width=3pt}
\definesubmol{a}{-P(=[::-90,0.75]O)(-[::90,0.75]HO)-}
\chemfig{[:-54]*5((--[::60]O([::-60]!aO([::-60]!aO([::60]!aHO))))<(-OH)
-[,,,,line width=2pt](-OH)>(-N*5(-=N-*6(-(-NH_2)=N-=N-)=_-))-O-)}/

\exemple*{Viagra}/\chemfig{N*6((-H_3C)---N(-S(=[::+120]O)(=[::+0]O)-[::-60]*6(-=-(-O-[::-60]-[::+60]CH_3)
=(-*6(=N-*5(-(--[::-60]-[::+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)}/

\exemple*{Cholesterol ester}/\chemfig{[:30]R-(=[::+60]O)-[::-60]O-*6(--*6(=--*6(-*5(---(-(-[::+60]Me)
-[::-60]-[::-60]-[::+60]-[::-60](-[::-60]Me)-[::+60]Me)-)-(-[::+0]Me)---)--)-(-[::+0]Me)---)}/

\exemple*{Porphyrin}/\chemfig{?=[::+72]*5(-N=(-=[::-72]*5(-[,,,2]HN-[,,2](=-[::-36]*5(=N-(=-[::-72]*5(-NH-[,,1]?=-=))
-=-))-=-))-=-)}/

\exemple*{Manganese 5,10,15,20-tetra(N-ethyl-3-carbazolyl) porphyrin}/\definesubmol{A}{*6(=-*5(-*6(-=-=-)--N(--[::-60])-)=-=-)}
\chemfig{([::+180]-!A)=[::+72]*5(-N=(-(-[::+54]!A)=[::-72]*5(-N(-[::-33,1.5,,,draw=none]Mn)
-(=(-[::+72]!A)-[::-36]*5(=N-(=(-[::+54]!A)-[::-72]*5(-N-(-)=-=))-=-))-=-))-=-)}/

\exemple*{Penicillin}/\chemfig{[:-90]HN(-[::-45](-[::-45]R)=[::+45]O)>[::+45]*4(-(=O)-N*5(-(<:(=[::-60]O)
-[::+60]OH)-(<[::+0])(<:[::-108])-S>)--)}/

\exemple*{LSD}/\chemfig{[:150]?*6(=*6(--*6(-N(-CH_3)--(<(=[::+60]O)-[::-60]N(-[::+60]-[::-60])
-[::-60]-[::+60])-=)([::-120]<H)---)-*6(-=-=-(-[::-30,1.155]\chembelow{N}{H}?)=))}/

\exemple*{Strychnine}/\chemfig{*6(=-*6(-N*6(-(=O)--([::-120]<:H)*7(-O--=?[0]([::-25.714]-[,2]?[1]))
-*6(-?[0,{>}]--(<N?[1]?[2])-(<[::-90]-[::-60]?[2]))(<:[::+0]H)-([::+120]<H))--?)=?-=-)}/

\exemple*{Codeine}/\chemfig{[:-30]**6(-(-OH)-?-*6(-(-[3]-[2,2]-[0,.5])*6(-(<:[:-150,1.155]O?)
-(<:OH)-=-)-(<:[1]H)-(-[2]NCH_3)--)---)}/

\exemple*{A dye (red)}/\chemfig{**6(--*6(-(-NO_2)=-(-\charge{90=\|,-90=\|}{O}-[0]H)=(-\charge{180=\|}{N}=[0]\charge{90=\|}{N}-[0]Ar)-)----)}/

\exemple*{Menthone}/\chemfig{CH_3-?(-[2]H)(-[::-30,2]-[::+60](=[1]\charge{0=\|,90=\|}{O})
-[::-150,1.5](-[:20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[::-90,2]-[::+60]?)}/

\exemple*{Fullerene}/\definesubmol\fragment1{
	(-[:#1,0.85,,,draw=none]
	-[::126]-[::-54](=_#(2pt,2pt)[::180])
	-[::-70](-[::-56.2,1.07]=^#(2pt,2pt)[::180,1.07])
	-[::110,0.6](-[::-148,0.60](=^[::180,0.35])-[::-18,1.1])
	-[::50,1.1](-[::18,0.60]=_[::180,0.35])
	-[::50,0.6]
	-[::110])
}
\chemfig{
	!\fragment{18}
	!\fragment{90}
	!\fragment{162}
	!\fragment{234}
	!\fragment{306}
}/% https://tex.stackexchange.com/questions/506293/how-to-draw-a-fullerene

\exemple*{Fischer indole synthesis}/\schemestart
	\chemfig{*6(=-*6(-\chembelow{N}{H}-NH_2)=-=-)}
	\+
	\chemfig{(=[:-150]O)(-[:-30]R_2)-[2]-[:150]R_1}
	\arrow(.mid east--.mid west){->[\chemfig{H^+}]}
	\chemfig{*6(-=*5(-\chembelow{N}{H}-(-R_2)=(-R_1)-)-=-=)}
\schemestop/

\exemple*{Reaction mechanisms: carbonyl group}/\schemestart
	\chemfig{C([3]-)([5]-)=[@{db,.5}]@{atoo}\charge{0=\|,-90=\|}{O}}
	\arrow(.mid east--.mid west){<->}
	\chemfig{\charge{90:3pt=$\scriptstyle\oplus$}{C}([3]-)([5]-)-%
		\charge{0=\|,90=\|,-90=\|,45:3pt=$\scriptstyle\ominus$}{O}}
\schemestop
\chemmove{\draw[shorten <=2pt, shorten >=2pt](db) ..controls +(up:5mm) and +(up:5mm)..(atoo);}/

\exemple*{Reaction mechanisms: nitro group}/\schemestart
	\chemfig{R-\charge{225:3pt=$\scriptstyle\oplus$}{N}([1]=[@{db}]@{atoo1}O)([7]-[@{sb}]@{atoo2}
	\charge{45=\|,-45=\|,-135=\|,45:5pt=$\scriptstyle\ominus$}{O})}
	\arrow(.mid east--.mid west){<->}
	\chemfig{R-\charge{135:3pt=$\scriptstyle\oplus$}{N}([1]-\charge{90:3pt=$\scriptstyle\ominus$}{O})([7]=O)}
\schemestop
\chemmove{
	\draw[shorten <=2pt, shorten >=2pt](db) ..controls +(120:5mm) and +(120:7mm)..(atoo1);
	\draw[shorten <=3pt, shorten >=2pt](atoo2) ..controls +(225:10mm) and +(225:10mm)..(sb);
}/

\exemple*{Nucleophilic addition. Primary amines}/\setchemfig{atom sep=2.5em,compound sep=5em}
\schemestart
	\chemfig{R-@{aton}\charge{90=\|}{N}H_2}
	\+
	\chemfig{@{atoc}C([3]-CH_3)([5]-CH_3)=[@{atoo1}]O}
	\chemfig{@{atoo2}\chemabove{H}{\scriptstyle\oplus}}
	\chemmove[-stealth,shorten <=3pt,dash pattern= on 1pt off 1pt,thin]{
		\draw[shorten >=2pt](aton) ..controls +(up:10mm) and +(left:5mm)..(atoc);
		\draw[shorten >=8pt](atoo1) ..controls +(up:10mm) and +(north west:10mm)..(atoo2);}
	\arrow{<=>[\tiny addition]}
	\chemfig{R-@{aton}\chembelow{N}{\scriptstyle\oplus}H([2]-[@{sb}]H)-C(-[2]CH_3)(-[6]CH_3)-OH}
\schemestop
\chemmove{
	\draw[-stealth,dash pattern= on 1pt off 1pt,shorten <=3pt, shorten >=2pt]
	(sb)..controls +(left:5mm) and +(135:2mm)..(aton);}
\par
\schemestart
	\arrow{<=>}
	\chemfig{R-@{aton}\charge{90=\|}{N}([6]-[@{sbh}]H)-[@{sb}]C(-[2]CH_3)(-[6]CH_3)-[@{sbo}]@{atoo}
	\chemabove{O}{\scriptstyle\oplus}(-[1]H)(-[7]H)}
	\chemmove[-stealth,shorten <=3pt,shorten >=2pt,dash pattern= on 1pt off 1pt,thin]{
		\draw(aton) ..controls +(up:5mm) and +(up:5mm)..(sb);
		\draw(sbh) ..controls +(left:5mm) and +(south west:5mm)..(aton);
		\draw(sbo) ..controls +(up:5mm) and +(north west:5mm)..(atoo);}
	\arrow{<=>[\tiny elimination]}\chemfig{R-N=C(-[1]CH_3)(-[7]CH_3)}
	\+
	\chemfig{H_3\chemabove{O}{\scriptstyle\oplus}}
\schemestop/

\exemple*{Reaction scheme}/\setchemfig{atom sep=2em}
\schemestart[-90]
	\chemfig{**6(---(-NH _2)---)}\arrow{0}\chemfig{HNO_2}
	\merge(c1)(c2)--()
	\chemfig{**6(---(-N_2|{}^\oplus)---)}\arrow{0}\chemfig{**6(---(-NH _2)---)}
	\merge(c3)(c4)--()
	\chemfig{**6(---(-N=[::-30]N-[::-30]**6(---(-NH_2)---))---)}
\schemestop/

\exemple*{Addition}/\setchemfig{atom sep=2.5em}
\schemestart
	\chemfig{*6(=-(-)(=[2]O))}
	\arrow{->[\+\chemfig{H^\oplus}]}
	\chemleft[\subscheme[90]{%
		\chemfig{*6((-[2,0.33,,,draw=none]\scriptstyle\oplus)-=(-)-OH)}
		\arrow{<->}
		\chemfig{*6(=-(-)(-[6,0.33,,,draw=none]\scriptstyle\oplus)-OH)}}\chemright]
	\arrow(@c3--)\chemfig{*6((-[2]R)-=(-)-OH)}
	\arrow(@c4--)\chemfig{*6(=-(-)(-[6]R)-OH)}
\schemestop/

\exemple*{Electrophilic aromatic substitution}Z\setchemfig{atom sep=1.5em}%
\definesubmol{+}{-[,-0.4,,,draw=none]\oplus}%
\schemestart
	\arrow{0}[,0]
	\chemleft[\subscheme{\chemfig{*6(=-=-(-[:120]Br)(-[:60]H)-(!+)-)}
		\arrow{<->}
		\chemfig{*6(-(!+)-=-(-[:120]Br)(-[:60]H)-=)}
		\arrow{<->}
		\chemfig{*6(-=-(!+)-(-[:120]Br)(-[:60]H)-=)}}\chemright]
	\arrow(@c2--){<-[*0\chemfig{{-}AlBr_4|^\ominus}][*0\chemfig{Br_2/Al_2Br_3}]}[90,1.5]
	\chemname{\chemfig{*6(-=-=-=-)}}{Benzene 1}
	\arrow(@c4--){->[*0\chemfig{{-}H^\oplus}]}[90,1.5]
	\chemname{\chemfig{*6(-=-=(-Br)-=-)}}{Bromobenzne 2}
	\arrow(@c5.mid east--@c6.mid west)
\schemestop
\chemnameinit{}Z

\exemple*{Reaction mechanism of chlorination}/\scriptsize\setchemfig{bond offset=1pt,atom sep=2em,compound sep=4em}
\schemestart
	\chemfig{Cl-[4]@{a0}(=[@{a1}:120]@{a2}O)-[:-120](=[:-60]O)-[4]Cl}\+\chemfig{*6(-=-=(-@{oh1}OH)-=)}\arrow
	\chemfig{*6((-O-[:150](-[@{o0}:150]@{o1}\charge{-90=\.}{O})(-[@{cl0}:60]@{cl1}Cl)-[:240](-[4]Cl)=[6]O)=-=-=-)}
	\arrow\chemfig{*6((-O-[:150](=[2]O)-[:-150](=[6]O)-[:150]Cl)=-=-=-)}\+\chemfig{HCl}
	\arrow(@c1--){0}[-90,0.5]
	\chemfig{*6(-=*6(-O-*6(-@{o2}(=[@{o3}]@{o4}O)-Cl)=)-=-=)}\+\chemfig{*6(-=-=(-@{oh2}OH)-=)}\arrow
	\chemfig{*6(-=*6(-O-(-(-[@{cl2}:60]@{cl3}Cl)(-[@{o5}:-120]@{o6}\charge{-90=\.}{O})-O-[::-40]*6(=-=-=-))=)-=-=)}
	\kern-3em \arrow\chemfig{[:30]*6(=-(-O-[:-60](=O)-[:-120](=[4]O)-[:-60]O-*6(=-=-=-))=-=-)}
	\kern-3em \+\chemfig{HCl}
\schemestop
\chemmove[line width=0.2pt,-stealth,dash pattern = on 2pt off 1pt]{
	\draw[shorten <=2pt](a1)..controls+(200:5mm)and+(200:5mm)..(a2);
	\draw[shorten >=2pt](oh1.west)..controls+(180:15mm)and+(60:5mm)..(a0);
	\draw[shorten <=6pt,shorten >=2pt](o1)..controls+(270:5mm)and+(270:5mm)..(o0);
	\draw[shorten <=2pt](cl0)..controls+(150:5mm)and+(150:5mm)..(cl1.150);
	\draw[shorten <=2pt](o3)..controls +(30:3mm) and +(30:5mm)..(o4.east);
	\draw[shorten >=2pt](oh2.135).. controls +(150:10mm) and +(90:10mm).. (o2);
	\draw[shorten >=2pt,shorten <=5pt]([xshift=-1.5mm]o6.315)..controls +(315:5mm) and +(315:5mm)..(o5);
	\draw[shorten <=2pt](cl2)..controls +(135:5mm) and +(135:5mm)..(cl3.north west);}/

\exemple*{Cannizzaro reaction}/\schemestart
	\chemfig{[:-30]*6(=-=(-@{atoc}C([6]=[@{db}]@{atoo1}O)-H)-=-)}
	\arrow(start.mid east--.mid west){->[\chemfig{@{atoo2}\chemabove{O}{\scriptstyle\ominus}}H]}
	\chemmove[-stealth,shorten >=2pt,dash pattern=on 1pt off 1pt,thin]{
			\draw[shorten <=8pt](atoo2) ..controls +(up:10mm) and +(up:10mm)..(atoc);
			\draw[shorten <=2pt](db) ..controls +(left:5mm) and +(west:5mm)..(atoo1);}
	\chemfig{[:-30]*6(=-=(-C([6]-[@{sb1}]@{atoo1}\chembelow{O}{\scriptstyle\ominus})([2]-OH)-[@{sb2}]H)-=-)}
	\hspace{1cm}
	\chemfig{[:-30]*6((-@{atoc}C([6]=[@{db}]@{atoo2}O)-[2]H)-=-=-=)}
	\chemmove[-stealth,shorten <=2pt,shorten >=2pt,dash pattern=on 1pt off 1pt,thin]{
			\draw([yshift=-4pt]atoo1.270) ..controls +(0:5mm) and +(right:10mm)..(sb1);
			\draw(sb2) ..controls +(up:10mm) and +(north west:10mm)..(atoc);
			\draw(db) ..controls +(right:5mm) and +(east:5mm)..(atoo2);}
	\arrow(@start.base west--){0}[-75,2]
	{}
	\arrow
	\chemfig{[:-30]*6(=-=(-C([1]-@{atoo2}O-[@{sb}0]@{atoh}H)([6]=O))-=-)}
	\arrow{0}
	\chemfig{[:-30]*6((-C(-[5]H)(-[7]H)-[2]@{atoo1}\chemabove{O}{\scriptstyle\ominus})-=-=-=)}
	\chemmove[-stealth,shorten >=2pt,dash pattern=on 1pt off 1pt,thin]{
			\draw[shorten <=7pt](atoo1.90) ..controls +(+90:8mm) and +(up:10mm)..(atoh);
			\draw[shorten <=2pt](sb) ..controls +(up:5mm) and +(up:5mm)..(atoo2);}
\schemestop/

\begingroup
\catcode`;=12
\exemple*{Beckmann rearrangement}/\setchemfig{bond offset=1pt,atom sep=2.5em,compound sep=5em,arrow offset=6pt}
\schemestart
	\chemfig{(-[:-150]R')(-[:-30]R)=[2]N-[:30]OH}
	\arrow{<=>[\chemfig{H^\oplus}]}
	\chemfig{(-[@{a0}:-150]R')(-[:-30]R)=[2]@{a1}N-[@{b0}:30]@{b1}\chemabove{O}{\scriptstyle\oplus}H_2}
	\chemmove[red,-stealth,red,shorten <=2pt]{
		\draw(a0)..controls +(135:2mm) and +(215:4mm).. (a1);
		\draw(b0)..controls +(120:2mm) and +(180:3mm).. ([yshift=7pt]b1.180);}
	\arrow{<=>[\chemfig{{-}H_2O}]}[,1.1]
	\chemleft[\subscheme[90]{%
		\chemfig{R'-\chemabove{N}{\scriptstyle\oplus}~C-R}
		\arrow{<->}[,0.75]
		\chemfig{R'-\charge{90=\:}{N}=@{a1}\chemabove{C}{\scriptstyle\oplus}-R}}\chemright]
	\arrow{<=>[\chemfig{H_2@{a0}\charge{0=\:,90=\:}{O}}]}[,1.1]
	\chemmove[red,-stealth,red,shorten <=3pt]{
		\draw(a0)..controls+(90:10mm)and+(45:10mm)..([yshift=6pt]a1.45);}
	\arrow(@c1--){0}[-90,0.333]
	\chemfig{*6(R\rlap{$'$}-N=(-R)-\chemabove{O}{\scriptstyle\oplus} H_2)}
	\arrow{<=>[\chemfig{{-}H^\oplus}]}
	\chemfig{*6(R\rlap{$'$}-N=(-R)-OH)}
	\arrow
	\chemfig{*6(R\rlap{$'$}-\chembelow{N}{H}-(-R)(=[2]O))}
\schemestop/
\endgroup

\exemple*{Reaction scheme}/\setchemfig{atom sep=1.5em,compound sep=4em}
\schemestart
	\chemfig{-[::30]=_[::-60](-[:: -60])-[::60]}
	\arrow{->[\chemfig{HCl}]}
	\chemfig{-[::30]-[::-60](-[::120]Cl)(-[::-60])-[::60]}\+\chemfig{-[::30](-[::60]Cl)-[::-60](-[::-60])-[::60]}
	\arrow(@c1--.north west){->[\chemfig{H_2O}]}[-45,1.7]
	\chemfig{-[::30]-[::-60](-[::120]OH)(-[::-60])-[::60]}\+\chemfig{-[::30](-[::60]OH)-[::-60](-[::-60])-[::60]}
\schemestop/

\exemple*{Esterification of formic acid}Z\tikzset{obrace/.style={left delimiter={[},inner sep=3pt},
	cbrace/.style={right delimiter={]},inner sep=3pt},
	braces/.style={left delimiter={[},right delimiter={]},inner sep=3pt}}
\setchemfig{atom sep=2em}
\schemestart
	\chemfig{H-C(=[:60]O)-[:-60]O-H}
	\arrow(--M1[obrace]){-U>[\scriptsize\chemfig{H_2SO_4^{}}][\scriptsize\chemfig{HSO_4^\ominus}][][.25]}%
		[,1.5,shorten >=6pt]
	\chemfig{H-@{a2}C(-[:60]O-H)(-[:30,.5,,,draw=none]{\scriptstyle\oplus})-[:-60]O-H}
	\arrow(--[cbrace]){<->}
	\chemfig{H-C(=[:60]\chemabove{O}{\scriptstyle\oplus}-H)-[:-60]O-H}
	\arrow(@M1--){<=>[*{0}\scriptsize\chemfig{H-[:120]@{a1}O-[:60]CH_3}][*{0}\tiny addition]}[-90,1.33]
	\chemfig{H-C(-[2]O-[:30]H)(-\chemabove{O}{\scriptstyle\oplus}(-[:60]CH_3)-[:-60]H)-[6]O-[:-30]H}
	\arrow{<=>[\tiny protolysis]}[180]
	\chemfig{H-C(-[2]O-[:30]H)(-O-CH_3)-[@{b1}6]@{a3}\chemabove{O}{\kern-4mm\scriptstyle\oplus}(-[:-150]H)-[:-30]H}
	\arrow(--[obrace]){<=>[*{0}\scriptsize\chemfig{{-}H_2O}][*{0}\tiny elimination]}[-90,,shorten >=6pt]
	\chemfig{H-C(-[:60]O-H)(-[,.5,,,draw=none]{\scriptstyle\oplus})-[:-60]O-CH_3}
	\arrow(--[cbrace]){<->}
	\chemfig{H-C(=[:60]\chemabove{O}{\scriptstyle\oplus}-H)-[:-60]O-CH_3}
	\arrow{-U>[\scriptsize\chemfig{HSO_4^\ominus}][\scriptsize\chemfig{H_2SO_4^{}}][][.25]}[,1.5]
	\chemfig{H-C(=[:60]O)-[:-60]O-CH_3}
	\arrow(@M1--[yshift=-5pt]){0}[180,.5]{\tiny protolysis}
	\chemmove[red,shorten <=3pt,shorten >=1pt]{
		\draw(a1)..controls +(0:1.5cm)and+(0:3cm).. (a2);
		\draw(b1)..controls +(0:5mm)and+(20:5mm)..(a3);}
\schemestop Z

\exemple*{Electrophilic addition of halogen to olefin}/\schemestart
	\subscheme{%
		\chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
		\arrow{0}[,0]\+\chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{90=\|,0=\|,270=\|}{Br}}}
	\arrow(@c1--olefin){<=>[*{0}rapide]}[-90]
	\chemfig{>[:-20]C(<[:40])=[@{db}6]C(<[:-130])<[:-20]}
	\arrow(--bromonium){0}[-90]
	\chemname{\chemfig{C*3((<)(<:[:-155])-\charge{45=\|,-45=\|,180:3pt=$\scriptstyle\oplus$}{Br}-C(<:)(<[:155])-)}}
		{bromonium ion}
	\arrow(--carbeniumA){<<->}[,1.5]
	\chemname{\chemfig{-[:-30]\chemabove{C}{\scriptstyle\oplus}(-[:30])-[6]C(<:[:-150])(<[:-100])-[:-30]
		\charge{45=\|,-45=\|,225=\|}{Br}}}{Xarbenium ion}
	\arrow(@bromonium--carbeniumB){<<->}[180,1.5]
	\chemname{\chemfig{-[:-30]\chemabove{C}{\scriptstyle\oplus}(-[:30])-[6]C(<[:-150])
		(<:[:-100])-[:-30]\charge{45=\|,-45=\|,135=\|}{Br}}}{carbenium ion}
	\arrow(@olefin--){0}[,.25]
	\chemfig{@{Br1}\charge{90=\|,180=\|,270=\|,90:5pt=$\scriptstyle\delta\oplus$}{Br}-[@{b2}]@{Br2}
		\charge{90=\|,0=\|,270=\|,90:5pt=$\scriptstyle\delta\ominus$}{Br}}
	\arrow(@olefin--[left]){0}[180,0]
	$\pi$ complexe
	\arrow(@carbeniumA--@olefin){<=>[lent, \chemfig{{-}Br^\ominus}]}
	\arrow(@carbeniumB--@olefin){<=>[lent, \chemfig{{-}Br^\ominus}]}
	\chemmove[-stealth,red,shorten <=3pt,shorten >=2pt]{
		\draw(db) .. controls +(20:5mm) and +(135:5mm) .. (Br1);
		\draw(b2) .. controls +(-90:5mm) and +(-120:5mm) .. (Br2);}
\schemestop
\chemnameinit{}/

\exemple*{Sulfonation of naphthalene}/\definesubmol\cycleoplus{-[,0.25,,,draw=none]\oplus}
\definesubmol{so2oh}{S(=[::90]O)(=[::-90]O)-OH}
\setchemfig{atom sep=2.5em}
\schemestart[,1.5]
	\chemname{\chemfig{*6(=-*6(-=-=-)=-=-)}}{Naphtalene}\+\chemfig{H_2SO_4}
	\arrow(nph.mid east--.south west){->[80\degres C]}[45]
	\chemname{\chemfig{*6(=-*6(-=-(!\cycleoplus)-(-SO_3H)-)=-=-)}}{Ion 1-arenium}
	\arrow(.mid east--.mid west)
	\chemname{\chemfig{*6(=-*6(-=-=(-!{so2oh})-)=-=-)}}{Acide 1-naphthalenesulfonique}
	\arrow(@nph.mid east--.north west){->[160\degres C]}[-45]
	\chemname{\chemfig{*6(=-*6(-=-(-SO_3H)-(!\cycleoplus)-)=-=-)}}{Ion 2-arenium}\kern-4em
	\arrow(.mid east--.mid west)
	\chemname{\chemfig{*6(=-*6(-=-(-!{so2oh})=-)=-=-)}}{Acide 2-naphthalenesulfonique}
\schemestop
\chemnameinit{}/

\begingroup\catcode`;12
\exemple*{Explanatory diagram}/\parbox{0.8\linewidth}{%
	\hspace{10em}
	\tikz[remember picture]\node(n0){\chemname{}{Attacks\\nucleophiles}};\par
	\vspace{2ex}\hspace{15em}
	\chemfig{R^2-(-[:-60]@{m3}H)-[:60]@{m0}\charge{45:5pt=$\scriptstyle\color{red}\delta+$}{}(-[:120]R^1)
		=[@{m1}]@{m2}\charge {45=\:,-45=\:,45:7pt=$\scriptstyle\color{red}\delta-$}{O}}
	\hspace{5em}
	\chemname[-15ex]{}{\tikz[remember picture]\node(n1){};Addition reactions}\kern1em
	\chemname{}{\tikz[remember picture]\node(n2){};Basic properties}\par
	\vspace{6ex}\hspace{8em}
	\chemname{}{Acidic properties of hydrogen\tikz[remember picture]\node(n3){};
		\\atom in $\alpha$ position}
	\chemmove[-stealth,line width=0.8pt,green!60!black!70]{
		\draw[shorten >=2pt](n0)..controls+(270:4em)and+(180:2em)..(a1);
		\draw[shorten >=8pt](n1)..controls+(180:2em)and+(60:2em)..(a2);
		\draw[shorten >=5pt](n2)..controls+(180:2em)and+(270:2em)..([xshift=3pt]a3.315);
		\draw[shorten >=2pt](n3)..controls+(0:2em)and+(270:2em)..(a0);
	}%
}
\chemnameinit{}/
\endgroup

\exemple*{Taxotere}/\chemfig{-[::-30](-[5])(-[7])-[::+60]-[::-60]O-[::+60](=[::-45]O)-[::+90]HN>:[::-60](-[::+60]**6(------))
-[::-30](<:[2]OH)-[::-60](=[6]O)-[::+60]O>:[::-60]*7(---?(<[::-120]OH)-(<|[1]CH_3)(<:[::-90]CH_3)
-(-[1](<[::+80]HO)-[0](=[::+60]O)-[7](<|[::+130]CH_3)(-[::+75](<|[2]OH)-[::-60]-[::-60](<[::+30]O-[::-90])
-[::-60](<[::+90])(<:[::+30]O-[7](-[6]CH_3)=[0]O)-[::-60])-[6]-[5,1.3]?(<:[7]O-[5](=[::-60]O)
-[6]**6(------)))=(-[2]CH_3)-)}/
\end{document}