7

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:

enter image description here

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

enter image description here

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\}
\]

2 Answers2

12

\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}

enter image description here

David Carlisle
  • 757,742
3

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} 

enter image description here

Bernard
  • 271,350