[Tex/LaTex] Drawing chemical reactions

chemfigchemistrymhchem

I am trying to draw reactions like this enter image description here

I tried it like this

\documentclass[11pt]{article}

\usepackage[version=4]{mhchem}
\usepackage{chemfig}

\begin{document}
  \ce{ \chemfig{CH_3-CH (-[2]OH)-CH_3}  + HI -> \chemfig{CH_3-CH(-[:90]I)-CH_3} + H2O}

\end{document}

the result looks very messy
.So how do i accomplish making such structures by showing only one bond between OH and Carbon at reactant and one bond at iodine and Carbon at product?
enter image description here

Best Answer

You want this result, right?

enter image description here

Then CH3CHCH3 must be considered as one group of 6 atoms (C, H, C, H, C and H) where the bond is leaving from the third atom. You need to tell this to chemfig using the bond's optional argument <departure>:

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

The code then is \chemfig{CH_3CHCH_3-[2,,3]OH}

\documentclass{article}
\usepackage{chemfig}
\usepackage[version=4]{mhchem}

\begin{document}

\ce{ \chemfig{CH_3CHCH_3-[2,,3]OH} + HI -> \chemfig{CH_3CHCH_3-[2,,3]I} + H2O}

\end{document}