# chemfig: order of atoms

I want to change the order of the "OH"-group at carbon 4: the "H" should be left of the "O".

\documentclass{standalone}
\usepackage{chemfig}

\begin{document}
\setatomsep{4em}\setcrambond{3pt}{}{}
\chemfig{
OH-[2,.7](-[3,0.15,,,draw=none]\scriptstyle\mbox{\small\textcolor{orange}{4}})
(
-[1,.7](-[2,0.5]-[3,0.5]OH)
-[0]{O}-[7,0.7]
)
<[7,0.7](-[2,0.5]HO)
-[,,,,line width=3pt](-[6,0.5]OH)
>[1,0.7](-[1,0.15,,,draw=none]\scriptstyle\mbox{\small\textcolor{orange}{1}})
-[2,.5]OH
}

\end{document}

• Welcome to TeX.sx! Change the beginning of your formula to HO-[2,.7,2]. You might want to check the chemfig manual for departure and arrival atoms and the optional arguments of bonds: <bond>[<angle>,<length factor>,<departure>,<arrival>,<tikz>] – cgnieder Jun 24 '15 at 18:56
• You should change the order on the sixth and third carbon atom as well, looks like hydrogen is attached to the carbon (and the oxygen) at the moment – user49901 Jun 24 '15 at 19:10

The order of atoms is the order you type them in: if you type OH then chemfig uses OH, if you type HO then chemfig uses HO. Ideally you also tell chemfig that the bond starts at the O. This can be done with the optional argument of a bond:

<bond>[<angle>,<length factor>,<departure>,<arrival>,<tikz>]


So starting your compound with HO-[2,.7,2] instead of OH-[2,.7] will give what you want. Applying this to other OH groups, too, gives:

\documentclass{standalone}
\usepackage{chemfig}

\begin{document}
\setatomsep{4em}\setcrambond{3pt}{}{}
\chemfig{
HO-[2,.7,2](-[3,0.15,,,draw=none]\scriptstyle\mbox{\small\textcolor{orange}{4}})
(
-[1,.7](-[2,0.5]-[3,0.5]HO)
-[0]{O}-[7,0.7]
)
<[7,0.7](-[2,0.5,,2]HO)
-[,,,,line width=3pt](-[6,0.5]OH)
>[1,0.7](-[1,0.15,,,draw=none]\scriptstyle\mbox{\small\textcolor{orange}{1}})
-[2,.5]OH
}

\end{document}