I want a particular spacing behavior for a custom operator. I can produce the desired spacing by setting math classes (\mathord
and so forth), but I have to do it on a case-by-case basis since no single math class works for all situations. Is there a more automatic solution?
In my document, the operator $(A\smalltriangleright B)$
means "coerce from A to B". It's a prefix operator and it takes subscripts in some situations.
-
When an operator is applied to an argument, there should be some space between operator and argument. Either mathbin space or mathrel space would be acceptable.
-
When operators are composed using the function composition operator
\circ
, they should act as ordinary symbols with\circ
playing the role of binary operator.
I haven't been able to get a single definition of the operator that has the right spacing in both situations:
\documentclass{article}
\usepackage{amsmath}
\usepackage{mathabx}
\newcommand{\coerceSub}[3]{(\mathord{#1}\smalltriangleright\mathord{#2})_{#3}}
\begin{document}
In an operator application, the ``mathrel'' version looks better.
\begin{gather}
% OK
\mathrel{\coerceSub uv1} x \\
% Not OK: no space between operator and operand
\coerceSub uv1 x
\end{gather}
In an operator composition, the plain version looks better.
\begin{gather}
% Not OK: no space between \circ and c
\mathrel{\coerceSub vw1} \circ c \\
% OK
\coerceSub vw1 \circ c
\end{gather}
\end{document}
Best Answer
I didn't have the fonts so I changed the operator, but I think
\mathinner
does what you want here, puts some space before an ord, and doesn't stop a bin atom having bin spacing,Top version in each of these: