# How to make an equation more compact?

I have an equation that wastes a lot of space around the union symbol:

\documentclass{article}

\usepackage[cmex10]{amsmath}
\usepackage{amssymb}

\begin{document}
\begin{equation}
RA_U  \left ( new , ref \right ) =
\bigcup_{
\left\{
i  \text{ such that }  f_i \left(  ref \right) < f_i \left( new \right)
\right\}
}
\left\{
X \in \mathbb{R}^M ;
x_i \in \left [ f_i \left(  ref \right) ; f_i \left( new \right) \right ]
\right\}
\end{equation}
\end{document} This is especially dreadful, since I am using IEEEtran.cls, which has two columns.

How can I compress the equation around the union symbol?

• Don't use the cmex10 option for amsmath; it's just for compatibility with very old TeX distributions. Nov 22, 2013 at 16:50
• I can't see the meaning of this formula. Is $X=(x_1,x_2,...x_m)$? If so, you are quantifying over $i$ twice, once in the \bigcup and again in the set to its right. This is a mathematical error.
– Dan
Nov 23, 2013 at 3:49
• I second Dan's comment. Ignoring that, it usually is sufficiently clear to simply have f_i(ref) < f_i(old) below the \bigcup since i is the only free variable. Nov 23, 2013 at 17:18
• Gnnnn ... must .... not .... give .... stupid ... answer ... to ... title ...... gaaahdamnIcantresist: algebra! Nov 26, 2013 at 20:46

You can use \mathclap from mathtools package:

\documentclass{article}

\usepackage[cmex10]{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}

\begin{document}
\begin{equation}
RA_U  ( \mathit{new}, \mathit{ref} ) =
\bigcup_{\mathclap{
\left\{
i  \text{ such that }  f_i (\mathit{ref}) < f_i ( \mathit{new} )
\right\}
}}
\left\{
X \in \mathbb{R}^M ;
x_i \in [ f_i ( \mathit{ref} ) ; f_i ( \mathit{new} ) ]
\right\}
\end{equation}
\end{document}


Output: • Better than mine, but I think that a qquad space on either side of the \bigcup will make it look much better (or pushing the subscript a bit down vertically with some \strut). Nov 22, 2013 at 16:47
• @Rmano This is left to the OP's taste. Nov 22, 2013 at 16:50
• Hmmm, something bad will happen if one put two \bigcup_{\mathclap{\text{longgggg}}}s together. Having no idea about this further more question, I got a ':(' from myself... Nov 22, 2013 at 17:00
• @Ch'enMeng, you can either let TeX arrange your equations, or take matters in your own hands. If you don't want to mash two subscripts together, just don't do it. Nov 22, 2013 at 21:05

I recommend you do the following:

• Get rid of all \left and \right directives since they (a) insert undesirable horizontal whitespace and (b) don't actually do anything useful in the present context.

• Use \substack (provided by the amsmath package) to break the line below \bigcup into two parts.

• Use \textup (or \textnormal) instead of the default math italics in the definitions of the variable names "ref" and "new".

• Use \mathclap (provided by the mathtools package) to suppress whitespace to the left and right of \bigcup. (This step is also featured in @karlkoeller's answer.) \documentclass{article}
\usepackage{mathtools,amssymb}
\newcommand\vnew{\textup{new}}
\newcommand\vref{\textup{ref}}
\begin{document}
Before:
\begin{equation}
RA_U  \left ( new , ref \right ) =
\bigcup_{
\left\{
i  \text{ such that }  f_i \left(  ref \right) < f_i \left( new \right)
\right\}
}
\left\{
X \in \mathbb{R}^M ;
x_i \in \left [ f_i \left(  ref \right) ; f_i \left( new \right) \right ]
\right\}
\end{equation}

After:
\begin{equation}
RA_U (\vnew,\vref) =
\bigcup_{ \mathclap{ \substack{i\text{ such that}\\f_i(\vref) < f_i(\vnew)}} } \,
\bigl\{ X\in\mathbb{R}^M ; x_i \in [ f_i(\vref) ; f_i(\vnew) ] \bigr\}
\end{equation}
\end{document}

• I would leave some space around \bigcup. Other than that, this looks very good to me :)
– yo'
Nov 22, 2013 at 17:00
• @tohecz - Thanks! I did insert \, (thinspace) to the right of \bigcup ... :-) Since space is at a premium, I chose not to insert any more space.
– Mico
Nov 22, 2013 at 17:03

This is not new with respect to other answers, but I'd like to introduce a couple of tricks:

\documentclass{article}

\usepackage{amsmath,mathtools}
\usepackage{amssymb}

\newcommand{\V}{\mathrm{#1}} % or \mathit
\newcommand{\numberset}{\mathbb{#1}}
\newcommand{\R}{\numberset{R}}

\begin{document}
This is the original equation
\begin{equation}
RA_{U}(\V{new},\V{ref}) =
\bigcup_{
\mathclap{\substack{
\text{$i$ such that}\\[\jot]
f_i(\V{ref}) < f_i(\V{new})
}}
}
\{
X \in \R^{M} :
x_i \in [f_i(\V{ref}); f_i(\V{new})]
\}
\end{equation}

\renewcommand{\V}{\mathit{#1}}
\renewcommand{\numberset}{\mathsf{#1}}

Just to see the effect of changing just a couple of commands
\begin{equation}
RA_{U}(\V{new},\V{ref}) =
\bigcup_{
\mathclap{\substack{
\text{$i$ such that}\\[\jot]
f_i(\V{ref}) < f_i(\V{new})
}}
}
\{
X \in \R^{M} :
x_i \in [f_i(\V{ref}); f_i(\V{new})]
\}
\end{equation}
\end{document}


The main trick is the macro \V for typesetting multiletter variables; then also \numberset is defined, which is used indirectly for defining \R (and other number sets). I show how, just changing those definitions, one can change the output.

For the wide subscript I use \substack in a \mathclap, but adding some space around it in order that the union symbol is not adjacent to its surroundings.

Note the \jot used for giving some room between the two lines in the subscript. Also \text{$i$ such that} is handier to type than i\text{ such that}, because spaces are ‘natural’. • The \V macro is really nifty!
– Mico
Nov 22, 2013 at 17:18
• What is your view on the relative advantages of using \textup vs. \mathrm for typesetting variable names (assuming, of course, that an upright font shape is to be used)? In my experience, \textup yields slightly more tightly spaced letters, which may (or may not...) be desirable.
– Mico
Nov 22, 2013 at 22:02
• @Mico The difference is that one is typeset as normal text, the other in math, which has different rules for kerning. For variable names probably \mathrm (just like operator names); for words in subscript probably text; example: $F_{\textup{eff}}$. Maybe \textnormal is even better. Nov 22, 2013 at 22:26

Firstly don;t use \left...\right all over the place, it is not a good idea.

Why not just write \{ i \mid f_i ( ref ) < f_i ( new ) \} ( it looks better to add space around the |)

• What is objectionable about using \left...\right? Nov 22, 2013 at 16:29
• @Olivier I am also trying to find out. This seems to be a good resource tex.stackexchange.com/questions/12773/or-left-parentheses Nov 22, 2013 at 16:31
• Hmmm, bypassing the problem rather than sloving it... Nov 22, 2013 at 16:33
• @OlivierBégassat - Since space is at a premium in the present equation, all instructions that needlessly insert whitespace should be avoided, right?
– Mico
Nov 22, 2013 at 16:47
• Use \left...\right when appropriate. Trying to auto scale all over the places makes the code much harder to read. There is no reason to use scaling in say \left( new \right) as the fenced material is not tall. Instead it just clutters the code. Nov 22, 2013 at 17:01

I would write the index to the joint in two lines as You can obtain this through

\documentclass{article}

\usepackage[cmex10]{amsmath}
\usepackage{amssymb}

\begin{document}
\begin{equation}
RA_U  \left ( new , ref \right ) =
\mkern-36mu
\bigcup_{
i, \atop f_i \left(  ref \right) < f_i \left( new \right)
}
\mkern-36mu
\left\{
X \in \mathbb{R}^M ;
x_i \in \left [ f_i \left(  ref \right) ; f_i \left( new \right) \right ]
\right\}
\end{equation}
\end{document}


Note that I addtionally customized the kerning by hand. You can use the mathtools package as well (see @Micos answers for example).

## Edit

According to @egregs comment I'd like to present a variety using the \substack command provided by amsmath that yelds better results regarding the size of the index:

\begin{equation}
RA_U  \left ( new , ref \right ) =
\mkern-40mu
\bigcup_{
\substack{
i, \\
f_i \left(  ref \right) < f_i \left( new \right)
}
}
\mkern-40mu
\left\{
X \in \mathbb{R}^M ;
x_i \in \left [ f_i \left(  ref \right) ; f_i \left( new \right) \right ]
\right\}
\end{equation}

• amsmath has \substack which is better than \atop. Nov 22, 2013 at 16:49

It is visual formatting, so it's better avoided if you can, but you can do:

\begin{equation}
RA_U  \left ( new , ref \right ) =
\qquad\bigcup_{\mathstrut\makebox[0pt][c]{$\left\{ i \text{ such that } f_i \left( ref \right) < f_i \left( new \right) \right\}$}
} 