# More elegant look in \equation for longer equations?

There's one equation I need to use \equation for (I want the \eqref later) but it turns out pretty ugly, like this:

I don't think it looks quite right. I use the basic code like this:

$$k^2lp=(xA+yB+zC+wD)^2+(xB-yA+zD-wC)^2+(xC-yD-zA+wB)^2+(xD+yC-zB-wA)^2$$


What would you recommend to do to make it look better? Centered in some way and have the equation label be placed properly to the right?

• Do not use $ for math inside environment equation, because the environment already sets math mode. Otherwise you get error messages. – Heiko Oberdiek Jun 12 '17 at 19:10 • You must have had a error from that $ if you get an error then the generated pdf is always nonsense If you carry on past an error then TeX only recovers enough to syntax check the remaining document, it makes no attempt at producing sensible typeset output. – David Carlisle Jun 12 '17 at 20:32

First of all DO NOT USE \$ inside equation, it's already a math environment!!

I can recommend two different math environments: multline disregards any alignment

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{multline}
k^2lp=(xA+yB+zC+wD)^2+(xB-yA+zD-wC)^2\\
{}+(xC-yD-zA+wB)^2+(xD+yC-zB-wA)^2
\end{multline}
\end{document}


The more elegant split has to be used inside of the equation, and allows alignment (with & and =). Thanks to the suggestions in the comments below, here is an example

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\begin{split} k^2lp&=(xA+yB+zC+wD)^2+(xB-yA+zD-wC)^2\\ &\qquad +(xC-yD-zA+wB)^2+(xD+yC-zB-wA)^2 \end{split}$$
\end{document}


Subsection 3.3.5b (p. 46) of Ellen Swanson's Mathematics into Type, Updated Edition (1999), to which @daleif drew our attention, recommends the following:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}

\begin{document}

Ellen Swanson's \emph{Mathematics into Type} recommends something like this:
$$\begin{split} k^{2}lp = {}& (xA+yB+zC+wD)^2+(xB-yA+zD-wC)^2\\ & +(xC-yD-zA+wB)^2+(xD+yC-zB-wA)^2 \end{split}$$
Or, to be fussy:
$$\begin{split} k^{2}lp = {}& (xA+yB+zC+wD)^2+(xB-yA+zD-wC)^2\\ &\mspace{-\medmuskip} +(xC-yD-zA+wB)^2+(xD+yC-zB-wA)^2 \end{split}$$

\end{document}


That is,

See also the manual of the mathtools package, on p. 20 (top).

Addition: It should be noted, on the other hand, that in Exercise 19.17 of The TeXbook Donald Knuth seems to endorse the &\qquad + idiom that you can see in the second example of @Moriambar’s answer (and in this comment too ;-).

• I like the "cascade" effect of highlighting the first line by indenting the others (that us what I use \MoveEqLeft  for (as moving the first line left is the same as indenting all subsequent lines). – daleif Jun 12 '17 at 20:48
• Well, I did include a pointer to p. 20 of the mathtools manual, didn’t I? :-) – GuM Jun 12 '17 at 20:54

It seems to me that it can't be put in an one-line equation, so I will put it in an array:

\begin{array}{cc}
k^2lp& =(xA+yB+zC+wD)^2 +(xB-yA+zD-wC)^2 \\
&+(xC-yD-zA+wB)^2+(xD+yC-zB-wA)^2
\end{array}


Edit: According to the comments, it is wrong to implement this using array. I guess I'll just keep the answer here so beginners can compare it with other solutions and learn what NOT to use.

• The first + of the second row has the spacing of a sign, not of a binary operator. – CarLaTeX Jun 12 '17 at 19:05
• array is designed for setting arrays (matrices) the spacing is completely wrong for equations and all the entries are set in inline math mode not display math mode, – David Carlisle Jun 12 '17 at 20:38
• I’ve downvoted for the reasons explained in the comments above. – GuM Jun 12 '17 at 20:46
• I'm not one of the downvoters, but I do think you should edit and improve your solution. First off, the spacing around the = symbol in the first row is all wrong. Second, there should be more space between the first + symbol on the second line and the subsequent ( symbol, to make clear that the + symbol is a binary and not a unary operator. Last but not least, there should be more space between the rows. – Mico Jun 13 '17 at 7:34