3

I was looking for a way to add some spacing after quantifiers and found the answer thanks to Best practice for typesetting quantifiers?. The following MWE works perfectly:

\documentclass[]{article}
\usepackage{amssymb}

\let\existstemp\exists
\let\foralltemp\forall
\renewcommand*{\exists}{\existstemp\,}
\renewcommand*{\forall}{\foralltemp\,}
\newcommand{\N}{\mathbb N}

\begin{document}
$\forall m \in \N, \exists n \in \N\colon m < n$
\end{document}

However, during my first attempts to solve the problem, I tried

\documentclass[]{article}
\usepackage{amssymb}

\renewcommand*{\exists}{\exists\,}
\renewcommand*{\forall}{\forall\,}
\newcommand{\N}{\mathbb N}

\begin{document}
$\forall m \in \N, \exists n \in \N\colon m < n$
\end{document}

but that crashed LaTeX.

Why didn't this work correctly? Is my working solution the shortest/cleanest one?

Jeroen
  • 4,491
  • 1
    Rather use something like \let\oldexists\exists\renewcommand{\exists}{\oldexists\,} or \makeatletter\g@addto@macro\exists{\,}\makeatother. – Werner Nov 02 '14 at 23:50

1 Answers1

8

TeX is a macro expansion language.

If you define

 \renewcommand*{\exists}{\exists\,}

Then when \exists is encountered it is replaced by its replacement text, then processing starts again so

\exists

becomes

\exists\,

which becomes

\exists\,\,

which becomes

 \exists\,\,\,

and so on until you run out of input stack.

David Carlisle
  • 757,742
  • Thank you for your super fast answer! I understand what went wrong now. Is using something like \let\existstemp\exists the only correct option? – Jeroen Nov 02 '14 at 23:35
  • @Jeroen for \exists which is a mathchar token not a macro, yes more or less. For macros you can extract their expansion and add further tokens. – David Carlisle Nov 02 '14 at 23:40
  • @DavidCarlisle Wouldn't it be most sensible to just change the group of the character? Something like \expandafter\mathchardef\exists\numexpr\the\exists-"3000\relax (or whatever chiffre, depending on by how many groups you need to shift the character)? – yo' Nov 03 '14 at 00:51
  • @tohecz no as I comment above \exists is an unexpandable token so \expandafter does nothing to it. – David Carlisle Nov 03 '14 at 00:54
  • @DavidCarlisle Ah, there's some \expandafter missing... And it would work: \expandafter\mathchardef\expandafter\exists\the\numexpr\the\exists+"1000\relax just it centers the symbol on the math axis... :-/ – yo' Nov 03 '14 at 01:00
  • @tohecz bm does more or less same to change the fam slot to bold, but in the context here I'm not sure that's really the way to go (especially as it's not clear that any mathclass has the desired spacing) – David Carlisle Nov 03 '14 at 01:03
  • @DavidCarlisle I would say that "1000 (op) works pretty well... but then there's the vertical alignment problem. – yo' Nov 03 '14 at 01:04