# Changing space between atoms in Chemabove

Consider this example:

  \documentclass{memoir}
\usepackage{fontspec}
\usepackage{chemfig}
\usepackage{unicode-math}
\pdfmapline{+arial arial <8r.enc <sAarial.ttf}
\begin{document}
\setmainfont{arial}
\setmathfont[range=\mathup] {arial}

\chemfig{HO-[:30]**6(---(-\Chemabove[6pt]{N}{H}-[:-30](=[6]O)-[:30])---)}
\end{document}


The N lies more or less on top of the H. How can I increase this distance?

EDIT: As seen in example below. For some reason the optional argument do not behave as expected. At least not with my font set up.

  \documentclass{memoir}
\usepackage{fontspec}
\usepackage{chemfig}
\usepackage{unicode-math}
\pdfmapline{+arial arial <8r.enc <sAarial.ttf}
\begin{document}
\setmainfont{arial}
\setmathfont[range=\mathup] {arial}

\chemfig{HO-[:30]**6(---(-\Chemabove[24pt]{N}{H}-[:-30](=[6]O)-[:30])---)}
\end{document}


• You could try something like \Chemabove{N}{\raisebox{0.6ex}{H}}. – Gonzalo Medina Apr 9 '13 at 14:32
• Clever. That worked very well actually. – jonalv Apr 9 '13 at 14:53
• Do you think I should turn my comment into an answer? – Gonzalo Medina Apr 9 '13 at 14:56
• Yea, I mean there could be some setting somewhere but this solution was so easy so yea I think it should be turned into an answer – jonalv Apr 9 '13 at 15:37
• Do you need to use arial? – cgnieder Apr 10 '13 at 9:09

One quick solution would be to use \raisebox:

\documentclass{memoir}
\usepackage{chemfig}

\begin{document}
\chemfig{HO-[:30]**6(---(-\Chemabove[6pt]{N}{H}-[:-30](=[6]O)-[:30])---)}
\chemfig{HO-[:30]**6(---(-\Chemabove[6pt]{\raisebox{1ex}{N}}{\raisebox{1ex}{H}}-[:-30](=[6]O)-[:30])---)}
\end{document}


The optional arguments of \chemabove and \chembelow do exactly that! Citing chemfig's manual:

The macros \chemabove[<dim>]{<code>}{<stuff>} and \chembelow[<dim>]{<code>}{<stuff>} place the <stuff> above and below the <code> respectively at a vertical distance <dim>, without changing the bounding box of <code>. The optional argument allows, if written, to specify this dimension at each call. If the optional argument is not used, a default size will be taken: its value is 1.5pt but it can be modified with the macro \setstacksep{<dimension>}. These commands are independent of the macro \chemfig and can be used either inside or outside its argument.

Notice the

without changing the bounding box of <code>

part which is exactly what sets these macros apart from the uppercase versions \Chemabove and \Chembelow which do change the bounding box! (There is another pair of macros with the same difference: \lewis and \Lewis.)

Let's see that it works.

The default distance (1.5pt):

\documentclass[margin=.75cm]{standalone}
\usepackage{chemfig}
\begin{document}

\chemfig{HO-[:30]**6(---(-\chemabove{N}{H}-[:-30](=[6]O)-[:30])---)}

\end{document}


A larger distance (5pt):

\documentclass[margin=.75cm]{standalone}
\usepackage{chemfig}
\begin{document}

\chemfig{HO-[:30]**6(---(-\chemabove[5pt]{N}{H}-[:-30](=[6]O)-[:30])---)}

\end{document}


A larger distance (5pt) and \Chemabove - notice that N is no longer correctly placed with respect to the bonds due to the changed bounding box:

\documentclass[margin=.75cm]{standalone}
\usepackage{chemfig}
\begin{document}

\chemfig{HO-[:30]**6(---(-\Chemabove[5pt]{N}{H}-[:-30](=[6]O)-[:30])---)}

\end{document}


• It's very intresting that you say so because that is what I thought too. However I had some major problems with getting that to work. Will look into it further and update the question accordingly real-soon-now™ – jonalv Apr 9 '13 at 18:41
• I suspect your problems have something to do with your font settings which I didn't use as I haven't arial available and which are the only real difference in your MWE and mine – cgnieder Apr 9 '13 at 18:49
• Yea most probably that is the case. – jonalv Apr 10 '13 at 7:45
• However. I think perhaps in most cases one do not want to change the bounding box and in fact keep the N at it's original place. Maybe I am missing some situation though... – jonalv Apr 10 '13 at 8:15
• @jonalv True. That's why I pointed to the difference of \chemabove and \Chemabove – cgnieder Apr 10 '13 at 8:49