# Quantifier spacing with unicode-math

When using consecutive quantification in a math formula, there is not enough spacing around the quantifiers. For example:

\documentclass{article}

\usepackage[colon=literal]{unicode-math}
\setmainfont{STIXGeneral}
\setmathfont{XITS Math}

\begin{document}

$∀{δ>0}∃{ε>0}∀{x: |x-x_0| < ε ⇒ |f(x)-f(x_0)| < δ}$

$∀\,{δ>0}\;∃\,{ε>0}\;∀\,x: |x-x_0| < ε ⇒ |f(x)-f(x_0)| < δ$
\end{document}


I’m using TeXLive 2012 and XeLaTeX. The output is

Now I certainly don’t want to manually put the spacing around all the quantifiers. I tried to use

\usepackage{newunicodechar}
\makeatletter
\newcommand\@quantifierspacing[1]{\,#1\@ifnextchar∃{\;}{\@ifnextchar∀{\;}{}}}
\newunicodechar{∀}{∀\@quantifierspacing}
\newunicodechar{∃}{∃\@quantifierspacing}
\makeatother


but that does not add the spacing in front. I also considered

\newunicodechar{∀}{\;∀\,}


Although I don’t think it is prudent, because then additional spacing is also added in front of the first quantifier. Is there a better way?

-
the symbols whose command names are \forall and \exists are defined in "basic" tex as "ordinary" characters, with no extra spacing to be added around them. this definition has been retained in the stix/xits fonts. (this is correct; otherwise many existing documents would be broken.) so what is needed is to redefine them as binary relations. i could give an answer if control sequences were being used, but don't want to dabble my toes in the waters of modifying character classes at the character or font level. –  barbara beeton Sep 27 '13 at 13:13
@egreg: Works for me, if for ∃ I change the -1mu to +1mu. I would accept it, if you put this into an answer. –  canaaerus Sep 27 '13 at 13:27

I think that the quantifier should be tightly bound to the variable it quantifies; so you have a couple of alternatives:

1. A thin space in front of the quantifier

\newunicodechar{∀}{\mathop{}\!∀}
\newunicodechar{∃}{\mathop{}\!∃}

2. A thick space in front of the quantifier

\newunicodechar{∀}{\mathrel{}\mskip-\thickmuskip ∀}
\newunicodechar{∃}{\mathrel{}\mskip-\thickmuskip ∃}


Here's a document showing the two possibilities

\documentclass{article}

\usepackage[colon=literal]{unicode-math}
\usepackage{newunicodechar}
\setmainfont{STIXGeneral}
\setmathfont{XITS Math}

\newunicodechar{∀}{\WHAT ∀}
\newunicodechar{∃}{\WHAT ∃}

\begin{document}
\def\WHAT{\mathop{}\!}
Thin space

X$∀δ>0 ∃ε>0 ∀x: |x-x_0| < ε ⇒ |f(x)-f(x_0)| < δ$X

\def\WHAT{\mathrel{}\mskip-\thickmuskip}
Thick space

X$∀δ>0 ∃ε>0 ∀x: |x-x_0| < ε ⇒ |f(x)-f(x_0)| < δ$X

\end{document}


The \WHAT trick is just to change the definitions mid document. The X before the formula shows that no additional space is added if the quantifier is at the start.

-
If he wants to use them as binary operators (IIUC, I can’t read math), why not just use \mathbin{}? –  Khaled Hosny Sep 28 '13 at 8:14
@KhaledHosny Because they aren't binary operators. ;-) –  egreg Sep 28 '13 at 17:24