Debian Codegraph @

texmf-dist/doc/generic/chemfig/chemfig-en.tex

raw
1 % !TeX TS-program = lualatex
2 \documentclass[10pt]{article}
3 \usepackage[a4paper,margin=2.5cm,footskip=10mm]{geometry}
4 \usepackage[bottom]{footmisc}
5 \usepackage{libertine,amsmath,array,longtable,xspace,fancybox,boites,textcomp,enumitem,chemfig,fancyhdr}
6 \usetikzlibrary{decorations.pathmorphing}
7 \usetikzlibrary{decorations.markings}
8 \usetikzlibrary{matrix}
9 \usepackage[protrusion=true,expansion,final,babel=true]{microtype}
10 \fancypagestyle{plain}{%
11 \fancyhead[L]{}
12 \fancyhead[C]{}
13 \fancyhead[R]{}
14 \fancyfoot[l]{\tiny Compiled the \today.}
15 \fancyfoot[c]{}
16 \fancyfoot[r]{\thepage}}
17 \renewcommand\headrulewidth{0pt}
18
19 \makeatletter
20 \usepackage[scaled=0.8]{GoMono}
21 \newcommand\make@car@active[1]{%
22 \catcode`#1\active
23 \begingroup
24 \lccode`\~`#1\relax
25 \lowercase{\endgroup\def~}%
26 }
27
28 \newif\if@exstar
29
30 \newcommand\exemple{%
31 \begingroup
32 \parskip\z@
33 \@makeother\;\@makeother\!\@makeother\?\@makeother\:% neutralise frenchb
34 \@ifstar{\@exstartrue\exemple@}{\@exstarfalse\exemple@}}
35
36 \newcommand\exemple@[2][65]{%
37 \medbreak\noindent
38 \begingroup
39 \let\do\@makeother\dospecials
40 \make@car@active\ { {}}%
41 \make@car@active\^^M{\par\leavevmode}%
42 \make@car@active\^^I{\space\space}%
43 \make@car@active\,{\leavevmode\kern\z@\string,}%
44 \make@car@active\-{\leavevmode\kern\z@\string-}%
45 \make@car@active\>{\leavevmode\kern\z@\string>}%
46 \make@car@active\<{\leavevmode\kern\z@\string<}%
47 \exemple@@{#1}{#2}%
48 }
49
50 \newcommand\exemple@@[3]{%
51 \def\@tempa##1#3{\exemple@@@{#1}{#2}{##1}}%
52 \@tempa
53 }
54
55 \newcommand\exemple@@@[3]{%
56 \xdef\the@code{#3}%
57 \endgroup
58 \if@exstar
59 \begingroup
60 \fboxrule0.4pt
61 \let\breakboxparindent\z@
62 \def\bkvz@bottom{\hrule\@height\fboxrule}%
63 \let\bkvz@before@breakbox\relax
64 \def\bkvz@set@linewidth{\advance\linewidth\dimexpr-2\fboxrule-2\fboxsep}%
65 \def\bkvz@left{\vrule\@width\fboxrule\hskip\fboxsep}%
66 \def\bkvz@right{\hskip\fboxsep\vrule\@width\fboxrule}%
67 \def\bkvz@top{\hbox to \hsize{%
68 \vrule\@width\fboxrule\@height\fboxrule
69 \leaders\bkvz@bottom\hfill
70 \sffamily
71 \fboxsep\z@
72 \colorbox{black}{\kern0.25em\color{white}\footnotesize\lower0.5ex\hbox{\strut#2}\kern0.25em}%
73 \leaders\bkvz@bottom\hfill
74 \vrule\@width\fboxrule\@height\fboxrule}}%
75 \breakbox
76 \kern.5ex\relax
77 \ttfamily\footnotesize\the@code\par
78 \normalfont
79 \kern3pt
80 \hrule height0.1pt width\linewidth depth0.1pt
81 \vskip5pt
82 \rightskip0pt plus 1fill
83 \everypar{{\color{lightgray}\rlap{\vrule height0.1pt width\linewidth depth0.1pt}}\hskip0pt plus 1fill}%
84 \newlinechar`\^^M\everyeof{\noexpand}\scantokens{#3}\par
85 \endbreakbox
86 \endgroup
87 \else
88 \vskip0.5ex
89 \boxput*(0,1)
90 {\fboxsep\z@
91 \hbox{\sffamily\colorbox{black}{\leavevmode\kern0.25em{\color{white}\footnotesize\strut#2}\kern0.25em}}%
92 }%
93 {\fboxsep5pt
94 \fbox{%
95 $\vcenter{\hsize\dimexpr0.#1\linewidth-\fboxsep-\fboxrule\relax
96 \kern5pt\parskip0pt \ttfamily\footnotesize\the@code}%
97 \vcenter{\kern5pt\hsize\dimexpr\linewidth-0.#1\linewidth-\fboxsep-\fboxrule\relax
98 \everypar{{\color{lightgray}\rlap{\vrule height0.1pt width\dimexpr\linewidth-0.#1\linewidth-\fboxsep-\fboxrule depth0.1pt}}}%
99 \footnotesize\newlinechar`\^^M\everyeof{\noexpand}\scantokens{#3}}$%
100 }%
101 }%
102 \fi
103 \medbreak
104 \endgroup
105 }
106
107 \begingroup
108 \catcode`\<13 \catcode`\>13
109 \gdef\Verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
110 \bgroup
111 \verb@eol@error \let\do\@makeother \dospecials
112 \verbatim@font\@noligs
113 \catcode`\<13 \catcode`\>13 \def<{\begingroup$\langle$\itshape}\def>{\/$\rangle$\endgroup}%
114 \@ifstar\@sverb\@verb}
115 \endgroup
116
117 \newcommand\falseverb[1]{{\ttfamily\detokenize\expandafter{\string#1}}}
118
119 \def\CFengdate@i#1/#2/#3\@nil{\number#3\relax\ifnum#3=1 \space\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}
120 \edef\CFengdate{\expandafter\CFengdate@i\CFdate\@nil}
121
122 \DeclareRobustCommand\CF{%
123 \textsf{chem{\itshape fig}}\xspace
124 }
125
126 \def\CF@log@date#1{\CF@log@date@a#1\@nil}
127 \def\CF@log@date@a#1/#2/#3\@nil{#3/#2/#1}
128 \begingroup
129 \catcode`\! 13 \catcode`\<13 \catcode`\>13
130 \gdef\CFchangelog@verb{%
131 \ifvmode\leavevmode\fi
132 \hbox\bgroup
133 \verb@eol@error \let\do\@makeother \dospecials
134 \verbatim@font\@noligs
135 \catcode`\<13 \catcode`\>13
136 \def<{\begingroup$\langle$\itshape}\def>{\/$\rangle$\endgroup}%
137 \catcode32 10
138 \ttfamily
139 \CFchangelog@verb@a
140 }%
141 \gdef\CFchangelog@verb@a#1!{%
142 #1%
143 \egroup}%
144 \gdef\CFchangelog#1#2{%
145 \paragraph{Version \@gobble#1 du \CF@log@date{#2}}
146 \par
147 \begingroup
148 \catcode`\! 13
149 \let!\CFchangelog@verb
150 \small
151 \begin{itemize}
152 }
153 \endgroup
154 \def\endCFchangelog{%
155 \end{itemize}
156 \endgroup
157 }
158
159 \makeatother
160
161 \usepackage[english]{babel}
162 \def\degres{\ensuremath{{}^\circ}}
163 \newcommand\TIKZ{ti\textit kz\xspace}
164 \newcommand\molht[1]{\begingroup\parskip3.5pt\par\hfill\chemfig{#1}\hfill\null\par\endgroup}
165 \newcommand\boxednode[2]{\fbox{$\mathrm{#1}\vphantom{M_1}$}_{#2}}
166 \newcommand\boxedfalseverb[1]{{\fboxsep0pt\fbox{\vphantom|\falseverb{#1}}}}
167 \newcommand*\chevrons[1]{\textlangle\textit{#1}\textrangle}
168 \newcommand*\CFkey[1]{{\color{teal}\texttt{\detokenize{#1}}}}
169 \newcommand*\CFval[1]{{\color{teal}\textlangle\textit{#1}\textrangle}}
170 \newcommand*\CFkv[2]{\CFkey{#1}{\color{teal}${}={}$}\CFval{#2}}
171 \newcommand*\CFparam[2]{%
172 \CFkey{#1}&%
173 \ifcat\relax\detokenize\expandafter\expandafter\expandafter{\useKV[chemfig]{#1}}\relax \textlangle\textit{empty}\textrangle\else\texttt{\detokenize\expandafter\expandafter\expandafter{\useKV[chemfig]{#1}}}\fi&%
174 #2\\%
175 }
176 \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}
177 \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}
178
179 \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}
180
181 \csname @addtoreset\endcsname{section}{part}
182 \usepackage{titlesec}
183 \titleformat{\part}[display]{\normalfont\filcenter\sffamily\bfseries}{}{0pt}{\Huge}
184
185 \begin{document}
186 \topsep=3pt plus5pt minus2pt\relax
187 \begin{titlepage}
188 \catcode`!12
189 \begin{tikzpicture}[remember picture,overlay]
190 \shade [left color=blue,right color=white]([yshift=2cm]current page.west) rectangle ([xshift=-1cm]current page.south);
191 \shade [left color=white,right color=blue] ([xshift=1cm]current page.south) rectangle ([yshift=2cm]current page.east);
192 \filldraw[black](current page.north west) rectangle ([yshift=7cm]current page.east);
193 \shade[top color=black,bottom color=blue]([yshift=7cm]current page.east)rectangle([yshift=2.5cm]current page.west);
194 \filldraw[black!55!blue!100]([yshift=2.5cm]current page.east)rectangle([yshift=2cm]current page.west);
195 \end{tikzpicture}
196 \begin{center}
197 \color{white}\sffamily\fontsize{50pt}{50pt}\selectfont\CF\par
198 \Large v\CFver\par
199 \CFengdate\par\bigbreak
200 \normalsize Christian Tellechea\smallbreak
201 \href{mailto:[email protected]}{\texttt{[email protected]}}\par\vskip1.5cm
202 \huge A \TeX{} package for drawing molecules%
203 \end{center}
204 \vskip4cm
205 \begin{center}
206 \scriptsize
207 \setchemfig{atom sep=3em}%
208 \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)-)}%
209 \par
210 {\sffamily\small Taxotere}%
211 \end{center}
212 \vskip1.5cm
213 \hfill
214 \hbox to 0pt{\hss\scriptsize
215 \setchemfig{bond offset=1pt,atom sep=2.5em,compound sep=5em,arrow offset=6pt}
216 \schemestart
217 \chemfig{(-[:-150]R')(-[:-30]R)=[2]N-[:30]OH}
218 \arrow{<=>[\chemfig{H^\oplus}]}
219 \chemfig{(-[@{a0}:-150]R')(-[:-30]R)=[2]@{a1}N-[@{b0}:30]@{b1}\chemabove{O}{\scriptstyle\oplus}H_2}
220 \chemmove[red,-stealth,red,shorten <=2pt]{
221 \draw(a0)..controls +(135:2mm) and +(215:4mm).. (a1);
222 \draw(b0)..controls +(120:2mm) and +(180:3mm).. ([yshift=7pt]b1.180);}
223 \arrow{<=>[\chemfig{{-}H_2O}]}[,1.1]
224 \chemleft[{\subscheme[90]{%
225 \chemfig{R'-\chemabove{N}{\scriptstyle\oplus}~C-R}
226 \arrow{<->}[,0.75]
227 \chemfig{R'-\charge{90=\:}{N}=@{a1}\chemabove{C}{\scriptstyle\oplus}-R}}}\chemright]
228 \arrow{<=>[\chemfig{H_2@{a0}\charge{0=\:,90=\:}{O}}]}[,1.1]
229 \chemmove[red,-stealth,red,shorten <=3pt]{
230 \draw(a0)..controls+(90:10mm)and+(45:10mm)..([yshift=6pt]a1.45);}
231 \chemfig{*6(R\rlap{$'$}-N=(-R)-\chemabove{O}{\scriptstyle\oplus} H_2)}
232 \arrow{<=>[\chemfig{{-}H^\oplus}]}
233 \chemfig{*6(R\rlap{$'$}-N=(-R)-OH)}
234 \arrow
235 \chemfig{*6(R\rlap{$'$}-\chembelow{N}{H}-(-R)(=[2]O))}
236 \schemestop\hss}\hfill\null
237 \begin{center}
238 \sffamily\small The Beckmann rearrangement%
239 \end{center}
240 \end{titlepage}
241 \parindent0pt\pagestyle{plain}
242 \tableofcontents
243 \parskip\medskipamount
244 \newpage
245
246 \setitemize{leftmargin=3em,topsep=0pt,parsep=0pt,itemsep=1.5pt}
247 \part{Introduction}
248 \section{New in v1.7}
249 The change log is no longer at the end of the \verb|chemfig.tex| file but at the end of this manual, see page~\pageref{changelogs}. It is not translated into English.
250
251 \subsection{Horizontal reaction}
252 To draw a horizontal reaction, \CF provides a new environment:
253 \begin{center}
254 \leavevmode
255 \vtop{%
256 \hbox{\Verb|\hreac[<keys>=<values>]|}\kern1.25ex
257 \hbox{\Verb| <reaction>|}\kern1.25ex
258 \hbox{\verb|\endhreac|}
259 }
260 \end{center}
261
262 This environment certainly has far fewer possibilities than \Verb|\schemestart <reaction> \schemestop|, but it allows you to draw a horizontal reaction more quickly while retaining certain advanced features. See page~\pageref{hreac}.
263
264 \subsection{Internal changes}
265 Some internal changes have been made:
266 \begin{itemize}
267 \item By default, starting with version 1.7, the strut of the previous atom is no longer added to the argument of \verb|\printatom|. This will slightly change the placement of atoms in some cases. However, you can revert to the previous behavior with \CFkv{use atom strut}{true}. See page~\pageref{liaisonentreatomes};
268 \item When \CFkv{use atom strut}{false} is set, which is the default behaviour, each atom is typeset only once, whereas previously it was sometimes 5 times or more.
269
270 An internal macro was corrected.
271 \end{itemize}
272
273 \textbf{\color{red}Important}: for consistency, the next version of \CF will require a change in the syntax of \verb|\schemestart|. The two optional arguments will be removed for a single optional argument containing \Verb|<keys>=<values>|. The settings that were possible with the two optional arguments will be accessible with new \Verb|<keys>|.
274
275 \section{Presenting \protect\CF}
276 To use this package, start by adding the following code to the preamble:
277 \begin{itemize}
278 \item {\color{blue}\verb-\input chemfig.tex-} with $\varepsilon$\TeX;
279 \item {\color{blue}\verb-\usepackage{chemfig}-} with \LaTeX;
280 \end{itemize}
281
282 In all cases, the \TIKZ package, if not loaded before, is loaded by \CF.
283
284 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.
285
286 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.
287
288 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:
289 \begin{itemize}
290 \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;
291 \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}}}.
292 \end{itemize}
293
294 \section{Acknowledgment}
295 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.
296 \medbreak
297 I also want to warmly thank Theo \textsc{Hopman} for offering to translate this manual into English.
298
299 \part{Operation of \protect\CF}
300 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.
301
302 \section{The \texttt{\textbackslash chemfig} macro}
303 The macro \verb|\chemfig| has the following syntax
304 \begin{center}
305 \Verb|\chemfig[list of <keys>=<values>]{<molecule code>}|
306 \end{center}
307 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.
308
309 Here is the complete list of parameters for the \verb|\chemfig| macro, their default values, and a brief description\label{listeparametres}.
310 \begin{center}
311 \begin{longtable}{rcp{7.5cm}}\hline
312 \chevrons{keys} & default \chevrons{values}& Description\\\hline\endhead
313 \CFparam{chemfig style}{ style given to ti\textit kz}
314 \CFparam{use atom strut}{put in the the strut of previous atom in the argument of \falseverb{\printaom}}
315 \CFparam{atom style}{style of ti\textit kz nodes containing atoms}
316 \CFparam{bond join}{boolean for bond joins}
317 \CFparam{fixed length}{boolean for fixed bond widths}
318 \CFparam{cram rectangle}{ boolean to draw rectangle Cram bond}
319 \CFparam{cram width}{length of the base of the triangles Cram bonds}
320 \CFparam{cram dash width}{width of dash Cram bonds}
321 \CFparam{cram dash sep}{space between dash Cram bonds}
322 \CFparam{atom sep}{space between atoms}
323 \CFparam{bond offset}{space between atom and bond}
324 \CFparam{double bond sep}{space between multiple bonds lines}
325 \CFparam{angle increment}{increment of the angle of bonds}
326 \CFparam{node style}{style of atoms}
327 \CFparam{bond style}{style of bonds}
328 \CFparam{baseline}{dimension or name of node to set the vertical position}
329 \CFparam{debug}{show nodes, anchors and names of nodes}
330 \CFparam{cycle radius coeff}{shrinkage ratio of the circle or arc inside cycles}
331 \CFparam{stack sep}{vertical gap between arguments of \falseverb\chemabove and \falseverb\chembelow macros}
332 \CFparam{show cntcycle}{show rings numbers}
333 \CFparam{autoreset cntcycle}{reset ring counter at \falseverb\chemfig execution}
334 \CFparam{gchemname}{if true, makes the depth assignments made by \falseverb\chemnameinit and \falseverb\chemname global}
335 \hline
336 \end{longtable}
337 \end{center}
338
339 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:
340 \begin{itemize}
341 \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;
342 \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;
343 \item spaces, but these are ignored by default because the atoms are composed in mathematical mode;
344 \item the "\verb|{|" and "\verb|}|" braces that have their normal behavior as group markers or macro argument delimiters;
345 \item macros.
346 \end{itemize}
347
348 \section{Groups of atoms}
349 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''.
350
351 {\fboxsep1pt
352 However, in this molecule
353 \molht{H_3C-C(-[:-30]OH)=[:30]O}
354 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.
355
356 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:
357 \renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
358 \molht{H_3C-C(=[:30]O)(-[:-30]OH)}}
359
360 A space is ignored when at the beginning of a group of atoms.
361
362 \section{First atom's role}\label{premieratome1}
363 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).
364
365 \exemple{Influence of the first atom}/\chemfig{A-B}\qquad
366 \chemfig{-B}\qquad
367 \chemfig{A^1-B}/
368
369 To set an arbitrary vertical offset or place a group of atoms on the baseline, use the \chevrons{baseline} key (see page~\pageref{baseline}).
370
371 \section{Different types of bonds}
372 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}
373 \begin{center}
374 \begin{tabular}{>{\centering\arraybackslash}m{1.7cm}>{\centering\arraybackslash}m{3cm}>{\centering\arraybackslash}m{2cm}m{4cm}}
375 \hline
376 Bond \#&Code &Result &Bond type\\\hline
377 1 &\verb+\chemfig{A-B}+ &\chemfig{A-B} &Single\\
378 2 &\verb+\chemfig{A=B}+ &\chemfig{A=B} &Double\\
379 3 &\verb+\chemfig{A~B}+ &\chemfig{A~B} &Triple\\
380 4 &\verb+\chemfig{A>B}+ &\chemfig{A>B} &right Cram, plain\\
381 5 &\verb+\chemfig{A<B}+ &\chemfig{A<B} &left Cram, plain\\
382 6 &\verb+\chemfig{A>:B}+&\chemfig{A>:B}&right Cram, dashed\\
383 7 &\verb+\chemfig{A<:B}+&\chemfig{A<:B}&left Cram, dashed\\
384 8 &\verb+\chemfig{A>|B}+&\chemfig{A>|B}&right Cram, hollow\\
385 9 &\verb+\chemfig{A<|B}+&\chemfig{A<|B}&left Cram, hollow\\\hline
386 \end{tabular}
387 \end{center}
388 \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.
389
390 \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.
391 \begin{center}
392 \begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline]
393 \node[draw] at(0,0)(aa){\huge A};
394 \node[draw]at(4,0)(bb){\huge B};
395 \path[shorten <=10pt,shorten >=10pt,draw](aa)--(bb)coordinate[pos=0](al) coordinate[pos=1](bl);
396 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(al){};
397 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=10pt]al){};
398 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(bl){};
399 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=-10pt]bl){};
400 \draw[blue,dash pattern=on 1pt off 1pt](bl)--([yshift=0.7cm]bl);
401 \draw[blue,dash pattern=on 1pt off 1pt]([xshift=-10pt]bl)--([xshift=-10pt,yshift=0.7cm]bl);
402 \draw[stealth-stealth]([yshift=0.6cm]bl.center)--([xshift=-10pt,yshift=0.6cm]bl.center) node [midway,above,draw=none]{$\delta$};
403 \draw[blue,dash pattern=on 1pt off 1pt](al)--([yshift=0.7cm]al);
404 \draw[blue,dash pattern=on 1pt off 1pt]([xshift=10pt]al)--([xshift=10pt,yshift=0.7cm]al);
405 \draw[stealth-stealth]([yshift=0.6cm]al.center)--([xshift=10pt,yshift=0.6cm]al.center) node [midway,above,draw=none]{$\delta$};
406 \node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(aa){};
407 \node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(bb){};
408 \draw[stealth-stealth]([yshift=1cm]aa.center)--([yshift=1cm]bb.center) node [midway,above,draw=none] {$\Delta$} ;
409 \draw[red,dash pattern=on 2pt off2pt](aa.center)--([yshift=1.1cm]aa.center);
410 \draw[red,dash pattern=on 2pt off2pt](bb.center)--([yshift=1.1cm]bb.center);
411 \end{tikzpicture}
412 \end{center}
413
414 \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.
415
416 \exemple{Interatomic distance}|\chemfig[atom sep=2em]{A-B}\par
417 \chemfig[atom sep=50pt]{A-B}|
418
419 \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.
420 \exemple{Trimming bonds}|\chemfig[bond offset=0pt]{A-B}\par
421 \chemfig[bond offset=5pt]{A-B}|
422
423 If one bond is followed immediately by another, then \CF inserts an empty group \verb-{}-. Around this empty group the separation $\delta$ is zero:
424 \exemple{Empty groups}/\chemfig{A-B=-=C}/
425
426 \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}.
427 \exemple{Style of bonds}/\chemfig[bond style={line width=1pt,red}]{A-B=C>|D<E>:F}/
428
429 \label{modif.retrait} The spacing $\delta$ for just one bond can be specified with either the character \verb-#-, the macro \verb|\#| or \verb|\CFhash|. It is important to notice that if the macro \verb|\chemfig| is in the argument of a macro, \verb-#- must \emph{not} be used and in that case, \verb|\#| or \verb|\CFhash| must be prefered.
430
431 The token \verb-#-, \verb|\#| or \verb|\CFhash| 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:
432 \begingroup
433 \catcode`\#12
434 \exemple{Fine adjustment of bond shortening}/\setchemfig{bond offset=4pt}
435 \chemfig{A-B-C}\par
436 \chemfig{A-#(,0pt)B-C}\par
437 \chemfig{A-B-#(0pt)C}\par
438 \chemfig{A-#(,0pt)B-#(0pt)C}/
439 \endgroup
440
441 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.}:
442 \exemple{Math mode}|\chemfig{A_1B^2-C _ 3 ^ 4}|
443
444 There are settings specifically for Cram bonds:
445 \begin{itemize}
446 \item \CFkv{cram width}{dim} is the size of the base of the triangle, and is 1.5pt by default;
447 \item \CFkv{cram dash width}{dim} is the thickness of the dots, and is 1pt by default;
448 \item \CFkv{cram dash sep}{dim} is the spacing between the dots, and is 2pt by default.
449 \end{itemize}
450
451 Here is an example where the three dimensions are changed:
452
453 \exemple{Modified Cram bonds}-\chemfig[cram width=10pt,
454 cram dash width=0.4pt,
455 cram dash sep=1pt]{A>B>:C>|D}-
456
457 \section{Bond angle}
458 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.
459
460 There are several ways of specifying the bond angle.
461 \subsection{Predefined angles}
462 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.
463
464 \exemple{Predefined angles}|\chemfig{A-B-[1]C-[3]-D-[7]E-[6]F}|
465
466 These angles remain valid if the atoms are empty, and this is the case for all the features we will see below:
467 \exemple{Predefined angles with empty groups}|\chemfig{--[1]-[3]--[7]-[6]}|
468
469 \label{angle increment}The \chevrons{key} \CFkv{angle increment}{angle} sets the default angle used to calculate the angle of a bond:
470
471 \exemple{Set the predefined angle}/Default (45) : \chemfig{-[1]-[-1]-[1]-[-1]}
472
473 Angle of 30 : \chemfig[angle increment=30]{-[1]-[-1]-[1]-[-1]}/
474
475 \subsection{Absolute angles}
476 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)$:
477 \exemple{Absolute angles}/\chemfig{A-[:30]B=[:-75]C-[:10]D-[:90]>|[:60]-[:-20]E-[:0]~[:-75]F}/
478
479 \subsection{Relative angles}\label{angle.relatif}
480 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-+-.
481
482 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:
483 \exemple{Result of relative angles}|\chemfig{A-[:-5]-[::+20]-[::20]B-[::+20]-[::20]C-[::20]}|
484
485 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.
486 \exemple{Result of relative angles followed by absolute}|\chemfig{A-[:-5]-[::20]-[::20]B-[7]-[::20]C-[::20]}|
487
488 \section{Length of a bond}
489 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:
490 \exemple{Influence of the size of atoms}|\chemfig{I-I}\par
491 \chemfig{M-M}|
492
493 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 $-$:
494 \exemple{Too-short bond}|\chemfig{A^{++}_{2}-B^{-}_3}|
495
496 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.
497
498 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}:
499
500 \begin{center}
501 \begin{tabular}{c@{\kern2cm}c}
502 \CFkv{fixed length}{false}&\CFkv{fixed length}{true}\\[2ex]
503 \begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline]
504 \node[draw] at(0,0)(aa){\huge A};
505 \node[draw]at(4,0)(bb){\huge B};
506 \path[shorten <=10pt,shorten >=10pt,draw](aa)--(bb)coordinate[pos=0](al) coordinate[pos=1](bl);
507 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(al){};
508 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=10pt]al){};
509 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(bl){};
510 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=-10pt]bl){};
511 \draw[blue,dash pattern=on 1pt off 1pt](bl)--([yshift=0.7cm]bl);
512 \draw[blue,dash pattern=on 1pt off 1pt]([xshift=-10pt]bl)--([xshift=-10pt,yshift=0.7cm]bl);
513 \draw[stealth-stealth]([yshift=0.6cm]bl.center)--([xshift=-10pt,yshift=0.6cm]bl.center) node [midway,above,draw=none]{$\delta$};
514 \draw[blue,dash pattern=on 1pt off 1pt](al)--([yshift=0.7cm]al);
515 \draw[blue,dash pattern=on 1pt off 1pt]([xshift=10pt]al)--([xshift=10pt,yshift=0.7cm]al);
516 \draw[stealth-stealth]([yshift=0.6cm]al.center)--([xshift=10pt,yshift=0.6cm]al.center) node [midway,above,draw=none]{$\delta$};
517 \node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(aa){};
518 \node[draw,circle,fill,red,minimum size=2pt,inner sep=0pt]at(bb){};
519 \draw[stealth-stealth]([yshift=1cm]aa.center)--([yshift=1cm]bb.center) node [midway,above,draw=none] {$\Delta$} ;
520 \draw[red,dash pattern=on 2pt off2pt](aa.center)--([yshift=1.1cm]aa.center);
521 \draw[red,dash pattern=on 2pt off2pt](bb.center)--([yshift=1.1cm]bb.center);
522 \end{tikzpicture}
523 &
524 \begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline]
525 \node[draw] at(0,0)(aa){\huge A};
526 \node[draw]at(5,0)(bb){\huge B};
527 \path[shorten <=10pt,shorten >=10pt,draw](aa)--(bb)coordinate[pos=0](al) coordinate[pos=1](bl);
528 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(al){};
529 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=10pt]al){};
530 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at(bl){};
531 \node[draw,circle,fill,blue,minimum size=1.5pt,inner sep=0pt]at([xshift=-10pt]bl){};
532 \draw[blue,dash pattern=on 1pt off 1pt](bl)--([yshift=0.7cm]bl);
533 \draw[blue,dash pattern=on 1pt off 1pt]([xshift=-10pt]bl)--([xshift=-10pt,yshift=0.7cm]bl);
534 \draw[stealth-stealth]([yshift=0.6cm]bl.center)--([xshift=-10pt,yshift=0.6cm]bl.center) node [midway,above,draw=none]{$\delta$};
535 \draw[blue,dash pattern=on 1pt off 1pt](al)--([yshift=0.7cm]al);
536 \draw[blue,dash pattern=on 1pt off 1pt]([xshift=10pt]al)--([xshift=10pt,yshift=0.7cm]al);
537 \draw[stealth-stealth]([yshift=0.6cm]al.center)--([xshift=10pt,yshift=0.6cm]al.center) node [midway,above,draw=none]{$\delta$};
538 \draw[stealth-stealth]([yshift=1cm]al)--([yshift=1cm]bl) node [midway,above,draw=none] {$\Delta$} ;
539 \draw[red,dash pattern=on 2pt off2pt](al)--([yshift=1.1cm]al);
540 \draw[red,dash pattern=on 2pt off2pt](bl)--([yshift=1.1cm]bl);
541 \end{tikzpicture}
542 \end{tabular}
543 \end{center}
544
545 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.
546
547 \exemple{Fixed length bonds}/\chemfig{Cl-Cl}\par
548 \chemfig[fixed length=true]{Cl-Cl}/
549
550 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.
551 \exemple{Modified bond length}/\chemfig{A^{++}_{2}-[,2]B^{-}_3}\par
552 \chemfig{A-B-[,2]C=[,0.5]D}\par
553 \chemfig{-=[,1.5]-[,0.75]=[:-20,2]}/
554
555 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:
556 \exemple{How to modify the size of molecule}/\normalsize \chemfig{H-[:30]O-[:-30]H}\par
557 \setchemfig{atom sep=2.5em}
558 \chemfig{H-[:30]O-[:-30]H}\par
559 \small \chemfig{H-[:30]O-[:-30]H}\par
560 \footnotesize \chemfig{H-[:30]O-[:-30]H}\par
561 \scriptsize \chemfig{H-[:30]O-[:-30]H}\par
562 \tiny \chemfig{H-[:30]O-[:-30]H}/
563
564 \section{Departure and arrival atoms}
565 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.
566
567 Here are some examples where the bond is in the interval $(-90,90)$, and where the bond is made between D and E:
568 \exemple{Default atom connections}|\chemfig{ABCD-[:75]EFG}\quad
569 \chemfig{ABCD-[:-85]EFG}\quad
570 \chemfig{ABCD-[1]EFG}|
571
572 In the following examples, the angles are in the interval $[90,270]$ and so the bond is made between A and G:
573 \exemple[60]{Default atom connections}|\chemfig{ABCD-[:100]EFG}\quad
574 \chemfig{ABCD-[:-110]EFG}\quad
575 \chemfig{ABCD-[5]EFG}|
576
577 In some cases, you may want a bond to start from atoms other than those calculated by \CF. You can force a starting atom or an ending atom with the optional argument of the bond. You must write:
578 \begin{center}
579 \Verb/[,,<integer 1>,<integer 2>]/
580 \end{center}
581 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.
582 \exemple{Specified atom connections}|\chemfig{ABCD-[:75,,2,3]EFG}\qquad
583 \chemfig{ABCD-[:75,,,2]EFG}\qquad
584 \chemfig{ABCD-[:75,,3,2]EFG}|
585
586 \section{Customization of bonds}\label{perso-liaisons}
587 There is a fifth and last optional argument for bonds which is found after the fourth comma:
588 \begin{center}
589 \Verb/[,,,,<tikz code>]/
590 \end{center}
591
592 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:
593 \exemple{Passing tikz code}|\chemfig{A-[,,,,red]B}\par
594 \chemfig{A-[,,,,dash pattern=on 2pt off 2pt]B}\par
595 \chemfig{A-[,,,,line width=2pt]B}\par
596 \chemfig{A-[,,,,red,line width=2pt]B}|
597
598 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:
599 \exemple{Wavy bonds}|\chemfig{A-[,3,,,decorate,decoration=snake]B}|
600
601 Cram bonds ignore thickness and dash settings.
602
603 \section{Connecting bonds}
604 By default, the lines representing single bonds do not connect, which can be too visible and unsightly when the line widths are large.
605
606 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.
607
608 \exemple{Connecting bonds}/\setchemfig{bond style={line width=3pt}}
609 \chemfig{-[1]-[7]} et
610 \chemfig[bond join=true]{-[1]-[7]}/
611
612 The problem is even more obvious with Cram bonds when they connect to a single bond or another Cram bond. Here again, setting \CFkey{bond join} to \CFval{true} makes for more aesthetically pleasing connections.\label{joinCram}
613
614 \exemple{Connecting Cram bonds}/
615 \chemfig{<[:-20]>[:50]}\qquad
616 \chemfig[bond join]{<[:-20]>[:50]}
617 \medbreak
618 \setchemfig{cram width=5pt}
619 \chemfig{<[:-45]-[:30,,,,line width=5pt]>[:-10]}\qquad
620 \chemfig[bond join]{<[:-45]-[:30,,,,line width=5pt]>[:-10]}/
621
622 It is important to note the tow following points:
623 \begin{itemize}
624 \item \CFkey{bond join} is \CFval{true}, the Cram bond is drawn without an outline: it will therefore appear slightly thinner (the importance depending on the \CFval{line width} parameter);
625 \item \CFkey{bond join} has no effect between a simple bond and a Cram bond when the 2 vertices of the base of the triangle of the Cram bond are outside the space delimited by the 2 parallel edges of the simple bond. Mathematically, it is the case when $d \cos\alpha>w$, where $d$ is the value of \CFval{cram width}, $w$ is the width of the single bond and $\alpha$ is the angle between the 2 bonds.
626 \end{itemize}
627
628 \exemple{Connecting Cram bonds}/
629 \setchemfig{cram width=5pt, bond join}
630 \chemfig{-[,,,,line width=3pt]>[:30]}\qquad
631 \chemfig{-[,,,,line width=3pt]>[:65]}/
632
633 \section{Default values}
634 At the beginning of each molecule, the default values for the optional arguments are initialized. They are:
635 \begin{itemize}
636 \item 0\degres{} for the bond angle;
637 \item 1 for the length multiplication coefficient;
638 \item \Verb-<empty>- for the numbers of the departure and arrival atoms, which lets \CF calculate these based on the bond angle;
639 \item \Verb-<empty>- for the parameters passed to \TIKZ.
640 \end{itemize}
641
642 These default values can be changed for the whole molecule by beginning the molecule code with
643 \begin{center}
644 \Verb/[<angle>,<coeff>,<n1>,<n2>,<code tikz>]/
645 \end{center}
646
647 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:
648 \exemple{Overriding default values}|\chemfig{[:20,1.5]A-B-C-[:-80,0.7]D-E-F}|
649
650 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:
651 \exemple{Default values}|\chemfig{[1,1.5,2,2,red,thick]ABC-DEF=GHI}|
652
653 \section{Branches}
654 \subsection{Principle}
655 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.
656
657 In this example, the sub-molecule ``\verb/-[1]W-X/'' will be attached to atom ``B'':
658 \exemple{A branch}|\chemfig{A-B(-[1]W-X)-C}|
659
660 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:
661 \exemple{Multiple branches}|\chemfig{A-B(-[1]W-X)(-[6]Y-[7]Z)-C}|
662
663 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/[::-30,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:
664 \exemple{Default values in branches}|\chemfig{A-B([:60]-D-E)([::-30,1.5]-X-Y)-C}|
665
666 Observe what happens if, at the beginning of the main molecule, one writes ``\verb/[:-45]/'':
667 \exemple{Effect of the default bond angle}|\chemfig{[:-45]A-B([:60]-D-E)([::-30,1.5]-X-Y)-C}|
668
669 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.
670
671 \subsection{Nesting}
672 Sub-molecules may be nested, and the rules seen in the preceding paragraphs stay in force:
673 \exemple{Nested branches}|\chemfig{A-B([1]-X([2]-Z)-Y)(-[7]D)-C}|
674
675 \subsection{Method}
676 Suppose now that we want to draw an acid anhydride molecule:
677 \chemfig{R-C(=[::+60]O)-[::-60]O-[::-60]C(=[::+60]O)-[::-60]R}
678
679 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:
680 \exemple{Acid anhydride structure}|\chemfig{R-C-[::-60]O-[::-60]C-[::-60]R}|
681
682 To this structure we just have to add two ``\verb/=O/'' sub-molecules to each of the carbon atoms:
683 \exemple{Acid anhydride}|\chemfig{R-C(=[::+60]O)-[::-60]O-[::-60]C(=[::+60]O)-[::-60]R}|
684
685 Because we used only relative angles, we can rotate this molecule by giving a default angle of e.g. 75\degres:
686 \exemple[70]{Rotation of a molecule}|\chemfig{[:75]R-C(=[::+60]O)-[::-60]O-[::-60]C(=[::+60]O)-[::-60]R}|
687
688 \section{Connecting distant atoms}
689 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''.
690
691 Let's take this molecule:
692 \exemple{Branched structure}|\chemfig{A-B(-[1]W-X)(-[7]Y-Z)-C}|
693
694 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/:
695 \exemple{Distant bond}|\chemfig{A-B(-[1]W-X?)(-[7]Y-Z)-C?}|
696
697 We could connect other atoms to X by following them with \verb-?-. Here it's the atoms \verb-C- and \verb-Z-:
698 \exemple{Several distant bonds}|\chemfig{A-B(-[1]W-X?)(-[7]Y-Z?)-C?}|
699
700 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:
701 \begin{center}
702 \Verb/?[<name>,<bond>,<tikz>]/
703 \end{center}
704 where each field takes its default value if it is empty:
705 \begin{itemize}
706 \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.
707 \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.)
708
709 Second, the field can be one of the bond character codes, provided that this character is \emph{between braces}.
710 \item \Verb-<tikz>- will be passed directly to \TIKZ as we have seen with regular bonds.
711 \end{itemize}
712
713 Here is our molecule with the required distant bonds, then with the bond \verb/A-W/ and \verb/X-C/ customized:
714 \exemple{Multiple distant bonds}|\chemfig{A?[a]-B(-[1]W?[a]-X?[b])(-[7]Y-Z?[b])-C?[b]}\par\medskip
715 \chemfig{A?[a]-B(-[1]W?[a,2,red]-X?[b])(-[7]Y-
716 Z?[b,1,{line width=2pt}])-C?[b,{>},blue]}|
717
718 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/:
719 \exemple{An incomplete ring}|\chemfig{A-[:-72]B-C-[:72]D-[:144]E}|
720
721 Then we must do this:
722 \exemple{Multiple distant bonds}|\chemfig{A?[a]-[:-72]B-C?[a]?[b]-[:72]D-[:144]E?[a]?[b]}|
723
724 \section{Rings}
725 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.
726
727 \subsection{Syntax}
728 \CF can easily draw regular polygons. The idea is to attach a ring to an \Verb/<atom>/ outside the ring with this syntax:
729 \begin{center}
730 \Verb/<atom>*<n>(<code>)/
731 \end{center}
732 \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.
733
734 Here is a 5-ring, attached to the atom ``\verb/A/'':
735 \exemple{5-ring}|\chemfig{A*5(-B=C-D-E=)}|
736
737 A ring can also be drawn with one, several, or all the groups of atoms empty, as is the case for diagrams outside rings:
738 \exemple{5-ring with empty groups}|\chemfig{*5(-=--=)}|
739
740 A ring can be incomplete:
741 \exemple{Incomplete 5-ring}|\chemfig{*5(-B=C-D)}|
742 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:
743 \exemple{Truncated 5-ring}|\chemfig{A*5(-B=C-D-E=F-G=H-I)}|
744
745 It is possible to draw a circle or an arc in the inside of a ring. To do so, the following syntax is used:
746 \begin{center}
747 \Verb/<atom>**[<angle 1>,<angle 2>,<tikz>]<n>(<code>)/
748 \end{center}
749 where each field of the optional argument takes its default value if it is empty:
750 \begin{itemize}
751 \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;
752 \item \Verb/<tikz>/ is the code that will be passed to \TIKZ for drawing the arc.
753 \end{itemize}
754
755 \exemple{Rings and arcs}|\chemfig{**6(------)}\quad
756 \chemfig{**[30,330]5(-----)}\quad
757 \chemfig{**[0,270,dash pattern=on 2pt off 2pt]4(----)}|
758
759 \subsection{Angular position}
760 \subsubsection{At the start}
761 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:
762 \exemple{Angular position of rings}|\chemfig{A*4(-B-C-D-)}\qquad\chemfig{A*6(------)}|
763
764 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$:
765 \exemple[55]{Rotation of rings}|\chemfig{[:30]A*6(------)}\qquad
766 \chemfig{[:-30]A*6(------)}\qquad
767 \chemfig{[:60]A*6(------)}|
768
769 \subsubsection{After a bond}
770 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.
771
772 Here is a simple case:
773 \exemple{Bond ending on a ring}|\chemfig{A-B*5(-C-D-E-F-)}|
774
775 The rule remains valid, whatever the angle of the preceding bond:
776 \exemple{Bonds ending on a ring}|\chemfig{A-[:25]B*4(----)}\vskip5pt
777 \chemfig{A=[:-30]*6(=-=-=-)}|
778
779 \subsection{Branches on a ring}
780 To have branches attached to the vertices of a ring, we use the syntax we have already seen:
781 \begin{center}
782 \Verb/<atom>(<code>)/
783 \end{center}
784 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:
785 \exemple{Branch on a ring}|\chemfig{X*6(-=-(-A-B=C)=-=-)}|
786
787 A sub-molecule can be attached to the first vertex of a ring, just like the other vertices:
788 \exemple{Ring and branches}|\chemfig{*5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)}|
789
790 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:
791 \exemple[50]{Branches at specified angles}|\chemfig{*5(---([:90]-A-B)--)}\qquad
792 \chemfig{*5(---(-[:90]A-B)--)}\qquad
793 \chemfig{*5(---([::+0]-A-B)--)}|
794
795 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.
796
797 We can now connect together rings with bonds:
798 \exemple{Connected rings}|\chemfig{*6(--(-*5(----(-*4(----))-))----)}|
799
800 \subsection{Nested rings}
801 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:
802 \exemple{Nested rings}|\chemfig{A*6(-B*5(----)=-=-=)}|
803
804 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.
805
806 It is quite possible to glue multiple rings together:
807 \exemple{Multiple nested rings}|\chemfig{*5(--*6(-*4(-*5(----)--)----)---)}|
808
809 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-''.
810 \exemple{Flawed drawing}|\chemfig{A-B*5(-C-D*5(-X-Y-Z-)-E-F-)}|
811
812 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/:
813 \exemple{Distant bond and ring}|\chemfig{A-B*5(-C-D*5(-X-Y-Z?)-E?-F-)}|
814
815 We could also use a \verb-\phantom{E}- at the last vertex of the 5-ring:
816 \exemple{Using \string\phantom}/\chemfig{A-B*5(-C-D*5(-X-Y-Z-\phantom{E})-E-F-)}/
817
818 \subsection{Rings and groups of atoms}
819 Some care must be taken with rings when one or more vertices are made up of groups of atoms:
820 \exemple{Ring and groups of atoms}|\chemfig{AB*5(-CDE-F-GH-I-)}|
821
822 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:
823 \exemple{Forced departure and arrival atoms}|\chemfig{AB*5(-CDE-[,,1]F-[,,,1]GH-I-)}|
824
825 \subsection{Center of rings}\label{centre_cycle}
826 Each ring has at its center a node of zero dimension whose name is \Verb|centrecycle<n>| where \Verb|<n>| is the number of the ring, (the rings are numbered in the order in which they are drawn). It is possible to display the number of each ring by setting the boolean \CFkey{show cntcycle} to true.
827
828 The default true boolean \CFkey{autoreset cntcycle} resets the ring counter at the beginning of each molecule to 0 (i.e., each time \verb|\chemfig| is executed).
829
830 \exemple{Centre of rings}/\chemfig{*5(---(-*3(---))--)}
831 \chemmove{\draw[red](cyclecenter1)to[out=20,in=-45](cyclecenter2);}
832 \qquad
833 \chemfig{*6(-=-=-=)}
834 \chemmove{%
835 \node[at=(cyclecenter1)](){.+}
836 node [at=(cyclecenter1),shift=(120:1.75cm)](end){\printatom{R^1}};
837 \draw[-,shorten <=.5cm](cyclecenter1)--(end);
838 }/
839
840 \section{Representing electron movements}\label{mecanismes-reactionnels}
841 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.
842
843 Two types of diagrams can arise, so we can ask for:
844 \begin{itemize}
845 \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;
846 \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.
847 \end{itemize}
848 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>-'':
849 \begin{center}
850 \Verb|\chemmove[<opt>]{\draw[<tikz opt>](<name1>)<tikz link>(<name2>);}|
851 \end{center}
852
853 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.
854
855 \subsection{Mesomeric effects}
856 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.
857
858 The macros \verb|\schemestart|, \verb|\schemestop|, \verb|\arrow| and \verb|\+| are explained in the chapter \ref{schemas}, starting on page \pageref{schemas}.
859
860 \exemple{Mesomeric effect 1}/\schemestart
861 \chemfig{@{a1}=_[@{db}::30]-[::-60]\charge{90=\|}{X}}
862 \arrow{<->}
863 \chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
864 \chemabove{X}{\scriptstyle\oplus}}
865 \schemestop
866 \chemmove{\draw(db).. controls +(100:5mm) and +(145:5mm).. (a1);}/
867
868 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.
869
870 To link the nodes ``db'' and ``a1'' we have used the following syntax:
871 \begin{center}
872 \Verb|\chemmove{\draw(db)..controls +(80:8mm) and +(145:8mm)..(a1);}|
873 \end{center}
874
875 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'').
876 \exemple{Mesomeric effect 2}/\schemestart
877 \chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\charge{90=\|}{X}}
878 \arrow{<->}
879 \chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
880 \chemabove{X}{\scriptstyle\oplus}}
881 \schemestop
882 \chemmove{
883 \draw(db)..controls +(100:5mm) and +(145:5mm)..(a1);
884 \draw(dnl)..controls +(90:4mm) and +(45:4mm)..(sb);}/
885
886 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.
887 \exemple{Mesomeric effect 3}/\schemestart
888 \chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\charge{90=\|}{X}}
889 \arrow{<->}
890 \chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
891 \chemabove{X}{\scriptstyle\oplus}}
892 \schemestop
893 \chemmove[->]{% change the tip style
894 \draw(db).. controls +(100:5mm) and +(145:5mm).. (a1);
895 \draw[shorten <=3pt,shorten >=1pt](dnl) .. controls +(90:4mm)
896 and +(45:4mm) .. (sb);}/
897
898 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.
899
900 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:
901 \exemple{Mesomeric effect 4}/\schemestart
902 \chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\charge{90=\|}{X}}
903 \arrow{<->}
904 \chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60]
905 \chemabove{X}{\scriptstyle\oplus}}
906 \schemestop
907 \chemmove{
908 \draw[-stealth,thin,dash pattern= on 2pt off 2pt,red]
909 (db).. controls +(100:5mm) and +(145:5mm)..
910 node[sloped,above] {$\pi$} (a1);
911 \draw[shorten <=3pt, shorten >= 1pt]
912 (dnl).. controls +(90:4mm) and +(45:4mm).. (sb);}/
913
914 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
915 \exemple{Departure or arrival anchor point 1}/\chemfig{@{x1}\charge{45=\:}{X}}
916 \hspace{2cm}
917 \chemfig{@{x2}\charge{90=\|}{X}}
918 \chemmove{
919 \draw[shorten >=4pt](x1).. controls +(90:1cm) and +(90:1cm).. (x2);}/
920
921 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'':
922 \exemple{Departure or arrival anchor point 2}/\chemfig{@{x1}\charge{45=\:}{X}}
923 \hspace{2cm}
924 \chemfig{@{x2}\charge{90=\|}{X}}
925 \chemmove[shorten <=4pt,shorten >=4pt]{
926 \draw(x1.57).. controls +(60:1cm) and +(120:1cm).. (x2.90);}/
927
928 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'':
929 \exemple{A single control point}/\chemfig{@{x1}\charge{45=\:}{X}}
930 \hspace{2cm}
931 \chemfig{@{x2}\charge{90=\|}{X}}
932 \chemmove[shorten <=4pt,shorten >=4pt]{
933 \draw(x1.57).. controls +(1cm,.8cm).. (x2.90);}/
934
935 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.
936
937 \subsection{Reaction mechanisms}
938 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.
939 \exemple{Esterification: step 1}/\setchemfig{atom sep=7mm}
940 \schemestart
941 \chemfig{R-@{dnl}\charge{90=\|,-90=\|}{O}-H}
942 \+
943 \chemfig{R-@{atoc}C([6]-OH)=[@{db}]O}
944 \arrow(.mid east--){<->[\chemfig{@{atoh}\chemabove{H}{\scriptstyle\oplus}}]}
945 \schemestop
946 \chemmove[shorten <=2pt]{
947 \draw(dnl)..controls +(90:1cm)and+(north:1cm)..(atoc);
948 \draw[shorten >=6pt](db)..controls +(north:5mm)and+(100:1cm)..(atoh);}/
949
950 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.
951 \exemple{Esterification: step 2}/\setchemfig{atom sep=7mm}
952 \chemfig{R-O-C(-[2]R)(-[6]OH)-@{dnl}\charge{90=\|,-90=\|}{O}H}\hspace{1cm}
953 \chemfig{@{atoh}\chemabove{H}{\scriptstyle\oplus}}
954 \chemmove{
955 \draw[shorten <=2pt, shorten >=7pt]
956 (dnl).. controls +(south:1cm) and +(north:1.5cm).. (atoh);}/
957
958 The rest is left as an exercise to the reader\dots.
959
960 \section{Writing a name under a molecule}\label{chemname}
961 For convenience, \CF can write the name of a molecule underneath it with the command
962 \begin{center}
963 \Verb/\chemname[<dim>]{\chemfig{<code of the molecule>}}{<name>}/
964 \end{center}
965
966 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.
967
968 Here is a reaction with the names under the molecules:
969 \exemple*{Displaying names of molecules}/\schemestart
970 \chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Acide carboxylique}
971 \+
972 \chemname{\chemfig{R'OH}}{Alcool}
973 \arrow(.mid east--.mid west)
974 \chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
975 \+
976 \chemname{\chemfig{H_2O}}{Water}
977 \schemestop
978 \chemnameinit{}/
979
980 There are some limitations to this command. Suppose we switch the acid and the alcohol on the left side:
981 \exemple*{Name alignment 1}/\schemestart
982 \chemname{\chemfig{R'OH}}{Alcohol}
983 \+
984 \chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Carboxylic acid}
985 \arrow(.mid east--.mid west)
986 \chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
987 \+
988 \chemname{\chemfig{H_2O}}{Water}
989 \schemestop
990 \chemnameinit{}/
991
992 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:
993 \begin{itemize}
994 \item write \Verb-\chemnameinit{<deepest molecule>}- before using the \verb-\chemname- command in a reaction, unless the reaction begins with the deepest molecule;
995 \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.
996 \end{itemize}
997
998 Note that the assignments for the largest depth are global if \CFkv{gchemname}{true}, which is the default behavior. They are local otherwise.
999
1000 Thus the correct code uses \falseverb{\chemnameinit} before and after the reaction:
1001 \exemple*{Name alignment 2}/\chemnameinit{\chemfig{R-C(-[:-30]OH)=[:30]O}}
1002 \schemestart
1003 \chemname{\chemfig{R'OH}}{Alcohol}
1004 \+
1005 \chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Carboxylic acid}
1006 \arrow(.mid east--.mid west)
1007 \chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
1008 \+
1009 \chemname{\chemfig{H_2O}}{Water}
1010 \schemestop
1011 \chemnameinit{}/
1012
1013 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.}:
1014 \exemple*{Name on 2 lines}/\schemestart
1015 \chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Carboxilic\\Acid}
1016 \+
1017 \chemname{\chemfig{R'OH}}{Alcohol}
1018 \arrow(.mid east--.mid west)
1019 \chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester}
1020 \+
1021 \chemname{\chemfig{H_2O}}{Water}
1022 \schemestop
1023 \chemnameinit{}/
1024
1025 If \Verb|\chemname*{<name>}| is written, the macro does not take into account the previous names.
1026
1027 \part{Advanced usage}\label{utilisation.avancee}
1028 \section{Separating atoms}\label{decoupage.atomes}
1029 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{@}}
1030
1031 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:
1032
1033 \exemple*{Alkene}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}/
1034
1035 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:
1036 \begin{center}
1037 \fboxsep=0pt
1038 \renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}%
1039 \chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}%
1040 \end{center}
1041 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:
1042
1043 \exemple*{Alkene}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C|{(CH_3)_3}}/
1044
1045 \section{Displaying atoms}\label{perso.affichage}
1046 Once a molecule has been split into atoms, the macro \falseverb{\printatom} is called internally by \CF in order to display each atom. Its only argument consists of tokens read in the molecule code representing the current atom (e.g., “\verb-H_3-”); when the \CFkey{use atom strut} key is set to \CFval{true}, a \verb|\vphantom| is added to this argument (see page~\pageref{liaisonentreatomes}). This macro switches to math mode and displays its argument using the math font “rm”. It is defined by the following code:
1047 \begin{itemize}
1048 \item \verb|\newcommand*\printatom[1]{\ensuremath{\mathrm{#1}}}|\qquad when compiling with \LaTeX{}
1049 \item \verb|\def\printatom#1{\ifmmode\rm#1\else$\rm#1$\fi}|\qquad when compiling with $\varepsilon$\TeX{} ou Con\TeX tX.
1050 \end{itemize}
1051
1052 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:
1053 \exemple{Redefinition of \string\printatom}/\fboxsep=1pt
1054 \renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
1055 \chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}/
1056
1057 Here is how to redefine it to use the ``sf'' font family of math mode:
1058 \exemple{Atoms displayed with ``sf'' font family}/\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}
1059 \chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}/
1060
1061 \section{Arguments given to tikz}\label{arguments.optionnels}
1062 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}''.
1063
1064 With the use of the first optional argument one can, for example, choose the global color or thickness of lines:
1065 \exemple{Style choice}/\chemfig{A-B-[2]C}\par\medskip
1066 \setchemfig{chemfig style={line width=1.5pt}}\chemfig{A-B-[2]C}\par\medskip
1067 \setchemfig{chemfig style=red}\chemfig{A-B-[2]C}/
1068
1069 With \CFkey{node style}, one can choose the colour of nodes drawn by \TIKZ, change the angle of the drawing or its scale:
1070 \exemple{Style choices}/\chemfig{A-B-[2]C}\par\medskip
1071 \setchemfig{atom style=red}\chemfig{A-B-[2]C}\par\medskip
1072 \setchemfig{atom style={rotate=20}}\chemfig{A-B-[2]C}\par\medskip
1073 \setchemfig{atom style={scale=0.5}}\chemfig{A-B-[2]C}/
1074
1075
1076 \section{Shifted double bonds}
1077 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.
1078
1079 To shift the bond to the left, write ``\verb-=^-'' and to shift it to the right, write ``\verb-=_-'':
1080 \exemple{Shifted double bonds}/\chemfig{A-=-B}\par
1081 \chemfig{A-=^-B}\par
1082 \chemfig{A-=_-B}/
1083
1084 In rings, double bonds are automatically shifted to the left. However, they can be shifted to the right by specifying it with ``\verb-=_-'':
1085 \exemple{Shifted double bonds and rings}/\chemfig{*6(-=-=-=)}\qquad
1086 \chemfig{*6(-=_-=_-=_)}/
1087
1088 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:
1089 \exemple{Shifted bonds and skeleton diagrams}/\chemfig{-[:30]=[:-30]-[:30]=[:-30]-[:30]}\par
1090 \chemfig{-[:30]=^[:-30]-[:30]=^[:-30]-[:30]}\par
1091 \chemfig{-[:30]=_[:-30]-[:30]=_[:-30]-[:30]}/
1092
1093 \section{Delocalized double bonds}
1094 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.
1095
1096 \exemple*{Delocalized bonds}|\catcode`\_=11
1097 \tikzset{
1098 ddbond/.style args={#1}{
1099 draw=none,
1100 decoration={%
1101 markings,
1102 mark=at position 0 with {
1103 \coordinate (CF@startdeloc) at (0,\dimexpr#1\CF_doublesep/2)
1104 coordinate (CF@startaxis) at (0,\dimexpr-#1\CF_doublesep/2);
1105 },
1106 mark=at position 1 with {
1107 \coordinate (CF@enddeloc) at (0,\dimexpr#1\CF_doublesep/2)
1108 coordinate (CF@endaxis) at (0,\dimexpr-#1\CF_doublesep/2);
1109 \draw[dash pattern=on 2pt off 1.5pt] (CF@startdeloc)--(CF@enddeloc);
1110 \draw (CF@startaxis)--(CF@endaxis);
1111 }
1112 },
1113 postaction={decorate}
1114 }
1115 }
1116 \catcode`\_=8
1117 \chemfig{A-[,,,,ddbond={+}]B-[,,,,ddbond={-}]C}|
1118
1119 \section{Saving a sub-molecule}\label{definesubmol}
1120 \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.
1121
1122 To do this, one gives the command
1123 \begin{center}
1124 \Verb|\definesubmol{<name>}{<code>}|
1125 \end{center}
1126 which saves the \Verb/<code>/ for recall in the code of the molecule via the shortcut ``\verb/!{name}/''. This \Verb-<name>- can be:
1127 \begin{itemize}
1128 \item a sequence of characters: all the alphanumeric characters able to be between \texttt{\string\csname} and \texttt{\string\endcsname} are accepted;
1129 \item a control sequence.
1130 \end{itemize}
1131
1132 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}
1133 \begin{center}
1134 \Verb|\redefinesubmol{<name>}{<code>}|
1135 \end{center}
1136
1137 Here is a code which draws the pentane molecule. An alias ``\verb/xy/'' was defined beforehand for the code \verb/CH_2/:
1138 \exemple{Pentane}|\definesubmol{xy}{CH_2}
1139 \chemfig{H_3C-!{xy}-!{xy}-!{xy}-CH_3}|
1140
1141 In this case the technique is not very interesting because ``\verb/!{xy}/'' is just as long to type as the code it replaces.
1142
1143 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:
1144 \exemple{Butane}|\definesubmol\xx{C(-[::+90]H)(-[::-90]H)}
1145 \chemfig{[:15]H-!\xx-!\xx-!\xx-!\xx-H}|
1146
1147 The \falseverb{\definesubmol} command takes an optional argument; its syntax is as follows:
1148 \begin{center}
1149 \Verb/\definesubmol{<name>}[<code1>]{code2}/
1150 \end{center}
1151
1152 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>-.
1153
1154 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:
1155 \exemple{Dual alias}/\definesubmol\Me[H_3C]{CH_3}
1156 \chemfig{*6((-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-)}/
1157
1158 \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:
1159 \begin{center}
1160 \Verb/\definesubmol{<name>}<number>[<code1>]{<code2>}/
1161 \end{center}
1162
1163 In the \Verb|<codes>|, the arguments must appear in their usual form "\Verb|#<n>|" where \Verb|<n>| is the argument number.
1164
1165 \exemple{\texttt{\string\definesubmol} with arguments}/\definesubmol\X1{-[,-0.2,,,draw=none]{\scriptstyle#1}}
1166 \chemfig{*6((!\X A)-(!\X B)-(!\X C)-(!\X D)-(!\X E)-(!\X F)-)}
1167
1168 \definesubmol{foo}3[#3|\textcolor{#1}{#2}]{\textcolor{#1}{#2}|#3}
1169 \chemfig{A(-[:135]!{foo}{red}XY)-B(-[:45]!{foo}{green}{W}{zoo})}/
1170
1171 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.
1172
1173 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.
1174
1175 \exemple{Use of \#}/\definesubmol\X2{#1-#2-#3-#(3pt,3pt)#4}
1176 \chemfig{A-!\X{M}{N}-B}/
1177
1178 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.
1179
1180 \section{Placement of Atoms}
1181 \subsection{Groups of atoms}\label{placementatomes}
1182 In a group of atoms, the atoms are placed one after the other in a well-established order:
1183 \begin{itemize}
1184 \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;
1185 \item the atoms to the right of the reference atom are then placed from left to right;
1186 \item atoms to the left of the reference atom are finally placed from right to left.
1187 \end{itemize}
1188
1189 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.
1190
1191 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:
1192 \begin{center}
1193 \def\0#1#2{%
1194 \vtop{%
1195 \def\tempprintatom##1{\ensuremath{\mathrm{##1}}}%
1196 \setbox0\hbox{\tempprintatom{#1}}%
1197 \def\tempvrule{\vrule height.33ex width.4pt}%
1198 \offinterlineskip\copy0 \kern2pt
1199 \hbox to\wd0{\kern.5pt \tempvrule\hrulefill\tempvrule\kern.5pt}\kern2pt
1200 \hbox to\wd0{\hss$\scriptstyle#2$\hss}}}
1201 \chemfig{A-[:-60,,,3]\0{B}{5}|\0{C}{4}|\0{D}{1}|\0{E}{2}|\0{F}{3}}
1202 \end{center}
1203
1204 \subsection{Vertical alignment}\label{baseline}
1205 The \CFkey{baseline} is used to finely control the vertical placement of the molecule in relation to the baseline of the current paragraph.
1206
1207 It is set to \CFval{0pt} by default, and in this case, the first atom encountered (whether empty or not) is the one placed on the baseline of the current paragraph, shown in gray on the examples in this manual. The choice of this first atom therefore conditions the placement of all the others, and often influences the placement of the entire molecule.
1208
1209 \exemple{First atom}/\chemfig{H-[7]C(-[5]H)=C(-[1]H)-[7]H}\qquad
1210 \chemfig{C(-[3]H)(-[5]H)=C(-[1]H)-[7]H}/
1211
1212 An arbitrary dimension can be specified to vertically shift the molecule by this value with the syntax \CFkv{baseline}{dimension}:
1213
1214 \exemple{Vertical shift}/\chemfig{A(-[:-60]-[:30]C)-[:45]B}\qquad
1215 \chemfig[baseline=5pt]{A(-[:-60]-[:30]C)-[:45]B}\qquad
1216 \chemfig[baseline=-5pt]{A(-[:-60]-[:30]C)-[:45]B}/
1217
1218 With the syntax \CFkv{baseline}{(name)} (the name must be in parentheses), we specify that the baseline of the molecule is at the node named \chevrons{name}. The name of the atom can be the one assigned automatically by \CF (of the form \Verb|n<a>-<b>|) or a name given by the user using the syntax \Verb|@{<name >}| (see page~\pageref{mecanismes-reactionnels}).
1219
1220 \exemple*{Alignment on atoms}/Default alignment : \chemfig{A(-[:-60]-[:30]C)-[:45]B}\medbreak
1221 Alignment on B: \chemfig[baseline=(b.base)]{A(-[:-60]-[:30]C)-[:45]@{b}B}\medbreak
1222 Alignment on empty atom: \chemfig[baseline=(vide)]{A(-[:-60]@{vide}-[:30]C)-[:45]B}\medbreak
1223 Alignment on C: \chemfig[baseline=(c.base)]{A(-[:-60]-[:30]@{c}C)-[:45]B}/
1224
1225 It is possible to name \TIKZ nodes. Thus, if we want to vertically center several molecules on the current baseline, we set \CFkey{baseline} to \CFval{(current bounding box.center)}.
1226
1227 \exemple*{Centered Alignment}/1) \chemfig{A-[:-45]B} et 2) \chemfig{B-[:45]C}\bigbreak
1228
1229 \setchemfig{baseline=(current bounding box.center)}% vertical centering of the following molecules
1230 1) \chemfig{A-[:-45]B} et 2) \chemfig{B-[:45]C}
1231 \setchemfig{baseline=0pt}% back to default value/
1232
1233 \subsection{Bonds between atoms}\label{liaisonentreatomes}
1234 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:
1235 \begin{center}
1236 \fboxsep=.25pt
1237 \renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
1238 \setchemfig{chemfig style={line width=1pt}}
1239 \Large
1240 \chemfig{A@ABC-[:65,,2,3]DE@BFG}
1241 \chemmove{%
1242 \draw[red,fill=red] (A.center)circle(.2ex);
1243 \draw[blue,fill=blue](B.center)circle(.2ex);
1244 \draw[gray,-,dashed,shorten <=-1.5em, shorten >=-1.5em](A.center)--(B.center);
1245 }
1246 \end{center}
1247 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.
1248 \exemple[55]{Horizontal alignment}/\large\setchemfig{atom sep=2em}
1249 \chemfig{A^1-B-C-D}\par
1250 \chemfig{E_1-F-G-H}/
1251
1252 This phenomenon can be highlighted by making the bounding boxes of the atoms visible, where we can clearly see that the atoms “\verb-B-” and “\verb-F-” have bounding boxes whose height takes into account the heights of the previous atoms:
1253 \exemple[55]{Horizontal placement and bounbding boxes}/\large\setchemfig{atom sep=2em}
1254 \fboxsep=-0.2pt \fboxrule0.2pt
1255 \renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm#1}}}
1256 \chemfig{A^1-B-C-D}\par
1257 \chemfig{E_1-F-G-H}/
1258
1259 Since the bounding box of the first atom has a different vertical extent than the next one, a vertical offset is created for the subsequent bounding boxes. This offset is clearly visible when the bonds are horizontal.
1260
1261 The behavior prior to version 1.7 of \CF masked this effect on the first atom following the problematic bounding box by adding the \verb|\vphantom| of the previous atom to the argument of each \verb|\printatom|. You can revert to this behavior by setting the \CFkey{use atom strut} key to \CFval{true}.
1262
1263 \exemple[55]{Horizontal placement and bounding boxes}/\large\setchemfig{atom sep=2em}
1264 \fboxsep=-0.2pt \fboxrule0.2pt
1265 \renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm#1}}}
1266 \chemfig{A^1-B-C-D}\quad
1267 \chemfig[use atom strut=true]{A^1-B-C-D}
1268
1269 \chemfig{E_1-F-G-H}\quad
1270 \chemfig[use atom strut=true]{E_1-F-G-H}/
1271
1272 Since no automatic solution is satisfactory, this problem can be manually circumvented by creating an end atom that is a “strut” equal to |vphantom{X}|: thus, the starting atom has a “normal” height and no offset will affect the following group of atoms. A sub-molecule is used here for greater conciseness.
1273 \exemple[55]{Bypassing vertical position}/\large\setchemfig{atom sep=2em}
1274 \definesubmol\I{\vphantom{X}}
1275 \chemfig{A^1|!\I-B-C-D}\par
1276 \chemfig{E_1|!\I-F-G-H}/
1277
1278 The disadvantage is that the first bond is too long because the departure atom now has a zero horizontal dimension.
1279
1280 \subsection{La macro \texttt{\char`\\chemskipalign}}\label{chemskipalign}
1281 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.
1282
1283 \exemple[60]{Deactivation of the alignment mechanism}/\large
1284 \chemfig{A-.-B}\quad
1285 \chemfig{A-\chemskipalign.-B}\par\bigskip
1286 \fboxsep=0pt
1287 \renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
1288 \chemfig{A-.-B}\quad
1289 \chemfig{A-\chemskipalign.-B}/
1290
1291 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-'':
1292 \exemple{Consequence of the \string\chemskipalign command}/\large
1293 \fboxsep=0pt
1294 \renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}
1295 \chemfig{A-\chemskipalign.B-C}/
1296
1297 This feature can sometimes be useful. Suppose we want to draw the following molecule
1298 \begin{center}
1299 \catcode`;12
1300 \def\emptydisk{\chemskipalign\tikz\draw(0,0)circle(2pt);}%
1301 \def\fulldisk{\chemskipalign\tikz\fill(0,0)circle(2pt);}%
1302 \chemfig{A-#(,0pt)\emptydisk-#(0pt,0pt)\fulldisk-#(0pt)B}%
1303 \end{center}
1304 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}.
1305 \begingroup\catcode`;12 \catcode`#12
1306 \exemple{Use of \string\chemskipalign\ and #}/\def\emptydisk{\chemskipalign\tikz\draw(0,0)circle(2pt);}
1307 \def\fulldisk{\chemskipalign\tikz\fill(0,0)circle(2pt);}
1308 \chemfig{A-\emptydisk-\fulldisk-B}\par
1309 \chemfig{A-#(,0pt)\emptydisk-#(0pt,0pt)\fulldisk-#(0pt)B}
1310 /\endgroup
1311
1312 \section{The macro \texttt{\char`\\charge}}\label{charge}
1313 \subsection{Overview}
1314 The macro \verb| load|, which requires two mandatory arguments, allows to arrange elements (called \chevrons{charges}) around an \chevrons{atome}; its syntax is
1315 \begin{center}
1316 \Verb|\charge{[<general parameters>]<position>[<tikz code>]=<charge>}{<atom>}|
1317 \end{center}
1318 where:
1319 \begin{itemize}
1320 \item the \chevrons{atom} is usually one or two letters, but it can also be empty;
1321 \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|;
1322 \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;
1323 \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|;
1324 \item the optionnal \chevrons{tikz code} sets the options given to the \TIKZ macro \verb|\node|, which places the \chevrons{charge}.
1325 \end{itemize}
1326
1327 \subsection{Parameters}
1328 The \chevrons{keys}${}={}$\chevrons{values} available in the \chevrons{general parameters} are:
1329
1330 \begin{longtable}{rlp{8.5cm}}\hline
1331 \chevrons{keys} & default \chevrons{values} & Description\\\hline\endhead
1332 \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).\\
1333 \Chargeparam{macro atom}&macro receiving the \chevrons{atom} as argument.\\
1334 \Chargeparam{circle} & boolean which, when \CFval{true}, puts the \chevrons{atom} in a circular node; otherwise, the node is rectangular.\\
1335 \Chargeparam{macro charge}&macro (e.g., \verb|\printatom| or \verb|\ensuremath|) receiving each charge as an argument.\\
1336 \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.\\
1337 \Chargeparam{overlay} & boolean which, when \CFval{true}, draws the \chevrons{charges} "overlay", i.e. outside the final bounding box.\\
1338 \Chargeparam{shortcuts}&boolean which, when \CFval{true}, activates the shortcuts"\verb-\.-," "\verb-\:-," "\verb-\|- and "\verb-\"-" to draw Lewis formuas.\\
1339 \Chargeparam{lewisautorot}&boolean which, when \CFval{true}, automatically rotates "\verb-\:-," "\verb-\|- and "\verb-\"-".\\
1340 \Chargeparam{.radius}&radius of the point used to plot "\verb|\.|" and "\verb|\:|".\\
1341 \Chargeparam{:sep} & separation between the two dots of "\verb|\:|".\\
1342 \Chargeparam{.style}&\TIKZ style used to draw the "\verb|\.|" and "\verb|\:|" dots.\\
1343 \Chargeparam{"length}&length of the rectangle "\verb-\- "and the line "\verb-\|-".\\
1344 \Chargeparam{"width}&width of the rectangle \verb-\"-.\\
1345 \Chargeparam{"style}&\TIKZ style used to draw the rectangle \verb-\"-.\\
1346 \Chargeparam{|style}&TIKZ style used to draw the line \verb-\|-.\\\hline
1347 \end{longtable}
1348
1349 It is possible to set some (or all) of these parameters by running the macro
1350 \begin{center}
1351 \Verb|\setcharge{<keys>=<values>}|
1352 \end{center}
1353 and reset all parameters to their default values with
1354 \begin{center}
1355 \verb|\resetcharge|
1356 \end{center}
1357 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.
1358 \medbreak
1359
1360 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}.
1361 \medbreak
1362
1363 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:
1364 \exemple{Generic example}|\setcharge{debug}
1365 Default then circle:
1366 \Charge{30=\:,120=$\ominus$,210=$\delta^+$}{Fe}\qquad
1367 \Charge{[circle]30=\:,120=$\ominus$,210=$\delta^+$}{Fe}|
1368
1369 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.
1370
1371 \exemple{Fine positioning}|\setcharge{debug}
1372 \Charge{30=\:,120:3pt=$\ominus$,210:5pt=$\delta^+$}{Fe}\qquad
1373 \Charge{[circle]30=\:,
1374 120[circle,anchor=180+\chargeangle]=$\ominus$,
1375 210[anchor=180+\chargeangle]=$\delta^+$}{Fe}|
1376
1377 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.
1378
1379 \exemple{Circular nodes}/\chemfig{\charge{90=\.}{N}H_3} : rectangle nodes\smallbreak
1380 \chemfig{\charge{[circle]90=\.}{N}H_3} : circle node/
1381
1382 \subsection{Lewis formula}
1383 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|.
1384
1385 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.
1386 \medbreak
1387
1388 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.
1389
1390 \exemple{Autorot}/\Charge{60=\:,150=\"}{A} et
1391 \Charge{[lewisautorot=false]60=\:,150=\"}{A}/
1392
1393 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}.
1394
1395 \exemple{Ccustomization}/\Charge{[.radius=1.5pt,.style={draw=gray}]
1396 45 =\.[{.style={draw=none,fill=red}}],
1397 135 =\.[{.style={draw=none,fill=blue}}],
1398 -45 =\.[{.style={draw=none,fill=green}}],
1399 -135=\.}{A}\quad
1400 \Charge{
1401 45 =\"[{"style={draw=red,fill=gray}}],
1402 135=\"[{"width=3pt,"style={line width=.8pt,draw=blue,fill=cyan}}]}{A}/
1403
1404 \subsection{Integration in \CF}
1405 A macro \verb|\charge| can take the place of an atom.
1406
1407 \exemple{Charge in \CF}*\chemfig{H-\charge{45:1.5pt=$\scriptstyle+$,-45=\|,-135=\"}{O}(-[2]H)-H}*
1408
1409 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.
1410
1411 \exemple{Charge in chain}/\chemfig{[:30]-\charge{90=\:}{}
1412 -[:-30]\charge{-90=\"}{}-\charge{90:2pt=$\delta^+$}{}-[:-30]}/
1413
1414 \section{Stacking}
1415 The macros\label{chemabove}
1416 \begin{center}
1417 \Verb|\chemabove[<dim>]{<code>}{<stuff>}|
1418 \end{center}
1419 and
1420 \begin{center}
1421 \Verb|\chembelow[<dim>]{<code>}{<stuff>}|
1422 \end{center}
1423 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}.
1424
1425 These commands are independent of the macro \verb-\chemfig- and can be used either inside or outside its argument.
1426
1427 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:
1428 \exemple{Staking in rings}|\chemfig{*5(-\chembelow{A}{B}--\chemabove{C}{D}--)}|
1429
1430 \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.
1431
1432 What's the difference between \verb|\chemabove| and \verb|\charge| for placing one item above or below another?
1433 \exemple{\string\chemabove\space or \string\charge}/\chemfig{*5(----\chemabove{A}{\oplus}-)}
1434 \chemfig{*5(----\charge{90[anchor=-90]=$\oplus$}{A}-)}/
1435
1436 By default, the two macros give very similar results. However, there are differences in their use:
1437 \begin{itemize}
1438 \item \verb|\chemabove| and \verb|\chemabelow| can only be used in the argument of \verb|chemfig|, which is not the case for \verb|\charge|;
1439 \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.
1440 \end{itemize}
1441
1442 \section{Using {\protect\ttfamily\protect\textbackslash chemfig} in the {\protect\ttfamily tikzpicture} environment}
1443 It is possible to call the \falseverb{\chemfig} inside a {\ttfamily\falseverb{tikzpicture}} environment:
1444 \exemple{\textbackslash chemfig inside tikzpicture}|\begin{tikzpicture}[help lines/.style={thin,draw=black!50}]
1445 \draw[help lines] (0,0) grid (4,4);
1446 \draw(0,0) -- (2,1);
1447 \draw(2,2) circle (0.5);
1448 \node at (1,3) {\chemfig{A=B-[:30]C}};
1449 \node[draw,red,anchor=base] at(3,2){\chemfig{X>[2,,,,blue]Y}};
1450 \end{tikzpicture}|
1451
1452 \section{Annotated examples}\label{exemples.commentes}
1453 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.
1454
1455 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.
1456
1457 \subsection{Ethanal}
1458 Here we will draw the ethanal (or acetaldehyde) molecule: \chemfig{H-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O}
1459
1460 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:
1461 \exemple{Backbone of ethanal}|\chemfig{H-C-C=[1]O}|
1462
1463 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)/'':
1464 \exemple{Ethanal}|\chemfig{H-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O}|
1465
1466 \subsection{2-amino-4-oxohexanoic acid}
1467 Here is the molecule to be drawn: \chemfig{-[::+30]-[::-60](=[:-90]O)-[::+60]-[::-60](-[:-90]NH_2)-[::+60](=[:90]O)-[::-60]OH}
1468
1469 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.
1470
1471 \subsubsection{Absolute angles}
1472 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$:
1473 \exemple{Backbone (absolute angles)}|\chemfig{[:30]--[:-30]--[:-30]--[:-30]OH}|
1474
1475 The branches ``\verb/(=[6]O)/'', ``\verb/(-[6]NH_2)/'' and ``\verb/(=[2]O)/'' still have to be added to the correct vertices:
1476 \exemple{Molecule (absolute angles)}|\chemfig{[:30]--[:-30](=[6]O)--[:-30](-[6]NH_2)-(=[2]O)-[:-30]OH}|
1477
1478 \subsubsection{Relative angles}
1479 A more general approach uses only relative angles, in this way:
1480 \exemple{Structure (relative angles)}|\chemfig{[:30]--[::-60]--[::-60]--[::-60]OH}|
1481
1482 then
1483 \exemple{Molecule (relative angles)}|\chemfig{[:30]--[::-60](=[::-60]O)--[::-60](-[::-60]NH_2)
1484 -(=[::60]O)-[::-60]OH}|
1485
1486 \subsubsection{Ring}
1487 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:
1488 \exemple{Backbone (ring)}|\chemfig{[:120]NH_2*6(---=O)}|
1489
1490 Now the branches must be added to the right vertices:
1491 \exemple{Molecule (ring)}|\chemfig{[:120]NH_2*6(-(-(=[::60]O)-[::-60]OH)--(--[::60])=O)}|
1492
1493 \subsubsection{Nested rings}
1494 Delving deeper into the ring method, we can also consider nesting incomplete 6-rings. We could start with this backbone:
1495 \exemple{Backbone (nested rings)}|\chemfig{*6(--*6(--=O))}|
1496
1497 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:
1498 \exemple{Molecule (nested rings)}|\chemfig{*6((-)-(=O)-*6(-(-NH_2)-(-OH)=O))}|
1499
1500 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:
1501 \exemple{Molecule (corrected nested rings)}|\chemfig{*6((-)-(=O)-*6(-(-NH_2)-(-OH)(=[::60]O)))}|
1502
1503 \subsection{Glucose}
1504 The goal here is to represent the glucose molecule according to several different conventions.
1505
1506 \subsubsection{Skeleton diagram}
1507 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$:
1508 \exemple[60]{Backbone}|\chemfig{[:-30]HO--[:30]--[:30]--[:30]-H}|
1509
1510 Adding the branches is no problem. We use predefined absolute angles:
1511 \exemple[60]{Glucose, skeleton diagram}|\chemfig{[:-30]HO--[:30](<[2]OH)-(<:[6]OH)
1512 -[:30](<:[2]OH)-(<:[6]OH)-[:30](=[2]O)-H}|
1513
1514 \subsubsection{Fisher projection}
1515 The goal is to get the molecule below:
1516 \begin{center}
1517 \definesubmol{x}{(-[4]H)(-[0]OH)}
1518 \definesubmol{y}{(-[0]H)(-[4]OH)}
1519 \chemfig{[2]OH-[3]-!x-!x-!y-!x-=[1]O}
1520 \end{center}
1521 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:
1522 \exemple{Skeleton}|\chemfig{[2]OH-[3]-a-b-c-d-=[1]O}|
1523
1524 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}-'':
1525 \exemple{Glucose (Fisher projection)}|\definesubmol{x}{(-[4]H)(-[0]OH)}
1526 \definesubmol{y}{(-[0]H)(-[4]OH)}
1527 \chemfig{[2]OH-[3]-!x-!x-!y-!x-=[1]O}|
1528
1529 \subsubsection{``Chair'' representation}
1530 We will depict the $\alpha$-D-glucose molecule:
1531 \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)}
1532
1533 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$.
1534 \exemple{Structure}|
1535 \chemfig{?-[:-50]-[:10]-[:-10]-[:130]O-[:190]?}|
1536
1537 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:
1538 \exemple{Chair representation}|\chemfig{?(-[:190]OH)-[:-50](-[:170]OH)-[:10](-[:-55,0.7]OH)
1539 -[:-10](-[6,0.7]OH)-[:130]O-[:190]?(-[:150,0.7]-[2,0.7]OH)}|
1540
1541 \subsubsection{Haworth projection}
1542 The goal is to depict this D-glucopyranose molecule:
1543 \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)}
1544
1545 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]/''.
1546
1547 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:
1548 \exemple{Structure}|\chemfig[cram width=2pt]{HO-[2,0.5,2]?<[7,0.7]-[,,,,
1549 line width=2pt]>[1,0.7]-[3,0.7]O-[4]?}|
1550
1551 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:
1552 \exemple{Projection de Haworth}|\chemfig[cram width=2pt]{HO-[2,0.5,2]?<[7,0.7](-[2,0.5]OH)-[,,,,
1553 line width=2pt](-[6,0.5]OH)>[1,0.7](-[6,0.5]OH)-[3,0.7]
1554 O-[4]?(-[2,0.3]-[3,0.5]OH)}|
1555
1556 \subsection{Adrenaline}
1557 We want to draw the adrenaline molecule:
1558 \chemfig{*6((-HO)-=-(-(<[::60]OH)-[::-60]-[::-60,,,2]HN-[::+60]CH_3)=-(-HO)=)}
1559
1560 We are going to use two different methods.
1561
1562 \subsubsection{Using one ring}
1563 First of all, we start with a 6-ring and we draw the start of the branches which leave it:
1564 \exemple[60]{Skeleton of adrenaline}|\chemfig{*6((-HO)-=-(-)=-(-HO)=)}|
1565
1566 The branch on the right still needs to be completed using, for example, relative angles:
1567 \exemple[60]{Adrenaline, step two}|\chemfig{*6((-HO)-=-(--[::-60]-[::-60]
1568 HN-[::+60]CH_3)=-(-HO)=)}|
1569
1570 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:
1571 \exemple[60]{Adrenaline}|\chemfig{*6((-HO)-=-(-(<[::60]OH)-[::-60]-[::-60,,,2]
1572 HN-[::+60]CH_3)=-(-HO)=)}|
1573
1574 \subsubsection{Using two rings}
1575 This method is less natural, but the goal is to show here how to make a bond invisible.
1576
1577 We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-rings adjacent to each other:
1578 \exemple[60]{Adrenaline, two-ring skeleton}|\chemfig{*6((-HO)-=*6(--HN---)-=-(-HO)=)}|
1579
1580 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:
1581 \exemple[60]{Adrenaline, step two}|\definesubmol{&}{-[,,,,draw=none]}
1582 \chemfig{*6((-HO)-=*6(!&!&HN---)-=-(-HO)=)}|
1583
1584 The rest becomes easy; just add the branches to the right vertices:
1585 \exemple[60]{Adrenaline, step three}|\definesubmol{&}{-[,,,,draw=none]}
1586 \chemfig{*6((-HO)-=*6(!&!&HN(-CH_3)--(<OH)-)-=-(-HO)=)}|
1587
1588 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-'':
1589 \exemple[60]{Adrenaline}|\definesubmol{&}{-[,,,,draw=none]}
1590 \definesubmol{&&}{-[,,,2,draw=none]}
1591 \chemfig{*6((-HO)-=*6(!&!{&&}HN(-CH_3)-[,,2]-(<OH)-)-=-(-HO)=)}|
1592
1593 \subsection{Guanine}
1594 We will draw the guanine molecule:
1595 \chemfig{*6((-H_2N)=N-*6(-\chembelow{N}{H}-=N?)=?-(=O)-HN-[,,2])}\medskip
1596
1597 First of all, let's begin by drawing the nested rings, putting just the nitrogen atoms at the vertices:
1598 \exemple{Guanine, skeleton}|\chemfig{*6(=N-*6(-N-=N)=--N-)}|
1599
1600 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:
1601 \exemple{Guanine, step two}|\chemfig{*6(=N-*6(-\chembelow{N}{H}-=N?)=?--HN-)}|
1602
1603 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]-'':
1604 \exemple{Guanine, step three}|\chemfig{*6(=N-*6(-\chembelow{N}{H}-=N?)=?--HN-[,,2])}|
1605
1606 Simply add the branches to the right vertices. Note especially the branch leaving the first vertex of the first 6-ring ``\verb/(-N_2N)/'':
1607 \exemple{Guanine}|\chemfig{*6((-H_2N)=N-*6(-\chembelow{N}{H}-=N?)=?-(=O)-HN-[,,2])}|
1608
1609 We could also draw the same molecule with a regular 5-ring, as is sometimes done:
1610 \exemple{Guanine with 5-ring}|\chemfig{*6((-H_2N)=N-*5(-\chembelow{N}{H}-=N-)=-(=O)-HN-[,,2])}|
1611
1612 \section{How to \protect\ldots}
1613 \subsection{Write a colored atom}
1614 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.
1615
1616 \exemple{Colors}/\chemfig{C\color{blue}H_3-C(=[1]O)-[7]O\color{red}H}/
1617
1618 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:
1619
1620 \exemple{Colors}/\chemfig{C|{\color{blue}H_3}-C(=[1]O)-[7]O|{\color{red}H}}/
1621
1622 The same effect can be obtained with \verb-\textcolor-:
1623
1624 \exemple{Colors}/\chemfig{C|\textcolor{blue}{H_3}-C(=[1]O)-[7]O|\textcolor{red}{H}}/
1625
1626 The main disadvantage is that we have to do the same for every atom that need to be colored, even if they are contiguous.
1627
1628 \subsection{Add a superscript without modifying a bond}
1629 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:
1630 \exemple{Charge and bond}/\chemfig{A^+-[2]B}
1631 \qquad
1632 \chemfig{A\rlap{${}^+$}-[2]B}/
1633
1634 The macro \verb|\charge| allows this task to be performed simply and accurately.
1635 \exemple{Placing charges}/\chemfig{\charge{[extra sep=0pt]45[anchor=180+\chargeangle]=%
1636 $\scriptstyle\oplus$}{A}-[2]B}
1637 \qquad
1638 \chemfig{*5(---\charge{90:2pt=$\scriptstyle\oplus$}{}-%
1639 \charge{135:2pt=$\scriptstyle-$}{}-)}/
1640
1641 \subsection{Draw a curve bond}
1642 We have already seen that with the \TIKZ library ``\verb-decorations.pathmorphing-'', we can draw a wavy bond:
1643
1644 \exemple{Wavy bond}|\chemfig{A-[,3,,,decorate,decoration=snake]B}
1645
1646 \chemfig{A-[,3,,,decorate,decoration={snake,amplitude=1.5mm,
1647 segment length=2.5mm}]B}|
1648
1649 It is also possible to define a "wb" sub-molecule to draw a wavy bond perpendicular to the previous bond:
1650
1651 \exemple{Wavy bond}|\definesubmol{wb}{%
1652 (-[::90,.5,,,draw=none]%
1653 -[::180,,,,blue,decorate,decoration={%
1654 snake,amplitude=0.2mm,segment length=0.75mm
1655 }%
1656 ])}
1657 \chemfig{!{wb}-O-[:60]}
1658 \qquad
1659 \chemfig{([:150]-!{wb})([:-90]-!{wb})=_[:30]-[:-30]!{wb}}
1660 |
1661
1662 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:
1663
1664 \exemple{Curved bonds}/\chemfig{@{a}A-[,,,,draw=none]@{b}B}
1665 \chemmove{\draw[-](a)..controls +(45:7mm) and +(225:7mm)..(b);}
1666 \bigskip
1667
1668 \chemfig{*6(@{a}---@{b}---)}
1669 \chemmove{\draw[-](a)..controls +(60:3em) and +(240:3em)..(b);}
1670 \quad
1671 \chemfig{*6(@{a}---@{b}---)}
1672 \chemmove{\draw[-](a)..controls +(60:3em) and +(30:1em)..
1673 ++(20:2em) ..controls +(210:3em) and +(-120:4em) ..(b);}/
1674
1675 \subsection{Draw a polymer element}\label{polymerdelim}
1676 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:
1677 \begin{center}
1678 \Verb|\polymerdelim[<keys>=<values>]{<node1>}<node2>}|
1679 \end{center}
1680
1681 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.
1682 \begin{center}
1683 \begin{tabular}{rlp{8cm}}\hline
1684 \chevrons{keys} & default \chevrons{values} & Action\\\hline
1685 \CFdelimparam{delimiters} & Defines the delimiters. If these delimiters are brackets, write \verb|delimiters={[]}|.\\
1686 \CFdelimparam{height} & Defines the height (above the node) of the delimiters.\\
1687 \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.\\
1688 \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.\\
1689 \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.\\
1690 \CFdelimparam{rotate}&When \CFkv{h align}{false} and \CFkv{auto rotate}{false}, sets the rotation angle of the two delimiters.\\
1691 \CFdelimparam{open xshift}& Defines the horizontal offset of the opening delimiter.\\
1692 \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.\\
1693 \CFdelimparam{indice} & Defines the indices that will be placed at the right bottom of the closing delimiter.\\\hline
1694 \end{tabular}
1695 \end{center}
1696 \exemple*{Polymers}|Polyethylen:
1697 \chemfig{\vphantom{CH_2}-[@{op,.75}]CH_2-CH_2-[@{cl,0.25}]}
1698 \polymerdelim[height = 5pt, indice = \!\!n]{op}{cl}
1699 \bigskip
1700
1701 Polyvinyl chloride:
1702 \chemfig{\vphantom{CH_2}-[@{op,1}]CH_2-CH(-[6]Cl)-[@{cl,0}]}
1703 \polymerdelim[height = 5pt, depth = 25pt, open xshift = -10pt, indice = \!\!n]{op}{cl}
1704 \bigskip
1705
1706 Nylon 6:
1707 \chemfig{\phantom{N}-[@{op,.75}]{N}(-[2]H)-C(=[2]O)-{(}CH_2{)_5}-[@{cl,0.25}]}
1708 \polymerdelim[height = 30pt, depth = 5pt, indice = {}]{op}{cl}
1709 \bigskip
1710
1711 Polycaprolactame
1712 \chemfig[atom sep = 2em]{[:-30]-[@{left,.75}]N(-[6]H)-[:30](=[2]O)--[:30]--[:30]--[@{right,0.25}:30]}
1713 \polymerdelim[height = 5pt, indice = \!\!n]{left}{right}
1714 \bigskip
1715
1716 Polyphenyl sulfide:
1717 \chemfig{\vphantom{S}-[@{op,.75}]S-(**6(---(-[@{cl,0.25}])---))}
1718 \polymerdelim[delimiters = (), height = 15pt, indice = {}]{op}{cl}
1719 \bigskip
1720
1721 \chemfig{-CH_2-CH([6]-CO-NH-CH_2-NH-CO-CH([4]-CH_2-)([0]-[@{downleft,0.8},2]CH_2
1722 -CH([2]-CO-NH_2)-[@{downright,0.3},2]CH_2-[,1.5]C?H-))-[@{upleft,0.8},2]CH_2
1723 -CH([6]-CO-NH_2)-[@{upright,0.3},2]CH_2-[,1.5]CH([6]-CO-NH-CH_2-NH-C?O)-}
1724 \polymerdelim[delimiters ={[]}, height = 5pt, depth = 40pt, indice = n]{upleft}{upright}
1725 \polymerdelim[delimiters ={[]}, height = 40pt, depth = 5pt, indice = n]{downleft}{downright}
1726
1727 \chemfig{-[@{op,.5}:-30]O-[::60](=[::60]O)-[::-60]*6(-=-(-(=[::-60]O)-[::60]O-[::-60]-[::60]-[@{cl,.5}::-60])=-=)}
1728 \polymerdelim[height=6ex, indice=n, h align=false]{op}{cl}|
1729
1730 \subsection{Draw the symmetrical of a molecule}\label{retournement}
1731 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.
1732
1733 \exemple{Symmetry}/\chemfig{H_3C-C(=[:30]O)-[:-30]OH}% original
1734
1735 \vflipnext
1736 \chemfig{H_3C-C(=[:30]O)-[:-30]OH}\medskip
1737
1738 \chemfig{H_3C-C(=[:30]O)-[:-30]OH}% original
1739 \hflipnext
1740 \chemfig{H_3C-C(=[:30]O)-[:-30]OH}/
1741
1742 \subsection{Add text above bonds and arc to angles}
1743 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.
1744
1745 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.
1746
1747 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.
1748
1749 \exemple*{Arcs and text on bonds}|\newcommand\angstrom{\mbox{\normalfont\AA}}
1750 \newcommand\namebond[4][5pt]{\chemmove{\path(#2)--(#3)node[midway,sloped,yshift=#1]{#4};}}
1751
1752 \newcommand\arcbetweennodes[3]{%
1753 \pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}%
1754 \let#3\pgfmathresult}
1755
1756 \newcommand\arclabel[6][stealth-stealth,shorten <=1pt,shorten >=1pt]{%
1757 \chemmove{%
1758 \arcbetweennodes{#4}{#3}\anglestart \arcbetweennodes{#4}{#5}\angleend
1759 \draw[#1]([shift=(\anglestart:#2)]#4)arc(\anglestart:\angleend:#2);
1760 \pgfmathparse{(\anglestart+\angleend)/2}\let\anglestart\pgfmathresult
1761 \node[shift=(\anglestart:#2+1pt)#4,anchor=\anglestart+180,rotate=\anglestart+90,inner sep=0pt,
1762 outer sep=0pt]at(#4){#6};}}
1763
1764 \chemfig{@{a}A=[:30,1.5]@{b}B-[7,2]@{c}C-@{d}D}
1765 \namebond{a}{b}{\scriptsize My text}
1766 \namebond[-3.5pt]{b}{c}{\small\color{red}$\pi$}
1767 \namebond{c}{d}{\small1 \angstrom}
1768 \medskip
1769
1770 Horizontal water molecule: \chemfig{@{1}H-[::37.775,2]@{2}O-[::-75.55,2]@{3}H}.
1771 \namebond{1}{2}{\footnotesize0.9584 \angstrom}
1772 \namebond{2}{3}{\footnotesize0.9584 \angstrom}
1773 \arclabel{0.5cm}{1}{2}{3}{\footnotesize104.45\textdegree}
1774 \qquad
1775 Water molecule rotated 30\textdegree: \chemfig{[:30]@1H-[::37.775,2]@2O-[::-75.55,2]@3H}
1776 \namebond12{\footnotesize0.9584 \angstrom}
1777 \namebond23{\footnotesize0.9584 \angstrom}
1778 \arclabel{0.5cm}{1}{2}{3}{\footnotesize104.45\textdegree}|
1779
1780 \subsection{Dessiner des liaisons multiples}
1781 Again, the ``decorations.markings'' library allows to draw multiple bonds:
1782
1783 \exemple*{Liaisons multiples}|\catcode`_=11
1784 \tikzset{nbond/.style args={#1}{%
1785 draw=none,%
1786 decoration={%
1787 markings,%
1788 mark=at position 0 with {\coordinate (CFstart@) at (0,0);},
1789 mark=at position 1 with {%
1790 \foreach\CF_i in{0,1,...,\number\numexpr#1-1}{%
1791 \pgfmathsetmacro\CF_nbondcoeff{\CF_i-0.5*(#1-1)}%
1792 \draw ([yshift=\CF_nbondcoeff\CF_doublesep]CFstart@)--(0,\CF_nbondcoeff\CF_doublesep);
1793 }%
1794 }
1795 },
1796 postaction={decorate}
1797 }
1798 }
1799 \catcode`\_=8
1800 \chemfig{A-[1,,,,nbond=4]B-[:-30,,,,nbond=5]C-[6,,,,nbond=6]D}|
1801
1802 \part{Reaction schemes}\label{schemas}
1803 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.
1804
1805 I thank Clemens \textsc {Niederberger} for his help and the tests he carried out on the new features presented in this part.
1806 \section{Overview}\label{schemestart}
1807 A reaction scheme has the following syntax:
1808
1809 \begin{center}
1810 \Verb|\schemestart[angle,coeff,style][position] <reaction> \schemestop|
1811 \end{center}
1812
1813 {\color{red}\textbf{Important}}: one of the next versions will change the syntax of optional arguments. The second will be removed, and the first will be used to contain a list of \CFkv{keys}{values}. It is therefore advisable to use the following \chevrons{keys} to make the settings allowed by the optional arguments: \CFkey{arrow angle}, \CFkey{arrow coeff}, \CFkey{arrow style}, and \CFkey{init anchor}.
1814
1815 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}:
1816 \exemple[50]{Example 1}/\setchemfig{scheme debug=false}
1817 \schemestart
1818 \chemfig{*6(-=-=-=)}\arrow
1819 \chemfig{X=[1]Y}\arrow
1820 \chemfig{S>T}
1821 \schemestop
1822 \bigskip
1823
1824 \setchemfig{scheme debug=true}
1825 \schemestart
1826 \chemfig{*6(-=-=-=)}\arrow
1827 \chemfig{X=[1]Y}\arrow
1828 \chemfig{S>T}
1829 \schemestop/
1830
1831 Some comments:
1832 \begin{itemize}
1833 \item the \falseverb{\arrow} commands draw the arrows;
1834 \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;
1835 \item arrows are plotted horizontally, this can obviously be modified;
1836 \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;
1837 \item debug information is displayed with the \CFkey{scheme debug} \chevrons{key}. It consists of:
1838 \begin{itemize}
1839 \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.
1840 \item display of the compounds bounding boxes;
1841 \item the arrows start and end points represented by red points and anchors by blue points;
1842 \end{itemize}
1843 \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;
1844 \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}
1845 \end{itemize}
1846
1847 Here is the complete list of parameters for the \verb|\schemestart| macro, their default values, and a brief description\label{listeparametresschemestart}. These parameters must be set using the \Verb|\setchemfig{<keys>=<values>}| macro.
1848
1849 \begin{center}
1850 \begin{longtable}{rcp{7.5cm}}\hline
1851 \chevrons{keys} & Default \chevrons{values} & Description\\\hline\endhead
1852 \CFparam{schemestart code}{ccode executed at the very beginning of a non nested reaction scheme}
1853 \CFparam{schemestop code}{code executed at the very end of a non-nested
1854 reaction scheme}
1855 \CFparam{scheme debug}{if \CFval{true}, show nodes, names and anchors}
1856 \CFparam{compound style}{style of compounds}
1857 \CFparam{compound sep}{space between compounds}
1858 \CFparam{name sep}{minimum vertical distance between the compound boxes and its name}
1859 \CFparam{arrow offset}{space between compound and arrow}
1860 \CFparam{arrow angle}{ angle of the reaction arrow}
1861 \CFparam{arrow coeff}{length ratio of arrows}
1862 \CFparam{arrow style}{style of arrows}
1863 \CFparam{arrow double sep}{space between double arrows}
1864 \CFparam{arrow double coeff}{ shrinkage ratio for the little arrow in
1865 ”\falseverb{<->>}” and ”\falseverb{<<->}”}
1866 \CFparam{arrow double harpoon}{boolean for double harpoon arrows}
1867 \CFparam{arrow label sep}{ space between arrow and its label}
1868 \CFparam{arrow head}{style of arrow head}
1869 \CFparam{+ sep left}{space before the $+$ sign}
1870 \CFparam{+ sep right}{space after the $+$ sign}
1871 \CFparam{+ vshift}{vertical shift of the $+$ sign}
1872 \hline
1873 \end{longtable}
1874 \end{center}
1875
1876 \textbf{\color{red}Important}: for consistency, the next version of \CF will require a change in the syntax of \verb|\schemestart|. The two optional arguments will be removed for a single optional argument containing \Verb|<keys>=<values>|. The settings that were possible with the two optional arguments will be accessible with new \Verb|<keys>|.
1877
1878 \section{Arrow types}\label{arrow}
1879 When the \falseverb{\arrow} command is followed by an optional argument in braces (which is not mandatory), the argument defines the type of arrow:
1880 \exemple[50]{Arrow types}|\schemestart A\arrow{->}B\schemestop\par % by default
1881 \schemestart A\arrow{-/>}B \schemestop\par
1882 \schemestart A\arrow{<-}B \schemestop\par
1883 \schemestart A\arrow{<->}B \schemestop\par
1884 \schemestart A\arrow{<=>}B \schemestop\par
1885 \schemestart A\arrow{<->>}B \schemestop\par
1886 \schemestart A\arrow{<<->}B \schemestop\par
1887 \schemestart A\arrow{0}B \schemestop\par
1888 \schemestart A\arrow{-U>}B \schemestop|
1889 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
1890
1891 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.
1892
1893 \section{Arrows features}
1894 Each \falseverb{arrow} is characterized by:
1895 \begin{itemize}
1896 \item an angle expressed in degrees;
1897 \item a coefficient that specifies the arrow length through the multiplication of the compounds spacing value defined by \CFkey{compound sep};
1898 \item a style with \TIKZ instructions to customize the color, the thickness or other graphical attribute of the arrow.
1899 \end{itemize}
1900
1901 These features are defined with the \chevrons{keys}
1902 \begin{itemize}
1903 \item \CFkv{arrow angle}{angle}, which default value is 0;
1904 \item \CFkv{arrow coeff}{decimal}, which default value is 1;
1905 \item \CFkv{arrow style}{code tikz}, empty by default.
1906 \end{itemize}
1907
1908 \exemple[50]{Definition of default values}/\schemestart A\arrow B\arrow C\schemestop
1909
1910 \setchemfig{arrow angle=15,arrow coeff=1.5,
1911 arrow style={red, thick}}
1912 \schemestart A\arrow B\arrow C\schemestop
1913
1914 \setchemfig{arrow coeff=2.5,arrow style=dashed}
1915 \schemestart A\arrow B\arrow C\schemestop
1916
1917 \setchemfig{arrow angle={},arrow coeff={},arrow style={}}
1918 \schemestart A\arrow B\arrow C\schemestop/
1919
1920 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:
1921 \exemple[50]{Optional argument}/\setchemfig{arrow angle=5,arrow coeff=2.5,arrow style=blue}
1922 \schemestart A\arrow B\arrow C\schemestop
1923
1924 \schemestart[0] A\arrow B\arrow C\schemestop
1925
1926 \schemestart[0,1] A\arrow B\arrow C\schemestop
1927
1928 \schemestart[0,1,thick] A\arrow B\arrow C\schemestop
1929
1930 \schemestart[0,1,black] A\arrow B\arrow C\schemestop/
1931
1932 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.
1933
1934 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.
1935 \exemple[50]{Arrows features}/\schemestart
1936 A\arrow[45]B\arrow[-20,2]C
1937 \schemestop
1938 \bigskip
1939
1940 \schemestart
1941 A\arrow[90,,thick]B\arrow[,2]C
1942 \arrow[-45,,dashed,red]D
1943 \schemestop/
1944
1945 \section{Compounds names}
1946 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.
1947
1948 Names are optional, and the argument can be either \verb/(n1--)/ and \verb/(--n2)/.
1949
1950 \exemple[50]{Compounds names}/\setchemfig{scheme debug=true}
1951 \schemestart
1952 A\arrow(aa--bb)B\arrow(--cc)C\arrow(--dd)D\arrow E
1953 \schemestop
1954 \bigskip
1955
1956 \schemestart
1957 A\arrow(aa--)B\arrow(bb--)C\arrow(cc--dd)D\arrow E
1958 \schemestop/
1959 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:
1960 \exemple[50]{Overfull naming}/\setchemfig{scheme debug=true}
1961 \schemestart
1962 A\arrow(--foo)B\arrow(bar--)C
1963 \schemestop/
1964 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:
1965
1966 \hfill\verb-Package chemfig Warning: two names for the same node, first name "foo" ignored-\hfill\null
1967
1968 \section{Anchoring}
1969 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:
1970
1971 \hfill\verb/(n1.a1--n2.a2)/\hfill\null
1972
1973 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:
1974 \exemple*{TikZ anchoring}|\Huge
1975 \begin{tikzpicture}[baseline]
1976 \node[anchor=base west,name=x,draw,inner sep=25pt] {\color{lightgray}Rectangle\vrule width 1pt height 2cm};
1977 \foreach \anchor/\placement in
1978 {north west/above left, north/above, north east/above right,west/left, center/above, east/right,
1979 mid west/left, mid/above, mid east/right,base west/left, base/below, base east/right,
1980 south west/below left, south/below, south east/below right,text/below,10/right,45/above,150/left}
1981 \draw[shift=(x.\anchor)] plot[mark=x] coordinates{(0,0)}
1982 node[\placement,inner sep=0pt,outer sep=2pt] {\scriptsize\texttt{(\anchor)}};
1983 \end{tikzpicture}|
1984 Like for names, arrival and departure anchoring points are independent and optional.
1985
1986 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:
1987 \exemple[50]{Alignment problems}/\setchemfig{scheme debug=true}
1988 \schemestart
1989 \chemfig{A*5(-----)}
1990 \arrow
1991 \chemfig{A*5(---(-)--)}
1992 \schemestop/
1993 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'':
1994 \exemple[50]{Alignment problems}/\setchemfig{scheme debug=true}
1995 \schemestart
1996 \chemfig{A*5(-----)}
1997 \arrow(.base east--.base west)
1998 \chemfig{A*5(---(-)--)}
1999 \schemestop
2000 \bigskip
2001
2002 \schemestart
2003 \chemfig{A*5(-----)}
2004 \arrow(foo.mid east--bar.mid west)
2005 \chemfig{A*5(---(-)--)}
2006 \schemestop/
2007
2008 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:
2009 \exemple[50]{Initial anchoring}/\setchemfig{scheme debug=true}
2010 Preceding text:
2011 \schemestart
2012 \chemfig{A*5(-----)}\arrow A
2013 \schemestop/
2014
2015 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:
2016 \exemple[50]{Adjusting the initial anchoring}/\setchemfig{scheme debug=true}
2017 Preceding text:
2018 \schemestart[][south]
2019 \chemfig{A*5(-----)}\arrow A
2020 \schemestop
2021 \bigskip
2022
2023 Preceding text:
2024 \schemestart[][north west]
2025 \chemfig{A*5(-----)}\arrow A
2026 \schemestop
2027 \bigskip
2028
2029 Preceding text:
2030 \schemestart[][west]
2031 \chemfig{A*5(-----)}\arrow A
2032 \schemestop/
2033
2034 \section{Compounds style}
2035 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:
2036
2037 \hfill\verb/\arrow(n1.a1[s1]--n2.a2[s2]){arrow type}[angle,coeff,arrow style]/\hfill\null
2038
2039 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.
2040
2041 \exemple[60]{Compounds style}/\schemestart
2042 A
2043 \arrow([red]--[fill=blue,semitransparent,text opacity=1,
2044 inner sep=10pt,rounded corners=2mm])
2045 B
2046 \schemestop
2047 \bigskip
2048
2049 \schemestart
2050 A\arrow(--foo[yshift=5mm])B
2051 \schemestop/
2052
2053 \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.
2054
2055 Here a style is defined with round corner-shaped boxes and semitransparent background:
2056 \exemple[50]{Global styles}/\setchemfig{compound style={draw,line width=0.8pt,
2057 semitransparent,text opacity=1,inner sep=8pt,
2058 rounded corners=1mm}}
2059 \schemestart
2060 A\arrow([fill=red]--[fill=blue])[90]
2061 B\arrow(--[fill=gray])
2062 C\arrow(--[fill=green])[-90]
2063 D\arrow(--[draw=none])[-180]
2064 \schemestop/
2065
2066 \section{Branching}
2067 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:
2068 \begin{itemize}
2069 \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;
2070 \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;
2071 \item \verb/(n1--@n2)/: this syntax is not permitted;
2072 \end{itemize}
2073
2074 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'':
2075 \exemple[50]{Branching}/\schemestart
2076 A\arrow(aa--bb)B\arrow(--cc)C\arrow D
2077 \arrow(@bb--xx1)[-90]X\arrow[-90]Y% 1st branch
2078 \arrow(@c4--)[-90]Z\arrow W% 2nd branch
2079 \arrow(@xx1--xx2)[-45]XX% 3rd branch
2080 \arrow(@xx2--@c4)% XX-to-D arrow
2081 \schemestop/
2082
2083 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'':
2084 \exemple[50]{Branching}/\schemestart
2085 A\arrow(aa--bb)B\arrow(--cc)C\arrow D
2086 \arrow(@bb--xx1)[-90]X\arrow[-90]Y\arrow(--xx2){0}XX
2087 \arrow(@c4--)[-90]Z\arrow W
2088 \arrow(@xx1--@xx2)% X-to-XX arrow
2089 \arrow(@xx2--@c4)% XX-to-D arrow
2090 \schemestop/
2091
2092 \section{Subscheme}\label{subscheme}
2093 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>'':
2094 \exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
2095 \schemestart
2096 A\arrow
2097 \subscheme{B\arrow[-90,2]C}
2098 \arrow
2099 D
2100 \schemestop/
2101 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:
2102 \exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
2103 \schemestart
2104 A\arrow(--.mid west)
2105 \subscheme{B\arrow[-90,2]C}
2106 \arrow
2107 D
2108 \schemestop/
2109 Note that since ``\falseverb\subscheme\Verb-{<scheme>}-'' is only a convenient shortcut for
2110 \begin{center}
2111 \falseverb\schemestart\Verb-<scheme>-\falseverb\schemestop
2112 \end{center}
2113 Consequently, it can be used with the same optional arguments as \falseverb\schemestart.
2114
2115 \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-:
2116 \begin{center}
2117 \Verb/\chemleft<car1><material>\chemright<car2>/
2118 \end{center}
2119 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.
2120 \exemple{The \string\chemleft\ and \string\chemright macros}/\chemleft\lfloor\chemfig{A-[1]B}\chemright)
2121
2122 \chemleft\{\chemfig{A-[1,1.25]B-[6,1.25]C}\chemright|
2123
2124 \chemleft[\chemfig{H-[1]O-[7]H}\chemright]/
2125 The code of the reaction scheme discussed above including \falseverb{\chemleft} and \falseverb{\chemright} is written:
2126 \exemple{Reaction scheme with \string\chemleft\ and \string\chemright}/\schemestart
2127 A\arrow
2128 \chemleft[\subscheme{B\arrow[-90,2]C}\chemright]
2129 \arrow
2130 D
2131 \schemestop/
2132 \label{chemup}By analogy, the macros \falseverb{\chemup} and \falseverb{\chemdown} can be used to draw expandable delimiters above and below the material, respectively:
2133 \begin{center}
2134 \Verb/\chemup<car1><material>\chemdown<car2>/
2135 \end{center}
2136 For example:
2137 \exemple{The \string\chemup\ and \string\chemdown macros}/\schemestart[-90]
2138 X\arrow
2139 \chemup\{\chemfig{A-[1]B-[7]C}\chemdown\}
2140 \arrow Y
2141 \schemestop
2142 \qquad
2143 \schemestart[-90]
2144 X\arrow
2145 \chemup[\chemfig{A-[1]B-[7]C}\chemdown]
2146 \arrow Y
2147 \schemestop/
2148
2149 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:
2150
2151 \hfill\verb-\usetikzlibrary{matrix}-\hfill\null
2152
2153 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.
2154
2155 The same brackets-delimited subscheme as above is presented again:
2156 \exemple[50]{The ``matrix'' library delimiters}/\schemestart
2157 A\arrow(--[left delimiter={[}, right delimiter={]}])
2158 \subscheme{B\arrow[-90,2]C}
2159 \arrow
2160 D
2161 \schemestop/
2162 Since the delimiters are drawn outside the bounding box, it is advisable to slightly shorten the incoming and outgoing arrows:
2163 \exemple[50]{Subscheme}/\schemestart
2164 A\arrow(--[left delimiter={[},
2165 right delimiter={]}])[,,shorten >=6pt]
2166 \subscheme{B\arrow[-90,2]C}
2167 \arrow[,,shorten <=6pt]
2168 D
2169 \schemestop/
2170
2171 Subschemes should be used with care, undesired results are sometimes observed. In this example, a subscheme is used to horizontally align 3 different compounds:
2172 \exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
2173 \schemestart
2174 A
2175 \arrow{0}[-90]
2176 \subscheme{%
2177 tagada\arrow{}
2178 tsoin\arrow{}
2179 fin}
2180 \arrow(xx--yy){}E
2181 \arrow(@c1--@c3){}
2182 \arrow(@c1--@c5){}
2183 \arrow(@c1--@c4){}
2184 \schemestop/
2185 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.
2186
2187 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.
2188 \exemple[50]{Subscheme}/\setchemfig{scheme debug=true}
2189 \schemestart
2190 A
2191 \arrow(--tsoin){->}[-90]
2192 tsoin
2193 \arrow{<-}[180]
2194 tagada
2195 \arrow(@tsoin--fin){}
2196 fin
2197 \arrow{}
2198 E
2199 \arrow(@c1--@c3){}
2200 \arrow(@c1--@fin){}
2201 \schemestop/
2202
2203 \section{Arrows optional arguments}\label{fleche.arg.optionnel}
2204 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:
2205 \begin{itemize}
2206 \item the arrows ``\verb|->|'', ``\verb|<-|'', ``\verb|<->|'', ``\verb|<=>|'', ``\verb|<<->|'',``\verb|<->>|'', ``\verb|-/>|'' have three optional arguments:
2207 \begin{itemize}
2208 \item the first one contains the ``label'' to be placed above the arrow;
2209 \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.
2210 \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.
2211 \end{itemize}
2212 \item the ``\verb|-U>|'' arrow has 5 optional arguments:
2213 \begin{itemize}
2214 \item the first three are identical to those found in the other arrow types;
2215 \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;
2216 \item the fifth one is the half-angle from the center of the arc path, it is 60 degrees by default.
2217 \end{itemize}
2218 \item the invisible arrow ``\verb-0-'' accepts two optional arguments of the same type as the first two listed above;
2219 \end{itemize}
2220 \exemple[50]{Arrows optional arguments}/\setchemfig{scheme debug=false}
2221 \schemestart A\arrow{->[up][down]}B \schemestop
2222 \qquad
2223 \schemestart A\arrow{->[up][down][4pt]}B \schemestop
2224 \qquad
2225 \schemestart A\arrow{->[up][down][-4pt]}B \schemestop
2226 \medskip
2227
2228 \schemestart A\arrow{<=>[up][down]}[30,1.5]B \schemestop
2229 \medskip
2230
2231 \schemestart[-20]
2232 A\arrow{->}B\arrow{->[][][3pt]}C\arrow{->[][][-3pt]}D
2233 \schemestop/
2234 A problem arises for vertical arrows:
2235 \exemple[50]{Vertical arrows}/\schemestart
2236 A\arrow{->[up][down]}[-90]B
2237 \schemestop/
2238 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:
2239 \exemple[55]{Choice of angles}/\setchemfig{scheme debug=true}
2240 \schemestart A\arrow{->[*{0}up][*{0}down]}[90]B\schemestop
2241 \qquad
2242 \schemestart A\arrow{->[*{0}up][*{0}down]}[45]B\schemestop
2243 \qquad
2244 \schemestart A\arrow{->[*{0}up][*{0}down]}[-45]B\schemestop
2245 \qquad
2246 \schemestart A\arrow{->[*{0}up][*{0}down]}[-90]B\schemestop/
2247 The default position of the label anchor can lead to undesired results:
2248 \exemple[50]{Anchors}/\setchemfig{scheme debug=true}
2249 \schemestart
2250 A\arrow{->[*{0}on top of][*{0}underneath]}[45,2]B
2251 \schemestop/
2252 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>}-.
2253 \exemple[50]{Anchors}/\setchemfig{scheme debug=true}
2254 \schemestart
2255 A\arrow{->[*{0.0}on top of][*{0.180}underneath]}[45,2]B
2256 \schemestop
2257 \qquad
2258 \schemestart
2259 A\arrow{->[*{0.south east}on top of]%
2260 [*{0.north west}underneath]}[45,2]B
2261 \schemestop/
2262
2263 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:
2264 \exemple[50]{The \texttt{-U>} arrow}/\schemestart A\arrow{-U>[123][456]}B\schemestop
2265 \qquad
2266 \schemestart A\arrow{-U>[123]}[30]B\schemestop
2267 \qquad
2268 \schemestart A\arrow{-U>[][456]}[-30]B\schemestop/
2269
2270 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:
2271 \exemple[50]{The \texttt{-U>} arrow}/\schemestart A\arrow{-U>[123][456][][0.25]}B\schemestop
2272 \qquad
2273 \schemestart A\arrow{-U>[123][456][][][90]}B\schemestop
2274 \qquad
2275 \schemestart A\arrow{-U>[123][456][][1][45]}B\schemestop/
2276 With negative values for the radius and the angle, the arc is drawn below the arrow:
2277 \exemple[50]{The \texttt{-U>} arrow}/\schemestart
2278 A\arrow{-U>[123][456][][-0.333][-60]}B
2279 \schemestop/
2280 Label angles and anchoring customization is controlled with the first two arguments, just like for other arrows:
2281 \exemple[50]{The \texttt{-U>} arrow}/\schemestart
2282 A\arrow{-U>[123][456]}[-90]B
2283 \schemestop
2284 \qquad
2285 \schemestart
2286 A\arrow{-U>[*{0.180}123][*{0.180}456]}[-90]B
2287 \schemestop/
2288
2289 \section{Arrows customization}\label{definearrow}
2290 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.
2291
2292 The \falseverb{\definearrow} command allows to build custom arrows. Its syntax is:
2293
2294 \hfill\Verb-\definearrow{<number>}{<arrow name>}{<code>}-\hfill\null
2295
2296 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.
2297
2298 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.
2299 \begin{itemize}
2300 \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;
2301 \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;
2302 \item \falseverb{\CF_arrowcurrentstyle} and \falseverb{\CF_arrowcurrentangle} contain the style and the angle of the arrow to be drawn;
2303 \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;
2304 \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:
2305 \begin{itemize}
2306 \item \verb-#1- and \verb-#5- are the labels to be written;
2307 \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;
2308 \item \verb-#3- and \verb-#7- are the ``+'' or ``-'' characters. ``+'' displays the label above the arrow, while ``-'' does it below it;
2309 \item \verb-#4- and \verb-#8- are the names of the nodes corresponding to the beginning and the end of the arrow.
2310 \end{itemize}
2311 \item arrow heads are based on ``\verb-CF-'' for a full arrow and have the ``harpoon'' option for half arrows.
2312 \end{itemize}
2313
2314 \subsection{First arrow}
2315 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.
2316
2317 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:
2318
2319 {\hskip2em\verb-\edef\pt_radius{\ifx\empty#4\empty 2pt\else #4\fi}% circle radius-\par\parskip0pt
2320 \hskip2em\verb/\expandafter\draw\expandafter[\CF_arrowcurrentstyle,-CF]/\par
2321 \hskip4em\verb/(\CF_arrowstartnode)--(\CF_arrowendnode)coordinate[midway](mid@point);/\par
2322 \hskip2em\verb-\filldraw(mid@point)circle(\pt_radius);%-}
2323
2324 The last step is to enter the labels, if any, with the folwing line:
2325
2326 \hskip2em\verb/\CF_arrowdisplaylabel{#1}{0.5}{+}{\CF_arrowstartnode}{#2}{0.5}{-}{\CF_arrowendnode}/
2327
2328 Here is the completed arrow:
2329 \exemple*{Arrow ``-.>''}/\catcode`\_11
2330 \definearrow4{-.>}{%
2331 \edef\pt_radius{\ifx\empty#4\empty 2pt\else #4\fi}% dot radius
2332 \CF_arrowshiftnodes{#3}%
2333 \expandafter\draw\expandafter[\CF_arrowcurrentstyle,-CF](\CF_arrowstartnode)--(\CF_arrowendnode)
2334 coordinate[midway](mid@point);
2335 \filldraw(mid@point)circle(\pt_radius);%
2336 \CF_arrowdisplaylabel{#1}{0.5}{+}{\CF_arrowstartnode}{#2}{0.5}{-}{\CF_arrowendnode}
2337 }
2338 \catcode`\_8
2339 \schemestart
2340 A \arrow{-.>} B \arrow{-.>[above][below][][1pt]} C \arrow{-.>[][below]}[30] D \arrow{-.>[above][][5pt][1.5pt]} E
2341 \schemestop/
2342
2343 \subsection{Curved arrow}
2344 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.
2345
2346 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:
2347
2348 {\verb/\draw[shorten <=\CF_arrowoffset,shorten >=\CF_arrowoffset,\CF_arrowcurrentstyle,-CF,/\par\parskip0pt
2349 \verb/(\CF_arrowstartname).. controls #1 ..(\CF_arrowendname);%/}
2350
2351 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:
2352 \begin{center}
2353 \verb/shorten <=\CF_arrowoffset, shorten >=\CF_arrowoffset/
2354 \end{center}
2355 this is the role the two lines after \verb-\else-.
2356
2357 So here is our curved arrow:
2358 \exemple*{Curved arrow}/\catcode`\_11
2359 \definearrow1{s>}{%
2360 \ifx\empty#1\empty
2361 \expandafter\draw\expandafter[\CF_arrowcurrentstyle,-CF](\CF_arrowstartnode)--(\CF_arrowendnode);%
2362 \else
2363 \def\curvedarrow_style{shorten <=\CF_arrowoffset,shorten >=\CF_arrowoffset,}%
2364 \CF_eaddtomacro\curvedarrow_style\CF_arrowcurrentstyle
2365 \expandafter\draw\expandafter[\curvedarrow_style,-CF](\CF_arrowstartname)..controls#1..(\CF_arrowendname);
2366 \fi
2367 }
2368 \catcode`\_8
2369 \schemestart
2370 A\arrow{s>}
2371 B\arrow{s>[+(0.5cm,0.5cm)]}
2372 C\arrow{s>[+(45:1cm)]}
2373 D\arrow(.60--.120){s>[+(60:1cm) and +(-120:1cm)]}
2374 E\arrow{s>[+(45:1) and +(-135:1)]}
2375 F\arrow{s>[+(-30:1) and +(150:1)]}[,1.5]
2376 G\arrow(.90--.90){s>[+(60:1)and+(120:1)]}[,2]
2377 H
2378 \schemestop
2379
2380 \schemestart
2381 A\arrow(.90--.180){s>[+(90:0.8) and +(180:0.8)]}[45]B
2382 \arrow(.0--.90){s>[+(0:0.8) and +(90:0.8)]}[-45]C
2383 \arrow(.-90--.0){s>[+(-90:0.8) and +(0:0.8)]}[-135]D
2384 \arrow(.180--.-90){s>[+(180:0.8) and +(-90:0.8)]}[135]
2385 \schemestop/
2386
2387 \section{The \protect\texttt{\textbackslash merge} command}
2388 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.
2389
2390 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-''.
2391
2392 The syntax follows with:
2393
2394 \hfill\verb/\merge{dir}(n1.a1)(n2.a2)(...)(ni.ai)--(n.a[s])/\hfill\null
2395
2396 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.
2397
2398 \exemple[50]{The \string\merge command}/\schemestart
2399 ABC\arrow[30]EFGHIJ\arrow[45]KLM\arrow[60]NO
2400 \merge>(c1)(c2)(c3)--()series 1
2401 \arrow series 2
2402 \schemestop
2403 \bigskip
2404
2405 \schemestart
2406 Foooo\arrow(foo--bar){<=>}Bar\arrow(--baz){<=>}Bz
2407 \merge^(foo)(bar)(baz)--()series
2408 \schemestop
2409 \bigskip
2410
2411 \setchemfig{scheme debug=true}
2412 \schemestart
2413 A\arrow{<->}[90]B
2414 \merge<(c1.120)(c2)--(foobar.45[circle,blue])CCC
2415 \schemestop/
2416
2417 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:
2418
2419 \hfill\verb/\merge{dir}(n1.a1)(n2.a2)(...)(ni.ai)--(n.a[s])[c1,c2,c,style]/\hfill\null
2420
2421 where:
2422 \begin{itemize}
2423 \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;
2424 \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;
2425 \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-^-);
2426 \item the style of the \falseverb{\merge} arrow is defined with the last argument: \verb-style-.
2427 \end{itemize}
2428
2429 \exemple*{Geometrical parameters of \string\merge}/\schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()C\schemestop\qquad
2430 \schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[1]C\schemestop\qquad
2431 \schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[,1]C\schemestop\qquad
2432 \schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[,,0.2]C\schemestop\qquad
2433 \schemestart A\arrow{<=>}[90]B\merge(c1)(c2)--()[,,0.9,red,thick]C\schemestop
2434 \bigskip
2435
2436 \schemestart A\arrow{<=>}B\merge^(c1)(c2)--()C\schemestop\qquad
2437 \schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[1]C\schemestop\qquad
2438 \schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[,1]C\schemestop\qquad
2439 \schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[,,0.2]C\schemestop\qquad
2440 \schemestart A\arrow{<=>}B\merge^(c1)(c2)--()[,,0.9,red,thick]C\schemestop/
2441
2442 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:
2443
2444 \hfill\verb/\merge{dir}[labelup][labeldow](n1.a1)(n2.a2)(...)(ni.ai)--(n.a[s])[c1,c2,c,style]/\hfill\null
2445
2446 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.
2447
2448 \exemple*{Labels of the \string\merge command}/\schemestart
2449 ABC\arrow{<=>}[90]DEF\merge>[above][below](c1)(c2)--()[0.25,1,0.75]GHIJ
2450 \schemestop\qquad
2451 \schemestart
2452 ABC\arrow{<=>}[90]DEF\merge>[*{45.south west}above][*{45.north east}below](c1)(c2)--()[0.25,1,0.75]GHIJ
2453 \schemestop\qquad
2454 \schemestart
2455 ABC\arrow{<=>}[90]DEF\merge>[*{90}above][*{90}below](c1)(c2)--()[0.25,1,0.75]GHIJ
2456 \schemestop
2457 \bigskip
2458
2459 \schemestart
2460 ABC\arrow{<=>}DEF\merge v[above][below](c1)(c2)--()[0.25,1,0.75]GHIJ
2461 \schemestop\qquad
2462 \schemestart
2463 ABC\arrow{<=>}DEF\merge v[*{45.north west}above][*{45.south east}below](c1)(c2)--()[0.25,1,0.75]GHIJ
2464 \schemestop\qquad
2465 \schemestart
2466 ABC\arrow{<=>}DEF\merge v[*{0}above][*{0}below](c1)(c2)--()[0.25,1,0.75]GHIJ
2467 \schemestop/
2468
2469 \section{The + sign}\label{signe+}
2470 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:
2471 \begin{itemize}
2472 \item \Verb-<dim1>- and \Verb-<dim2>- are the dimensions to be inserted before and after the ${}+{}$ sign;
2473 \item \Verb-<dim3>- is the vertical offset of the sign.
2474 \end{itemize}
2475
2476 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.
2477
2478 \exemple[50]{The \string\+ command}/\schemestart
2479 A\+B\+{2em,,5pt}C\+{0pt,0pt,-5pt}D\arrow E\+F
2480 \schemestop
2481
2482 \setchemfig{+ sep left=1em,+ sep right=1em,+ vshift=0pt}
2483 \schemestart
2484 A\+B\+{2em,,5pt}C\+{0pt,0pt,-5pt}D\arrow E\+F
2485 \schemestop/
2486
2487 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:
2488 \exemple[50]{Compounds and \string\+}/\setchemfig{scheme debug=true}
2489 \schemestart A\+ B\+{,,5pt}C\arrow D\+ E\schemestop/
2490 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:
2491 \exemple[50]{Subcompound and \string\+}/\setchemfig{scheme debug=true}
2492 \schemestart
2493 \subscheme{A}\+ B\arrow C
2494 \arrow(@c2--)[-90]E
2495 \schemestop
2496 \medskip
2497
2498 \schemestart
2499 A\subscheme{\+}BCDEF \arrow G
2500 \arrow(@c2--)[-90]H
2501 \schemestop/%
2502
2503 A common problem can be the misalignment of the ``+'' sign with the molecules before or after it. For example:
2504 \exemple{+ sign alignment}/\setchemfig{scheme debug=true}
2505 \schemestart
2506 \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
2507 \+
2508 \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
2509 \schemestop/
2510 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:
2511 \exemple{+ sign alignment}/\setchemfig{scheme debug=true}
2512 \schemestart[][west]
2513 \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
2514 \arrow{0}[,0]\+
2515 \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
2516 \schemestop/
2517 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:
2518 \exemple{+ sign alignment}/\setchemfig{scheme debug=true}
2519 \schemestart[][west]
2520 \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
2521 \arrow(--[yshift=-10pt]){0}[,0]\+
2522 \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
2523 \schemestop
2524 \medskip
2525
2526 \schemestart[][west]
2527 \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
2528 \arrow(.south east--.south west){0}[,0]\+
2529 \chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{0=\|,90=\|,-90=\|}{Br}}
2530 \schemestop/
2531
2532 \part{Horizontal reactions}\label{hreac}
2533 To typeset a horizontal reaction with a simpler syntax, you can use the environment “\verb|hreac|”.
2534 \begin{center}
2535 \leavevmode
2536 \vtop{%
2537 \hbox{\Verb|\hreac[<keys>=<values>]|}\kern1.25ex
2538 \hbox{\Verb| <reaction>|}\kern1.25ex
2539 \hbox{\verb|\endhreac|}
2540 }
2541 \end{center}
2542
2543 As seen previously, the options can be set with \Verb|\setchemfig{<keys>=<values>}| if you want to set them for the rest of the document.
2544
2545 To apply settings to a single reaction only, use the optional argument of the environment.
2546
2547 Here is the complete list of parameters for the \verb|\hreac| macro, their default values, and a short description\label{listeparametreshreac}.
2548 \begin{center}
2549 \begin{longtable}{rcp{7.5cm}}\\\hline
2550 Key & Default value & \hfill Description\hfill\null\\\hline
2551 \CFparam{harrow minwidth}{minimal length of an arrow}
2552 \CFparam{label xsep}{when the arrow extends to fit its labels, its length is equal to the length of the longest label plus twice that dimension}
2553 \CFparam{label align}{text alignment in arrow labels (possible values \CFval{c}, \CFval{r}, or \CFval{l})}
2554 \CFparam{name sep}{minimum vertical distance between the compound boxes and its name}
2555 \CFparam{hreac anchor}{anchor of the first compound}
2556 \CFparam{hreac sep}{horizontal space between boxes containing compounds}
2557 \CFparam{hreac debug}{if \CFval{true}, draw the boundaries of the compounds, the anchors, the node names, and the horizon line}
2558 \CFparam{arrow label sep}{for this key and the following ones, see options of \falseverb\schemestart\ page~\pageref{listeparametresschemestart}}
2559 \CFparam{arrow style}{}
2560 \CFparam{arrow double sep}{}
2561 \CFparam{arrow double coeff}{}
2562 \CFparam{arrow double harpoon}{}
2563 \CFparam{arrow label sep}{}
2564 \CFparam{arrow head}{}
2565 \hline
2566 \end{longtable}
2567 \end{center}
2568
2569 \section{Syntax}
2570 The tokens {\ttfamily\boxedfalseverb+,\boxedfalseverb>, \boxedfalseverb\> \boxedfalseverb\^} have meaning for the syntax of \Verb|<reaction>|.
2571
2572 In \Verb|<reaction>|, compounds, \verb|+| signs, and arrows may exist according to the following syntax and rules:
2573 \begin{itemize}
2574 \item a \Verb|<compound>| extends to the next occurrence of “\verb|+|”, “\verb|>|” or the end of the environment;
2575 \item in \Verb|<reaction>|, any code belonging to a \Verb|<compound>| between braces is not examined and is left as it is between braces;
2576 \item spaces are ignored (except when they are between braces, see previous point);
2577 \item a \Verb|<compound>| consists of any code except the reserved tokens seen above, unless they are between braces;
2578 \item the sign “\verb|+|” displays the sign $+$ and is a \Verb|<compound>| on its own;
2579 \item the sign “\verb|>|” displays an arrow and is a \Verb|<compound>| on its own;
2580 \end{itemize}
2581 \exemple[60]{Example 1}/
2582 \hreac
2583 \chemfig{*6(-=-=-=)}
2584 +
2585 \chemfig{X=[1]Y}
2586 +
2587 Z > X + Y
2588 \endhreac/
2589
2590 \section{Placement of compounds}\label{hreacshift}
2591 All compounds are numbered \Verb|c<n>| (where \Verb|<n>| is an integer) and are placed in boxes. The centers of all boxes are placed on the same horizontal line, which is drawn in red dots when the \verb|hreac debug| option is enabled:
2592 \exemple[60]{Vertical alignement vertical of compounds}/
2593 \hreac[hreac debug]
2594 \chemfig{*6(-=-=-=)}
2595 +
2596 \chemfig{X=[1]Y}
2597 +
2598 Z > X + Y
2599 \endhreac/
2600
2601 When \verb|\>|\Verb|{<dimension>}| is encountered at the beginning of \Verb|<compound>|, the latter is moved horizontally by \Verb|{<dimension>}|.
2602 \exemple[60]{Horizontal adjustment of compounds}/
2603 \hreac[hreac debug]
2604 \chemfig{*6(-=-=-=)}
2605 +
2606 \>{-5pt}\chemfig{X=[1]Y}
2607 +
2608 \>{5pt}Z > X + Y
2609 \endhreac/
2610
2611 When \Verb|\^{<dimension>}| is encountered at the beginning of \Verb|<compound>|, the latter (and only the latter) is moved vertically by \Verb|{<dimension>}|. In the starred version \Verb|\^*{<dimension>}|, the compound and all subsequent ones are affected.
2612 \exemple[60]{Vertical adjustment of compounds}/
2613 \hreac[hreac debug]
2614 \chemfig{*6(-=-=-=)}
2615 +
2616 \^{10pt}\chemfig{X=[1]Y}
2617 +
2618 Z > X + Y
2619 \endhreac\medbreak
2620 \hreac[hreac debug]
2621 \chemfig{*6(-=-=-=)}
2622 +
2623 \^*{10pt}\chemfig{X=[1]Y}
2624 +
2625 Z > X + Y
2626 \endhreac/
2627
2628 \section{Compound names}\label{hreacname}
2629 To display the \Verb|<name>| of a \Verb|<compound>|, either of the following syntaxes can be used:
2630 \begin{itemize}
2631 \item \Verb|\chemname[<dimension>]{<compound>}{<name>}|;
2632 \item \Verb|<compound>\name[<dimension>]{<name>}| or \Verb|\name[<dimension>]{<name>}<compound>|, the order of appearance being irrelevant
2633 \end{itemize}
2634
2635 The optional \Verb|<dimension>| is the minimum distance between the \Verb|<compound>| box and the \Verb|<name>| box. When omitted, its default value is the value of the \CFkey{name sep} key.
2636
2637 All names are numbered \Verb|name<n>| where \Verb|<n>| is the integer corresponding to \Verb|<compound>|. They are placed in boxes whose width is that of \Verb|<compound>|. The upper borders of these boxes on the same horizontal line are positioned vertically so as to be below the compound with the greatest depth.
2638 \exemple[60]{Names of compounds}/
2639 \hreac[hreac debug]
2640 \chemfig{*6(-=-=-=)}\name{cycle}
2641 +
2642 \chemfig{X=[1]Y}\name{nom}
2643 +
2644 Z > X + Y
2645 \endhreac/
2646
2647 If the width of a \Verb|<name>| exceeds that of its \Verb|<compound>|, no adjustment is made to the width of the \Verb|<compound>| and the \Verb|<name>| will extend beyond the boundaries of the box containing it. It is up to the user to use the \verb|\\| macro to display the \Verb|<name>| on multiple lines.
2648 \exemple[60]{Name of compounds}/
2649 \hreac[hreac debug]
2650 \chemfig{*6(-=-=-=)}\name{cycle}
2651 +
2652 \chemfig{X=[1]Y}\name{name much too long}
2653 +
2654 Z > X + Y
2655 \endhreac\medbreak
2656 \hreac[hreac debug]
2657 \chemfig{*6(-=-=-=)}\name{cycle} +
2658 \chemfig{X=[1]Y}\name{name\\too\\long} +
2659 Z > X + Y
2660 \endhreac/
2661
2662 \section{Arrow labels}\label{hreaclabel}
2663 If the token “\verb|>|” is immediately followed by an optional argument \Verb|[<label>]|, this \Verb|<label>| will be placed above the arrow. If another optional argument \Verb|[<label>]| is present, the other \Verb|<label>| will be placed below the arrow.
2664 \exemple[60]{Arrow labels}/
2665 \hreac[hreac debug]
2666 A >[up] B >[][down] C >[up][down] D
2667 \endhreac/
2668
2669 The default width of an arrow is \verb|3em|, but if a label exceeds this dimension, the arrow lengthens.
2670 \exemple[60]{Arrow lengthening}/
2671 \hreac[hreac debug]
2672 A >[up][down] B
2673 \endhreac
2674 \qquad
2675 \hreac[hreac debug]
2676 A >[very long label][down] B
2677 \endhreac/
2678
2679 As with compound names, it is possible to use \verb|\\| to compose a \Verb|<label>| over several lines.
2680 \exemple[60]{Label over several lines}/
2681 \hreac[hreac debug]
2682 A >[very\\long\\label][bas] B
2683 \endhreac/
2684
2685 The box containing the bottom label has no influence on the vertical position of the compound names.
2686 \exemple[60]{Independence of labels and names}/
2687 \hreac[hreac debug]
2688 \chemfig{*6(-=-=-=)}\name{cycle}
2689 +
2690 \chemfig{X=[1]Y}\name{name}
2691 +
2692 Z >[][label\\under\\arrow\\very\\deep] X
2693 \endhreac/
2694
2695 \section{Arrow types}\label{hreacarrow}
2696 If the token \verb|>| is immediately followed by text between curly braces, this optional text specifies the arrow type. Its default value is the value of the key \CFkey{arrow head}, which contains \CFval{-CF} by default.
2697
2698 The complete syntax of the \verb|>| token is therefore:
2699 \begin{center}
2700 \verb|>|\Verb|{<arrow type>}[<top label>][<bottom label>]|
2701 \end{center}
2702
2703 By using this optional parameter between curly brackets, you can access these other types of arrows, already described in the section “Reaction diagrams” (page~\pageref{arrow}) : “\verb|->|”, “\verb|<-|”, “\verb|<->|”, “\verb|<=>|”, "\verb|<< ->|,“ and ”\verb|<->>|."
2704 \exemple[60]{The 6 types of arrows}/
2705 \hreac A > B \endhreac\par% identique à >{->}
2706 \hreac A >{<-} B \endhreac\par
2707 \hreac A >{<->} B \endhreac\par
2708 \hreac A >{<=>} B \endhreac\par
2709 \hreac A >{<<->} B \endhreac\par
2710 \hreac A >{<->>} B \endhreac/
2711
2712 \part{List of commands}
2713 The commands created by \CF are:
2714 \begin{center}
2715 \begin{longtable}{>\footnotesize l>\footnotesize p{9cm}}\\\hline
2716 \hfill\normalsize Commands\hfill\null &\hfill\normalsize Description\hfill\null\\\hline
2717 \Verb-\chemfig[<settings>]{<code>}-& draws the molecule whose design is described by the \Verb-<code>-\\
2718 \Verb|\setchemfig{<settings>}|& sets the parameters with the syntax \chevrons{key}${}={}$\chevrons{value}. These \chevrons{key} and \chevrons{value} are listed on page~\pageref{listeparametres} for \verb|\chemfig|, page~\pageref{listeparametresschemestart} for the \verb|\schemestart| macro, and page~\pageref{listeparametreshreac} for the \verb|\hreac| macro.
2719 \\
2720 \verb|\resetchemfig|&Reset the parameters to their default values\\
2721 \falseverb\printatom& displays the atoms within the molecules. It can be redefined to customize the output. See page~\pageref{perso.affichage}\\
2722 \falseverb\hflipnext&the next molecule will be horizontally flipped\\
2723 \falseverb\vflipnext&the next molecule will be vertically flipped\\
2724 \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}\\
2725 \falseverb\chemskipalign& tells the vertical alignment mechanism to ignore the current group of atoms. See page~\pageref{chemskipalign}.\\
2726 \Verb-\redefinesubmol{<name>}<n>[<code1>]{<code2>}- & replaces a preexisting alias \Verb-!<name>- with the new \Verb-<code>-. See page~\pageref{redefinesubmol}\\[2ex]\hline
2727 &\\
2728 \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}\\
2729 \Verb-\Charge{[<parameters>]<pos>[<tikz>]}{<atom>}-& Same behaviour as \verb|\charge|, but the final bounding box takes the charges into account.\\
2730 \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
2731 &\\
2732 \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}\\
2733 \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}\\
2734 \Verb-\Chemabove[<dim>]{<txt1>}{txt2}- & writes \Verb-<txt1>- and places \Verb-<txt2>- above, leaving \Verb-<dim>- of vertical space. See page~\pageref{chemabove}\\
2735 \Verb-\Chembelow[<dim>]{<txt1>}{txt2}- & writes \Verb-{txt1}- and places \Verb-<txt2>- below, leaving \Verb-<dim>- of vertical space. See page~\pageref{chemabove}\\
2736 \Verb-\chemname[<dim>]{<molecule>}{<name>}- & Places \Verb-<name>- under the \Verb-<molecule>-\\
2737 \falseverb\chemnameinit & Initializes the greatest molecule depth to ensure correct alignment of the names of the following molecules.\\[2ex]\hline
2738 &\\
2739 \falseverb\schemestart\dots\falseverb\schemestop& commands between which a reaction scheme is drawn. See page~\pageref{schemestart}.\\
2740 \falseverb\arrow& draws an arrow in a reaction scheme (this command is only defined inside a reaction scheme). See page~\pageref{arrow}.\\
2741 \falseverb\+ & prints a $+$ sign in a reaction scheme (this command is only defined inside a reaction scheme). See page~\pageref{signe+}.\\
2742 \falseverb\subscheme\Verb-{<code>}- & draws a subscheme (this command is only defined inside a reaction scheme). See~\pageref{subscheme}.\\
2743 \falseverb\definearrow & defines an arrow. See page~\pageref{definearrow}.\\
2744 \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}.\\
2745 \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}.\\
2746 \Verb|\polymerdelim[<settings]{<node1>}{node2>}|& draws delimiters at specified nodes, see page~\pageref{polymerdelim}\\[2ex]\hline
2747 \verb|\hreac...\endhreac|&tags between which a horizontal reaction is drawn, see page~\pageref{hreac}\\
2748 \verb|>|\Verb|{<type>}[<top label>][<bottom label>]|&draws a horizontal arrow, see page~\pageref{hreacshift}\\
2749 \verb|+|&displays the $+$ sign in the horizontal reaction\\
2750 \verb|\>|\Verb|{<dimension>}|&moves the current compound horizontally, see page~\pageref{hreacarrow}\\
2751 \Verb|\^{<dimension>}| or \Verb|\^*{<dimension>}|&moves the current compound vertically, see page~\pageref{hreacshift}\\
2752 \Verb|\chemname{<compound>}{<name>}|&typeset \Verb|<name>| under \Verb|<compound>|, see page~\pageref{hreacname}\\
2753 \Verb|\name{<name>}|&typeset \Verb|<name>| under the current compound, see page~\pageref{hreacname}\\\hline
2754 \end{longtable}
2755 \end{center}
2756
2757 \part{Gallery}
2758 This manual concludes with drawings of molecules of varying complexity.
2759
2760 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.
2761
2762 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:[email protected]}{\texttt{\textbf{email}}} to let me know of any malfunctions or suggestions for improvement.
2763
2764 \hfill Christian \textsc{Tellechea}
2765 \bigskip
2766
2767 \begin{center}
2768 \parskip0pt
2769 $\star$\par
2770 $\star\quad\star$
2771 \end{center}
2772 \bigskip
2773
2774 \exemple*{2-methylpentane}/\chemfig{[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3}/
2775
2776 \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}/
2777
2778 \exemple*{Stearine, condensed structural diagram}/\definesubmol{@}{([0,2]-O-[0,1]C(=[2,1]O)-C_{17}H_{33})}
2779 \chemfig{[2,2]CH_2!@-CH_{\phantom 2}!@-CH_2!@}/
2780
2781 \exemple*{Stearine, skeleton diagram}/\definesubmol{x}{-[:+30,.6]-[:-30,.6]}
2782 \definesubmol{y}{-O-(=[2,.6]O)-!x!x!x!x!x!x!x!x}
2783 \chemfig{[2]([0]!y)-[,1.5]([0]!y)-[,1.5]([0]!y)}/
2784
2785 \exemple*{Methyl 2-methylpropanoate}/\chemfig{H_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3}/
2786
2787 \exemple*{Vanillin}/\chemfig{HC*6(-C(-OH)=C(-O-[::-60]CH_3)-CH=C(-[,,,2]HC=[::-60]O)-HC=[,,2])} \quad or \quad
2788 \chemfig{*6(-(-OH)=(-OCH_3)-=(-=[::-60]O)-=)}/
2789
2790 \exemple*{Caffeine}/\chemfig{*6((=O)-N(-CH_3)-*5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)}/
2791
2792 \exemple*{Aspirin}/\chemfig{*6(-=-(-O-[::-60](=[::-60]O)-[::+60])=(-(=[::+60])-[::-60]OH)-=)}/Aspirin is a registered trademark of Bayer in many countries.
2793
2794 \exemple*{Phthalic anhydride}/\chemfig{*6(=*5(-(=O)-O-(=O)-)-=-=-)}/
2795
2796 \exemple*{Camphor}/\chemfig{*6(-(<:[::120](-[::-100,0.7])(-[::100,0.7]))--(=O)-(-)(<:[::120])--)}
2797 \quad or \quad
2798 \setchemfig{cram width=3pt}
2799 \chemfig{<[:10](>[:85,1.8]?(-[:160,0.6])-[:20,0.6])
2800 >[:-10]-[:60](=[:30,0.6]O)-[:170]?(-[:30,0.6])-[:190]-[:240]}/
2801
2802 \exemple*{Triphenylmethane}/\chemfig{*6(-=-*6(-(-*6(=-=-=-))-*6(=-=-=-))=-=)}
2803 \quad or \quad
2804 \definesubmol{@}{*6(=-=-=-)}
2805 \chemfig{(-[:-30]!@)(-[:90]!@)(-[:210]!@)}/
2806
2807 \exemple*{Amygdalin}/\setchemfig{cram width=2pt}
2808 \definesubmol{c1}{-[:200]-[:120]O-[:190]}
2809 \definesubmol{c2}{-[:170](-[:200,0.7]HO)<[:300](-[:170,0.6]HO)
2810 -[:10,,,,line width=2pt](-[:-40,0.6]OH)>[:-10]}
2811 \definesubmol{csub}{-[:155,0.65]-[:90,0.65]}
2812 \chemfig{O(!{c1}(!{csub}O(!{c1}(!{csub}OH)!{c2}))!{c2})-[:-30](-[:-90]CN)-[:30]*6(=-=-=-)}/
2813
2814 \exemple*{Adenosine triphosphate}/\setchemfig{cram width=3pt}
2815 \definesubmol{a}{-P(=[::-90,0.75]O)(-[::90,0.75]HO)-}
2816 \chemfig{[:-54]*5((--[::60]O([::-60]!aO([::-60]!aO([::60]!aHO))))<(-OH)
2817 -[,,,,line width=2pt](-OH)>(-N*5(-=N-*6(-(-NH_2)=N-=N-)=_-))-O-)}/
2818
2819 \exemple*{Viagra}/\chemfig{N*6((-H_3C)---N(-S(=[::+120]O)(=[::+0]O)-[::-60]*6(-=-(-O-[::-60]-[::+60]CH_3)
2820 =(-*6(=N-*5(-(--[::-60]-[::+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)}/
2821
2822 \exemple*{Cholesterol ester}/\chemfig{[:30]R-(=[::+60]O)-[::-60]O-*6(--*6(=--*6(-*5(---(-(-[::+60]Me)
2823 -[::-60]-[::-60]-[::+60]-[::-60](-[::-60]Me)-[::+60]Me)-)-(-[::+0]Me)---)--)-(-[::+0]Me)---)}/
2824
2825 \exemple*{Porphyrin}/\chemfig{?=[::+72]*5(-N=(-=[::-72]*5(-[,,,2]HN-[,,2](=-[::-36]*5(=N-(=-[::-72]*5(-NH-[,,1]?=-=))
2826 -=-))-=-))-=-)}/
2827
2828 \exemple*{Manganese 5,10,15,20-tetra(N-ethyl-3-carbazolyl) porphyrin}/\definesubmol{A}{*6(=-*5(-*6(-=-=-)--N(--[::-60])-)=-=-)}
2829 \chemfig{([::+180]-!A)=[::+72]*5(-N=(-(-[::+54]!A)=[::-72]*5(-N(-[::-33,1.5,,,draw=none]Mn)
2830 -(=(-[::+72]!A)-[::-36]*5(=N-(=(-[::+54]!A)-[::-72]*5(-N-(-)=-=))-=-))-=-))-=-)}/
2831
2832 \exemple*{Penicillin}/\chemfig{[:-90]HN(-[::-45](-[::-45]R)=[::+45]O)>[::+45]*4(-(=O)-N*5(-(<:(=[::-60]O)
2833 -[::+60]OH)-(<[::+0])(<:[::-108])-S>)--)}/
2834
2835 \exemple*{LSD}/\chemfig{[:150]?*6(=*6(--*6(-N(-CH_3)--(<(=[::+60]O)-[::-60]N(-[::+60]-[::-60])
2836 -[::-60]-[::+60])-=)([::-120]<H)---)-*6(-=-=-(-[::-30,1.155]\chembelow{N}{H}?)=))}/
2837
2838 \exemple*{Strychnine}/\chemfig{*6(=-*6(-N*6(-(=O)--([::-120]<:H)*7(-O--=?[0]([::-25.714]-[,2]?[1]))
2839 -*6(-?[0,{>}]--(<N?[1]?[2])-(<[::-90]-[::-60]?[2]))(<:[::+0]H)-([::+120]<H))--?)=?-=-)}/
2840
2841 \exemple*{Codeine}/\chemfig{[:-30]**6(-(-OH)-?-*6(-(-[3]-[2,2]-[0,.5])*6(-(<:[:-150,1.155]O?)
2842 -(<:OH)-=-)-(<:[1]H)-(-[2]NCH_3)--)---)}/
2843
2844 \exemple*{A dye (red)}/\chemfig{**6(--*6(-(-NO_2)=-(-\charge{90=\|,-90=\|}{O}-[0]H)=(-\charge{180=\|}{N}=[0]\charge{90=\|}{N}-[0]Ar)-)----)}/
2845
2846 \exemple*{Menthone}/\chemfig{CH_3-?(-[2]H)(-[::-30,2]-[::+60](=[1]\charge{0=\|,90=\|}{O})
2847 -[::-150,1.5](-[:20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[::-90,2]-[::+60]?)}/
2848
2849 \exemple*{Fullerene}/\definesubmol\fragment1{
2850 (-[:#1,0.85,,,draw=none]
2851 -[::126]-[::-54](=_#(2pt,2pt)[::180])
2852 -[::-70](-[::-56.2,1.07]=^#(2pt,2pt)[::180,1.07])
2853 -[::110,0.6](-[::-148,0.60](=^[::180,0.35])-[::-18,1.1])
2854 -[::50,1.1](-[::18,0.60]=_[::180,0.35])
2855 -[::50,0.6]
2856 -[::110])
2857 }
2858 \chemfig{
2859 !\fragment{18}
2860 !\fragment{90}
2861 !\fragment{162}
2862 !\fragment{234}
2863 !\fragment{306}
2864 }/% https://tex.stackexchange.com/questions/506293/how-to-draw-a-fullerene
2865
2866 \exemple*{Fischer indole synthesis}/\schemestart
2867 \chemfig{*6(=-*6(-\chembelow{N}{H}-NH_2)=-=-)}
2868 \+
2869 \chemfig{(=[:-150]O)(-[:-30]R_2)-[2]-[:150]R_1}
2870 \arrow(.mid east--.mid west){->[\chemfig{H^+}]}
2871 \chemfig{*6(-=*5(-\chembelow{N}{H}-(-R_2)=(-R_1)-)-=-=)}
2872 \schemestop/
2873
2874 \exemple*{Reaction mechanisms: carbonyl group}/\schemestart
2875 \chemfig{C([3]-)([5]-)=[@{db,.5}]@{atoo}\charge{0=\|,-90=\|}{O}}
2876 \arrow(.mid east--.mid west){<->}
2877 \chemfig{\charge{90:3pt=$\scriptstyle\oplus$}{C}([3]-)([5]-)-%
2878 \charge{0=\|,90=\|,-90=\|,45:3pt=$\scriptstyle\ominus$}{O}}
2879 \schemestop
2880 \chemmove{\draw[shorten <=2pt, shorten >=2pt](db) ..controls +(up:5mm) and +(up:5mm)..(atoo);}/
2881
2882 \exemple*{Reaction mechanisms: nitro group}/\schemestart
2883 \chemfig{R-\charge{225:3pt=$\scriptstyle\oplus$}{N}([1]=[@{db}]@{atoo1}O)([7]-[@{sb}]@{atoo2}
2884 \charge{45=\|,-45=\|,-135=\|,45:5pt=$\scriptstyle\ominus$}{O})}
2885 \arrow(.mid east--.mid west){<->}
2886 \chemfig{R-\charge{135:3pt=$\scriptstyle\oplus$}{N}([1]-\charge{90:3pt=$\scriptstyle\ominus$}{O})([7]=O)}
2887 \schemestop
2888 \chemmove{
2889 \draw[shorten <=2pt, shorten >=2pt](db) ..controls +(120:5mm) and +(120:7mm)..(atoo1);
2890 \draw[shorten <=3pt, shorten >=2pt](atoo2) ..controls +(225:10mm) and +(225:10mm)..(sb);
2891 }/
2892
2893 \exemple*{Calcium alginate gel}?\definesubmol{0}{-[-3,.15,,,draw=none]}% invisible bond to stack
2894 \definesubmol{COO/Na+}1{-[7]((-[-3,.66]COO^{-}!0N|a^+#1))}
2895 \definesubmol{chain}{-[5]!{COO/Na+}{}-[5]!{COO/Na+}{}-[5]-[7]}
2896 \definesubmol{COO/Ca2+}1{-[7]((-[-3,.66]COO^{-}!0C|a^{2+}!0COO^{-}-[-3,.66](-[7]-[5])#1))}
2897 \hreac[fixed length,atom sep=2.5em,angle increment=30]
2898 \chemfig{-[5]!{COO/Na+}{!0\phantom{C}!0(!{COO/Na+}{}!{chain})(-[-1])}!{chain}}
2899 >[\printatom{Ca^{2+}}]
2900 \chemfig{-[5]!{COO/Ca2+}{(-[-1]-[1])}-[5]!{COO/Ca2+}{}-[5]!{COO/Ca2+}{}-[5]-[7]}
2901 \endhreac?
2902
2903 \exemple*{Nucleophilic addition. Primary amines}/\setchemfig{atom sep=2.5em,compound sep=5em}
2904 \schemestart
2905 \chemfig{R-@{aton}\charge{90=\|}{N}H_2}
2906 \+
2907 \chemfig{@{atoc}C([3]-CH_3)([5]-CH_3)=[@{atoo1}]O}
2908 \chemfig{@{atoo2}\chemabove{H}{\scriptstyle\oplus}}
2909 \chemmove[-stealth,shorten <=3pt,dash pattern= on 1pt off 1pt,thin]{
2910 \draw[shorten >=2pt](aton) ..controls +(up:10mm) and +(left:5mm)..(atoc);
2911 \draw[shorten >=8pt](atoo1) ..controls +(up:10mm) and +(north west:10mm)..(atoo2);}
2912 \arrow{<=>[\tiny addition]}
2913 \chemfig{R-@{aton}\chembelow{N}{\scriptstyle\oplus}H([2]-[@{sb}]H)-C(-[2]CH_3)(-[6]CH_3)-OH}
2914 \schemestop
2915 \chemmove{
2916 \draw[-stealth,dash pattern= on 1pt off 1pt,shorten <=3pt, shorten >=2pt]
2917 (sb)..controls +(left:5mm) and +(135:2mm)..(aton);}
2918 \par
2919 \schemestart
2920 \arrow{<=>}
2921 \chemfig{R-@{aton}\charge{90=\|}{N}([6]-[@{sbh}]H)-[@{sb}]C(-[2]CH_3)(-[6]CH_3)-[@{sbo}]@{atoo}
2922 \chemabove{O}{\scriptstyle\oplus}(-[1]H)(-[7]H)}
2923 \chemmove[-stealth,shorten <=3pt,shorten >=2pt,dash pattern= on 1pt off 1pt,thin]{
2924 \draw(aton) ..controls +(up:5mm) and +(up:5mm)..(sb);
2925 \draw(sbh) ..controls +(left:5mm) and +(south west:5mm)..(aton);
2926 \draw(sbo) ..controls +(up:5mm) and +(north west:5mm)..(atoo);}
2927 \arrow{<=>[\tiny elimination]}\chemfig{R-N=C(-[1]CH_3)(-[7]CH_3)}
2928 \+
2929 \chemfig{H_3\chemabove{O}{\scriptstyle\oplus}}
2930 \schemestop/
2931
2932 \exemple*{Reaction scheme}/\setchemfig{atom sep=2em}
2933 \schemestart[-90]
2934 \chemfig{**6(---(-NH _2)---)}\arrow{0}\chemfig{HNO_2}
2935 \merge(c1)(c2)--()
2936 \chemfig{**6(---(-N_2|{}^\oplus)---)}\arrow{0}\chemfig{**6(---(-NH _2)---)}
2937 \merge(c3)(c4)--()
2938 \chemfig{**6(---(-N=[::-30]N-[::-30]**6(---(-NH_2)---))---)}
2939 \schemestop/
2940
2941 \exemple*{Addition}/\setchemfig{atom sep=2.5em}
2942 \schemestart
2943 \chemfig{*6(=-(-)(=[2]O))}
2944 \arrow{->[\+\chemfig{H^\oplus}]}
2945 \chemleft[\subscheme[90]{%
2946 \chemfig{*6((-[2,0.33,,,draw=none]\scriptstyle\oplus)-=(-)-OH)}
2947 \arrow{<->}
2948 \chemfig{*6(=-(-)(-[6,0.33,,,draw=none]\scriptstyle\oplus)-OH)}}\chemright]
2949 \arrow(@c3--)\chemfig{*6((-[2]R)-=(-)-OH)}
2950 \arrow(@c4--)\chemfig{*6(=-(-)(-[6]R)-OH)}
2951 \schemestop/
2952
2953 \exemple*{Electrophilic aromatic substitution}Z\setchemfig{atom sep=1.5em}%
2954 \definesubmol{+}{-[,-0.4,,,draw=none]\oplus}%
2955 \schemestart
2956 \arrow{0}[,0]
2957 \chemleft[\subscheme{\chemfig{*6(=-=-(-[:120]Br)(-[:60]H)-(!+)-)}
2958 \arrow{<->}
2959 \chemfig{*6(-(!+)-=-(-[:120]Br)(-[:60]H)-=)}
2960 \arrow{<->}
2961 \chemfig{*6(-=-(!+)-(-[:120]Br)(-[:60]H)-=)}}\chemright]
2962 \arrow(@c2--){<-[*0\chemfig{{-}AlBr_4|^\ominus}][*0\chemfig{Br_2/Al_2Br_3}]}[90,1.5]
2963 \chemname{\chemfig{*6(-=-=-=-)}}{Benzene 1}
2964 \arrow(@c4--){->[*0\chemfig{{-}H^\oplus}]}[90,1.5]
2965 \chemname{\chemfig{*6(-=-=(-Br)-=-)}}{Bromobenzne 2}
2966 \arrow(@c5.mid [email protected] west)
2967 \schemestop
2968 \chemnameinit{}Z
2969
2970 \exemple*{Reaction mechanism of chlorination}/\scriptsize\setchemfig{bond offset=1pt,atom sep=2em,compound sep=4em}
2971 \schemestart
2972 \chemfig{Cl-[4]@{a0}(=[@{a1}:120]@{a2}O)-[:-120](=[:-60]O)-[4]Cl}\+\chemfig{*6(-=-=(-@{oh1}OH)-=)}\arrow
2973 \chemfig{*6((-O-[:150](-[@{o0}:150]@{o1}\charge{-90=\.}{O})(-[@{cl0}:60]@{cl1}Cl)-[:240](-[4]Cl)=[6]O)=-=-=-)}
2974 \arrow\chemfig{*6((-O-[:150](=[2]O)-[:-150](=[6]O)-[:150]Cl)=-=-=-)}\+\chemfig{HCl}
2975 \arrow(@c1--){0}[-90,0.5]
2976 \chemfig{*6(-=*6(-O-*6(-@{o2}(=[@{o3}]@{o4}O)-Cl)=)-=-=)}\+\chemfig{*6(-=-=(-@{oh2}OH)-=)}\arrow
2977 \chemfig{*6(-=*6(-O-(-(-[@{cl2}:60]@{cl3}Cl)(-[@{o5}:-120]@{o6}\charge{-90=\.}{O})-O-[::-40]*6(=-=-=-))=)-=-=)}
2978 \kern-3em \arrow\chemfig{[:30]*6(=-(-O-[:-60](=O)-[:-120](=[4]O)-[:-60]O-*6(=-=-=-))=-=-)}
2979 \kern-3em \+\chemfig{HCl}
2980 \schemestop
2981 \chemmove[line width=0.2pt,-stealth,dash pattern = on 2pt off 1pt]{
2982 \draw[shorten <=2pt](a1)..controls+(200:5mm)and+(200:5mm)..(a2);
2983 \draw[shorten >=2pt](oh1.west)..controls+(180:15mm)and+(60:5mm)..(a0);
2984 \draw[shorten <=6pt,shorten >=2pt](o1)..controls+(270:5mm)and+(270:5mm)..(o0);
2985 \draw[shorten <=2pt](cl0)..controls+(150:5mm)and+(150:5mm)..(cl1.150);
2986 \draw[shorten <=2pt](o3)..controls +(30:3mm) and +(30:5mm)..(o4.east);
2987 \draw[shorten >=2pt](oh2.135).. controls +(150:10mm) and +(90:10mm).. (o2);
2988 \draw[shorten >=2pt,shorten <=5pt]([xshift=-1.5mm]o6.315)..controls +(315:5mm) and +(315:5mm)..(o5);
2989 \draw[shorten <=2pt](cl2)..controls +(135:5mm) and +(135:5mm)..(cl3.north west);}/
2990
2991 \exemple*{Cannizzaro reaction}/\schemestart
2992 \chemfig{[:-30]*6(=-=(-@{atoc}C([6]=[@{db}]@{atoo1}O)-H)-=-)}
2993 \arrow(start.mid east--.mid west){->[\chemfig{@{atoo2}\chemabove{O}{\scriptstyle\ominus}}H]}
2994 \chemmove[-stealth,shorten >=2pt,dash pattern=on 1pt off 1pt,thin]{
2995 \draw[shorten <=8pt](atoo2) ..controls +(up:10mm) and +(up:10mm)..(atoc);
2996 \draw[shorten <=2pt](db) ..controls +(left:5mm) and +(west:5mm)..(atoo1);}
2997 \chemfig{[:-30]*6(=-=(-C([6]-[@{sb1}]@{atoo1}\chembelow{O}{\scriptstyle\ominus})([2]-OH)-[@{sb2}]H)-=-)}
2998 \hspace{1cm}
2999 \chemfig{[:-30]*6((-@{atoc}C([6]=[@{db}]@{atoo2}O)-[2]H)-=-=-=)}
3000 \chemmove[-stealth,shorten <=2pt,shorten >=2pt,dash pattern=on 1pt off 1pt,thin]{
3001 \draw([yshift=-4pt]atoo1.270) ..controls +(0:5mm) and +(right:10mm)..(sb1);
3002 \draw(sb2) ..controls +(up:10mm) and +(north west:10mm)..(atoc);
3003 \draw(db) ..controls +(right:5mm) and +(east:5mm)..(atoo2);}
3004 \arrow(@start.base west--){0}[-75,2]
3005 {}
3006 \arrow
3007 \chemfig{[:-30]*6(=-=(-C([1]-@{atoo2}O-[@{sb}0]@{atoh}H)([6]=O))-=-)}
3008 \arrow{0}
3009 \chemfig{[:-30]*6((-C(-[5]H)(-[7]H)-[2]@{atoo1}\chemabove{O}{\scriptstyle\ominus})-=-=-=)}
3010 \chemmove[-stealth,shorten >=2pt,dash pattern=on 1pt off 1pt,thin]{
3011 \draw[shorten <=7pt](atoo1.90) ..controls +(+90:8mm) and +(up:10mm)..(atoh);
3012 \draw[shorten <=2pt](sb) ..controls +(up:5mm) and +(up:5mm)..(atoo2);}
3013 \schemestop/
3014
3015 \begingroup
3016 \catcode`;=12
3017 \exemple*{Beckmann rearrangement}/\setchemfig{bond offset=1pt,atom sep=2.5em,compound sep=5em,arrow offset=6pt}
3018 \schemestart
3019 \chemfig{(-[:-150]R')(-[:-30]R)=[2]N-[:30]OH}
3020 \arrow{<=>[\chemfig{H^\oplus}]}
3021 \chemfig{(-[@{a0}:-150]R')(-[:-30]R)=[2]@{a1}N-[@{b0}:30]@{b1}\chemabove{O}{\scriptstyle\oplus}H_2}
3022 \chemmove[red,-stealth,red,shorten <=2pt]{
3023 \draw(a0)..controls +(135:2mm) and +(215:4mm).. (a1);
3024 \draw(b0)..controls +(120:2mm) and +(180:3mm).. ([yshift=7pt]b1.180);}
3025 \arrow{<=>[\chemfig{{-}H_2O}]}[,1.1]
3026 \chemleft[\subscheme[90]{%
3027 \chemfig{R'-\chemabove{N}{\scriptstyle\oplus}~C-R}
3028 \arrow{<->}[,0.75]
3029 \chemfig{R'-\charge{90=\:}{N}=@{a1}\chemabove{C}{\scriptstyle\oplus}-R}}\chemright]
3030 \arrow{<=>[\chemfig{H_2@{a0}\charge{0=\:,90=\:}{O}}]}[,1.1]
3031 \chemmove[red,-stealth,red,shorten <=3pt]{
3032 \draw(a0)..controls+(90:10mm)and+(45:10mm)..([yshift=6pt]a1.45);}
3033 \arrow(@c1--){0}[-90,0.333]
3034 \chemfig{*6(R\rlap{$'$}-N=(-R)-\chemabove{O}{\scriptstyle\oplus} H_2)}
3035 \arrow{<=>[\chemfig{{-}H^\oplus}]}
3036 \chemfig{*6(R\rlap{$'$}-N=(-R)-OH)}
3037 \arrow
3038 \chemfig{*6(R\rlap{$'$}-\chembelow{N}{H}-(-R)(=[2]O))}
3039 \schemestop/
3040 \endgroup
3041
3042 \exemple*{Reaction scheme}/\setchemfig{atom sep=1.5em,compound sep=4em}
3043 \schemestart
3044 \chemfig{-[::30]=_[::-60](-[:: -60])-[::60]}
3045 \arrow{->[\chemfig{HCl}]}
3046 \chemfig{-[::30]-[::-60](-[::120]Cl)(-[::-60])-[::60]}\+\chemfig{-[::30](-[::60]Cl)-[::-60](-[::-60])-[::60]}
3047 \arrow(@c1--.north west){->[\chemfig{H_2O}]}[-45,1.7]
3048 \chemfig{-[::30]-[::-60](-[::120]OH)(-[::-60])-[::60]}\+\chemfig{-[::30](-[::60]OH)-[::-60](-[::-60])-[::60]}
3049 \schemestop/
3050
3051 \exemple*{Esterification of formic acid}Z\tikzset{obrace/.style={left delimiter={[},inner sep=3pt},
3052 cbrace/.style={right delimiter={]},inner sep=3pt},
3053 braces/.style={left delimiter={[},right delimiter={]},inner sep=3pt}}
3054 \setchemfig{atom sep=2em}
3055 \schemestart
3056 \chemfig{H-C(=[:60]O)-[:-60]O-H}
3057 \arrow(--M1[obrace]){-U>[\scriptsize\chemfig{H_2SO_4^{}}][\scriptsize\chemfig{HSO_4^\ominus}][][.25]}%
3058 [,1.5,shorten >=6pt]
3059 \chemfig{H-@{a2}C(-[:60]O-H)(-[:30,.5,,,draw=none]{\scriptstyle\oplus})-[:-60]O-H}
3060 \arrow(--[cbrace]){<->}
3061 \chemfig{H-C(=[:60]\chemabove{O}{\scriptstyle\oplus}-H)-[:-60]O-H}
3062 \arrow(@M1--){<=>[*{0}\scriptsize\chemfig{H-[:120]@{a1}O-[:60]CH_3}][*{0}\tiny addition]}[-90,1.33]
3063 \chemfig{H-C(-[2]O-[:30]H)(-\chemabove{O}{\scriptstyle\oplus}(-[:60]CH_3)-[:-60]H)-[6]O-[:-30]H}
3064 \arrow{<=>[\tiny protolysis]}[180]
3065 \chemfig{H-C(-[2]O-[:30]H)(-O-CH_3)-[@{b1}6]@{a3}\chemabove{O}{\kern-4mm\scriptstyle\oplus}(-[:-150]H)-[:-30]H}
3066 \arrow(--[obrace]){<=>[*{0}\scriptsize\chemfig{{-}H_2O}][*{0}\tiny elimination]}[-90,,shorten >=6pt]
3067 \chemfig{H-C(-[:60]O-H)(-[,.5,,,draw=none]{\scriptstyle\oplus})-[:-60]O-CH_3}
3068 \arrow(--[cbrace]){<->}
3069 \chemfig{H-C(=[:60]\chemabove{O}{\scriptstyle\oplus}-H)-[:-60]O-CH_3}
3070 \arrow{-U>[\scriptsize\chemfig{HSO_4^\ominus}][\scriptsize\chemfig{H_2SO_4^{}}][][.25]}[,1.5]
3071 \chemfig{H-C(=[:60]O)-[:-60]O-CH_3}
3072 \arrow(@M1--[yshift=-5pt]){0}[180,.5]{\tiny protolysis}
3073 \chemmove[red,shorten <=3pt,shorten >=1pt]{
3074 \draw(a1)..controls +(0:1.5cm)and+(0:3cm).. (a2);
3075 \draw(b1)..controls +(0:5mm)and+(20:5mm)..(a3);}
3076 \schemestop Z
3077
3078 \exemple*{Electrophilic addition of halogen to olefin}/\schemestart
3079 \subscheme{%
3080 \chemfig{C(<[:40])(<[:160])=[6]C(<[:-130])<[:-20]}
3081 \arrow{0}[,0]\+\chemfig{\charge{90=\|,180=\|,270=\|}{Br}-\charge{90=\|,0=\|,270=\|}{Br}}}
3082 \arrow(@c1--olefin){<=>[*{0}rapide]}[-90]
3083 \chemfig{>[:-20]C(<[:40])=[@{db}6]C(<[:-130])<[:-20]}
3084 \arrow(--bromonium){0}[-90]
3085 \chemname{\chemfig{C*3((<)(<:[:-155])-\charge{45=\|,-45=\|,180:3pt=$\scriptstyle\oplus$}{Br}-C(<:)(<[:155])-)}}
3086 {bromonium ion}
3087 \arrow(--carbeniumA){<<->}[,1.5]
3088 \chemname{\chemfig{-[:-30]\chemabove{C}{\scriptstyle\oplus}(-[:30])-[6]C(<:[:-150])(<[:-100])-[:-30]
3089 \charge{45=\|,-45=\|,225=\|}{Br}}}{Xarbenium ion}
3090 \arrow(@bromonium--carbeniumB){<<->}[180,1.5]
3091 \chemname{\chemfig{-[:-30]\chemabove{C}{\scriptstyle\oplus}(-[:30])-[6]C(<[:-150])
3092 (<:[:-100])-[:-30]\charge{45=\|,-45=\|,135=\|}{Br}}}{carbenium ion}
3093 \arrow(@olefin--){0}[,.25]
3094 \chemfig{@{Br1}\charge{90=\|,180=\|,270=\|,90:5pt=$\scriptstyle\delta\oplus$}{Br}-[@{b2}]@{Br2}
3095 \charge{90=\|,0=\|,270=\|,90:5pt=$\scriptstyle\delta\ominus$}{Br}}
3096 \arrow(@olefin--[left]){0}[180,0]
3097 $\pi$ complexe
3098 \arrow(@carbeniumA--@olefin){<=>[lent, \chemfig{{-}Br^\ominus}]}
3099 \arrow(@carbeniumB--@olefin){<=>[lent, \chemfig{{-}Br^\ominus}]}
3100 \chemmove[-stealth,red,shorten <=3pt,shorten >=2pt]{
3101 \draw(db) .. controls +(20:5mm) and +(135:5mm) .. (Br1);
3102 \draw(b2) .. controls +(-90:5mm) and +(-120:5mm) .. (Br2);}
3103 \schemestop
3104 \chemnameinit{}/
3105
3106 \exemple*{Sulfonation of naphthalene}/\definesubmol\cycleoplus{-[,0.25,,,draw=none]\oplus}
3107 \definesubmol{so2oh}{S(=[::90]O)(=[::-90]O)-OH}
3108 \setchemfig{atom sep=2.5em}
3109 \schemestart[,1.5]
3110 \chemname{\chemfig{*6(=-*6(-=-=-)=-=-)}}{Naphtalene}\+\chemfig{H_2SO_4}
3111 \arrow(nph.mid east--.south west){->[80\degres C]}[45]
3112 \chemname{\chemfig{*6(=-*6(-=-(!\cycleoplus)-(-SO_3H)-)=-=-)}}{Ion 1-arenium}
3113 \arrow(.mid east--.mid west)
3114 \chemname{\chemfig{*6(=-*6(-=-=(-!{so2oh})-)=-=-)}}{Acide 1-naphthalenesulfonique}
3115 \arrow(@nph.mid east--.north west){->[160\degres C]}[-45]
3116 \chemname{\chemfig{*6(=-*6(-=-(-SO_3H)-(!\cycleoplus)-)=-=-)}}{Ion 2-arenium}\kern-4em
3117 \arrow(.mid east--.mid west)
3118 \chemname{\chemfig{*6(=-*6(-=-(-!{so2oh})=-)=-=-)}}{Acide 2-naphthalenesulfonique}
3119 \schemestop
3120 \chemnameinit{}/
3121
3122 \exemple*{Taxotere}/\chemfig{-[::-30](-[5])(-[7])-[::+60]-[::-60]O-[::+60](=[::-45]O)-[::+90]HN>:[::-60](-[::+60]**6(------))
3123 -[::-30](<:[2]OH)-[::-60](=[6]O)-[::+60]O>:[::-60]*7(---?(<[::-120]OH)-(<|[1]CH_3)(<:[::-90]CH_3)
3124 -(-[1](<[::+80]HO)-[0](=[::+60]O)-[7](<|[::+130]CH_3)(-[::+75](<|[2]OH)-[::-60]-[::-60](<[::+30]O-[::-90])
3125 -[::-60](<[::+90])(<:[::+30]O-[7](-[6]CH_3)=[0]O)-[::-60])-[6]-[5,1.3]?(<:[7]O-[5](=[::-60]O)
3126 -[6]**6(------)))=(-[2]CH_3)-)}/
3127
3128 % https://tex.stackexchange.com/questions/673490/diverging-arrow-in-chemfig/673572#673572
3129 \exemple*{Diverging arrows}/\schemestart
3130 \chemfig{(-[:210]R_2)(-[:330]R_1)=[2]O}
3131 \arrow(a--)[,1.5,,,draw=none]
3132 \subscheme{
3133 \charge{30:4pt=$\mathrm{S}_1$}{\chemleft{[}\chemfig{(-[:210]R_2)(-[:330]R_1)=[2]O}\chemright{]}}
3134 \arrow(b--c){->[*{0}ISC]}[-90,1.5]
3135 \charge{30:4pt=$\mathrm{T}_1$}{\chemleft[\chemfig{(-[:210]R_2)(-[:330]R_1)=[2]O}\chemright{]}}
3136 }
3137 \arrow(--d)[,1.5,,,draw=none]
3138 \chemfig{(-[:210]R_2)(-[:330,0.1,,,draw=none]\charge{330:-1pt=\.\,}{})=[2]O}
3139 \+
3140 \chemfig{\charge{90:1pt=\.\,}{R}_1}
3141 \schemestop
3142 \chemmove{
3143 \draw[thick,shorten >=10pt] (a.east) -- ++(1,0) |- (b.west);
3144 \draw[thick,shorten >=10pt] (a.east) -- ++(1,0) |- (c.west);
3145 \draw[-,thick,shorten >=15pt,shorten <=8pt] (b.east) -- ++(1.3,0) |- (d.west);
3146 \draw[thick,shorten >=10pt,shorten <=8pt] (c.east) -- ++(1.3,0) |- (d.west);
3147 }/
3148
3149 \part{Change history}\label{changelogs}
3150 Changes (most recent first) made in \CF since the first version. This section has not been translated into English.
3151 \input{changelog.tex}
3152 \end{document}