找回密码
 快速注册
搜索
查看: 226|回复: 8

[MathJax]Missing argument for \mathbf

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-4-29 07:07 |阅读模式
$\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}
复制代码
是正常的啊

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

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

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

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2022-4-29 21:33
按我的理解,\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 命令可能并不带参数!那它展开成什么?

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

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

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

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

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

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

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

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

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-4-30 00:41
回复 2# kuing
谢谢! 我看到了,这里使用了noerrors扩展

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-4-30 00:51
  1. \documentclass{minimal}
  2. \begin{document}
  3. $\widehat\mathbf e$
  4. \end{document}
复制代码
\widehat\mathbf e也是有效的.
  1. \documentclass{minimal}
  2. \begin{document}
  3. $\overline\mathbf e$
  4. \end{document}
复制代码
\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}
复制代码
应该是同样的原理
(虽然不知道是啥原理

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2022-4-30 00:56
回复 7# hbghlyj

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

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

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

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

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 12:13

Powered by Discuz!

× 快速回复 返回顶部 返回列表