Forgot password?
 Create new account
View 2548|Reply 1

\nonumber 的「反」

[Copy link]

701

Threads

110K

Posts

910K

Credits

Credits
94167
QQ

Show all posts

kuing Posted at 2017-6-19 01:32:25 |Read mode
可能以前也讲过,不管了。

我们都知道在多行公式环境(如 align)中可以用 \nonumber(或 \notag)来禁止某行生成编号,像这样
  1. \begin{align}
  2. a &= a,\\
  3. b &= b,\\
  4. c &= c, \nonumber \\
  5. d &= d,
  6. \end{align}
Copy the Code
\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}
Copy the Code
\begin{align}
a &= b \nonumber \\
&= \cdots \nonumber \\
&= \cdots \nonumber \\
&= x,
\end{align}
这显然不方便,理应有一个与 \nonumber 相反的命令——即能对无编号的 align* 环境中的某些行编号(并且号码是自动增加的)才是,但 amsmath 并未提供,尽管定义它并不难:
  1. \newcommand\addtag{\refstepcounter{equation}\tag{\theequation}}
Copy the Code
这样,上面的就可以这样输了
  1. \begin{align*}
  2. a &= b \\
  3. &= \cdots \\
  4. &= \cdots \\
  5. &= x, \addtag
  6. \end{align*}
Copy the Code
同样可以加 \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*}
Copy the Code
然后用 eqref 来引用它们。

测试文档:texide.com/project/5946b41c5c818003306ed73e(已挂)

701

Threads

110K

Posts

910K

Credits

Credits
94167
QQ

Show all posts

 Author| kuing Posted at 2021-12-14 14:15:39
网址: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}
Copy the Code
效果如下:
v2-2e2d3356c690f3c40c67011557307deb_r.jpg

编辑于 2021-12-13 14:16

手机版Mobile version|Leisure Math Forum

2025-4-20 21:59 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list