TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with the automatic reference by cleveref and the chemmacros package. When i refer to a reaction with cleveref, then cleveref types "eq. (1)" because chemmacros use the equation environment. That's why a simple customization with \crefname, \creflabelformat or \crefformat has no effects. But i want, that cleveref detect the reaction and set the reference to reaction {1}. Here the MWE.

Before a little text.
A -> B \label{rxn:test}
After the ref with cleveref \cref{rxn:test}.

The cleveref package provides an advanced \label-command with a optional argument to overwrite the reference type.

A -> B \label[reaction]{rxn:test}


A -> Breaction]rxn:test

But no erros and correct reference output. According to the cleveref documentation, you should use the folliwing code for the optional \label-command

A -> B {\label[reaction]{rxn:test}}

Gives me 3 times the error

amsmath: Multiple \label's: label '[reaction]{rxn:test}' will be lost. \end{reaction}

But with a \crefname{reaction}{reaction}{reactions} and \creflabelformat{reaction}{#2{#1}#3} the reference output is correct.

During the investigations i found out, that with this code (add a 1 to the labeltag)

A -> B {\label[reaction]{rxn:test1}}

several errors come and no correct ref output.

Undefined control sequence ...n:test\chemformula_subscript:n {1}}{{1}{1}}

Undefined control sequence ...ubscript:n {1}@cref}{{[reaction][3][]1}{1}}

amsmath: Multiple \label's: label '[reaction]{rxn:test\chemformula_subscript:n {1}}' will be lost. \end{reaction}

Undefined control sequence ...n:test\chemformula_subscript:n {1}}{{1}{1}}

Undefined control sequence ...ubscript:n {1}@cref}{{[reaction][4][]1}{1}}

chemmacros define the reaction by the environ. chemmacros or environ processes the optional \label-command incorrect.

Does anyone have an idea to connect chemmacros with cleveref? Thanks!

share|improve this question
It seems that chemmacros interprets the label like a subscript from a formula -> \chemformula_subscript:n – maphy-psd Apr 4 '14 at 16:46
The reaction environment is a wrapper around an equation environment and I didn't build in the possibility of an optional argument to \label . But since I have scheduled the next update I see if I can add something – clemens Apr 4 '14 at 17:14
I know of the wrapper attribute. I studied the *.sty of chemmacros and cleveref 2 hours. So, therefore I thing is better to fix the reaction environment that the cleveref label command works, isn't it? – maphy-psd Apr 4 '14 at 19:13
That's the plan... – clemens Apr 4 '14 at 23:56
up vote 2 down vote accepted

With version 4.5 (2014/04/08) chemmacros supports an optional argument to \label:





  A -> B \label[reaction]{rct:ab}

See \cref{rct:ab}\ldots


enter image description here

share|improve this answer

Your Answer


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.