TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

E.g., I have this set:

\{ \alpha \in \Sigma^\omega | \exists^\omega n : \alpha [0,n] \notin \Sigma^* a_1 \Sigma^* a_2 \dotsb a_n \Sigma^* \}

Here, I use | as the separator for the condition part. But LaTeX doesn't add any spaces around it, thus it looks a bit strange/wrong. I could manually add some space here but I wondered if there is some more "correct" way. E.g. also to make it behave similar as : (which I actually want to behave different here; in this case, : adds too much space in front of it for my taste).

Related questions: here or here.

share|improve this question
I had an additional question regarding this topic, which you may find here if you are interested. – aulste Aug 10 '11 at 18:27
up vote 15 down vote accepted

I sometimes do something a little more evil

 { #1 \,\delimsize| \,\mathopen{} #2 }
\Set*{ x }{ x>0 }

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

\providecommand\given{} % so it exists
   \nonscript\,#1\vert \allowbreak \nonscript\,\mathopen{}}
 { \renewcommand\given{\SetSymbol[\delimsize]} #1 }
\Set*{ x \given x>0 }

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.

share|improve this answer
Hehe, yea, I actually use some similar construct now. Whereby I used \newcommand. Is there any advantage with \DeclarePairedDelimiterX? – Albert Mar 16 '11 at 15:20
Test the document, it defines more than one command, try \Set[\big]{...}{...} – daleif Mar 16 '11 at 15:23
Hm, it seems something is wrong there. I get the error Runaway argument? ./texdefs.tex:33: Paragraph ended before \DeclarePairedDelimiterX was complete. <to be read again> \par l.33 ? – Albert Mar 16 '11 at 15:25
@Albert: @daleif 's code works OK in my system. The error message suggests that you forgot a closing brace. If that's not the case, we'll need to see the problematic code to detect the problem. – Gonzalo Medina Mar 16 '11 at 15:35
My code: \DeclarePairedDelimiterX\SetC[2]{\lbrace}{\rbrace}{ #1 \,\delimsize|\, #2 } – Albert Mar 16 '11 at 15:37

You should use \mid instead of |. And use \colon instead of : after the existential quantifier (although I would just put a thinspace).

share|improve this answer
I started to use \bigl\{ and \bigr\} now. What about \bigm| instead of \mid? Is there a difference except that it is slightly bigger? – Albert Mar 16 '11 at 15:19
I would think : might be correct there whereas \colon is more for F\colon A\to B – daleif Mar 16 '11 at 15:23
The problem with \mid is that it is not a fence, thus not scalable – daleif Mar 16 '11 at 15:24
If you use big braces, you should indeed use \bigm| instead of \mid since \mid is not defined as a delimiter and thus cannot be used with \bigm. – Michael Ummels Mar 16 '11 at 15:24

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 }
share|improve this answer

Your Answer


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.