# Using array inside alignat to create equation legend

I want to describe the parameters in used in the equation in two columns below the equations. Something like this

**** = *******
*** = **********

-                               -
|   A: something                |  D: something
-|   B: something               -|  E: something
|   C: smething                 |  F: something
-                               -


Using array inside alignat, the following output is produced

\begin{figure} \label{eq1}
\tiny
\begin{alignat}{2}
& E_{\mathrm{access}}    \mathord{=} E_{\mathrm{read}} \mathord{+} E_{\mathrm{write}} = E_{\mathrm{R\_L1}} \mathord{+} E_{\mathrm{R\_lower}} \mathord{+} E_{\mathrm{W\_L1}} \mathord{+} E_{\mathrm{W\_lower}} \label{equation1} \\
.... \\
\begin{array}{l l}
&h_{r1},h_{w1}: &  \text{Read,Write hits in L1}  \\
&h_{r2},h_{w2}: &  \text{Read,Write hits in local L2} \\
&h_{r3},h_{w3}: &  \text{Read,Write hits in peer L2} \\
&h_{r4},h_{w4}: &  \text{Read,Write hits in memory} \\
&E_{1}:         &  \text{Energy per access at L1} \\
&E_{2}:         &  \text{Energy per access at L2 slice} \\
&E_{d}:         &  \text{Energy per access at directory} \\
&E_{r}:         &  \text{Energy per access at router} \\
&E_{m}:         &  \text{Energy per access at memory} \\
&E_{N}:         &  \text{Number of hops} \\
&E_{i}(\mathrm{T}):         &  \text{Energy of tag array} \\
&E_{i}(\mathrm{T,D}):         &  \text{Aggregate energy of tag and data arrays} \\
\end{array}
\end{alignat}
\end{figure}


The weird thing is that the equations are pushed to the right and that is because I used \\ in the last equation. The equations are lengthy, so I didn't paste them.

Additionally, how can I create two column legend?

Remove the array from the aligned portion and set it as a regular math element. Since you're in a figure, it should be centered by default making it look like a math display:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{figure}
\centering
\begin{align}
f(x) &= ax^2 + bx + c
\end{align}

$\begin{array}{l l} h_{r1},h_{w1}: & \text{Read,Write hits in L1} \\ h_{r2},h_{w2}: & \text{Read,Write hits in local L2} \\ h_{r3},h_{w3}: & \text{Read,Write hits in peer L2} \\ h_{r4},h_{w4}: & \text{Read,Write hits in memory} \\ E_{1}: & \text{Energy per access at L1} \\ E_{2}: & \text{Energy per access at L2 slice} \\ E_{d}: & \text{Energy per access at directory} \\ E_{r}: & \text{Energy per access at router} \\ E_{m}: & \text{Energy per access at memory} \\ E_{N}: & \text{Number of hops} \\ E_{i}(\mathrm{T}): & \text{Energy of tag array} \\ E_{i}(\mathrm{T,D}): & \text{Aggregate energy of tag and data arrays} \\ \end{array}$
\end{figure}
\end{document}


You may also consider using an array column specification l @{\ :\ } l to set the : automatically. Expected output would be

Due to your thin columns, you won't be able to split the array into multiple side-be-side columns. However, this is how you can do that independent of the align construction:

%...
$\begin{array}{l @{\ :\ } l} h_{r1},h_{w1} & \text{Read,Write hits in L1} \\ h_{r2},h_{w2} & \text{Read,Write hits in local L2} \\ h_{r3},h_{w3} & \text{Read,Write hits in peer L2} \\ h_{r4},h_{w4} & \text{Read,Write hits in memory} \\ E_{1} & \text{Energy per access at L1} \\ E_{2} & \text{Energy per access at L2 slice} \end{array}\quad \begin{array}{l @{\ :\ } l} E_{d} & \text{Energy per access at directory} \\ E_{r} & \text{Energy per access at router} \\ E_{m} & \text{Energy per access at memory} \\ E_{N} & \text{Number of hops} \\ E_{i}(\mathrm{T}) & \text{Energy of tag array} \\ E_{i}(\mathrm{T,D}) & \text{Aggregate energy of tag and data arrays} \end{array}$
%...


\quad ensures a gap between the left/right portions of the arrays. Here is the too-wide output: