Amsmath – Fixing Too Small Space When Using DeclareMathOperator

amsmathmath-operators

Currenlty I'm writing a math script (ring theory, PDF). When I need a new math operator I use \DeclareMathOperator from the amsopn-package. However I noticed some strange behaviour when using an operation with \circ. Example:

\listfiles
\documentclass[draft]{minimal}
\usepackage{amsopn}
\DeclareMathOperator*{\id}{id}
\begin{document}
$\id\circ g$

$h\circ g$
\end{document}

In the first version the g is very close at the \circ whereas the second version seems normal. This spacing issue only happens when I use \DeclareMathOperator. Is this problem known to you? What can I do to prevent it?

The file list:

minimal.cls    2001/05/25 Standard LaTeX minimal class
 amsopn.sty    1999/12/14 v2.01 operator names
 amsgen.sty    1999/11/30 v2.0

Best Answer

If \id denotes the identity map, then it shouldn't be an operator, but an ordinary symbol:

\newcommand{\id}{\mathrm{id}}

Notice also that \DeclareMathOperator* is meant for defining operators that take limits above and below them (such as \min and \max).

The behavior is easily explained: when we write \log -2 we want the - not to be treated as a binary operation symbol. For TeX your \id\circ g is just the same: if a Bin atom follows an Op atom, it is converted into an Ord atom. It's a mistake to define something with \DeclareMathOperator just to have upright letters.

Related Question