6

I want to use \middle| inside of brackets like this.

\documentclass{article}
\begin{document}

\begin{equation}
  \left\{\frac{1}{n} \middle| n>0\right\}
\end{equation}

\end{document}

\end{document}

But this examples lacks space before and after the mid |. I don't want to write every time:

left\{\frac{1}{n} \;\middle|\; n>0\right\}

How can I redefine the \middle| command to mean \;\middle|\;? I tried

\edef{\middle|}{\,\middle|\,}

and

\let\originalmiddle\middle
\renewcommand{\middle}{\;\originalmiddle\;}

but neither works. What is the difference between both commands and why do they not work with \middle?

4
  • Maybe you just want \mid? Though, that won't scale vertically.
    – morbusg
    Commented Jul 23, 2014 at 16:28
  • 1
    I want the middle command to scale vertically like \middle| does. Commented Jul 23, 2014 at 16:31
  • 2
    See tex.stackexchange.com/q/5502 to get \middle| to behave exactly as \mid Commented Jul 23, 2014 at 16:48
  • Thx for hint, I used your suggestion. Commented Jul 24, 2014 at 7:52

1 Answer 1

8

The symbol needs to come after the \middle so

\let\originalmiddle\middle
\renewcommand{\middle}[1]{\;\originalmiddle#1\;}

Although redefining primitives always breaks something, somewhere so I would suggest instead

\newcommand{\xmiddle}[1]{\;\middle#1\;}

and use \xmiddle (or any other name you wish)

8
  • Wow thx, that was fast! I tried to play around with a parameter but somehow did not manage to get things right. Commented Jul 23, 2014 at 16:33
  • Just out of curiosity, do you know how would one do that with a \(U)delcode or \(U)delimiter? (i.e., without \middle?)
    – morbusg
    Commented Jul 23, 2014 at 16:35
  • 1
    @morbusg \bigm|?
    – Manuel
    Commented Jul 23, 2014 at 16:45
  • 1
    @morbusg \bigm \Biggm and friends are defined already to be relation just as \bigr is \mathopen Commented Jul 23, 2014 at 16:45
  • 1
    \newcommand{\relmiddle}{\nonscript\;\middle\nonscript\;}
    – egreg
    Commented Jul 23, 2014 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .