# A command to replace \middle| when it's missing?

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?

-
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

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

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


\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).

-
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

-
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.

-