chemfig
Operation of chemfig
6 Length of a bond¶
Rather than speaking of length of a bond, we should use the term interatomic spacing. If effect, only the interatomic spacing is adjustable with atom sep as we have seen on section 4. 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:
\chemfig{I-I}\par
\chemfig{M-M}
This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts. In this example, the bond is extremely short, to the point of confusion with a negative sign \(-\):
\chemfig{A^{++}_{2}-B^{-}_3}
It is important to note that the exponent - is put inside braces. If this were not done, chemfig would stop the atom on this character, which is a bond character. The atom would then be “B^”, which would lead to unexpected results.
It is possible to change the behavior of chemfig about the interatomic spacing. Indeed, when the \chemfig macro is immediately followed by a star, the ⟨key⟩ atom sepno longer defines the distance between the centers of atoms, denoted \(\Delta\), but 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 section 4 and what becomes with the two boolean values of key fixed length:
| fixed length = ⟨false⟩ | fixed length = ⟨true⟩ |
In rings, even when fixed length = ⟨true⟩, the default behavior is restored for the bonds of the cycle, in order to draw regular polygons.
\chemfig{Cl-Cl}\par
\chemfig[fixed length=true]{Cl-Cl}
Especially with the default behavior, to avoid too short bonds, it is sometimes necessary to increase (or perhaps reduce) the interatomic distance. For this, the optional argument to bonds is actually made up of several comma-separated fields. As we have seen, the first field specifies the angle. The second field, if it is not empty, is a coefficient which multiplies the default interatomic distance \(\Delta\). Thus, writing -[,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.
\chemfig{A^{++}_{2}-[,2]B^{-}_3}\par
\chemfig{A-B-[,2]C=[,0.5]D}\par
\chemfig{-=[,1.5]-[,0.75]=[:-20,2]}
We can change the size of molecules by altering the font size or the ⟨key⟩ atom sep, possibly on both, being careful to confine these changes within a group if we want to limit the scope:
\normalsize \chemfig{H-[:30]O-[:-30]H}\par
\setchemfig{atom sep=2.5em}
\chemfig{H-[:30]O-[:-30]H}\par
\small \chemfig{H-[:30]O-[:-30]H}\par
\footnotesize \chemfig{H-[:30]O-[:-30]H}\par
\scriptsize \chemfig{H-[:30]O-[:-30]H}\par
\tiny \chemfig{H-[:30]O-[:-30]H}