TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the example below, the presence of \mycommand changes the first minus sign into a binary operation atom, so that the spacing between - and 1 is increased.

\newcommand\mycommand{\mbox{ abc } }
\mycommand -1 = -1

I know that this can be dealt with on a case by case basis, but I would like to change the macro definition so that the first atom after a \mycommand behaves as if it were the first atom in the equation. Is this possible?

share|improve this question
It's not \mycommand per se, but the fact that it produces \mbox{abc} which is an ordinary atom. If you want that a minus sign is not mistaken in that situation, write \mycommand {-1}=-1. – egreg Jun 20 '12 at 6:28
@egreg --- see edited question. – Ian Thompson Jun 20 '12 at 9:39
Sorry, but the answer is no. If \mycommand contributes an atom to the math list, that will be the first. Wouldn't it be better to show the real thing you want to do? – egreg Jun 20 '12 at 9:43
@egreg --- this more or less is what I want to do. Sometimes I have small pieces of text such as 'and' or 'as' in displayed equations, and these can affect spacing around subsequent atoms. I would like to define a macro that prevents this. – Ian Thompson Jun 20 '12 at 9:54
up vote 5 down vote accepted

The rule about \mathbin atoms being converted to \mathord is different from what you're thinking it is:

If a \mathbin atom is between two atoms incompatible with it being an binary operation symbol (or if it is the first atom in a math list), then consider it as \mathord.

Thus in $-1=-1$, both - symbols will be converted to ordinary atoms. The first one because it's the first, the second one because it's between a relation and an ordinary.

You may try

\newcommand{\mycommand}[1]{\mathopen{\mbox{ #1 }}}

so the \mathopen nature of the atom will disallow a \mathbin immediately following. TeX never inserts spaces following a \mathopen atom.

Assuming that what comes before this text is an ordinary atom or a \mathclose, nothing bad should happen as regards to spacing.

However I'd simply use

1 = 1 \text{ and } {-1}=-1
share|improve this answer
\begin{pedantry} I didn't say anything about the rule! I only said that I want the atom following a \mycommand to behave as if it were the first. \end{pedantry} – Ian Thompson Jun 20 '12 at 10:21
@IanThompson I had to review the rule in order to find a way out. :) – egreg Jun 20 '12 at 10:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.