(unicode-mathまたはnewtxmath)+ \ newcommand {\ nmodels} {\ not \ models} + $\not\models$ =失速

Sep 16 2020

入力のフィード

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

、、のいずれかにpdflatex、xelatexまたはlualatex無限ループを引き起こします。さて、の場合には\ニンが定義されている場合XeLaTeX +のユニコード・数学無限ループに入りますか?の\notin代わりに使用できますが\not\in、\models(の形ではなく)の形が好きで、\vDash否定形が必要で、それを呼び出したい場合は\nmodelsどうしますか?形式は、\nvDashそう、それは両方を使用することをお勧めしません、異なっている\modelsと、\nvDash同じドキュメントに。MnSymbols(全体)の使用は問題外です。まだバグがある可能性があり(10年ほど前に使用を停止したことはわかっていました)、かなりの数の記号が変更され、NewTXフォントと衝突します。

回答

4 egreg Sep 16 2020 at 15:10

の現在の実装は、(Xe | Lua)LaTeXと\not基本的に同じです。pdflatexunicode-math

より正確に\notは、次のトークンを取得し\foo、最初に\notfoo定義されているかどうかを確認します。テストが成功した場合は、\notfooが使用されます。それ以外の場合、次のチェック\nfooは定義されているかどうかです。この場合も、このテストが成功した場合\nfooはが使用されます。それ以外の場合、LaTeXは行い\n@tch@r\fooます。

今、あなたはなぜ無限ループが開始されて参照してください\nmodelsありません\not\models。以降\nmodelsに定義され、ないこれ、使用されています\not\models...

あなたは適用することで問題を回避することができます\notし\relax(どちらことを期待\notrelaxもが\nrelaxそうである、定義されていません)。

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

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

\begin{document}

\(\nmodels\)

\(\not\models\)

\end{document}

とにかく、これは否定するのに特に良い方法ではありません\models。以下と比較してください。

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

4 Davislor Sep 16 2020 at 10:55

の定義は、すでに存在する\notかどうかを調べることによって、半分賢くなりすぎています。\nmodels\notmodels

名前を変更すると機能します。

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

このルックアップは、シンボルが使用されるたびに実行され、の定義\notは完全に拡張可能ではないため、\letまたは\edefを使用してシンボルを定義し、これを回避することはできません。

ただし、\ooalign代わりにを使用してシンボルを作成することもできます。(の代わりにを使用/してください。)newtxmath\mathslash

明らかに、unicode-mathプレフィックスを検索する必要がありますaint。

更新

\not名前を使用せずに呼び出すこともでき\models、ルックアップを防ぐことができます。例えば、

\documentclass{standalone}
\usepackage{iftex}

\usepackage{unicode-math}


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

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