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'm using this LaTeX plugin for a Wiki (Confluence, blech), and it doesn't support the \middle| command. I'm guessing it doesn't have eTex primitives or some such backwardness. Anyway, I guess I can write things like

\newcommand{\fakemiddlebar}[2]{{\kern-\nulldelimiterspace\left.\vphantom{{#1}{#2}}\right|}}
\newcommand{\condset}[2]{\left\{ #1 \mathrel{\fakemiddlebar{#1}{#2}} #} \right\}}

(improved as per @egreg's suggestion).

Edit: But I want to do better! I want to have an argument-less command with the same effect is \middle|. Also, I can't \include or \usepackage. Is that possible?

share|improve this question
1  
See tex.ac.uk/cgi-bin/texfaq2html?label=braket for more on the \middle command and the braket package. –  Mico Sep 12 '12 at 15:52

3 Answers 3

You get the same result with \condset{x\in X}{x<\frac{1}{2}} as

\left\{x\in X\middle|x<\frac{1}{2}}

by modifying your macros into

\newcommand{\fakemiddlepipe}[2]{{\kern-\nulldelimiterspace\left.\vphantom{{#1}{#2}}\right|}}
\newcommand{\condset}[2]{\left\{ #1 \fakemiddlepipe{#1}{#2} #2 \right\}}

Note the additional pair of braces around the body of \fakedmiddlepipe and the \kern instruction that takes away the space added by \left.. Of course there would be no space around the pipe, so the final definition might be

\newcommand{\condset}[2]{\left\{ #1 \mathrel{\fakemiddlepipe{#1}{#2}} #2 \right\}}

so that the result of \condset{x\in X}{x<\frac{1}{2}} would be the same as the more correct

\left\{x\in X\;\middle|\;x<\frac{1}{2}}

(and you could even remove the additional pair of braces in the definition of \fakemiddlepipe; but I'd leave them for other possible usages).

enter image description here

share|improve this answer
2  
grrr.. 2 minutes. 2 minutes! :-( –  morbusg Sep 12 '12 at 15:39
    
@morbusg we'll never beat egreg! =) –  cmhughes Sep 12 '12 at 15:41
    
@morbusg Sorry, this is the kind of questions that fascinates me the most. :) –  egreg Sep 12 '12 at 15:43
    
;-) The difference I had was the negative kern of \nulldelimiterspace after the \right., and wrapping the whole \left/\right into a \mathord. The spacing looked the same as with a \middle that way. –  morbusg Sep 12 '12 at 15:46
    
@morbusg Those are really equivalent: ${something}$ and $\mathord{something}$ are the same. –  egreg Sep 12 '12 at 15:48

If you are only interested in \middle| (and not any other delimiter), just use \vrule.

$$\left\{x\in X\;\vrule\; x< {1 \over 2} \right\}$$
\bye
share|improve this answer
    
Hmmm... so what's the use in \middle| then? –  einpoklum Sep 13 '12 at 18:47
    
You can use any delimiter with \middle: \middle\Vert, \middle\), etc. (Not that I can think of a reason why the latter will be needed. Note that the bracket package internally use \vrule for non eTeX engines. –  Aditya Sep 13 '12 at 21:30

As @Mico suggests, the braket package has the solution: Change the catcode of |, and use | instead of \middle| . You just have to be careful not to use it out of a group by mistake.

share|improve this answer

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.