$-6$ によって作成されたマイナス記号のフォント (数式モードではハイフン)

$-6$ によって作成されたマイナス記号のフォント (数式モードではハイフン)

マイナス記号が Unicode 文字 "2212 で作成されたか、数式モードでハイフンを使用して作成されたかに関係なく、すべてのマイナス記号のフォント (以下の例では Times New Roman) を指定します。

の範囲オプションに「2212」を追加すると\setmathfont、適切な Unicode 文字「マイナス記号」を使用してテキストを書き込むときに機能します。私の例の最初の 2 つの 6 を参照してください。

しかし、$-6$ (ここで - は通常のハイフン) と書くと、出力は正しいマイナス記号になりますが、Times New Roman ではありません。私の例の最後の 6 を見てください。

\documentclass{article}
\RequirePackage[silent]{fontspec}
\setmainfont{Times New Roman}
\RequirePackage{unicode-math}
\setmathfont{STIXTwoMath}[]
\setmathfont{Times New Roman}[ range = { up/{num,latin,Latin}, "2212 } ]

\begin{document}

%% Minus ("2212) in source code:
−6 and $−6$

%% Hyphen ("002D) in source code:
-6 and $-6$ 

\end{document}

出力:

ここに画像の説明を入力してください

$ 環境でハイフンに「アクセス」する方法を知っている人はいますか?

答え1

なぜそうなるのかはわかりませんが、 と言えば機能しますが、実際にはと のrange = { "2212, \minus }両方を明記する必要があります。"2212\minus

\documentclass{article}
\RequirePackage[silent]{fontspec}
\setmainfont{Times New Roman}
\RequirePackage{unicode-math}
\setmathfont{STIX Two Math}
\setmathfont{Times New Roman}[ 
    range = { "2212, \minus } 
]

\begin{document}

%% Minus ("2212) in source code:
−6 and $−6$

%% Hyphen ("002D) in source code:
-6 and $-6$ 

\end{document}

ここに画像の説明を入力してください

したがって、プラス記号とマイナス記号に同じフォントを選択するには、次のようにします。

\documentclass{article}
\RequirePackage[silent]{fontspec}
\setmainfont{Times New Roman}
\RequirePackage{unicode-math}
\setmathfont{STIX Two Math}
\setmathfont{Times New Roman}[ 
    range = { "2212, \minus, "002B } 
]

\begin{document}

-6 and $-6$ 

+6 and $+6$ 

\end{document}

ここに画像の説明を入力してください

答え2

と書くことをお勧めします\textnormal{-}

ここに画像の説明を入力してください

\documentclass{article}
\RequirePackage{unicode-math}
\setmainfont{Times New Roman}
\setmathfont{STIXTwoMath}[]
\setmathfont{Times New Roman}[ range = { up/{num,latin,Latin}, "2212 } ]

\begin{document}

%% Minus ("2212) in source code:
−6 and $−6$

%% Hyphen ("002D) in source code:
-6 and $\textnormal{-}6$ 

\end{document}

関連情報