1

I changed the labeling format that also the chapter number is included (R 0.1). When I cross reference to the reaction only the number (1) and not the whole label with chapter number is used. How can I get the same format/label also for the cross reference?

\documentclass{scrreprt}

\usepackage{chemmacros}
\chemsetup{modules={all}}
\chemsetup[reactions]{
    before-tag = R \thechapter.,
    tag-open = ( ,
    tag-close = )
}

\begin{document}

\begin{reactions}
  A + B &-> C "\label{test1}" \\
  X + Y + Z &-> XX "\label{test2}"
\end{reactions}

In reaction \ref{test1} and \ref{test2}
\end{document}
2
  • 4
    \renewcommand\thereaction{R~\thechapter.\arabic{reaction}} instead of the before-tag key? Feb 27, 2020 at 8:46
  • Thank you, that is all what I needed!
    – michael.ro
    Feb 27, 2020 at 10:31

1 Answer 1

0

You see the same for math equations. This is because the tag is what is put around the counter number in equations.

\the<counter is what represents how the counter number is actually to be printed, everywhere:

\documentclass{article}

\usepackage{mathtools}
\renewtagform{default}{[}{]}
\usetagform{default}

\begin{document}

\begin{equation}
  1 \neq 2 \label{foo}
\end{equation}

\ref{foo} % not [1] but 1

\renewtagform{default}{}{}
\renewcommand\theequation{[\arabic{equation}]}

\begin{equation}
  3=3 \label{bar}
\end{equation}

\ref{bar} % [2]

\end{document}

enter image description here

It's completely analoguous with chemmacros reactions:

\documentclass{article}

\usepackage{chemmacros}
\usechemmodule{reactions}
\renewtagform{reaction}{[}{]}

\begin{document}

\begin{reaction}
  CH4 \label{foo}
\end{reaction}

\ref{foo} % not [1] but 1

\renewtagform{reaction}{}{}
\renewcommand\thereaction{[\arabic{reaction}]}

\begin{reaction}
  H2O \label{bar}
\end{reaction}

\ref{bar} % [2]

\end{document}

enter image description here

chemmacros options are really just wrappers around mathtools' \renewtagform.

You must log in to answer this question.

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