1

As in How to force a special numbering for a specific equation I want to introduce a set of chemical reactions (see code below) within a text containing some standard equations. Standard equations should be numbered continuously, but the chemical reactions should be numbered C1-Cn.

In addition to hereinabove mentionned problem I have two reactions below each other with the same product, so I'd like to get a numbering like C1a and C1b.

In equation-mode it is possible by introducing "subequations", see example below. How can I do that? Thank you for your help!

This works:

\begin{subequations}
  \begin{equation}
     1 + 3 = 4
    \label{eq:1plus3}
  \end{equation}
  \begin{equation}
     2 + 2 = 4 
    \label{eq:2plus2}
  \end{equation}
 \label{eq:result_equals_4}%
\end{subequations}

If I refer to this equations in my text, by using \eqref{eq:1plus3} I get (1.1a) and if I refer to \eqref{eq:2plus2} I get (1.1b), if I refer to \eqref{eq:result_equals_4} I get (1.1).

But this doesn't work:

\begin{subequations}
   \reaction[react:NO2_a]{2 NO + O_2 <=> 2 NO_2 + 114,2\,\mathrm{\frac{kJ}{mol}}}
   \reaction[react:NO2_b]{NO + O <=> NO_2 + 306,3\,\mathrm{\frac{kJ}{mol}}}
   \label{react:NO2}%
\end{subequations}

The result:

\reref{react:NO2_a} --> (C 1.1)

\reref{react:NO2_b} --> (C 1.2)

\reref{react:NO2} --> (1.20) (because I have 19 "standard, mathematical" equations)

I'd like to get:

\reref{react:NO2_a} --> (C 1.1a)

\reref{react:NO2_b} --> (C 1.1b)

\reref{react:NO2} --> (C 1.1)

Edit:

\documentclass[
paper=a4,                           % alle weiteren Papierformat einstellbar
fontsize=12pt,              % Schriftgröße (12pt, 11pt (Standard))
BCOR=5mm,                           % Bindekorrektur, bspw. 1 cm
DIV=calc,                           % führt die Satzspiegelberechnung neu aus
]

{scrbook}

\addtolength{\topmargin}{\baselineskip}     % oberer Seitenrand
\setlength{\parindent}{0mm}                             % Absatzeinrückung
\setlength{\parskip}{1.25ex plus 0.5ex minus 0.5ex}     % Absatzabstand
\setlength{\headheight}{1.3\baselineskip}
\renewcommand{\textfraction}{0.05}
\renewcommand{\topfraction}{0.85}
\renewcommand{\floatpagefraction}{0.65}
\renewcommand{\baselinestretch}{1.2}
\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\usepackage{repage}
\usepackage{amsmath}
\usepackage{amssymb}
\let\amsboldsymbol\boldsymbol
\usepackage{bm}% ändert \boldsymbol
\let\boldsymbol\amsboldsymbol
\usepackage[textsize=small,obeyDraft]{todonotes}
\usepackage[version=4,layout=stacked]{mhchem}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp} 
\usepackage{esvect}
\addtokomafont{chapter}{\rmfamily}

\makeatletter
\renewcommand{\eqref}[1]{\textup{\textbf{Gl.~\ref{#1}}}}
\newcommand{\reref}[1]{\textup{\textbf{\ref{#1}}}}
\makeatother

\makeatletter
\newcounter{reaction}
%%% >> for article <<
%\renewcommand\thereaction{C\,\arabic{reaction}}
%%% << for article <<
%%% >> for report and book >>
\renewcommand\thereaction{C\,\thechapter.\arabic{reaction}}
\@addtoreset{reaction}{chapter}
%%% << for report and book <<
\newcommand\reactiontag%
{\refstepcounter{reaction}\tag{\thereaction}}
\newcommand\reaction@[2][]%
{\begin{equation}\ce{#2}%
\ifx\@empty#1\@empty\else\label{#1}\fi%
\reactiontag\end{equation}}
\newcommand\reaction@nonumber[1]%
{\begin{equation*}\ce{#1}\end{equation*}}
\newcommand\reaction%
{\@ifstar{\reaction@nonumber}{\reaction@}}
\makeatother

\begin{document}

\chapter{How to force a special numbering with literals for a specific equation}

\begin{subequations}
      \begin{equation}
         1 + 3 = 4
        \label{eq:1plus3}
      \end{equation}
      \begin{equation}
         2 + 2 = 4 
        \label{eq:2plus2}
      \end{equation}
     \label{eq:result_equals_4}%
\end{subequations}

\begin{subequations}
       \reaction[react:NO2_a]{2 NO + O_2 <=> 2 NO_2 + 114,2\,\mathrm{\frac{kJ}{mol}}}
       \reaction[react:NO2_b]{NO + O <=> NO_2 + 306,3\,\mathrm{\frac{kJ}{mol}}}
       \label{react:NO2}%
 \end{subequations}

Result: \eqref{eq:1plus3} and \eqref{eq:2plus2} and \eqref{eq:result_equals_4}. \\
Result: \reref{react:NO2_a}, \reref{react:NO2_b}, \reref{react:NO2}.

\end{document}
  • Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in Maarten's edit. You can also highlight the code and click the "code" button (with "{}" on it). – ebosi May 25 '16 at 10:08
  • 1
    Could you post a full compilable code? Help us to help you! – Bernard May 25 '16 at 10:36
  • Thank you for your answers, I have added a compilable code in my question above. – Isabell May 25 '16 at 11:10
  • @Isabell: you can still give a try to the "code" button (with {} on it)... it's worth it (-; – ebosi May 25 '16 at 11:49
  • @ ebo, sorry, I used the {} but I didn't get, that using ` code ` does not make the same like using ctrl + k... – Isabell May 25 '16 at 12:00
1

Here is a solution: I defined a clone of the subequations environment, under the name of subreactions:

\documentclass[
paper=a4, % alle weiteren Papierformat einstellbar
fontsize=12pt, % Schriftgröße (12pt, 11pt (Standard))
BCOR=5mm, % Bindekorrektur, bspw. 1 cm
DIV=calc, % führt die Satzspiegelberechnung neu aus
]
{scrbook}

\addtolength{\topmargin}{\baselineskip} % oberer Seitenrand
\setlength{\parindent}{0mm} % Absatzeinrückung
\setlength{\parskip}{1.25ex plus 0.5ex minus 0.5ex} % Absatzabstand
\setlength{\headheight}{1.3\baselineskip}
\renewcommand{\textfraction}{0.05}
\renewcommand{\topfraction}{0.85}
\renewcommand{\floatpagefraction}{0.65}
\renewcommand{\baselinestretch}{1.2}
\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
%\usepackage{repage}
\usepackage{mathtools}
\usepackage{amssymb}
\let\amsboldsymbol\boldsymbol
\usepackage{bm}% ändert \boldsymbol
\let\boldsymbol\amsboldsymbol
%\usepackage[textsize=small,obeyDraft]{todonotes}
\usepackage[version=4,layout=stacked]{mhchem}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{esvect}
\addtokomafont{chapter}{\rmfamily}

\makeatletter
\renewcommand{\eqref}[1]{\textup{\textbf{Gl.~\ref{#1}}}}
\newcommand{\reref}[1]{\textup{\textbf{\ref{#1}}}}
\makeatother

\makeatletter
\newcounter{reaction}
%%% >> for article <<
%\renewcommand\thereaction{C\,\arabic{reaction}}
%%% << for article <<
%%% >> for report and book >>
\renewcommand\thereaction{C\,\thechapter.\arabic{reaction}}
\@addtoreset{reaction}{chapter}
%%% << for report and book <<
\newcommand\reactiontag%
{\refstepcounter{reaction}\tag{\thereaction}}
\newcommand\reaction@[2][]%
{\begin{equation}\ce{#2}%
\ifx\@empty#1\@empty\else\label{#1}\fi%
\reactiontag\end{equation}}
\newcommand\reaction@nonumber[1]%
{\begin{equation*}\ce{#1}\end{equation*}}
\newcommand\reaction%
{\@ifstar{\reaction@nonumber}{\reaction@}}

\newcounter{parentreaction}% Counter for ``parent reaction''.
\@ifundefined{ignorespacesafterend}{%
  \def\ignorespacesafterend{\global\@ignoretrue}%
}{}
\newenvironment{subreactions}{%
  \refstepcounter{reaction}%
  \protected@edef\theparentreaction{\thereaction}%
  \setcounter{parentreaction}{\value{reaction}}%
  \setcounter{reaction}{0}%
  \def\thereaction{\theparentreaction\alph{reaction}}%
  \ignorespaces
}{%
  \setcounter{reaction}{\value{parentreaction}}%
  \ignorespacesafterend
}
\makeatother

\begin{document}

\chapter{How to force a special numbering with literals for a specific equation}

\begin{subequations}
      \begin{equation}
         1 + 3 = 4
        \label{eq:1plus3}
      \end{equation}
      \begin{equation}
         2 + 2 = 4
        \label{eq:2plus2}
      \end{equation}
     \label{eq:result_equals₄}%
\end{subequations}

\begin{subreactions}
       \reaction[react:NO2_a]{2 NO + O₂ <=> 2 NO₂ + 114,2\,\mathrm{\frac{kJ}{mol}}}
       \reaction[react:NO2_b]{NO + O <=> NO₂ + 306,3\,\mathrm{\frac{kJ}{mol}}}
       \label{react:NO2}%
 \end{subreactions}

Result: \eqref{eq:1plus3} and \eqref{eq:2plus2} and \eqref{eq:result_equals₄}. \\
Result: \reref{react:NO2_a}, \reref{react:NO2_b}, \reref{react:NO2}.

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.