Equations (to be tagged, but how?) too long to fit in a Beamer alertblock

In the following code the 3rd equation is going out of the alert block. I want to align those equations beautifully inside the alert block. And also I want to indicate that the first equation is 'Mass conservation', second is 'Momentum conservation' and last as 'Total fluid energy conservation'. How can I do that?

\documentclass[handout,13pt,compress,c]{beamer}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{mathtools}
\usetheme{PaloAlto}

\begin{document}

\begin{frame}
\frametitle{Physical equations}
\framesubtitle{The equations that we are solving by Enzo during the simulation}

\begin{alertblock}{Eulerian equations of ideal magnetohydrodynamics (MHD) including    gravity, in comoving coordinate}
$$\dfrac{\partial \rho }{\partial t} + \dfrac{1}{a}\nabla .(\rho \vec{v}) = 0$$
$$\dfrac{\partial \rho \vec{v}}{\partial t} + \dfrac{1}{a}\nabla .\left(\rho \vec{v}\vec{v} + \vec{I}p^* - \dfrac{\vec{B}\vec{B}}{a}\right) = -\dfrac{\dot{a}}{a}\rho \vec{v} - \dfrac{1}{a}\rho \nabla \phi$$
$$\dfrac {\partial E} {\partial t} + \dfrac {1}{a} \nabla . \left[ (E+p^*) - \dfrac{1}{a}\vec{B}(\vec{B}.\vec{v})\right] = - \dfrac{\dot{a}}{a}\left( 2E - \dfrac{B^2}{2a}\right) - \dfrac{\rho }{a}\vec{v}.\nabla \phi - \Lambda + \Gamma + \dfrac{1}{a^2}\nabla . \vec{F}_{cond},$$

\end{frame}

\end{document}
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. You should have a look at this. – jub0bs Jul 28 '13 at 14:56

Here is one option using alignat*

\documentclass[handout,13pt,compress,c]{beamer}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{mathtools}
\usetheme{PaloAlto}

\begin{document}

\begin{frame}
\frametitle{Physical equations}
\framesubtitle{The equations that we are solving by Enzo during the
simulation}

\begin{alertblock}{Eulerian equations of ideal magnetohydrodynamics (MHD)
including    gravity, in comoving coordinate}
$\frac{\partial \rho }{\partial t} + \frac{1}{a}\nabla .(\rho \vec{v}) = 0$
$\frac{\partial \rho \vec{v}}{\partial t} + \dfrac{1}{a}\nabla .\left(\rho \vec{v}\vec{v} + \vec{I}p^* - \frac{\vec{B}\vec{B}}{a}\right) = -\frac{\dot{a}}{a}\rho \vec{v} - \frac{1}{a}\rho \nabla \phi$
\begin{alignat*}{2}
\frac {\partial E} {\partial t} + \frac {1}{a} \nabla . \left[ (E+p^*) -
\frac{1}{a}\vec{B}(\vec{B}.\vec{v})\right] &= &&-
\frac{\dot{a}}{a}\left(2E - \frac{B^2}{2a}\right) \\
& &&  - \frac{\rho}{a}\vec{v}.\nabla \phi
- \Lambda + \Gamma\\
& && + \dfrac{1}{a^2}\nabla . \vec{F}_{cond},
\end{alignat*}

\end{frame}

\end{document}

Also, you don't need \dfrac in display math and you should use  over double dollars.

Why is $...$ preferable to $$...$$?

By naming, do mean numbering and referencing a label name later on?

\begin{align}
\dfrac{\partial \rho }{\partial t} + \dfrac{1}{a}\nabla .(\rho \vec{v}) &=
0\label{eqname}\\
\dfrac{\partial \rho \vec{v}}{\partial t} + \dfrac{1}{a}\nabla
.\left(\rho \vec{v}\vec{v} + \vec{I}p^* - \dfrac{\vec{B}\vec{B}}{a}\right)
&=
-\dfrac{\dot{a}}{a}\rho \vec{v} - \dfrac{1}{a}\rho \nabla
\phi\label{eq2name}
\end{align}
\vspace*{-.6cm}        \begin{alignat}{2}
\dfrac {\partial E} {\partial t} + \dfrac {1}{a} \nabla . \left[ (E+p^*) -
\dfrac{1}{a}\vec{B}(\vec{B}.\vec{v})\right] &= &&-
\dfrac{\dot{a}}{a}\left(2E - \dfrac{B^2}{2a}\right) \notag\\
& &&  - \frac{\rho}{a}\vec{v}.\nabla \phi
- \Lambda + \Gamma\notag\\
& && + \dfrac{1}{a^2}\nabla . \vec{F}_{cond},\label{eq3name}
\end{alignat}

To change the numbers to names, add \tag{name}.

\begin{align}
\dfrac{\partial \rho }{\partial t} + \dfrac{1}{a}\nabla .(\rho \vec{v}) &=
0\tag{Mass Conservation}\\
\dfrac{\partial \rho \vec{v}}{\partial t} + \dfrac{1}{a}\nabla
.\left(\rho \vec{v}\vec{v} + \vec{I}p^* - \dfrac{\vec{B}\vec{B}}{a}\right)
&=
-\dfrac{\dot{a}}{a}\rho \vec{v} - \dfrac{1}{a}\rho \nabla
\phi\tag{Momentum Conservation}
\end{align}
\vspace*{-.6cm}
\begin{alignat}{2}
\dfrac {\partial E} {\partial t} + \dfrac {1}{a} \nabla . \left[ (E+p^*) -
\dfrac{1}{a}\vec{B}(\vec{B}.\vec{v})\right] &= &&-
\dfrac{\dot{a}}{a}\left(2E - \dfrac{B^2}{2a}\right) \notag\\
& &&  - \frac{\rho}{a}\vec{v}.\nabla \phi
- \Lambda + \Gamma\notag\\
& && + \dfrac{1}{a^2}\nabla . \vec{F}_{cond},
\tag{Total Fluid Energy}
\end{alignat}
• By naming I meant to display 'Mass conservation' exactly below(or left or right) to first equation. Display 'Momentum conservation' to exactly below(or left or right) to second equation and so on. – R S John Jul 28 '13 at 15:22
• since you're using amsmath, if you give the [leqno] option, the labels will appear on the left, and if a label requires an additional line, it will be placed above the first line of the relevant equation. – barbara beeton Jul 28 '13 at 16:20
• @barbarabeeton I just added that option and nothing changed. – dustin Jul 28 '13 at 16:26
• @dustin -- how very peculiar! you're correct, the labels are still on the right. there was a message, ! LaTeX Error: Option clash for package amsmath at the \usepackage line (before reading {xcolor}); while it didn't say what option was clashing, i'll guess that it has something to do with the labeling. if mathtools is moved up (to replace amsmath -- it loads amsmath anyway), the error message goes away, but still nothing changes. i'll take a look, but not right now. thanks for pointing it out. – barbara beeton Jul 28 '13 at 16:44

What "beautifully aligned" means here is open to interpretation. Since tags are reguired and space is limited, I would

• locally set the font size to \footnotesize
• opt for a gather environment combined with two split environments.

In order to avoid confusion, it's also probably a good idea to leave more vertical space between successive equations than a simple line break would.

\documentclass[handout,13pt,compress,c]{beamer}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{mathtools}
\usetheme{PaloAlto}

\begin{document}

\begin{frame}
\frametitle{Physical equations}
\framesubtitle{The equations that we are solving by Enzo during the simulation}

\begin{alertblock}{Eulerian equations of ideal magnetohydrodynamics (MHD)
including gravity, in comoving coordinate}
\footnotesize
\begin{gather*}
\dfrac{\partial \rho }{\partial t} + \dfrac{1}{a}\nabla .(\rho \vec{v}) =
0 \tag{Mass Conservation} \\[1em]
\begin{split}
&\dfrac{\partial \rho \vec{v}}{\partial t} + \dfrac{1}{a}\nabla .
\left(\rho \vec{v}\vec{v} + \vec{I}p^* - \dfrac{\vec{B}\vec{B}}{a}\right) \\
&\qquad = -\dfrac{\dot{a}}{a}\rho \vec{v} - \dfrac{1}{a}\rho \nabla \phi
\end{split} \tag{Momentum Conservation}\\[1em]
\begin{split}
&\dfrac {\partial E} {\partial t} + \dfrac {1}{a} \nabla . \left[ (E+p^*)
- \dfrac{1}{a}\vec{B}(\vec{B}.\vec{v})\right] \\
&\qquad = - \dfrac{\dot{a}}{a}\left( 2E - \dfrac{B^2}{2a}\right) -
\dfrac{\rho }{a}\vec{v}.\nabla \phi - \Lambda\\
&\qquad \phantom{=} + \Gamma + \dfrac{1}{a^2}\nabla . \vec{F}_{cond},
\end{split} \tag{Total Fluid Energy}
\end{gather*}