`\not\perp` 使用 unicode-math 无法正确显示

`\not\perp` 使用 unicode-math 无法正确显示

我正在使用 unicode-math 包,我想写入符号来表示两个向量不垂直,但\not\perp 无法正确显示(“不”栏太高):

在此处输入图片描述

梅威瑟:

\documentclass{article}

\usepackage{mathtools}
\usepackage{unicode-math}

\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}

\begin{document}
    $$\vec{u} \not\perp \vec{v}$$
\end{document}

(我使用的是 STIX Two 字体,但默认字体的效果更差)

我想要一些带有“非”栏的东西,像这样:

在此处输入图片描述

但仍然保留字体符号的默认形状\perp,没有任何问题。

答案1

这似乎是 XeTeX 中的一个错误(或缺失的功能)。该宏\not会进行一些检查,如果不存在从以下标记派生的合适名称(它应该是 Unicode 定义的否定符号),它会使用\notaccent

https://github.com/wspr/unicode-math/issues/363

此命令应该将重音符叠加在符号上,但在 XeTeX 中却不行。但在 LuaTeX 中却可以。

解决方法:定义一个合适的\notperp宏。

\documentclass{article}
\usepackage{iftex}
\usepackage{mathtools}
\usepackage{unicode-math}

\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}


\ifxetex
\NewDocumentCommand{\notperp}{}{%
  \mathrel{\mathpalette\overlaynot\perp}%
}
\makeatletter
\newcommand{\overlaynot}[2]{%
  \sbox\z@{$\m@th#1\notaccent{}$}%
  \sbox\tw@{$\m@th#1#2$}%
  \dimen@=\dimexpr(\ht\tw@-\ht\z@)/2\relax
  \vphantom{\raisebox{\dimen@}{\copy\z@}}%
  \ooalign{\hidewidth\raisebox{\dimen@}{\box\z@}\hidewidth\cr\box\tw@}
}
\makeatother
\else
\NewDocumentCommand{\notperp}{}{\mathrel{\notaccent\perp}}
\fi

\begin{document}

\[
\vec{u} \not\perp \vec{v}
\]

\end{document}

在此处输入图片描述

我尝试使用 LuaTeX(因此代码不适用),我得到了

在此处输入图片描述

这又显示了另一个问题,因为该符号不被视为关系符号(当涉及数学重音时,这是正常的)。所以我还添加了一个 LuaTeX 分支,\notperp也为其定义,输出与 XeTeX 相同(使用解决方法)。

相关内容