1
\documentclass{article}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ifthen}
\usepackage{mathtools}

% Set former {x|P(x)} and {x,y,z}
\newcommand {\setof} [2] []
   { \ifthenelse {\equal{#1}{def}}
       {\{ #2 \}}
       {\{ #2 | #1 \} p1=#1}
   }

\begin{document}
Test setof substack = $\setof[\exists_{\substack{{x \\ y}}}] {foo}$

\end{document}

Gets the error message

! Use of \\setof doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.17 ...setof[\exists_{\substack{{x \\ y}}}] {foo}
5
  • Not the answer, but: Never use \exists and \forall with subscripts. The proper versions for such usage are \bigvee and \bigwedge. Sep 8, 2016 at 16:40
  • \bigvee and \bigwedge are" or" and "and" operators, not alternate versions of the qualifiers \exists and \forall.
    – shmuel
    Sep 8, 2016 at 17:02
  • 1
    It's not really clear why you're comparing #1 to def. If you leave out the optional argument you get some strange output. And | should be \mid.
    – egreg
    Sep 8, 2016 at 17:08
  • @shmuel They are so called Kuratowski quantifiers. See pl.wikipedia.org/wiki/Kwantyfikator (in Polish, but the usage is easy to deduce). Sep 8, 2016 at 17:09
  • I was testing against def because of this sentence in latex2e.pdf: "If this optional parameter is present, it means that the command's first argument is optional. The default value of the optional argument is def."
    – shmuel
    Sep 8, 2016 at 17:26

1 Answer 1

3

This error is typical of "fragile command in moving argument" errors (google for that phrase:-)

In this case:

\documentclass{article}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ifthen}
\usepackage{mathtools}

% Set former {x|P(x)} and {x,y,z}
\newcommand {\setof}[2][]
   {\ifthenelse {\equal{#1}{def}}
       {\{ #2 \}}
      {\{ #2 | #1 \} p1=#1}%
   }

\begin{document}
Test setof substack = $\setof[\exists_{\protect\substack{x \\ y}}] {foo}$

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .