免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享
返回列表 发帖

\nonumber 的「反」

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

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

测试文档:https://www.texide.com/project/5946b41c5c818003306ed73e(已挂)
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
$\href{https://kuingggg.github.io/}{\text{About Me}}$

网址:https://www.zhihu.com/question/505455777
标题:Latex 中的公式编号怎么在保持自动编号的数字后加下标字母?
类似
x^2+y^2=1 (1)_m

用类似于楼上的方法解决,我的回答:
  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \newcommand\tagsub[1]{%
  4. \refstepcounter{equation}\tag*{(\theequation)$_{#1}$}}
  5. \begin{document}
  6. \begin{align}
  7. a &= b \\
  8. &= c \tagsub{m} \\
  9. &= d \tagsub{n} \label{eqn}\\
  10. &= e
  11. \end{align}
  12. ref test: \ref{eqn}
  13. \end{document}
复制代码
效果如下:
v2-2e2d3356c690f3c40c67011557307deb_r.jpg
2021-12-14 14:15


编辑于 2021-12-13 14:16

TOP

返回列表 回复 发帖