# Space around vertical bar/pipe

I am new to Latex and am giving it a try on a homework assignment. My professor's notes (which are written in Latex) include a formula that looks like this:

When I try and recreate this formula using Latex, my version looks like this:

There are a few differences between these two renderings, but the one that is bothering me most is that my professor's pipe character (|) has a comfortable amount of horizontal white space on either side; my pipe has very little space surrounding it.

How can I make my pipe character look like my professor's? Is he using a different character than I am?

Here is the code I am using:

$E_1 = \big\{ \langle 5, j \rangle \big| j \in \{1, \cdots, n \} - \{ 5 \} \big\}$

• \mid is the command for | used as an infix operator. Note also big\{ should be \bigl\{ and \big\} should be \bigr\} or you lose the open/close spacing on the delimiters Aug 31, 2018 at 12:09
• @DavidCarlisle - \mid was what I was looking for! Thanks! If you add your comment as an answer, I'll accept. Aug 31, 2018 at 12:18
• I already did:-) Aug 31, 2018 at 12:19
• @DavidCarlisle - Also, I converted the \bigs to \bigl and \bigr, but didn't notice a difference. Aug 31, 2018 at 12:19
• Welcome to TeX.SX! Do you know about the tools offered by the \mathtools package? If not, you might want to have a look to this question and to this.
– GuM
Aug 31, 2018 at 12:38

\mid is the command for | used as an infix operator. Note also big\{ should be \bigl\{ and \big\} should be \bigr\} or you lose the open/close spacing on the delimiters, however unfortunately you can't use the \bigm variant with \mid as it isn't a delimiter so you need \bigm| :

\documentclass{article}

\usepackage{amsmath}

\begin{document}

aaa
$E_1 = \{ \langle 5, j \rangle \mid j \in \{1, \cdots, n \} - \{ 5 \} \}$

bbb
$E_1 = \bigl\{ \langle 5, j \rangle \bigm| j \in \{1, \cdots, n \} - \{ 5 \} \bigr\}$
\end{document}


• @GuM I'm getting too old for this:-) Aug 31, 2018 at 12:56

I propose to define macros \set and \innerp with packages xparse and mathtools, using a simple syntax: \set{x;P(x)} and \innerp{x,y}.

These commands have a starred version, which adds a pair of implicit \left \right in front of the delimiters and ensures a proper spacing. They also can have as an optional argument one of \big, \Big, \bigg, \Bigg, which similarly adds a pair of implicit \bigl \bigr, &c.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{xparse}
\usepackage{mathtools}

\DeclarePairedDelimiterX{\set}[1]\{\}{\setargs{#1}}
%%% Syntax: \set{x ; P(x)})
\NewDocumentCommand{\setargs}{>{\SplitArgument{1}{;}}m}
{\setargsaux#1}
\NewDocumentCommand{\setargsaux}{mm}
{\IfNoValueTF{#2}{#1}{\nonscript\,#1\nonscript\;\delimsize\vert\nonscript\:\mathopen{} #2\nonscript\,}}

\DeclarePairedDelimiterX{\innerp}[1]{\langle}{\rangle}{\innpargs{#1}}
%%% Syntax: \innerp{x,y}
\NewDocumentCommand{\innpargs}{ >{\SplitArgument{1}{,}}m }
{\innpargsaux#1}
\NewDocumentCommand{\innpargsaux}{ m m }
{#1\:,\,\mathopen{}#2}%

\begin{document}

$E_1 = \set*{ \innerp{5, j} ; j \in \set{1, \cdots, n } - \set{5} }$

$E_1 = \set[\Big]{ \innerp{5, j} ; j \in \set{1, \cdots, n } - \set{5} }$

\end{document}