# Complementary pairs of Guanine and Cytosine

I am new to TikZ and need help with drawing the following diagram of complementary pairs of Guanine and Cytosine.

I am trying to do it the following way but do not know how to rotate and join the links.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{chemfig}
\usepackage{tikz}

\title{Chemistry}
\begin{document}
\begin{tikzpicture}[help lines/.style={thin,draw=black!50}]
\chemfig{*6((-H_2N)=N-*5(-\chembelow{N}{H}-=N-)=-(=O)-HN-[,,2])}
\end{tikzpicture}
\end{document}

• Hello and welcome to TeX.SE. Have you tried any code? Have you a MWE? – Romain Picot Aug 5 '15 at 6:30
• Please give the O.P. some time to improve his post before voting to close or flagging it as LQ ... – user31729 Aug 5 '15 at 7:23

Package chemfig provides a powerful interface for chemistry via TikZ (two LaTeX runs required):

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\begin{tikzpicture}
\setatomsep{2em}
\path
node[anchor=base east] (Guanine)
{\chemfig{%
[:180]N(-[:0]@{L2}H)*6(-(=@{L1}O)-(*5(-N=-N(-R)-))=-N=%
(-N(-[:0]@{L3}H)-[:240]H)-)}}
(Guanine.base east)
node[anchor=base west, xshift=-.15em] (Cytosin)
{\chemfig{%
[:-30]@{R2}N*6(-(=@{R3}O)-N(-R)-=-(-N(-[:180]@{R1}H)-[:60]H)=)}}
;
\chemmove{%
\foreach \i in {1, 2, 3} {
\draw[-, dashed, shorten <=.2em, shorten >=.2em] (L\i) -- (R\i);
}%
}
\path (Guanine.south west) (Cytosin.north east); % update bouning box
\path[inner sep=0pt, below=1.5ex]
(Guanine.south) node {Guanine}
(Cytosin.south |- Guanine.south) node {Cytosine}
;
\end{tikzpicture}
\end{document}


As already noted chemfig is quite powerful. So powerful, that actually no additional TikZ is needed if the hydrogen bridges were drawn as bonds (from chemfig's point of view, using the bond's fourth optional argument to make them dashed) and both molecules were drawn as one chemfig formula.

But even if you draw them both separately you can exploit the fact that you can give names to the nodes where the atoms are placed in in a chemfig formula (@{<name>}-syntax). To these nodes can later be referred to in another tikzpicture with remember picture and overlay options for which chemfig has the wrapper \chemmove. The only thing one has to take care of is that both molecules have the same baseline.

\documentclass{article}
\usepackage{chemfig}
\begin{document}

\chemname
{\chemfig{@{H1}H-[:180](-[:-120]H)-[:120]*6(-N(-@{H2}H)-(=@{O3}O)-(*5(-N=-N(-R)-))=-N-)}}
{Guanine}
\chemname
{\chemfig{@{O1}O=[:60]*6(-N(-R)-=-(-N(-[::60]@{H3}H)-[::-60]H)=@{N2}N-)}}
{Cytosine}
\chemmove[dashed]{\draw (H1) -- (O1) (H2) -- (N2) (O3) -- (H3) ;}

\end{document}


You can even have the molecules as submols:

\documentclass{article}
\usepackage{chemfig}

\definesubmol{guanine}{
@{hb-gua1}H-[:180](-[:-120]H)
-[:120]*6(
-N(-@{hb-gua2}H)
-(=@{hb-gua3}O)
-(*5(-N=-N(-R)-))
=-N-
)
}

\definesubmol{cytosine}{
@{hb-cyt1}O=[:60]*6(
-N(-R)
-=-(
-N(-[::60]@{hb-cyt3}H)
-[::-60]H
)
=@{hb-cyt2}N-
)
}

\begin{document}

\chemname{\chemfig{!{guanine}}}{Guanine}