[Tex/LaTex] How to align long subequations while breaking each one

alignsubequations

I want to align all the terms of two similar subequations, but the problem is that each one is long enough to need breaking. The problem is that after breaking \align tries to align every line with each other.

What I want, apparently is to align all the terms of line 1 with those of line 3 and all the terms of line 2 with those of line 4, simply because lines 1-2 contain the first equation and lines 3-4 the second. I have read all other align questions but no one really aligns long subequations.

This is the code that I have ended up with after numerous tries.

    \begin{subequations}
    \label{energy13}
    \begin{align}
    & u_e\frac{\partial \left(\varrho_e u_e\right)}{\partial t}
    + u_e\frac{\partial \left(\varrho_e u_e^2\right)}{\partial s}
    + u_e\frac{\partial \left(\varrho_e u_e v_e\right)}{\partial n} 
    -2 \varrho_e \varOmega u_e v_e \nonumber \\ 
    &=- u_e\frac {\partial p_e}{\partial s}
    +\qquad
    +\varrho_e u_e\left(\varOmega^2R_{OPs}+\frac{\partial\varOmega}{\partial 
    t}(R_{OPn}+n)-\frac{\partial^2 R_{Os}}{\partial t^2}\right) \\
    & u\frac{\partial \left(\varrho u\right)}{\partial t}
    + u\frac{\partial \left(\varrho u^2 \right)}{\partial s}
    + u\frac{\partial \left(\varrho u v \right)}{\partial n}  
    -2 \varrho \varOmega u v \nonumber \\
    &=- u\frac {\partial p}{\partial s}
    +\mu u\frac {\partial^2 u}{\partial n^2}
    +\varrho u \left(\varOmega^2R_{OPs}+\frac{\partial\varOmega}{\partial 
    t}(R_{OPn}+n)-\frac{\partial^2 R_{Os}}{\partial t^2}\right)
    \end{align}
    \end{subequations}

It barely aligns anything as it is. I am confused, is there a fix within the amsmath package without using IEEE special align stuff?

Best Answer

mathtools provides the multlined "subenvironment", which shifts the first line left, the last line right, and applies only one number to each subequation. put multiple multlined subequations together with gather:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\noindent X\hrulefill X\ignorespaces
\begin{subequations}
\label{energy13}
\begin{gather}
\begin{multlined}
 u_e\frac{\partial \left(\varrho_e u_e\right)}{\partial t}
+ u_e\frac{\partial \left(\varrho_e u_e^2\right)}{\partial s}
+ u_e\frac{\partial \left(\varrho_e u_e v_e\right)}{\partial n} 
-2 \varrho_e \varOmega u_e v_e \\ 
=- u_e\frac {\partial p_e}{\partial s}
+\qquad
+\varrho_e u_e\left(\varOmega^2R_{OPs}+\frac{\partial\varOmega}{\partial 
t}(R_{OPn}+n)-\frac{\partial^2 R_{Os}}{\partial t^2}\right)
\end{multlined}
 \\
\begin{multlined}
 u\frac{\partial \left(\varrho u\right)}{\partial t}
+ u\frac{\partial \left(\varrho u^2 \right)}{\partial s}
+ u\frac{\partial \left(\varrho u v \right)}{\partial n}  
-2 \varrho \varOmega u v \\
=- u\frac {\partial p}{\partial s}
+\mu u\frac {\partial^2 u}{\partial n^2}
+\varrho u \left(\varOmega^2R_{OPs}+\frac{\partial\varOmega}{\partial 
t}(R_{OPn}+n)-\frac{\partial^2 R_{Os}}{\partial t^2}\right)
\end{multlined}
\end{gather}
\end{subequations}
\end{document}

output of example code

the equation numbers are centered vertically on the subequations, rather than being set on the last line -- that's how all the "subenvironments" work.

Related Question