# How to annotate chemfig drawing with circles and lines?

I want to draw circles on top of a chemfig molecule and then connect these circles with elements in a table above. I have gotten this far:

\documentclass{memoir}
\usepackage{tikz}
\usepackage{chemfig}

\begin{document}
\begin{figure}
\begin{tikzpicture}[node distance=0]
\node (foo){};
\node (a)  [draw,minimum height=0.5cm,minimum width = 0.7cm, above of = foo, node distance = 60 pt, xshift=0cm, ]{$1$};
\node (b)  [draw,minimum height=0.5cm,minimum width = 0.7cm, right of = a, xshift=0.7cm]{$1$};
\node (c)  [draw,minimum height=0.5cm,minimum width = 0.7cm, right of = a, xshift=1.4cm]{$1$};
\node (d)  [draw,minimum height=0.5cm,minimum width = 0.7cm, right of = a, xshift=2.1cm]{$0$};
\node [above of = a, node distance = 12pt] {\small$C$};
\node [above of = b, node distance = 12pt] {\small$O$};
\node [above of = c, node distance = 12pt] {\small$OH$};
\node [above of = d, node distance = 12pt] {\small$N$};

\setatomsep{2.5em}
\chemfig[below of = a]{H-C(-[:90]H)(-[:-90]H)-C(-[:-90]H)(-[:90]H)-O-[:60]H}

\draw (-0.3,0.5) circle (0.8cm);
\draw (-0.3,0.5) -- (c);
\end{tikzpicture}
\end{figure}

\end{document}


For some reason I have trouble making the line go to the right location but I also wonder if I have to guess where my circles go like this or of there is some nice way of figuring out the location of the chemfig atoms?

This is what my current stuff looks like and some crude drawing in red explaining what more I wanted to do but didn't really manage to do:

• See section 11 of the manual - you can use the remember picture option to tikz and to use the @{argument} syntax to create nodes that you can refer to later – darthbith Dec 10 '14 at 15:43

I was able to draw using \chemmove, remember picture and @{} syntax for naming atoms and links.

\documentclass[varwidth,border=50]{standalone}
\usepackage{tikz}
\usepackage{chemfig}

\begin{document}
\begin{tikzpicture}[remember picture, node distance=0]
\node (foo){};
\node (a)  [draw,minimum height=0.5cm,minimum width = 0.7cm, above of = foo, node distance = 60 pt, xshift=0cm, ]{$1$};
\node (b)  [draw,minimum height=0.5cm,minimum width = 0.7cm, right of = a, xshift=0.7cm]{$1$};
\node (c)  [draw,minimum height=0.5cm,minimum width = 0.7cm, right of = a, xshift=1.4cm]{$1$};
\node (d)  [draw,minimum height=0.5cm,minimum width = 0.7cm, right of = a, xshift=2.1cm]{$0$};
\node [above of = a, node distance = 12pt] {\small$C$};
\node [above of = b, node distance = 12pt] {\small$O$};
\node [above of = c, node distance = 12pt] {\small$OH$};
\node [above of = d, node distance = 12pt] {\small$N$};
\end{tikzpicture}
\vspace{-7mm}

\setatomsep{2.5em}
\chemfig[remember picture]{H-@{c1}C(-[:90]H)(-[:-90]H)-@{c2}C(-[:-90]H)(-[:90]H)-@{o}O-[@{oh,.5}:60]H}
\chemmove{
\draw[-latex,shorten >=.4em, red, very thick]
(a) edge[bend right] (c1) (c1.center) circle(.7em)
(a) edge[bend left=1em] (c2) (c2.center) circle(.7em)
(b.south) edge[bend left=2em] (o) (o.center) circle(.7em)
(c.south) edge[shorten >=2.1em,bend left=3em,in=170] (oh) (oh.center) circle(2.14em);
}

\end{document}