3

I just found chemfig fantastic for drawing even difficult molecules. Now, I have a question: how can I put under the molecule a line with a caption like "Figure #: captiontext" and, even more important, how can I refer in the text to the drawn molecule?

1 Answer 1

5

I must confess the question is a bit unclear to me but it seems like you simply want a {figure} environment. If by »refer to the [...] molecule« you mean the practice of refering to molecules with numbers in the text you may want to have a look at the chemnum package.

\documentclass{article}
\usepackage{chemfig}
\usepackage{chemnum}
\newcommand*\pkg[1]{\textsf{#1}}
\begin{document}

\begin{figure}
  \centering
  \chemfig{-[:30](=[:90]O)-[:-30]OH}
  \caption{The sceletal formula of ethanol (\cmpd{ethanol}) drawn with
    \pkg{chemfig}.}
  \label{fig:ethanol}
\end{figure}

The formula of \cmpd{ethanol} is shown in figure~\ref{fig:ethanol}.

\end{document}

enter image description here

Caution: the number of the molecule is determined by the first use of the corresponding \cmpd. This means it may haben in the \listoffigures if you use \cmpd in a caption. For cases like this there is \cmpd+ which only fetches the number:

\begin{figure}
  ...
  \caption{... ethanol (\cmpd+{ethanol}) ...}
\end{figure}

The formula of \cmpd{ethanol} ...

You must log in to answer this question.

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