# Preventing accumulating whitespace from using “\left.”

Sorry if this has been asked before, but googling seems to not work well with "\left." or variations.

I'm using the following pattern taken from a formula on Wikipedia's Cartesian product section on infinite products, where the vertical bars match the bracket height unlike \mid

\prod_{i \in I} X_i = \left\{\left. f : I \to \bigcup_{i \in I} X_i\ \right|\ (\forall i)(f(i) \in X_i)\right\}


Rendered as:

But it seems to have a small whitespace before the first word that accumulates with repeated use.

\begin{align*}
& \left(a\right) \\
& \left(\left.a \ \right|\ b\right) \\
& \left(\left.\left.a\ \right|\ b\ \right|\ c\right) \\
& \left(\left.\left.\left.a\ \right|\ b\ \right|\ c\ \right|\ d\right)
\end{align*}


Is rendered as:

Is there any way to achieve correct height vertical bars without the accumulating whitespace after the left bracket?

Every \left. or \right. adds space in the amount of \nulldelimiterspace, so you can remove it by

\kern-\nulldelimiterspace


On the other hand, there are better ways to type the formula. I'd go with the last one.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\noindent
First attempt (yours):
$\left\{ \left.f\colon I \to \bigcup_{i \in I} X_i\ \right|\ (\forall i)(f(i) \in X_i)\right\}$
Second attempt:
$\left\{ f\colon I \to \bigcup_{i \in I} X_i \;\middle|\; (\forall i)(f(i) \in X_i)\right\}$
Third attempt:
$\biggl\{ f\colon I \to \bigcup_{i \in I} X_i \biggm| (\forall i)(f(i) \in X_i)\biggr\}$
Fourth attempt:
$\Bigl\{ f\colon I \to \bigcup_{i \in I} X_i \Bigm| (\forall i)(f(i) \in X_i)\Bigr\}$

\end{document}


• @AkariAkaori: You might also want to have a look at section 3.6 of the manual of the mathtools package. – GuM Apr 22 '17 at 17:58