Forgot password?
 Create new account
View 394|Reply 3

=& 与 &=

[Copy link]

700

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-20 22:07:51 |Read mode
源自:zhihu.com/question/498648165
为何latex中在等号右侧添加&符号会减小=与右侧字符之间间距?
以下公式的代码为:
\begin{aligned}
=&a=a
\end{aligned}

知乎显示为:
$\begin{aligned} =&a=a \end{aligned}$
可见第一个=a间的间距远小于第二个

我的回答:
因为 aligned 实际上是对 & 两边的内容分开各自排版的,因此:
$$
\begin{aligned}
=&a=a
\end{aligned}
$$

相当于 $$ {=}{a=a} $$,第一个 = 是孤独的,不产生任何间距${=}{a=a}$

想要让第一个 = 与后面产生间距,就得让它的后面有东西,加一个空的 {} 即可:
$$
\begin{aligned}
={}&a=a
\end{aligned}
$$

这样 = 就会与 {} 产生间距,从而得到$\begin{aligned} ={}&a=a \end{aligned}$

然鹅,如果按刚才所说,那以下写法的间距应该也有问题:
$$
\begin{aligned}
a&=a
\end{aligned}
$$

如果相当于 $$ {a}{=a} $$ 效果应该是 ${a}{=a}$ ,而实际结果是正常的 $\begin{aligned} a&=a \end{aligned}$

原因是 amsmath 的设计者暗中在右边的开头处添加了一个 {},见下图:

QQ截图20211116024934.png

因此刚才那代码是相当于 $$ {a}{{}=a} $$,间距就正常了。

所以通常建议 & 写在 = 左边,需要写在右边时,就得像刚才说的那样写成 ={}&

再多说两句,$-1$${}-1$ 也是不同间距的,所以
$$
\begin{aligned}
-1
\end{aligned}
$$


$$
\begin{aligned}
&-1
\end{aligned}
$$

效果分别为
$\begin{aligned} -1 \end{aligned}$
$\begin{aligned} &-1 \end{aligned}$

编辑于 11-16 04:29

801

Threads

4889

Posts

310K

Credits

Credits
36169

Show all posts

isee Posted at 2021-11-20 23:12:54
Last edited by isee at 2021-11-20 23:26:00都来改良宏包代码了,拜服~

700

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

 Author| kuing Posted at 2021-11-20 23:31:44
回复 2# isee

?我没改良啊,我只是在解释现象……

801

Threads

4889

Posts

310K

Credits

Credits
36169

Show all posts

isee Posted at 2021-11-20 23:56:28
回复 3# kuing



“美丽”的误会了

手机版Mobile version|Leisure Math Forum

2025-4-21 01:29 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list