4

Feeding the input

\RequirePackage{ifthen}
\RequirePackage{ifxetex,ifluatex}
\newif\ifxetexorluatex
\ifxetex
  \xetexorluatextrue
\else
  \ifluatex
    \xetexorluatextrue
  \else
    \xetexorluatexfalse
  \fi
\fi
\documentclass{standalone}
\ifxetexorluatex
\usepackage{unicode-math}
\else
\usepackage{newtxmath}
\fi
\newcommand{\nmodels}{\not\models}%%% or \providecommand, or \providecommand* instead of \newcommand; the effect is the same.
\begin{document}
\(\nmodels\) %%% or \(\not\models\); the effect is the same.
\end{document}

to any of pdflatex, xelatex, or lualatex causes an infinite loop. Well, in case of XeLaTeX + unicode-math enters infinite loop if \nin is defined? you can use \notin instead of \not\in, but what do you do if you like the shape of \models (rather than that of \vDash), want a negated form of it, and want to call it \nmodels? The form of \nvDash is different, so, it's not advisable to use both \models and \nvDash in the same document. Using (the whole of) MnSymbols is out of question: it may still have bugs (I knew it had some 10 years ago and stopped using it then), changes quite a a few symbols, and clashes with NewTX fonts.

2 Answers 2

4

The current implementation of \not does essentially the same in pdflatex as in (Xe|Lua)LaTeX with unicode-math.

More precisely, \not takes the next token, say \foo and first checks whether \notfoo is defined; if the test succeeds, \notfoo is used. Otherwise the next check is whether \nfoo is defined. Again, if this test succeeds, \nfoo is used. Otherwise LaTeX does \n@tch@r\foo.

Now you see why an infinite loop is started: \nmodels does \not\models; since \nmodels is defined, it is used, which does \not\models

You can avoid the issue by applying \not to \relax (hoping that neither \notrelax nor \nrelax are defined, which is unlikely).

\documentclass{standalone}
\usepackage{iftex}
\iftutex
  \usepackage{unicode-math}
\else
  \usepackage{newtxmath}
\fi

\newcommand{\nmodels}{\not\relax\models}%

\begin{document}

\(\nmodels\)

\(\not\models\)

\end{document}

enter image description here

Anyway, this is not a particularly good way to negate \models. Compare with the following.

\documentclass[border=4]{standalone}
\usepackage{iftex}
\iftutex
  \usepackage{unicode-math}
\else
  \usepackage{newtxmath}
\fi
\usepackage{centernot}

\newcommand{\nmodels}{\centernot\models}%

\begin{document}

\(\nmodels\)

\(\not\models\)

\end{document}

enter image description here

1
  • Thank you! It turned out that I don't include the centernot package but still have the \centernot command (with the intended semantics) due to one of the dozens of other packages I use. Sep 21, 2020 at 22:51
4

The definition of \not is getting too clever by half by looking up whether \nmodels or \notmodels already exist.

It works if you change the name:

\documentclass{standalone}
\usepackage{iftex}

\iftutex
  \usepackage{unicode-math}
\else
  \usepackage{newtxmath}
\fi

%\newcommand{\aintmodel}%
  %{\mathrel{\ooalign{\(\models\)\cr\hidewidth\(\mathslash\)\hidewidth}}}

\newcommand\aintmodel{\not\models}

\begin{document}
\( \aintmodel \)
\end{document}

This lookup gets performed whenever the symbol is used, and the definition of \not isn’t fully-expandable, so you can’t define the symbol with \let or \edef and sidestep this.

You could, however, create the symbol with \ooalign instead. (Use / with newtxmath instead of \mathslash.)

Clearly, unicode-math now needs to search for the prefix aint.

Update

You can also call \not without using the name \models, preventing the look-up. For example,

\documentclass{standalone}
\usepackage{iftex}

\usepackage{unicode-math}


\newcommand\nmodels{\mathrel{\not\symbol{"22A7}}}

\begin{document}
\( \nmodels \)
\end{document}
2
  • "[...] want to call it \nmodels [...]" Sep 16, 2020 at 13:51
  • @GeekestGeek Okay. I posted a solution different from egreg’s that lets you call it \nmodels. He’s got a good one too.
    – Davislor
    Sep 17, 2020 at 0:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.