Define pretty sets in LaTeX; esp., how to do the condition-separator?
I sometimes do something a little more evil
\documentclass[a4paper]{memoir}
\usepackage{mathtools}
\DeclarePairedDelimiterX\Set[2]{\lbrace}{\rbrace}%
{ #1 \,\delimsize| \,\mathopen{} #2 }
\begin{document}
\[
\Set*{ x }{ x>0 }
\]
\end{document}
and thus hide the symbol inside the construction. Both a starred and non-starred \Set
is created with \Set*
autoscaling braces and vertical line is used.
Update August 2014: I no longer recommend a two argument solution, but rather this as I feel it gives an interface much closer to the mathematical meaning
\documentclass[a4paper]{memoir}
\usepackage{mathtools}
\providecommand\given{} % so it exists
\newcommand\SetSymbol[1][]{
\nonscript\,#1\vert \allowbreak \nonscript\,\mathopen{}}
\DeclarePairedDelimiterX\Set[1]{\lbrace}{\rbrace}%
{ \renewcommand\given{\SetSymbol[\delimsize]} #1 }
\begin{document}
\[
\Set*{ x \given x>0 }
\]
\end{document}
BTW: notice the added \mathopen{}
withput it \Set{ X \given -a < x < a}
would give us the wrong -a
(a subtraction minus, not a sign minus)
Update March 2015: Moved the \allowbreak
in front of the proceeding inserted space. Then that space disappears if a line break happens.
You should use \mid
instead of |
. And use \colon
instead of :
after the existential quantifier (although I would just put a thinspace).
The braket
package contains a \set
command which does what you want :
\set{\alpha \in \Sigma^\omega | \exists^\omega n : \alpha [0,n] \notin \Sigma^* a_1 \Sigma^* a_2 \dotsb a_n \Sigma^*}
It also defines \Set
, where the first |
is expandable, which allows to properly typeset sets like
\Set{x| x\in\mathbb R, |x|<\frac12 }