# Trouble with hooks in chemfig

I am trying to construct this EDTA molecule coordinated to a metal:

and this is what I have so far:

With this code:

\chemfig{
O=[2,,]C
(-[3,2,,1]CH_2-[1,,1]N
(-[7,,,2]H_2C-[0,,]C
(=[7,,]O)
(-[1,,]O^{-}))
(-[4,,,2]H_2C-[2,,2,2]H_2C-[0,,]N
(-[1,,,2]H_2C-[0,,2]C
(=[1,,]O)
(-[7,,]O^{-}))
(-[3,,,2]H_2C-[1,2,2]C
(=[2,,]O)
(-[7,,]O^{-}))))
(-[1,,]O^{-})
}


What I can't figure out how to do is include the metal in the center. I know I have to use hooks somehow but I don't know where to start. Would I have to start over and begin the figure at the metal?

Bonus question: how do I change the color of the bonds to the metal?

Placing the M is rather straightforward: use \chemmove, which produces an overlay tikzpicture and then e.g. the calc syntax. What I find more difficult is to reproduce the bond styles. I ended up looking up the definitions and then to repeat what I think they do. (EDIT: Minor fine-tuning, big thanks to AndréC for pushing me.)

\documentclass{article}

\usepackage{chemfig}
\usetikzlibrary{calc}
\begin{document}
\chemfig{
O=[2,,]C
(-[3,1.8,,1]CH_2-[1,,1]@{N1}{N}
(-[7,,,2]H_2C-[0,,]@{C1}{C}
(=[7,,]O)
(-[1,,]@{OM1}{O^{-}}))
(-[4,,,2]H_2C-[2,,2,2]H_2C-[0,,]@{N2}{N}
(-[1,,,2]H_2C-[0,,2]@{C2}{C}
(=[1,,]O)
(-[7,,]@{OM2}{O^{-}}))
(-[3,1.2,,2]H_2C-[1,2,2]C
(=[2,,]O)
(-[7,,]@{OM3}{O^{-}}))))
(-[1,,]@{OM4}{O^{-}})
}
\chemmove[brown!70!black]{%
\node (M) at ($(OM1)!0.5!(N2)$) {M};
\fill let \p1=($(M)-(OM1)$),\n1={atan2(\y1,\x1)} in
($(OM1.\n1)!1mm!(M)$) coordinate (aux1)  (M) --
($(aux1)!1mm!90:(M)$) -- ($(aux1)!1mm!-90:(M)$)
-- cycle;
\fill let \p1=($(M)-(N1)$),\n1={atan2(\y1,\x1)} in
($(N1.\n1)!1mm!(M)$) coordinate (aux2)
(M) --
($(aux2)!1mm!90:(M)$) -- ($(aux2)!1mm!-90:(M)$)
-- cycle;
\draw[thick,-,shorten >=1mm] (M) to (OM3.south -|M.center);
\draw[thick,-,shorten >=1mm] (M) to (OM4.north -|M.center);
\begin{scope}
\clip let \p1=($(M)-(OM2)$),\n1={atan2(\y1,\x1)} in
($(OM2.\n1)!1mm!(M)$) coordinate (aux3)  (M) --
($(aux3)!1mm!90:(M)$) -- ($(aux3)!1mm!-90:(M)$)
-- cycle;
\draw[-,line width=2mm, dash pattern=on 1pt off 2pt,line cap=butt] (M) --(aux3);
\end{scope}
\begin{scope}
\clip let \p1=($(M)-(N2)$),\n1={atan2(\y1,\x1)} in
($(N2.\n1)!1mm!(M)$) coordinate (aux4)  (M) --
($(aux4)!1mm!90:(M)$) -- ($(aux4)!1mm!-90:(M)$)
-- cycle;
\draw[-,line width=2mm, dash pattern=on 1pt off 2pt,line cap=butt] (M) --(aux4);
\end{scope}
}
\end{document}


• The vertical line from one O- to the other is not well centered, it is slightly too far to the left. – AndréC Oct 25 '18 at 5:24
• @AndréC One can either have a vertical line or a centered line in the OP's setup. If one makes the C--H_2C lines a bit longer, it is better centered. – user121799 Oct 25 '18 at 5:26
• Unfortunately I can't get this to work properly. Can this be used in a figure environment? – Antidisestablishmentarianism Oct 25 '18 at 5:37
• +1, perfect now! – AndréC Oct 25 '18 at 5:38
• @Antidisestablishmentarianism You have to compile twice to get the right placement! – AndréC Oct 25 '18 at 5:38