\begin{document} は \Re の再定義を中断します

\begin{document} は \Re の再定義を中断します

ゴシック型の実数部演算子を単純な「Re」に置き換えるには、次のようにします。

\documentclass[a4paper,11pt,twoside,fleqn]{report}
[...]
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage[bold-style=ISO]{unicode-math} % must come after ams and symbols
[...]
\begin{document}
\def\Re{\operatorname{Re}}

しかし、最後の 2 行を入れ替えると、 の再定義は\Re無効になります。何が起こっているのでしょうか?\begin{document}マクロの再定義を上書きするにはどうすればよいですか?

答え1

には、処理がコマンドに到達した時点で最初に実行されるコマンドが多数unicode-math含まれています。同じトリックを使用して、定義をオーバーライドすることもできます。\AtBeginDocument\begin{document}

サンプル出力

\documentclass[a4paper,11pt,twoside,fleqn]{report}

\usepackage{mathtools}
\usepackage[bold-style=ISO]{unicode-math}

\AtBeginDocument{\renewcommand{\Re}{\operatorname{Re}}}
\begin{document}

\( \Re z \)
\end{document}

などの類似のコマンドも\AtEndOfPackageコア LaTeX で定義されています。 などの追加コマンドはパッケージ\AtBeginEnvironment内にありますetoolbox

関連情報