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.
\documentclass{scrartcl}
\usepackage{chemmacros}
\usepackage{cleveref}
\begin{document}
Before a little text.
\begin{reaction}
A -> B \label{rxn:test}
\end{reaction}
After the ref with cleveref \cref{rxn:test}.
\end{document}
The cleveref package provides an advanced \label-command with a optional argument to overwrite the reference type.
\begin{reaction}
A -> B \label[reaction]{rxn:test}
\end{reaction}
Gives
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
\begin{reaction}
A -> B {\label[reaction]{rxn:test}}
\end{reaction}
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)
\begin{reaction}
A -> B {\label[reaction]{rxn:test1}}
\end{reaction}
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!