\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}
获取错误信息
! 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}
答案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_{\protect\substack{x \\ y}}] {foo}$
\end{document}