2

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}

\begin{equation}
\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{equation}

\begin{equation}
\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{equation}

\begin{equation}
\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{equation}
\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? – egreg Oct 19 '17 at 9:31
  • Welcome to TeX SX! Could you post a full compilable code? – Bernard Oct 19 '17 at 9:32
3

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{equation}
\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{equation}

\end{document}

enter image description here

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}

enter image description here

| improve this answer | |
1

This is not answering your question directly, though it may solve your problem.

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}

\begin{equation}
  \abs{\frac{A + B}{2}}^2 + \abs{\frac{C + D}{2i}}^2 = 1,
\end{equation}
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}

enter image description here

| improve this answer | |
0

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}

\begin{equation}
  \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
\end{equation}

\begin{multline}
  \quad\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\quad
\end{multline}

\begin{equation}
  \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
\end{equation}

\begin{equation}
  \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
\end{equation}

\end{document} 

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.