[Tex/LaTex] Spacing around \text{} in mathmode

math-modespacing

Inspired by this question, here's my mathmode spacing bugbear.

I quite often have equations that look like this:

\begin{equation}
  \text{If}\ B_1 \succeq B_2 \ \text{and}\ B_2 \succeq B_3 \ \text{then}\ B_1 \succeq B_3
\end{equation}

Now, you might notice that before and after each bit of \text{...} there is a "normal sized space". I can't imagine why I wouldn't want that space there, but I have to add it manually. Surely this should be the default behaviour of mathmode's text macro?

Why isn't it, and how could I make it so?

Best Answer

It's not the default behavior because you don't always want space. For instance, in your example, you don't want space before \text{If}, since that would indent your equation. Or consider

\[ x = \begin{cases}
         1 & \text{if $f(x)$}
         0 & \text{otherwise}
       \end{cases} \]

Again, that shouldn't be spaced out. Also, like in Caramdir's answer, I re-entered math mode within the \text, which often solves the spacing problems as well. You could define an \stext command for spaced out text:

\newcommand*{\stext}[1]{\text{ #1 }}

(Literal spaces inside are the same as outside, I believe.) Another option might be

\newcommand*{\textop}[1]{\mathbin{\text{#1}}}
\newcommand*{\textrel}[1]{\mathrel{\text{#1}}}

Then \textop{foo} would set foo as a binary operator, and \textrel{bar} would set bar as a binary relation. I'm not sure how this spacing would look, though, but it might work for what you want.