5

I am learning LaTeX and I find one annoying thing.

I have to keep typing \, when in math mode to add that tiny space between different variables when I want one. This makes the LaTeX code harder to read and modify.

For example, I'd rather just write

 $a b c$ 

and have it come out as

 a b c 

instead of

 abc  

Now one has to write

 $a\,b\,c$

So a single space or more, is interpreted as \, when in math mode, so writing $a b c$ it will come out to be a b c. If the \, is present, then that is ok. So when writing

 $a\,  b c$

it will come out as

  a  b c

I do not see that this will cause a problem. If I do not want the \, then I will write ab and if I want the space, I'll write a b much easier, less things to type, and the LaTeX code becomes easier to read.

Is it possible to have some magic macro or renewcommand to do this?

Update

Ok, thanks for the advice. Will take it. I thought I needed to add space to make it look better.

Here is an example:

\documentclass{article}
\begin{document}
$$s(t)= A_c \cos(2 \pi  f_c t + \beta  m(t))$$ 

$$s(t)= A_c \cos(2 \pi  f_c t + \beta\,  m(t))$$ 
\end{document}

Here is the output enter image description here

after looking more at it, I see that I really did not need the extra space between the \beta and the m.

2
  • 9
    Don't add \, between letters denoting single variable or constants that are multiplied. This is never done in good math typography.
    – egreg
    Jan 21, 2013 at 11:12
  • Ok, I was thinking I needed an extra space. But I think you and David are both correct. It does look better without an extra space. I put an example above. So, this is good news. I was adding \, everywhere and was getting tired. Now I do not have to do it.
    – Nasser
    Jan 21, 2013 at 11:22

1 Answer 1

11

The sidebearings of the math italic font are designed such that this should not be necessary, they are designed such that $abc$ has traditional spacing for a sequence of variables and $\mathit{abc}$ is the markup that uses a text italic font with tighter spacing for a multi-letter identifier.

However something along these lines does what you ask

enter image description here

\documentclass{article}


\begin{document}
$abc$

$\mathit{abc}$

$a\,b\,c$

$a b c$



{\catcode`\ =13 \def {\,}$ a b c $}

\end{document}

But making spaces active is likely to be incompatible with many other constructs that are not expecting that.

1
  • It would be possible to make the space only mathematically active by assigning it globally mathcode 32768 and catcode 12 inside \everymath and \everydisplay. Something like \mathcodè\ ="8000` {\catcodè \ =\active \gdef\defmathactivesp{\def {\mkern18mu}} \global\everymath\expandafter{\the\everymath\catcodè \ =12 \defmathactivesp} }. Of course $\hbox{ }$ would then be still a problem if the space was currently catcode active.
    – user4686
    Jan 21, 2013 at 14:57

You must log in to answer this question.

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