I would like to create a command which prints its arguments in a set builder notation. The problem
\documentclass{article}
\newcommand{\set}[2]{\left\{\ #1 \ \left| \ #2 \ \right. \right\} }
\begin{document}
$\set{A}{ (B) }$
\bigskip
$\set{A}{\Bigg(B\Bigg)}$
\bigskip
% but:
$\set{\Bigg(A\Bigg)}{B}$
\end{document}
is that my attempt to make the height of the middle bar automatically adjusted to the contents of the set, only works wih respect to the content of the right hand side of it. I know I could use the colon instead, but I just don't like the way it looks.
Is there any simple work around?
Thanks in advance
Best Answer
Here is a solution, adapted from a code in the documentation of
mathtools
, with a natural syntax: it uses two arguments in one, separated by a semi-colon. If the second argument does not exist, it also works, letting you define a set as a list of its elements.The \set command has a starred version, adding a pair of implicit
\left \right
. It also can take an optional argument:\big,\Big, \bigg, \Bigg
which adds a pair of implicit\bigl \bigr
or one of its siblings.