8

I am using the unicode-math package and I would like to write the symbol to indicate that two vectors are not perpendicular, but \not\perp does not display properly (the 'not' bar is too high):

enter image description here

MWE:

\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}

(I am using the STIX Two font, but with the default font it is even worse)

I would like something with the 'not' bar like this:

enter image description here

but still preserving the default shape of the \perp symbol of the font which does not have any problem.

2
  • I think this is a bug in XeTeX; \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.
    – egreg
    Commented May 20, 2020 at 14:28
  • Can confirm that lualatex does not exhibit the same behavior. Commented May 20, 2020 at 14:33

1 Answer 1

8

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}

enter image description here

I tried with LuaTeX (so the code is not applied) and I got

enter image description here

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).

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .