就像如何强制对特定方程式进行特殊编号我想在包含一些标准方程式的文本中引入一组化学反应(见下面的代码)。标准方程式应该连续编号,但化学反应应该编号为 C1-Cn。
此外上述问题我有两个针对同一产品的反应,所以我想得到像 C1a 和 C1b 这样的编号。
在方程式模式下,通过引入“子方程式”可以实现这一点,见下面的示例。我该怎么做?谢谢您的帮助!
这有效:
\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}
如果我在文中引用这个方程,使用时\eqref{eq:1plus3}
我得到 (1.1a),如果我引用时\eqref{eq:2plus2}
我得到 (1.1b),如果我引用时\eqref{eq:result_equals_4}
我得到 (1.1)。
但这不起作用:
\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}
结果:
\reref{react:NO2_a}
-->(C1.1)
\reref{react:NO2_b}
-->(C1.2)
\reref{react:NO2}
--> (1.20)(因为我有 19 个“标准数学”方程式)
我想要得到:
\reref{react:NO2_a}
-->(C 1.1a)
\reref{react:NO2_b}
--> (第 1.1b 条)
\reref{react:NO2}
-->(C1.1)
编辑:
\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}
答案1
这是一个解决方案:我定义了一个subequations
环境的克隆,名称为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}