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?

Marco Breitig
  • 257
  • 3
  • 10

1 Answers1

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)

David Carlisle
  • 757,742