chemfig
Advanced usage
1 Separating atoms¶
The separating atom mechanism described previously extends each atom until the next capital letter or one of the characters - = ~ ( ! * < > @
In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagram. Consider this example molecule, noting that the “(” character is placed between braces so that chemfig doesn’t incorrectly create a branch:
\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}
We find that the bond which arrives at the carbon atom in the upper right is too short. This happens because, if we apply the chemfig rules for separating atoms to the upper right group, the atoms are split in this way: “C{(}”, “C”, “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:
=0pt
The character “'' forces splitting of the atom when it is encountered. Thus we can write \texttt{C\textcolor{red}{{(CH_3)_3} to ensure that chemfig separates just two atoms here: “C” and “{(CH_3)_3}”. The problem of the too-short bond is thus solved:
\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C|{(CH_3)_3}}