0

So I'm using the lower version as in: How to force a special numbering for a specific equation

switching between reactions and default with \usetagform{reaction} and \usetagform{default}

The numbering however stays the same. Is it at least possible when refering to a \label{R1} with \ref{R1} to include the prefix R defined in the header \newtagform{reaction}[R]()

Here is the MWE:

    \documentclass[12pt,fleqn,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage[ngerman]{babel}

\newtagform{reaction}{(R}{)}

\begin{document}

\usetagform{reaction}
\begin{align}
    X + Y \quad \longrightarrow \quad Z \label{R1}
\end{align}

\usetagform{default}
\begin{align}
    x + y = z \label{eq2}
\end{align}

This is what I get:
\begin{enumerate}
    \item reaction (\ref{R1})
    \item equation (\ref{eq2})
\end{enumerate}


But I want:
\begin{enumerate}
    \item reaction ({\rm R}\ref{R1})
    \item equation (\ref{eq2})
\end{enumerate}


\end{document}
5
  • 2
    You may want to provide an MWE such that others can reproduce your observation. And I'm wondering if \newtagform{reaction}{(R}{)} gives you what you want.
    – user121799
    Mar 4, 2018 at 2:17
  • added the MWE...
    – Diger
    Mar 4, 2018 at 2:37
  • No surprise. In the mathtools manual it is written that "When you reference an equation with \eqref, the tag form in effect at the time of refer- encing controls the formatting, so be careful if you use different tag forms throughout your document.".
    – user121799
    Mar 4, 2018 at 9:21
  • Out of curiosity: do you know chemmacros and its reaction environments?
    – cgnieder
    Mar 5, 2018 at 10:49
  • No I dont, should i ?
    – Diger
    Mar 5, 2018 at 21:10

1 Answer 1

1

UPDATE: Is this closer to what you want?

\documentclass[12pt,fleqn,a4paper]{article}
\usepackage{amsmath}

\newcommand{\PrependEqNo}[1]{\stepcounter{equation}\tag{#1\theequation}}

\begin{document}

\begin{align}
    X + Y \quad &\longrightarrow \quad Z \PrependEqNo{R}
    \label{R1}\\
    A + B \quad &\longrightarrow \quad C \label{2}  
\end{align}
Above are reaction \eqref{R1} and equation \eqref{2}.
\begin{subequations}
\begin{align}
 U+V\quad &\longrightarrow \quad W\PrependEqNo{R}\\
 F+G\quad &\longrightarrow \quad H
\end{align}
\end{subequations}
\end{document}

enter image description here

OLD STUFF: In the mathtools manual it is written that "When you reference an equation with \eqref, the tag form in effect at the time of refer- encing controls the formatting, so be careful if you use different tag forms throughout your document.". However, I think that the following might do what you want.

\documentclass[12pt,fleqn,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage[ngerman]{babel}

\newtagform{reaction}{(R}{)}


\newcommand{\SwitchToChem}{\renewcommand{\theequation}{R\arabic{equation}}}
\newcommand{\SwitchBack}{\renewcommand{\theequation}{\arabic{equation}}}


\begin{document}

\usetagform{reaction}
\begin{align}
    X + Y \quad \longrightarrow \quad Z \label{R1}
\end{align}

\usetagform{default}
\begin{align}
    x + y = z \label{eq2}
\end{align}

This is what I get:
\begin{enumerate}
\usetagform{reaction}
    \item reaction \eqref{R1}
\usetagform{default}    
    \item equation \eqref{eq2}
\end{enumerate}

If you want to have this without switching, use 
\SwitchToChem
\begin{equation}
 U+W\quad\longrightarrow\quad V\label{R2}
\end{equation}
\SwitchBack
Here comes \eqref{R2}.
\end{document}
6
  • Why is \eqref prefered over \ref ???
    – Diger
    Mar 4, 2018 at 13:26
  • Also do I have to use "theequation" environment, or does the latter also work with align. BTW: Why do you prefer: {(R}{)} over [R]()
    – Diger
    Mar 4, 2018 at 13:33
  • @Diger theequation is not an environment, I just wrote two options that were not explicitly discussed in the answers to (this question)[tex.stackexchange.com/questions/147851/…, and with \newtagform{reaction}{(R}{)} I just follow the mathtools manual.
    – user121799
    Mar 4, 2018 at 20:03
  • Well the other answer however relies on the mhchem package... I was wondering if using a new command like you I can do the same but with the align environment instead (is that an environment?)
    – Diger
    Mar 4, 2018 at 21:23
  • @Diger So you want an align environment in which some numbers have an R in front and others not?
    – user121799
    Mar 4, 2018 at 21:30

You must log in to answer this question.

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