6

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?

4

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.

  • The solution is pretty elegant, I really like the multlined environment, it makes sense. Is it going to be a problem to use the mathtools package in the document while I am using the amsmath package as well (it is a big document)? And just for the shake of it, is it possible that the terms of line 1 and 3 align as well independently from 2 and 4? – uknown Mar 27 '14 at 10:40
  • @user48703 -- since mathtools loads amsmath, there's no problem using them together -- you don't even have to load amsmath yourself. and as for the alignment, it's "nonexistent"; what looks like alignment here is caused simply by the relative lengths of the pieces, and the fact that multlined (same as multline but "subsidiary") shoves the first line to the left and the last line to the right. for information on what happens with lines in the middle when there are more than two, see the amsmath documentation (texdoc amsmath). – barbara beeton Mar 27 '14 at 13:06
1

Here's a solution that preserves the use of an align environment within a subequation environment. It uses &\qquad on lines 2 and 4 to indent them relative to lines 1 and 3. Separately, it gets rid of the (unneeded) \left and \right directives and uses text-italics instead of (the default) math italics for the subscripts "OPn", "OPs", and "Os". If you don't like the square brackets, just replace them with round parentheses.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\newcommand{\OPn}{\textit{OPn}}
\newcommand{\OPs}{\textit{OPs}}
\newcommand{\Os}{\textit{Os}}
\begin{document}
\begin{subequations} \label{eq:energy13}
\begin{align}
&  u_e\frac{\partial (\varrho_e u_e    )}{\partial t}
 + u_e\frac{\partial (\varrho_e u_e^2  )}{\partial s}
 + u_e\frac{\partial (\varrho_e u_e v_e)}{\partial n} 
 -2 \varrho_e \varOmega u_e v_e \nonumber \\ 
&\qquad=-     u_e\frac {\partial p_e}{\partial s} +\qquad
   +\varrho_e u_e\biggl[\varOmega^2R_{\OPs}
   +\frac{\partial\varOmega}{\partial t}(R_{\OPn}+n)
   -\frac{\partial^2 R_{\Os}}{\partial t^2}\biggr] \label{eq:energy13a}\\
&  u\frac{\partial (\varrho u   )}{\partial t} 
 + u\frac{\partial (\varrho u^2 )}{\partial s}
 + u\frac{\partial (\varrho u v )}{\partial n}  
 -2 \varrho \varOmega u v \nonumber \\
&\qquad=-    u\frac {\partial p  }{\partial s}
        +\mu u\frac {\partial^2 u}{\partial n^2}
   +\varrho u \biggl[ \varOmega^2R_{\OPs}
   +\frac{\partial\varOmega}{\partial t}(R_{\OPn}+n)
   -\frac{\partial^2 R_{\Os}}{\partial t^2}\biggr] \label{eq:energy13b}
\end{align}
\end{subequations}

Here's a cross-reference to equation \eqref{eq:energy13b}.
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.