This seems to be a bug (or a missing feature) in XeTeX. The macro \not
does a few checks and if a suitable name derived from the following token does not exist (it should be a Unicode defined negated symbol), it uses \notaccent
.
See https://github.com/wspr/unicode-math/issues/363
This command should overlay the accent on the symbol, but it doesn't in XeTeX. It does with LuaTeX.
Workaround: define a suitable \notperp
macro.
\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}
I tried with LuaTeX (so the code is not applied) and I got
which shows yet another problem, because the symbol is not treated as a relation symbol (it's normal when math accents are involved). So I also added a LuaTeX branch, defining \notperp
also for it and the output is the same as for XeTeX (with the workaround).
\not
is defined through\notaccent
, because there is no negated symbol for\perp
in Unicode; this uses\mathaccentoverlay
which shouldn't move the accent depending on the accentee dimensions.