6

I'm trying to put a number of different molecule structures into one document with the help of the chemfig package. The package also allows to add the name of the compound to the structure as a caption via the chemname command. As far as I understand the distance of the label from the structure is measured by the package and to avoid overlaps the largest spacing found is used for all subsequent labels. This leads to the effect of a large distance if the following molecule structure is small.

Is there a way to reset the distance measured between the \chemname commands?

Thank you very much for your help and please also see the example code below.

Thomas

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{chemfig}
\begin{document}
\chemname{\chemfig{-[7]-[1]P(=[2]O)(-[6]-[7])-[7]-[1]}}{Triethylphosphine oxide}

\chemname{\chemfig{-[1](-[2]OH)-[7]}}{Isopropanol}

\chemname{\chemfig{H_2N-[1](=[2]O)-[7]NH_2}}{Urea}
\end{document}
1

1 Answer 1

10

The \chemname command takes an optional argument for vertical spacing:

\chemname[<dim>]{\chemfig{<code of the molecule>}}{<name>}

However, since your problem is a common one chemfig gives you the possibility to initialize the space. Quoting the manual:

In fact, to draw the <name> the command \chemname inserts 1.5ex + the largest of the depths of the molecules thus far below the baseline of each molecule (light grey for the examples in this manual). The command \chenameinit{<stuff>} initializes this largest depth with the <stuff>. Therefore one should:

  • write \chemnameinit{<deepest molecule>} before using the \chemname command in a reaction, unless the reaction begins with the deepest molecule;
  • write \chemnameinit{} after having written all the names in a chemical reaction lest the greatest depth in this reaction interfere with a future reaction.

So there's your answer: use \chemnameinit{} to reset the behaviour of \chemname.

1
  • ok thank you so I must have overlooked or misunderstood the manual then will give it a try. Nov 18, 2012 at 20:03

You must log in to answer this question.

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