# Align mathematics equation in a box

I have the following code of maths equation in a box :

\begin{framed}
\begin{align*}
&C_\star \rightarrow E_\star :  &x=3\dfrac{5\phi^2+24\phi+12v+24}{\phi^2}, &y=108\dfrac{-\phi^3+5\phi^2+2\phi v+12\phi+4v+8}{\phi^3}\\
&E_\star \rightarrow C_\star :  &\phi=12\dfrac{6-x}{6x-y-198}, &v=2\dfrac{x^3-18x^2+3267x-324y-71658}{x^3+36x^2-12xy-5643x+396y+84834}
\end{align*}
\end{framed}

Everything is fine except that x and \phi is not aligned. Is there anything wrong with the code as I want to make sure x aligns with \phi and y aligns with v.

Doubling ampersands gives the desired result:

\documentclass{article}
\usepackage{amsmath}
\usepackage{framed}
\begin{document}

\begin{framed}
\begin{align*}
&C_\star \rightarrow E_\star :  &&x=3\dfrac{5\phi^2+24\phi+12v+24}{\phi^2}, &&y=108\dfrac{-\phi^3+5\phi^2+2\phi v+12\phi+4v+8}{\phi^3}\\
&E_\star \rightarrow C_\star :  &&\phi=12\dfrac{6-x}{6x-y-198}, &&v=2\dfrac{x^3-18x^2+3267x-324y-71658}{x^3+36x^2-12xy-5643x+396y+84834}
\end{align*}
\end{framed}

\end{document}

• Could you perhaps give any insight why and how a double ampersand behaves differently from a single one? – Daniel Nov 3 '15 at 8:53

You possibly want to have a look at empheq:

\documentclass{article}
\usepackage[a4paper,margin=2cm]{geometry} % or whatever options
\usepackage{amsmath}
\usepackage{empheq}

\begin{document}

\begin{empheq}[box=\fbox]{alignat*=3}
&C_\star \rightarrow E_\star