在对齐环境中自定义标签

在对齐环境中自定义标签

我想在对齐环境中稍微定制一下标签。当我在同一行上有两个方程式时,就会出现这种需要,我想给它们贴上 (1a,b) 或类似的标签。当我使用方程式环境时,下面的示例按预期工作,因为它标记了方程式 (1a,b) 和 (2a,b),这正是我想要的。但是,如果我用对齐环境替换方程式环境,我的定制将不起作用。我在方程式环境中的定制是:

\renewcommand{\theequation}{\arabic{equation}a,b}

\renewcommand{\theequation}{\arabic{\theparentequation{a,b}} 

但这些在 align 环境中不起作用。它们的等价物是什么?具体来说,在下面的最后一个示例中,在 subequations 环境中使用 align,我想标记方程 (4a,b) 和 (4c,d) 和 (4e),其中 '4' 是自动提供的方程编号,'a,b' 和 'c,d' 和 'e' 是我手动添加的。这是 MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\subsubsection*{Using equation}
\textit{Case 1:}  works as expected
\begin{equation}
\renewcommand{\theequation}{\arabic{equation}a,b}
a = b, \qquad b = c
\end{equation}
\textit{Case 2:} still works, but the alignment cannot be adjusted.
\begin{subequations}
\begin{equation}
\renewcommand{\theequation}{\theparentequation{a,b}}
a = b, \qquad b = c
\end{equation}
\begin{equation}
\renewcommand{\theequation}{\theparentequation{c,d}}
d = f = h, \qquad f = g     
\end{equation}
\end{subequations}

\subsubsection*{Using align}
The following cases do not work in the same way using the align environment. \\
\textit{Case 3:} This case is fine, but doesn't 
help as I could do the same thing with the equation environment. 
\begingroup
\renewcommand{\theequation}{\arabic{equation}a,b}
\begin{align}
a = b, \qquad b = c
\end{align}
\endgroup
\textit{Case 4:} Now here is the case that I want to work, but it does not. 
I would like it to label the three equations (4a,b), (4c,d) and (4e)
\begin{subequations}
\begingroup
\renewcommand{\theequation}{\theparentequation{a,b}}
\begin{align}
a = b, \qquad & b = c \\
\renewcommand{\theequation}{\theparentequation{c,d}}
d = f = h, \qquad & f = g \\
\renewcommand{\theequation}{\theparentequation{e}}
& g = h
\end{align}
\endgroup
\end{subequations}
\end{document}

答案1

我建议使用subequations,以及一个新命令:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\newcommand{\subtag}[1]{\tag{\theparentequation#1}}

Here is first a single equation
\begin{subequations}
\begin{equation}
a = b, \qquad b = c \subtag{a,b}
\end{equation}
and then an alignment
\begin{gather}
\begin{align}
a &= b,     & b = c \subtag{c,d}\\
d &= f = h, & f = g \subtag{e,f}
\end{align}\\
g = h \subtag{g}
\end{gather}
\end{subequations}

\end{document}

在此处输入图片描述

答案2

在 的情况下align,这不起作用,因为 的每个单元align都是一个不同的本地组,并且新的定义在该组之外不会持续存在。

如果你重新定义 \begin{align}它会产生您想要的效果,但不幸的是,它不会在该块之后自动消失,因此您必须将其隔离,方法是将整个块放在括号或之间\begingroup ... \endgroup

在这种情况下,情况有些类似(尽管更复杂)subequations。实际上,由于一个subequations组会a在第一行、b第二行等等,所以你所说的期望并不是真正应该期望的。如果你移动重新定义

\renewcommand{\theequation}{\theparentequation{a,b}}

在 的范围之外align,应用的计数器将是 的最后一个前一个值\theparentequation,而不是计数器的下一个逻辑值equation,并且分配的标签后面还会跟着“a”,对于“(Na,ba)”,这根本不是您想要的。

我并不确信您是否真的想使用align这种经过修改的subequations计数器和标签,但也许您有理由在“普通”align环境中使用它;我只是不知道。

align这确实证明了不应该用于单行显示的另一个原因。

相关内容