在我的LaTeX模板中(我使用的是XeLaTeX,其他版本不知道是否也会报错),需要导入
mathtools
包使用 align
环境,同时也为了在数学公式中使用unicode数学符号,需要导入 unicode-math
包。但同时导入二者时发现出现使用下括号 \underbrace
排版错误的情况:此外,导入 unicode-math 后所有数学公式中的字体都变为了sans-serif字体,这不是我想要的:
下面三篇来自Stack Exchange的文章解决了这些问题:
- Underbraces are ruined by mathtools (and maybe unicode-math?). How do I keep both?
- Force Computer Modern Maths Font in Maths Mode
- Suppress warning by unicode-math regarding mathtools
排版错误是
unicode-math
库和 mathtools
库冲突导致的,同时冲突会导致下面的报错:
Using \overbracket and \underbracket from(unicode-math) `mathtools' package.
I'm going to overwrite the following commands(unicode-math) from the `mathtools' package:(unicode-math)(unicode-math) \dblcolon, \coloneqq, \Coloneqq, \eqqcolon.
解决方法是:
- 按照
amsmath、mathtools、unicode-math
的顺序依次导入三个包。 - 在导入
unicode-math
时加上参数mathrm=sym,warnings-off={mathtools-colon,mathtools-overbracket}
,其中mathrm
选项避免了与amsmath的冲突,mathtools-xxx
选项避免了使用overbracket
和colon
的错误提示。
最后三者的导入可以写为:(我是写在.sty模板中所以用 \RequirePackage
,如果正文使用改为 \usepackage
即可。
\RequirePackage{amsmath} % AMS数学字体, 环境等
\RequirePackage{mathtools} % align 需要
\RequirePackage[mathrm=sym,warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math}
修正后能正确显示下括号: