# Incorrect placement of equations, spanned and centered

The following set of equations, produce an output which is justified in center (although I haven't set such an option) and also the equations are spanned on two columns (which again I didn't set such option)

\begin{alignat}{2}
&E_{\mathrm{hit-L1}} = E_{L1}(\mathrm{tag+data}) \\
&E_{\mathrm{miss-L1}} =  E_{L1}(\mathrm{tag}) \\
&E_{\mathrm{hit-local-L2}} = E_{L2}(\mathrm{tag+data}) \\
&E_{\mathrm{miss-local-L2}} = E_{L2}(\mathrm{tag}) \\
&E_{\mathrm{hit-peer-L2}} = E_{\mathrm{dir}}+E_{\mathrm{router}}+E_{L2}(\mathrm{tag+data}) \\
&E_{\mathrm{miss-peer-L2}} = E_{L2}(\mathrm{tag}) + E_{\mathrm{dir}} \\
&E = E_{\mathrm{hit-L1}} + (1-h_{1}) \times (E_{\mathrm{miss-L1}}& \\
h_{2} \times E_{\mathrm{hit-local-L2}} + (1-h_{2}) \times& \\
\big( E_{\mathrm{miss-local-L2}} + h_{3} \times E_{\mathrm{hit-peer-L2}}& \\
+(1-h_{3}) \big( E_{\mathrm{miss-peer-L2}} + E_{mem} \big) \big) )
\end{alignat}


and the output looks like

I would like to have one columned equations and the numbers should be in front of them (right side of the equations). Also, since I have used \\, the last big equations should be paste in multiple lines and not spanning to two columns.

-
What would you like to have, exactly? –  Bernard Aug 6 '14 at 18:39
Please see the udpated post –  mahmood Aug 6 '14 at 18:42
For future reference, while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Aug 6 '14 at 18:53
Please provide some information about the intended meaning of the - symbols in the subscipts: Are they supposed to be minus signs, simple dashes/hyphens, or en-dashes that indicate a range (e.g., "from miss to local to L2"). If it's the second option, you should probably use \textrm instead of \mathrm. If it's the third option, you may want to write \textrm{miss--local--L2} to generate real typographic en-dashes. –  Mico Aug 6 '14 at 20:56

Actually, you did request the output exactly as shown. An & specifies that the text to the left is right aligned, and the text to the right of the & is left aligned. Thus, the first & in each line specified that the text following it is to be left aligned, which is did for the first 7 lines. Then on the last three lines you added a single & at the end of the line (and none at the beginning). So the text following the single & is set to be left aligned (i.e., the text before the single & is to be right aligned) with the leading & in the lines above.

I think what you want is:

## Notes:

• For the lines you don't want numbered you can apply \nonumber.

## Code:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat}{2}
E_{\mathrm{hit-L1}} &= E_{L1}(\mathrm{tag+data}) \\
E_{\mathrm{miss-L1}} &=  E_{L1}(\mathrm{tag}) \\
E_{\mathrm{hit-local-L2}} &= E_{L2}(\mathrm{tag+data}) \\
E_{\mathrm{miss-local-L2}} &= E_{L2}(\mathrm{tag}) \\
E_{\mathrm{hit-peer-L2}} &= E_{\mathrm{dir}}+E_{\mathrm{router}}+E_{L2}(\mathrm{tag+data}) \\
E_{\mathrm{miss-peer-L2}} &= E_{L2}(\mathrm{tag}) + E_{\mathrm{dir}} \\
E &= E_{\mathrm{hit-L1}} + (1-h_{1}) \times \Big(E_{\mathrm{miss-L1}} \nonumber\\
&\qquad h_{2} \times E_{\mathrm{hit-local-L2}} + (1-h_{2}) \times \nonumber\\
&\qquad \big( E_{\mathrm{miss-local-L2}} + h_{3} \times E_{\mathrm{hit-peer-L2}} \nonumber\\
&\qquad +(1-h_{3}) \big( E_{\mathrm{miss-peer-L2}} + E_{mem} \big) \big) \Big) \nonumber
\end{alignat}
\end{document}

-

I would rather separate the last equation from the others, not aligning it, but using a multlined environment. Semantically, it seems to be different, as it uses the left members of the six first equations. It makes this equation more readable, in my opinion. Still for readability I changed a pair of \big to \Big:

\documentclass{article}
\usepackage{mathtools}
\usepackage[showframe]{geometry}

\begin{document}

\begin{align}
E_{\mathrm{hit-L1}} &= E_{L1}(\mathrm{tag+data}) \\
E_{\mathrm{miss-L1}} &=  E_{L1}(\mathrm{tag}) \\
E_{\mathrm{hit-local-L2}} &= E_{L2}(\mathrm{tag+data}) \\
E_{\mathrm{miss-local-L2}} &= E_{L2}(\mathrm{tag}) \\
E_{\mathrm{hit-peer-L2}} &= E_{\mathrm{dir}}+E_{\mathrm{router}}+E_{L2}(\mathrm{tag+data}) \\
E_{\mathrm{miss-peer-L2}} &= E_{L2}(\mathrm{tag}) + E_{\mathrm{dir}}
\end{align}\vskip-1\baselineskip
$$E =\begin{multlined}[t] E_{\mathrm{hit-L1}} + (1-h_{1}) \times \Big(E_{\mathrm{miss-L1}} h_{2} \times E_{\mathrm{hit-local-L2}}+ (1-h_{2}) \times\\[-3pt] \Big( E_{\mathrm{miss-local-L2}} + h_{3} \times E_{\mathrm{hit-peer-L2}} +(1-h_{3}) \big( E_{\mathrm{miss-peer-L2}} + E_{\mathrm{mem}} \big) \Big) \Big) \end{multlined}$$

\end{document}


-
the hack to space up 1\baselineskip is probably not robust if it happens to fall at the end of a page. however, grouping everything with gather and using alignedat won't give every line an equation number. this comment is just to let you know that assigning equation numbers in such a situation is on the list to be considered when amsmath is next updated. –  barbara beeton Aug 6 '14 at 20:30