# [Tex/LaTex] How to make equation fit in the column

acmfontsmath-modemath-operators

HI here is the latex code

    \documentclass{sig-alternate}
\usepackage{ctable}
\begin{document}
$G_{CS}(\mathbb{S_c})= \begin{cases} \displaystyle\sum_{k=1}^{r} \frac{Gmax(k)-q_k(s)}{Gmax(k)-Gmin(k)}.w_k & if\ Gmax(k) \neq Gmin(k)\\ 1 & if\ Gmax(k) = Gmin(k) \end{cases}$
This is boundary This is boundary This is boundary This is boundary This is boundary This is boundary This is boundary This is boundaryThis is boundary This is boundary This is boundary This is boundary This is boundary This is boundary This is boundary This is boundary

\end{document}


And here is the latex

I am using two columns in with ACM SIG Proceedings template http://www.acm.org/sigs/publications/proceedings-templates

The equation has gone out from the boundary, is there a way to make it within the boundary?
One way I can think of is make the space of red circle becomes smaller, and the font in red rectangle becomes smaller, but i am not sure how to achieve it. Furthermore, two multilines of equation are too near(draw by red line) is there a way to seperate it further?

There are many ways to reduce the place needed by the equation:

• \noindent skips the paragraph indenting.
• The spacing around binary operators and relational symbols can be reduced by changing \thinmuskip and \medmuskip. Instead of using \medmuskip=.625\medmuskip the expression below with \muexpr also scales the shrink and stretch components and keeps them.
• \mathit{Gmin} (BTW italic or upright?) saves some space, because Gmin is set as word and not as product G * m * i * n with additional spacing.
• The cases environment adds \quad (= 1em), \hspace{-.5em} reduces that space.
• The whole formula is set in smaller font size \small, the cases text in \scriptsize.
• The word if should be set as word, not as product of i * f: \text{if}.
• \cdot looks better than . as multiplication sign. The dot is omitted here to save some space, because it is not really needed here.

The example file:

\documentclass{sig-alternate}
\newcommand*{\Gmin}{\mathit{Gmin}}
\newcommand*{\Gmax}{\mathit{Gmax}}
\begin{document}
\noindent
\begingroup
\small
\thinmuskip=\muexpr\thinmuskip*5/8\relax
\medmuskip=\muexpr\medmuskip*5/8\relax
$G_{\mathit{CS}}(\mathbb{S_c})= \begin{cases} \displaystyle \sum_{k=1}^{r} \frac{\Gmax(k)-q_k(s)}{\Gmax(k)-\Gmin(k)}\,w_k & \text{\hspace{-.5em}\scriptsize if$\Gmax(k) \neq \Gmin(k)$}\\ 1 & \text{\hspace{-.5em}\scriptsize if$\Gmax(k) = \Gmin(k)$} \end{cases}$%
\endgroup\\
This is boundary This is boundary This is boundary This is boundary This
is boundary This is boundary This is boundary This is boundaryThis is
boundary This is boundary This is boundary This is boundary This is boundary
This is boundary This is boundary This is boundary
\end{document}


## Variant with \resizebox

The sledgehammer method is using \resizebox to scale the equation down to \linewidth:

\documentclass{sig-alternate}
\usepackage{graphicx}
\newcommand*{\Gmin}{\mathit{Gmin}}
\newcommand*{\Gmax}{\mathit{Gmax}}
\begin{document}
\noindent
\resizebox{\linewidth}{!}{%
$G_{\mathit{CS}}(\mathbb{S_c})= \begin{cases} \displaystyle \sum_{k=1}^{r} \frac{\Gmax(k)-q_k(s)}{\Gmax(k)-\Gmin(k)}\cdot w_k & \text{if$\Gmax(k) \neq \Gmin(k)$}\\ 1 & \text{if$\Gmax(k) = \Gmin(k)$} \end{cases}$%
}\\
This is boundary This is boundary This is boundary This is boundary This
is boundary This is boundary This is boundary This is boundaryThis is
boundary This is boundary This is boundary This is boundary This is boundary
This is boundary This is boundary This is boundary
\end{document}


This can also be combined or replaced with asymmetrical scaling \resizebox{\linewidth}{\height} or (a nested) \scalebox{.975}{1}. Reducing the horizontal width only avoids small looking fonts. But the asymmetries should be kept as small as possible to avoid the equation looking ugly distorted.

And these methods and tricks can be combined, e.g. first reducing the space with the tricks at the beginning and resizing to get the last points.

## Variant with max and min as subscripts

Following Gregorio's suggestion by using max and min as subscripts, it becomes easier to adjust the width of the equation, e.g.:

\documentclass{sig-alternate}
\newcommand*{\Gmin}{\mathit{G_{\mathrm{min}}}}
\newcommand*{\Gmax}{\mathit{G_{\mathrm{max}}}}
\begin{document}
\noindent
\begingroup
\small
$G_{\mathrm{CS}}(\mathbb{S_c})= \begin{cases} \displaystyle \sum_{k=1}^{r} \frac{\Gmax(k)-q_k(s)}{\Gmax(k)-\Gmin(k)}\,w_k & \text{\hspace{-.5em} if$\Gmax(k) \neq \Gmin(k)$}\\ 1 & \text{\hspace{-.5em} if$\Gmax(k) = \Gmin(k)$} \end{cases}$%
\endgroup\\
This is boundary This is boundary This is boundary This is boundary This
is boundary This is boundary This is boundary This is boundaryThis is
boundary This is boundary This is boundary This is boundary This is boundary
This is boundary This is boundary This is boundary
\end{document}