# Equation taking too much horizontal space

Ok, so I have these three equations:

\documentclass[a4,12pt,norsk]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel, amsmath, pgfplots, amsfonts, mathtools}

\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%

\makeatletter
\let\oldabs\abs
\def\abs{\@ifstar{\oldabs}{\oldabs*}}

\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother

\begin{document}

$$\abs{\left(\frac{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}{2}\right)}^2 + \abs{\left(\frac{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}{2i}\right)}^2 = 1$$

$$\left(\frac{\abs{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}}{\abs{2}}\right)^2 + \left(\frac{\abs{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}}{\abs{2i}}\right)^2 = 1$$

$$\frac{\cos^2{a}(e^{-2b}+2+e^{2b}) + \sin^2{a}(e^{-2b}-2+e^{2b}) +\cos^2{a}(e^{-2b}-2+e^{2b}) +\sin^2{a}(e^{-2b}+2+e^{2b})}{4} = 1$$
\end{document}


and they are all taking too much horizontal space. apart from giving me error messsages with "\hbox too full...", it also looks bad. Is there a way to solve this? either making the equation less spaced or "moving" the equations backwards, so they are more centered?

• How do you define \abs? Oct 19, 2017 at 9:31
• Welcome to TeX SX! Could you post a full compilable code? Oct 19, 2017 at 9:32

I suggest multline for the first two equations and split for the last one (not using a long fraction line).

I also suggest not to interchange the role of * in the definition of \abs: \left and \right should be added only when they're really necessary.

\documentclass{article}
\usepackage{amsmath,mathtools}

\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\begin{document}

\begin{multline}
\abs*{\left(\frac{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}{2}\right)}^2 \\
+ \abs*{\left(\frac{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}{2i}\right)}^2 = 1
\end{multline}

\begin{multline}
\left(\frac{\abs{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}}{\abs{2}}\right)^2 \\
+ \left(\frac{\abs{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}}{\abs{2i}}\right)^2 = 1
\end{multline}

$$\begin{split} \frac{1}{4}\bigl(&\cos^2{a}(e^{-2b}+2+e^{2b}) + \sin^2{a}(e^{-2b}-2+e^{2b})\\ & +\cos^2{a}(e^{-2b}-2+e^{2b}) +\sin^2{a}(e^{-2b}+2+e^{2b})\bigr) = 1 \end{split}$$

\end{document}


If the three equations are to be printed together, just one display should be used:

\documentclass{article}
\usepackage{amsmath,mathtools}

\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\begin{document}

\begin{align}
&\begin{multlined}[b]
\abs*{\left(\frac{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}{2}\right)}^2 \\
+ \abs*{\left(\frac{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}{2i}\right)}^2 = 1
\end{multlined}
\\[2ex]
&\begin{multlined}[b]
\left(\frac{\abs{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}}{\abs{2}}\right)^2 \\
+ \left(\frac{\abs{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}}{\abs{2i}}\right)^2 = 1
\end{multlined}
\\[2ex]
&\begin{multlined}[b]
\frac{1}{4}\bigl(\cos^2{a}(e^{-2b}+2+e^{2b}) + \sin^2{a}(e^{-2b}-2+e^{2b})\\
+\cos^2{a}(e^{-2b}-2+e^{2b}) +\sin^2{a}(e^{-2b}+2+e^{2b})\bigr) = 1
\end{multlined}
\end{align}

\end{document}


Assuming this is some kind of school exercise, where it is important to show how you achieve some kind of simplified algebraic expression, I'm tempted to shorten the entire equation problem:

\documentclass[a4,12pt,norsk]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel, amsmath, pgfplots, amsfonts, mathtools}
\usepackage{geometry}

\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%

\makeatletter
\let\oldabs\abs
\def\abs{\@ifstar{\oldabs}{\oldabs*}}

\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother

\begin{document}

$$\abs{\frac{A + B}{2}}^2 + \abs{\frac{C + D}{2i}}^2 = 1,$$
where
\begin{subequations}
\begin{align}
A & = \cos{a}(e^{-b}+e^{b}), \\
B & = i\sin{a}(e^{-b}-e^{b}), \\
C & = \cos{a}(e^{-b}-e^{b}), \\
D & = i\sin{a}(e^{-b}+e^{b}).
\end{align}
\end{subequations}

Applying the following identities,
\begin{align}
\abs{\frac{n}{m}} &= \frac{\abs{n}}{\abs{m}}, \\
& \text{some more identities}
\end{align}

et cetera, yields the results ...
\end{document}


In part the same solutions with multline. I'll add the \splitfrac command from math tools for your last equation, and an example with \mfrac (medium-sized fraction) from nccmath.

Also, if you don't use margin notes, you'll have more sensible margins just loading geometry. Note you don't have to load amsmath when you load mathtools.

\documentclass[a4,12pt,norsk]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{babel, , amsfonts, mathtools, nccmath}

\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%

\begin{document}

\vspace*{0.5cm}
\begin{multline}
\abs*{\left(\frac{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}{2}\right)}^2\\ + \abs*{\left(\frac{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}{2i}\right)}^2 = 1
\end{multline}

$$\abs*{\left(\mfrac{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}{2}\right)}^2 + \abs*{\left(\mfrac{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}{2i}\right)}^2 = 1$$

\begin{multline}
$$\frac{\splitfrac{\cos^2{a}(e^{-2b}+2+e^{2b}) + \sin^2{a}(e^{-2b}-2+e^{2b})\qquad}{\qquad+\cos^2{a}(e^{-2b}-2+e^{2b}) +\sin^2{a}(e^{-2b}+2+e^{2b})}}{4} = 1$$
$$\abs*{\left(\mfrac{\cos{a}(e^{-b}+e^{b}) + i\sin{a}(e^{-b}-e^{b})}{2}\right)}^2 + \abs*{\left(\mfrac{\cos{a}(e^{-b}-e^{b}) + i\sin{a}(e^{-b}+e^{b})}{2i}\right)}^2 = 1$$