# Should using spaces in math mode be a common thing?

Since I'm a beginner I want your opinion on a couple of things.

$$A_4 = \left\{ f | f(x) > g(x) , x \in [0;1] \right\}$$


This is not a particularly interesting example, but would you use it? I guess it's alright, but doesn't | symbol look somewhat jammed to you?

$$\forall f \in A_4 \exists r > 0 : B(f,r) \subset A_4$$


Now here \exists symbol definitely looks jammed to me since there is pretty much no space between those two "sentences". Or it it normal in international papers?

I know I can start using \, , \: , \; and similar stuff but this would make it much harder to stay perfectly consistent which is pretty much a point of using LaTeX for me.

• You can use \, to add thin space, \: to add medium space, \; to add thick space, or \! to add thin negative space. It is perfectly reasonable to modify intervariable spacing to suit your desires. – Steven B. Segletes Mar 5 '13 at 16:17
• If you're after consistency, define a macro that suits your needs and use it exclusively. See Consistent typography. In your instance, perhaps \newcommand{\suchthat}{\;|\;}. – Werner Mar 5 '13 at 16:19
• Welcome to TeX.sx! Note that you shouldn't use $$..$$, see Why is $…$ preferable to ? – Torbjørn T. Mar 5 '13 at 16:23
• I use spacing in my maths absolutely all the time, without apology. Mathematics is information-dense text, and you may wish to emphasize particular structures in that text in a way that simply cannot be gotten at using generic (however aesthetically pleasing) typesetting practice. Just be consistent with your spacing practise so that people can parse your expressions the same way throughout your paper... and don't go completely crazy with your spacing (subtle is good). – Niel de Beaudrap Mar 5 '13 at 16:40
• Regarding the \exists symbol: If the math expression were read out aloud, one would generally use the words "there exists" (in English) for this symbol. Hence, in my own math writing, I always insert an explicit space (\ ) both before and after the \exists symbol. – Mico Mar 5 '13 at 22:58

Getting the spacing around \exists and \forall is tricky. Look at this example: $\forall W\forall A$ gives Of course there should be more space after the W. More interestingly, the spacing between \forall and W is too tight, whereas between \forall and A it is maybe even a bit too loose. Why is this so?

If you use the standard Computer Modern fonts, then \exists and \forall come from the math symbol font cmsy, whereas letters like f and r come from the math italic font cmmi. Now the point is: TeX doesn't allow automatic kerning of characters from different fonts. But in order to have good spacing after \exists and \forall in all cases, you'd need specific kerning information depending on the subsequent character, as the above example shows.

The kerning information would have to be provided by the font designer, and it would have to be one font containing all the characters involved. I don't know if there are fonts where this is realized.

So yes, for the Computer Modern fonts (and probably most other math fonts) you'll have to rely on manual kerning with \, and friends to get things right. Here's an example how you could do it. Note that I use \colon instead of a :. Moreover, I define \+ which adds a space slightly smaller than \,. \documentclass{article}
\usepackage{amsmath}
\let\eps\varepsilon
\newcommand\+{\mkern2mu}
\begin{document}
$\forall\eps>0\; \exists\+\delta>0\;\forall x,y\in X\colon\dots$
\end{document}

• Does XeLaTex/unicode-math help in this case? – Johan_E Mar 5 '13 at 21:42
• @Johan_E: That might well be, but as I wrote, I don't know about fonts where this kerning is realized. – Hendrik Vogt Mar 5 '13 at 21:53

Your first math expression:

$A_4 = \left\{ f | f(x) > g(x) , x \in [0;1] \right\}$


looks like this when typeset with Computer Modern fonts: This does look quite cramped.

In the TeXbook (in one of the chapters on math typesetting), Knuth proposes (i) using the command \mid instead of | when expressing a "given that" or "conditional on" thought and (ii) inserting thin-spaces after the opening left curly brace and before the closing right curly brace. It's also a good idea to insert an explicit space after the comma, to highlight the fact that f(x) > g(x) and x \in [0,1] represent separate conditional clauses. Incidentally, the \left and \right directives do nothing useful in the present example and should probably be omitted.

I.e., it's probably better to write:

$A_4 = \{ \, f \mid f(x) > g(x) ,\ x \in [0,1] \, \}$ As for \forall and \exists I can't help you, but I think you are right. There is not enough free space around them. I would fix this just as Werner suggested.

But with the | I have a handy solution: Use \mid instead.

You can use \DeclareMathOperator from the package amsmath:

\usepackage{amsmath}
\let\oldforall\forall
\let\forall\undefined
\DeclareMathOperator{\forall}{\oldforall}


Based on this answer.