1

I have been trying to draw a chemistry diagram using the following code:

    \schemestart
{\scriptsize \chemfig{
H-[:30]C(-[:90]H)(-[:-90]H)-[:-30]\Lewis{2:,N}(-[:-90]H)-[:30]C(-[:90]H)(-[:-90]H)-[:-30]C(-[:90]H)(-[:-90]N\rlap{${}^+$}(-[:-150]H)(-[:-90]H)-[:-30]H)-[:30]C(=[:90]\Lewis{1:3:,O})-[:-30]\Lewis{1:5:7:,O}^\rlap{${}^-$}
}}
\arrow{<=>}
{\scriptsize \chemfig{
H-[:30]C(-[:90]H)(-[:-90]H)-[:-30]N\rlap{${}^+$}(-[:-90]H)(-[:90]H)-[:30]C(-[:90]H)(-[:-90]H)-[:-30]C(-[:90]H)(-[:-90]N(-[:-150]H)-[:-30]H)-[:30]C(=[:90]\Lewis{1:3:,O})-[:-30]\Lewis{1:5:7:,O}\rlap{${}^-$}
}}
\arrow{<=>[$+$\chemfig{H^+}]}
{\scriptsize \chemfig{
H-[:30]C(-[:90]H)(-[:-90]H)-[:-30]N\rlap{${}^+$}(-[:-90]H)(-[:90]H)-[:30]C(-[:90]H)(-[:-90]H)-[:-30]C(-[:90]H)(-[:-90]N\rlap{${}^+$}(-[:-150]H)(-[:-90]H)-[:-30]H)-[:30]C(=[:90]\Lewis{1:3:,O})-[:-30]\Lewis{1:5:7:,O}\rlap{${}^-$}
}}
\schemestop

Unfortunately the following error comes ! Missing { inserted.<to be read again>\hbox { ! Missing { inserted.<inserted text>{ The error is attached to the second molecule, that is the line where {\scriptsize \chemfig{ appears for the second time. How do I fix this error?

4
  • 1
    The issue is the ^\rlap{${}^-$} at the end of the first chemfig. What precisely do you want to achieve with it?
    – user121799
    Commented Oct 5, 2018 at 12:12
  • 1
    The bonds will treat the whole \Lewis{1:5:7:,O}^- as one 'box'. See the chemfig documentation (mirror.aarnet.edu.au/pub/CTAN/macros/generic/chemfig/…) and page 42 section 12.2
    – sab hoque
    Commented Oct 5, 2018 at 12:15
  • 1
    Yes, but what you have now yields an error, which disappears once you remove ^\rlap{${}^-$}. So I am asking to understand what it is good for to be able with an alternative way to achieve the same.
    – user121799
    Commented Oct 5, 2018 at 12:17
  • 1
    The nitrogens and the oxygens are off centre in the atom as the whole N^+ or O^- section is treated as one 'atom', whereas I only want the N or the O part to be treated as the 'atom' so it is in line.
    – sab hoque
    Commented Oct 5, 2018 at 12:19

1 Answer 1

1

You just had an excess ^ in front of \rlap.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{chemfig}
\begin{document}
\schemestart
{\scriptsize \chemfig{
H-[:30]C(-[:90]H)(-[:-90]H)-[:-30]\Lewis{2:,N}(-[:-90]H)-[:30]C(-[:90]H)(-[:-90]H)-[:-30]C(-[:90]H)(-[:-90]N\rlap{${}^+$}(-[:-150]H)(-[:-90]H)-[:-30]H)-[:30]C(=[:90]\Lewis{1:3:,O})-[:-30]\Lewis{1:5:7:,O}\rlap{${}^-$}
}}
\arrow{<=>}
{\scriptsize \chemfig{
H-[:30]C(-[:90]H)(-[:-90]H)-[:-30]N\rlap{${}^+$}(-[:-90]H)(-[:90]H)-[:30]C(-[:90]H)(-[:-90]H)-[:-30]C(-[:90]H)(-[:-90]N(-[:-150]H)-[:-30]H)-[:30]C(=[:90]\Lewis{1:3:,O})-[:-30]\Lewis{1:5:7:,O}\rlap{${}^-$}
}}
\arrow{<=>[$+$\chemfig{H^+}]}
{\scriptsize \chemfig{
H-[:30]C(-[:90]H)(-[:-90]H)-[:-30]N\rlap{${}^+$}(-[:-90]H)(-[:90]H)-[:30]C(-[:90]H)(-[:-90]H)-[:-30]C(-[:90]H)(-[:-90]N\rlap{${}^+$}(-[:-150]H)(-[:-90]H)-[:-30]H)-[:30]C(=[:90]\Lewis{1:3:,O})-[:-30]\Lewis{1:5:7:,O}\rlap{${}^-$}
}}
\schemestop
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .