Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Hi I'm trying to redefine the \forall command so that it accepts an argument instead of using the regular juxtaposition.

What it looks like at the moment is

\renewcommand{\forall}[1]{\forall{(#1)}\;}

which doesn't work on

\forall{(u,v) \in V \times V}

producing the error message:

! TeX capacity exceeded, sorry [input stack size=5000].

\forall #1->\forall (
                     #1)\;

However the following works fine albeit would require to substitute every occurrence of \forall in the document:

\newcommand{\all}[1]{\forall{(#1)}\;}

Is there an intrinsic recursiveness in that redefinition?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Your definition is a recursion. Do

\documentclass{article}

\let\ForAll\forall
\renewcommand\forall[1]{\ForAll{(#1)}\;}
\begin{document}

$\forall{(u,v) \in V \times V}$

\end{document}
share|improve this answer
    
Plus, plesae consider writing the for all part as words instead, it makes the text much more readable than having symbols all over the place. –  daleif Dec 17 '13 at 12:58
    
Great, thanks a lot! –  user42869 Dec 17 '13 at 13:04

I wouldn't change the semantics of a standard command. It's probably better to define \Forall:

\newcommand{\Forall}[1]{\forall{(#1)}\;}

rather than redefining \forall.

Just for fun, a “\let free” solution of your problem, should you decide to disobey:

\documentclass{article}

\edef\forall#1{\mathchar\number\forall{(#1)}\noexpand\;}

\begin{document}

$\forall{(u,v) \in V \times V}$

\end{document}

A bit more difficult with \renewcommand, but doable:

\expandafter\renewcommand\expandafter\forall\expandafter[\expandafter1\expandafter]%
\expandafter{\expandafter\mathchar\number\forall{(#1)}\;}

or

\begingroup\edef\x{\endgroup
  \unexpanded{\renewcommand\forall[1]}{\mathchar\number\forall{(##1)}\noexpand\;}%
}\x
share|improve this answer
    
show off.......;-) –  daleif Dec 17 '13 at 13:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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