悠闲数学娱乐论坛(第2版)'s Archiver

kuing 发表于 2017-6-19 01:32

\nonumber 的「反」

可能以前也讲过,不管了。

我们都知道在多行公式环境(如 align)中可以用 \nonumber(或 \notag)来禁止某行生成编号,像这样[code]\begin{align}
a &= a,\\
b &= b,\\
c &= c, \nonumber \\
d &= d,
\end{align}[/code]\begin{align}
a &= a,\\
b &= b,\\
c &= c, \nonumber \\
d &= d,
\end{align}
但如果行数多而需要编号的行却很少时,那就要加很多个 \nonumber 了,经常遇到的情况就是只有最后一行才编号,结果代码就像这样[code]\begin{align}
a &= b \nonumber \\
&= \cdots \nonumber \\
&= \cdots \nonumber \\
&= x,
\end{align}[/code]\begin{align}
a &= b \nonumber \\
&= \cdots \nonumber \\
&= \cdots \nonumber \\
&= x,
\end{align}
这显然不方便,理应有一个与 \nonumber 相反的命令——即能对无编号的 align* 环境中的某些行编号(并且号码是自动增加的)才是,但 amsmath 并未提供,尽管定义它并不难:[code]\newcommand\addtag{\refstepcounter{equation}\tag{\theequation}}[/code]这样,上面的就可以这样输了[code]\begin{align*}
a &= b \\
&= \cdots \\
&= \cdots \\
&= x, \addtag
\end{align*}[/code]同样可以加 \label,不过要放在 \addtag 后面,像这样[code]\begin{align*}
a &= a,\\
b &= b,\\
c &= c, \addtag\label{eqx}\\
d &= d, \addtag\label{eqy}\\
e &= e,
\end{align*}[/code]然后用 eqref 来引用它们。

测试文档:[url]https://www.texide.com/project/5946b41c5c818003306ed73e[/url](已挂)

kuing 发表于 2021-12-14 14:15

[quote]网址:[url]https://www.zhihu.com/question/505455777[/url]
标题:Latex 中的公式编号怎么在保持自动编号的数字后加下标字母?
类似
x^2+y^2=1 (1)_m[/quote]
用类似于楼上的方法解决,[url=https://www.zhihu.com/question/505455777/answer/2268850740]我的回答:[/url][code]\documentclass{article}
\usepackage{amsmath}
\newcommand\tagsub[1]{%
\refstepcounter{equation}\tag*{(\theequation)$_{#1}$}}
\begin{document}
\begin{align}
a &= b \\
&= c \tagsub{m} \\
&= d \tagsub{n} \label{eqn}\\
&= e
\end{align}
ref test: \ref{eqn}
\end{document}[/code]效果如下:
[attach]10713[/attach]

编辑于 2021-12-13 14:16

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.