2

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}
2
  • You should use \mathop for operators (\mathrel is for relations and expects infix placement). Mar 1, 2012 at 19:24
  • @AndreyVihrov, problem OP has is that \mathop converts a following \mathbin into a \mathord so loses the spacing. Hence I suggested \mathinner in my answer, even though it isn't really an inner operation. Mar 1, 2012 at 19:29

1 Answer 1

8

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:

enter image description here

\documentclass{article}
\usepackage{amsmath,amssymb}

\newcommand{\coerceSub}[3]{(\mathord{#1}{\smallfrown}\mathord{#2})_{#3}}

\begin{document}

In an operator application, the ``mathrel'' version looks better.
\begin{gather}
  % OK                                                                          
  \mathinner{\coerceSub uv1} x \\
  \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}
  \mathinner{\coerceSub uw1} \circ c \\
  % Not OK: no space between \circ and c                                        
  \mathrel{\coerceSub vw1} \circ c \\
  % OK                                                                          
  \coerceSub vw1 \circ c
\end{gather}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .