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?

1
  • 1
    Rather use something like \let\oldexists\exists\renewcommand{\exists}{\oldexists\,} or \makeatletter\g@addto@macro\exists{\,}\makeatother. – Werner Nov 2 '14 at 23:50
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.

7
  • 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 2 '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 2 '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 3 '14 at 0:51
  • @tohecz no as I comment above \exists is an unexpandable token so \expandafter does nothing to it. – David Carlisle Nov 3 '14 at 0: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 3 '14 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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