# chemfig: Colored atoms don't align, and how to draw bonds to an electric charge?

So I want to show the ionic interaction between a molecule and a charged element. But when I use color to highlight a part of the molecule, the bond alignment is no longer correct. The first example is ok, the other two shows the problem. I've tried two different ways to draw lines between the calcium and the electeric charge (\ominus), with strange results. I'm using texlive and chemfig v1.0h Nov 28 2013.

\documentclass{article}
\usepackage{chemfig,amsmath}
\newcommand{\gammach}{$\gamma$}
\begin{document}

\schemedebug{false}
\definesubmol{Glu}{
[:0,0.75]\phantom{X}-[:30]HN-
([:60]
--[:0]
(-[:60]COO^{\ominus}
)
)
(-[::-60]CO-[:0,0.5]\vphantom{X})
}
\schemestart
\chemname{  \chemfig{ !{Glu} }}{glutamic acid}
\arrow{->[\gammach-carboxylase]}
\chemname{\chemfig{
[:0,0.75]\phantom{X}-[:30]HN-
([:60]
--[:0]
(-[:60]COO^{\ominus}
(-[:-40,0.975,,,dotted]Ca^{2+}?[Cahook])
)
(-[:-60]COO^{\ominus}-[,0.2,,,draw=none]?[Cahook,1,dotted,red])
)
(-[:-60]CO-[:0,0.5]\phantom{X})
}}{\gammach-carboxylated glutamic acid}
\schemestop

\schemestart
\chemname{\chemfig{ !{Glu} }}{glutamic acid}
\arrow{->[\gammach-carboxylase][\+ \color{red}CO$_2$]}
\chemname{\chemfig{
[:0,0.75]\phantom{X}-[:30]HN-
([:60]
--[:0]
(-[:60]COO^{\ominus}
(-[:-40,0.975,,,dotted]Ca^{2+}?[Cahook])
)
(-[:-60]{\color{red}COO^{\ominus}}-[,0.2,,,draw=none]?[Cahook,1,dotted,red])
)
(-[:-60]CO-[:0,0.5]\phantom{X})
}}{\gammach-carboxylated glutamic acid}
\schemestop

\schemestart
\chemname{\chemfig{ !{Glu} }}{glutamic acid}
\arrow{->[\gammach-carboxylase][\+ \color{red}CO$_2$]}
\chemname{\chemfig{
[:0,0.75]\phantom{X}-[:30]HN-
([:60]
--[:00]
(-[:60]COO^{\ominus{}}@{higherCOO}
(-[:-30,0.975,,,dotted,red]Ca^{2+}@{ca})
)
(-[:-60,,,,blue]{\color{red}COO^{\scriptstyle\ominus{}}
}@{lowerCOO}-[:30,0.975,,,green,dotted]
)
)
(-[:-60]CO-[:0,0.55])
}}{\gammach-carboxylated glutamic acid}
\schemestop

\chemmove{ \draw[red,dotted] (ca)--(lowerCOO); }

\end{document}

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Martin Schröder Jan 26 '14 at 13:49

Here is my try:

\documentclass{article}
\usepackage{chemfig}
\newcommand\gammach{$\gamma$}
\begin{document}
\setbondstyle{thick}
\schemedebug{false}
\definesubmol{Glu}{[:0,0.75]-[:30]HN-([:60]--[:0](-[:60]COO^\ominus))(-[::-60]CO-[:0,0.5])}
\schemestart
\chemname{\chemfig{!{Glu}}}{glutamic acid}
\arrow{->[\gammach-carboxylase]}
\chemname{%
\chemfig{ [,0.75]%
-[:30]HN-([:60]--[:0](-[:60]COO|^\ominus(-[:-40,1,,,dotted]Ca?|^{2+}))%
(-[:-60]COO^\ominus?[,,dotted,red]))(-[:-60]CO-[:0,0.5])}}%
{\gammach-carboxylated glutamic acid}%
\schemestop
\bigbreak

\schemestart
\chemname{\chemfig{!{Glu}}}{glutamic acid}
\arrow{->[\gammach-carboxylase][\+ \color{red}CO$_2$]}
\chemname{%
\chemfig{ [,0.75]%
-[:30]HN-([:60]--[:0](-[:60]COO|^\ominus(-[:-40,1,,,dotted]Ca?|^{2+}))%
(-[:-60]{\color{red}C}|{\color{red}O}|{\color{red}O^\ominus}?[,,dotted,red]))(-[:-60]CO-[:0,0.5])}}%
{\gammach-carboxylated glutamic acid}%
\schemestop
\bigbreak

\schemestart
\chemname{\chemfig{!{Glu}}}{glutamic acid}
\arrow{->[\gammach-carboxylase][\+ \color{red}CO$_2$]}
\chemname{%
\chemfig{ [,0.75]%
-[:30]HN-([:60]--[:0](-[:60]COO|^\ominus(-[:-40,1,,,dotted]Ca?|^{2+}))%
(-[:-60,,,,blue]{\color{red}C}|{\color{red}O}|{\color{red}O^\ominus}?[,,dotted,green]))(-[:-60]CO-[:0,0.5])}}%
{\gammach-carboxylated glutamic acid}%
\schemestop
\end{document}


-
Spot-on! Thank you very much. Ahh... so I see the delimiters '|' could be placed after each colored atoms and not in front of them. I'm surprised that the delimiter was used in the hooks as well. Much appreciated. –  Erik Jan 25 '14 at 23:05