Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I refer to this question and particularly to this answer. I defined \set by

\usepackage{mathtools}
...
\DeclarePairedDelimiterX\set[2]{\{}{\}}{#1 \mathrel{\delimsize|} #2}

where \mathrel{\delimsize|} imitates \mid, which itself is of math relation type but not scaleable.

Although \set[\big]{...}{...}, \set[\Big]{...}{...} etc. work fine, the starred-form \set*{...}{...} does not. The problem is that, in this case, \delimsize expands to \middle and \mathrel{\middle|} leads to an error, which can easily be reproduced:

\left\{x \mathrel{\middle|} y\right\}

I could define \set alternatively like

\DeclarePairedDelimiterX\setnew[2]{\{}{\}}{#1 \;\delimsize|\; #2}

which should produce in most cases the same spaces around | as the version above. However, there is a difference if a set is in scriptstyle:

A_{\set{x}{y}}

puts no spaces around |, whereas

A_{\setnew{x}{y}}

still prints \;|\;.

Do you know a way to make \mathrel and \middle compatible?

share|improve this question
    
Similar question: tex.stackexchange.com/q/5502 –  Philippe Goutet Aug 11 '11 at 9:50
add comment

2 Answers

up vote 10 down vote accepted

No space is inserted in script or scriptscript styles if you precede \; with \nonscript:

\DeclarePairedDelimiterX\setnew[2]{\{}{\}}{#1 \nonscript\;\delimsize|\nonscript\; #2}

Another solution that avoids \nonscript is

\DeclarePairedDelimiterX\set[2]{\{}{\}}
  {#1 \mathrel{}\mathclose{}\delimsize|\mathopen{}\mathrel{} #2}
share|improve this answer
    
Thanks, this solved my problem :-) In addition, if anyone knows a solution for the other version, \set, I would be glad if you posted it, too. –  aulste Aug 10 '11 at 18:18
3  
\left, \right and \middle must be at the same brace level. –  egreg Aug 10 '11 at 21:32
    
See edited answer. –  egreg Aug 10 '11 at 21:53
    
Great! Your second solution is exactly what I wanted. Thank you! –  aulste Aug 11 '11 at 13:40
    
Actually the first one is more efficient. –  egreg Aug 11 '11 at 16:56
add comment

If you are comfortable in using the alternative spacing you suggest:

\DeclarePairedDelimiterX\setnew[2]{\{}{\}}{#1 \;\delimsize|\; #2}

rather than

\DeclarePairedDelimiterX\set[2]{\{}{\}}{#1 \mathrel{\delimsize|} #2}

then try adding

\usepackage{etex}

in your document preamble. \middle is part of an etex extension.

share|improve this answer
    
Thanks for your suggestion. I would prefer \set to \setnew. Unfortunately, adding \usepackage{etex} didn't have an effect on both versions. The problem is not that the \middle command doesn't work but that it causes an error if I put \mathrel{...} around it. –  aulste Aug 10 '11 at 14:38
add comment

Your Answer

 
discard

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.