Forgot password?
 Create new account
View 371|Reply 8

[MathJax]Missing argument for \mathbf

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2022-4-29 07:07:19 |Read mode
$\hat\mathbf e$
mathjax.org/#demo报错信息是Missing argument for \mathbf 为什么这里的MathJax没有报错信息?

但是LaTeX里
  1. \documentclass{minimal}
  2. \begin{document}
  3. $\hat\mathbf e$
  4. \end{document}
Copy the Code
是正常的啊

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-4-29 21:17:25
为什么这里的MathJax没有报错信息?
hbghlyj 发表于 2022-4-29 07:07

鼠标停留在报错的地方,就会有

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-4-29 21:33:04
按我的理解,\hat\mathbf e 这写法本来应该是错误的,LaTeX 里竟然没问题,我也想不明白……

\hat 命令需要一个必要参数,而这后面并没有 { },于是 \mathbf 就成了它的参数,因此 \hat\mathbf e 等价于 \hat{\mathbf}e ,而 \mathbf 也需要参数,但 e 落在外面了,所以 \mathbf 就缺少参数了,MathJax 报“Missing argument”正是这原因,可见 MathJax 的处理和我的理解应该是一样的。

正确的写法应该是 \hat{\mathbf e},效果:$\hat{\mathbf e}$

难道 LaTeX 能智能地将 \hat\mathbf e 补全为 \hat{\mathbf e} ?并不是,因为如果将 \mathbf 换成 \sqrt ,则 LaTeX 同样也报错:
捕获.PNG
而 \hat{\sqrt e} 是没问题的,这就证明了 \hat\sqrt e 并不会自动补全为 \hat{\sqrt e}。

又在 LaTeX 里尝试 \hat{\mathbf}e 也是报错喔,看来 \hat\mathbf e 并不等价于 \hat{\mathbf}e !

由此推得:我一开始就判断错了,在 LaTeX 里,\hat 命令可能并不带参数!那它展开成什么?

看来我得看看内部代码先……

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-4-29 22:11:06
source2e.pdf 里查到 \hat 的定义是
\DeclareMathAccent{\hat}{\mathalpha}{operators}{"5E}
而 \DeclareMathAccent 的定义非常复杂,看不来呀

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-4-29 22:18:25
又发现,1# 的代码如果加上 \usepackage{amsmath} ,则同样也报错!

看来 amsmath 宏包改变了 \hat 命令。

MathJax 使用 amsmath,于是报错也就合情理了。

PS、这帖还是移到 TeX 区好一些。

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-4-30 00:41:19
回复 2# kuing
谢谢! 我看到了,这里使用了noerrors扩展

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-4-30 00:51:35
  1. \documentclass{minimal}
  2. \begin{document}
  3. $\widehat\mathbf e$
  4. \end{document}
Copy the Code
\widehat\mathbf e也是有效的.
  1. \documentclass{minimal}
  2. \begin{document}
  3. $\overline\mathbf e$
  4. \end{document}
Copy the Code
\overline\mathbf e也是有效的.
  1. \documentclass{minimal}
  2. \begin{document}
  3. $\check\mathbf e$
  4. $\tilde\mathbf e$
  5. $\widetilde\mathbf e$
  6. $\acute\mathbf e$
  7. $\grave\mathbf e$
  8. $\dot\mathbf e$
  9. $\ddot\mathbf e$
  10. $\breve\mathbf e$
  11. $\bar\mathbf e$
  12. $\vec\mathbf e$
  13. \end{document}
Copy the Code
应该是同样的原理
(虽然不知道是啥原理

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-4-30 00:56:09
回复 7# hbghlyj

\widehat 的即使加 \usepackage{amsmath} 也不报错,但是加 \usepackage{amssymb} 就会报错!
\overline 的加 \usepackage{amsmath} 就报错。
后面那些应该和 \hat 一样,在 LaTeX 里它们都是用相同的方法定义的:
捕获.PNG
捕获2.PNG

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-4-30 01:23:01
其实还有个类似事:
  1. $A_\alpha$
  2. $A_\frac12$
  3. $A_\sqrt2$
  4. $A_\max$
Copy the Code
这四行代码在 LaTeX 里,前两个 OK,后两个报错。
最难理解的是第四个,\max 并不需要参数,竟然也报错……
哦对了,如果报错也强行通过,PDF 输出也是正常的……

MathJax 全部通过……
$A_\alpha$
$A_\frac12$
$A_\sqrt2$
$A_\max$

手机版Mobile version|Leisure Math Forum

2025-4-20 22:14 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list