All of chemfig
's bonds have optional arguments which accept the following input:
<bond symb>[<angle spec>,<length factor>,<dpt atom>,<arr atom>,<tikz spec>]
The third, <dpt atom>
, and fourth ,<arr atom>
, are the important ones here: they specify from which atom of a group of atoms the bond departs and at which atom of a group of atoms the bond arrives. This is described in section 5 of part II in the manual (Departure and arrival atoms). These arguments are integers that refer to the position of the respective atom in the group (counted from the left). If they're not specified chemfig
determines the atom depending on the angle with which the bond departs or arrives. The specified atoms must exist otherwise an error is thrown. The following picture is taken from the documentation:
![enter image description here](https://i.stack.imgur.com/dFP2N.png)
Applying this to your code we get:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig{
C
([:0]-C(=[:30]O)(-[:-30]O^{-}))
([:180]-H_{3}N^{+})
([:-90]-H)
([:90]-CH_{2}([:90]-([:60]*5(-NH-[,,1]=NH^{+}-=))))% <= NH-[,,1] : depart from `N'
}
\chemfig{
C
([:0]-C(=[:30]O)(-[:-30]O^{-}))
([:-90]-H)
*5([:135]-CH_2-CH_2-H_2C-[,,,2]H_{2}N^{+}-)% <= C-[,,,2] : arrive at `N'
}
\end{document}
![enter image description here](https://i.stack.imgur.com/9uxNc.png)
Further adjustments you could make to improve the looks of the molecules:
- in the rings use
\chemabove{<atom>}{<above>}
and mathtools
' \mathrlap{<stuff>}
to get single atoms as far as the rings are concerned; the rings will look more even.
- use
O|^{-}
in the carboxyl groups (notice the |
); this will make sure that the additional height of the superscript is not taken into account when placing the O
the the bond; there are other places in the molecules where this syntax can come in handy, too. See section 1 of part III, Separating atoms, in the manual for details on this.
Applying this to your examples this would be the result:
![enter image description here](https://i.stack.imgur.com/UAJey.png)
\documentclass{article}
\usepackage{chemfig}
\usepackage{mathtools}% provides \mathrlap
\begin{document}
\chemfig{
H_{3}\chemabove{N}{\quad\scriptstyle+}-
C
([:-90]-H)
([:90]
-CH_{2}-
([:90]*5(-NH-[,,1]=\chemabove{\chemabove{N}{H}}{\hskip1.5em\scriptstyle+}-=))
)
-C(=[:45]O)(-[:-45]O|^{-})
}
\qquad
\chemfig{
H-[2]
C
(-C(=[:45]O)(-[:-45]O|^{-}))
*5([:135]-C|H_2-\chemabove{C}{H\mathrlap{_2}}-H_2|C-[,,,2]H_{2}|\chemabove{N}{\quad\scriptstyle+}-)
}
\end{document}
If you place the first two compounds in a \subscheme{...}
the whole subscheme gets a unique name that you can refer to in an arrow using the \arrow{@<name>--)
syntax:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
% uncomment to see the names:
% schemedebug{true}
\schemestart
\subscheme{
\chemfig{R-[:30](=[:90]O)-[:-30]R}
\arrow{0}[,.5]
\chemfig{R'-[:30](=[:90]O)-[:-30]R'}
}
\arrow{0}[,1.5]
\chemfig{R'-[:30](=[:90]O)-[:-30]R}
% use an invisible arrow pointing downwards to place the label text:
\arrow(@c1--){0}[-90,.1]
Below the first two compounds
\schemestop
\end{document}
![enter image description here](https://i.stack.imgur.com/5scfd.png)
Best Answer
Since you can use tikzpictures inside of tikzpictures you can for example define some
\circleatom
command and use it inside\chemfig
:Edited: a better definition of
\circleatom
would beThe
\printatom
will ensure that that aroms are displayed the same if you change it to, say, have sans serif printed atoms.BTW: I would probably use
chemfig
's scheming commands\schemestart
,\arrow
and\schemestop
to typeset the reaction.