2

In math mode, a whitespace may be inserted using either a tilde (~) or a comma command (\,).

E.g.:

W=\{x,y~|~x+y=3\}
% or
W=\{x,y\,|\,x+y=3\}

Are either of these frowned upon in general? Is it largely just a stylistic difference? When should I use a tilde as opposed to a comma command?

8
  • 2
    Use semantic / symbolic commands. Isn't W = \{ x, y \given x + y = 3 \} better? Or may be with little more effort you have a bit more power W = \set{ x, y \given x + y = 3 }. Then you can define \given in any way you want (this doesn't answer this specific question, but I think it's a good way to go).
    – Manuel
    Sep 29 '16 at 16:20
  • I hadn't thought of creating a \given macro, thanks! It helps in this specific case, but I'm interested in a general-case answer; white space exists outside of set notation, after all.
    – Jules
    Sep 29 '16 at 16:22
  • 1
    See the mathtools manual for a set defining macro that uses the idea of \given, hint it has build in scaling abilities.
    – daleif
    Sep 29 '16 at 16:24
  • 1
    Also space in math is a very special discussion and is very different than outside math. I'd never use ~ in math mode.
    – daleif
    Sep 29 '16 at 16:26
  • 1
    Here's my two cent: W = \{\, (x,y) \mid x+y=3 \,\}
    – egreg
    Sep 29 '16 at 17:08
8

In the TeXbook, Knuth advocates writing neither \,|\, nor ~|~ for the expression at hand. Given that (pun intended) the | symbol would be read out loud as "given that", it is a relational operator (in TeX jargon) and should therefore be surrounded by "thickspace". (Other objects of mode "mathrel" are =, <, and >.) PlainTeX and LaTeX both provide the macro \mid to meet this particular typesetting purpose.

In fact, the TeXbook would recommend writing your equation as

W=\{ \, x,y \mid x+y=3 \, \}

Observe the thinspace directives inside the opening and closing curly braces -- in addition to \mid.

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