Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Welcome to TeX.SE! and thanks for the (MWE). –  percusse Nov 18 '12 at 19:50

1 Answer 1

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.

share|improve this answer
    
ok thank you so I must have overlooked or misunderstood the manual then will give it a try. –  Thomas Feldmann Nov 18 '12 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.