[Tex/LaTex] How to squeeze a long equation

equationsmath-mode

I am writing in IEEEtran two-column environment and has a display formula like this \sqrt{\frac{1^{2}}{0.111222}(0.111222\times1.111163+0.066987^{2}\times0.111222)-1}=\sqrt{0.111222}=0.111222. Before the first equal sign is a long square root. This square root is just a little bit wider than the column. Is there a way I can squeeze the square root within the column as a first line and put the rest beginning with the "=" as a second line?

enter image description here

Best Answer

The answer is yes. Here's an illustration (followed by an explanation).

\documentclass{IEEEtran}

\usepackage{amsmath}

\newcommand*\squeezespaces[1]{% %% <- #1 is a number between 0 and 1
  \thickmuskip=\scalemuskip{\thickmuskip}{#1}%
  \medmuskip=\scalemuskip{\medmuskip}{#1}%
  \thinmuskip=\scalemuskip{\thinmuskip}{#1}%
  \nulldelimiterspace=#1\nulldelimiterspace
  \scriptspace=#1\scriptspace
}
\newcommand*\scalemuskip[2]{%
  \muexpr #1*\numexpr\dimexpr#2pt\relax\relax/65536\relax
} %% <- based on  https://tex.stackexchange.com/a/198966/156366

\begin{document}

This is a long equation This is a long equation This is a long equation
This is a long equation This is a long equation This is a long equation
\[ %% vv Unaltered vv
    \sqrt{\frac{1^{2}}{0.111222}
      (0.111222\times1.111163+0.066987^{2}\times0.111222)-1}
    = \sqrt{0.111222}=0.111222
\]
This is a long equation This is a long equation This is a long equation
This is a long equation This is a long equation This is a long equation
\[ %% vv Squeezed and split vv
    \begin{split}                  %% <- split up equation, &'s will be aligned
        \kern 4em & \kern-4em      %% <- move anchor right by 4em
        \mbox{$\squeezespaces{0.5} %% <- reduce whitespace, switch to \textstyle
          \sqrt{\frac{1^{2}}{0.111222}
          (0.111222\times1.111163+0.066987^{2}\times0.111222)-1}
        $}
        \\&
          = \sqrt{0.111222}
        \\&                        %% <- leave this out if you want
          = 0.111222
    \end{split}
\]
This is a long equation This is a long equation This is a long equation
This is a long equation This is a long equation This is a long equation

\end{document}

output

I've done the following:

  1. I've used the split environment from amsmath to split up the equation in three lines. You can reduce this to two lines by removing the second \\&.

  2. To place the anchor (&) at the right spot, I've inserted a horizontal space in front of it and a negative horizontal space of equal magnitude after it with \kern 4em & \kern-4em.

  3. The amount of whitespace inserted at several places in an equation is governed by the following paramters: \thickmuskip (\; and space around e.g. =), \medmuskip (\: and space around e.g. +), \thinmuskip (\, and space around e.g. \sum and \sin), \nulldelimiterspace (space around e.g. fractions) and \scriptspace (space after sub-/superscripts). I've halved each of these lengths using \squeezespaces{0.5} (which is defined in the preamble).

    Doing this affects an entire equation and it can't be done inside split, so I've put the square root inside an \mbox{$<…>$} and used \squeezespaces{0.5} in the inner math environment. You can replace 0.5 by another number between 0 and 1 if you want.

  4. A side-effect of putting the \sqrt in a box is that it is set in \textstyle, which also saves space because it makes e.g. fractions smaller. You could also have accomplished this by using \tfrac instead of \frac or by inserting \textstyle right before \sqrt (or at the beginning of its first argument).

    If you don't want text style fractions you should use \mbox{$\displaystyle<…>$}.