1

I have the following latex code:

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{subequations}
\begin{align}
\Phi_1^l(r)&=-(2l+1)\frac{q}{2la}\left(\frac{r}{a}\right)^l\\
\Phi_1^0(r)\bigg|_{q@0}&=\frac{q}{r}\\
\Phi_1^0(r)\bigg|_{q@2a}&=0\\
E_1^l(r)&=-(2l+1)\frac{q}{2ar}\left(\frac{r}{a}\right)^l\\
E_1^0(r)\bigg|_{q@0}&=-\frac{q}{r^2}\\
E_1^0(r)\bigg|_{q@2a}&=0
\end{align}
\end{subequations}
\begin{subequations}
\begin{align}
\Phi_2^l(r)&=-(2l+1)\frac{q}{2la}\left(\frac{2a-r}{a}\right)^l\\
\Phi_2^0(r)\bigg|_{q@0}&=\frac{q}{a}\\
\Phi_2^0(r)\bigg|_{q@2a}&=-\frac{q}{a}+\frac{q}{2a-r}\\
E_2^l(r)&=(1+2l)\frac{q}{2a(2a-r)}\left(\frac{2a-r}{a}\right)^l\\
E_2^0(r)\bigg|_{q@0}&=0\\
E_2^0(r)\bigg|_{q@2a}&=\frac{q}{(2a-r)^2}
\end{align}
\end{subequations}
\end{document}

What I would like to do is align the two align environments while keeping the sub equation numbering the same as it is. I'm aware of the already answered questions regarding aligning two different align environments, but they don't seem to help me with equation numbering since the align environments are inside subequation environments.

1

Here is a solution with the nccmath package. You just have to insert your two align and subequations environmments into a fleqn, an environment designed to type temporarily equations as the fleqn option of amsmath. This environment can take an optional argument – the distance from the left margin at which equations will start. The value was chosen by trial and errors.

However I find the result not so nice. In my opinion, alignment on the = sign is not a dogma. I suggest using the same method, but aligning on the left-hand side instead.

Here's an ilustration of both layouts with the following code:

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath, nccmath}
\usepackage{amssymb}

\begin{document}

\begin{fleqn}[7em]
  \begin{subequations}
    \begin{align}
      \Phi_1^l(r) & =-(2l+1)\frac{q}{2la}\left(\frac{r}{a}\right)^l \\
      \Phi_1^0(r)\bigg|_{q@0} & =\frac{q}{r} \\
      \Phi_1^0(r)\bigg|_{q@2a} & =0 \\
      E_1^l(r) & =-(2l+1)\frac{q}{2ar}\left(\frac{r}{a}\right)^l \\
      E_1^0(r)\bigg|_{q@0} & =-\frac{q}{r^2} \\
      E_1^0(r)\bigg|_{q@2a} & =0 %
    \end{align}
  \end{subequations}
  \begin{subequations}
    \begin{align}
      \Phi_2^l(r) & =-(2l+1)\frac{q}{2la}\left(\frac{2a-r}{a}\right)^l \\
      \Phi_2^0(r)\bigg|_{q@0} & =\frac{q}{a} \\
      \Phi_2^0(r)\bigg|_{q@2a} & =-\frac{q}{a}+\frac{q}{2a-r} \\
      E_2^l(r) & =(1+2l)\frac{q}{2a(2a-r)}\left(\frac{2a-r}{a}\right)^l \\
      E_2^0(r)\bigg|_{q@0} & =0 \\
      E_2^0(r)\bigg|_{q@2a} & =\frac{q}{(2a-r)^2}
    \end{align}
  \end{subequations}
\end{fleqn}

\begin{fleqn}[7em]
  \begin{subequations}
    \begin{align}
       & \Phi_1^l(r)=-(2l+1)\frac{q}{2la}\left(\frac{r}{a}\right)^l \\
       & \Phi_1^0(r)\bigg|_{q@0}=\frac{q}{r} \\
       & \Phi_1^0(r)\bigg|_{q@2a}=0 \\
       & E_1^l(r)=-(2l+1)\frac{q}{2ar}\left(\frac{r}{a}\right)^l \\
       & E_1^0(r)\bigg|_{q@0}=-\frac{q}{r^2} \\
       & E_1^0(r)\bigg|_{q@2a}=0 %
    \end{align}
  \end{subequations}
  \begin{subequations}
    \begin{align}
       & \Phi_2^l(r)=-(2l+1)\frac{q}{2la}\left(\frac{2a-r}{a}\right)^l \\
       & \Phi_2^0(r)\bigg|_{q@0}=\frac{q}{a} \\
       & \Phi_2^0(r)\bigg|_{q@2a}=-\frac{q}{a}+\frac{q}{2a-r} \\
       & E_2^l(r)=(1+2l)\frac{q}{2a(2a-r)}\left(\frac{2a-r}{a}\right)^l \\
       & E_2^0(r)\bigg|_{q@0}=0 \\
       & E_2^0(r)\bigg|_{q@2a}=\frac{q}{(2a-r)^2}
    \end{align}
  \end{subequations}
\end{fleqn}

\end{document} 

enter image description here enter image description here

| improve this answer | |
1

Hoping you don't have too many of these alignments,

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amssymb}

\makeatletter
\newcommand{\stepsubequations}{%
  \ifmeasuring@
  \else
    \stepcounter{parentequation}\setcounter{equation}{0}%
    \xdef\theparentequation{\arabic{parentequation}}%
  \fi
}
\makeatother

\begin{document}

\begin{subequations}
\begin{align}
\Phi_1^l(r)&=-(2l+1)\frac{q}{2la}\left(\frac{r}{a}\right)^l\\
\Phi_1^0(r)\Big|_{q@0}&=\frac{q}{r}\\
\Phi_1^0(r)\Big|_{q@2a}&=0\\
E_1^l(r)&=-(2l+1)\frac{q}{2ar}\left(\frac{r}{a}\right)^l\\
E_1^0(r)\Big|_{q@0}&=-\frac{q}{r^2}\\
E_1^0(r)\Big|_{q@2a}&=0
\\% <---- change here the value
\stepsubequations
\Phi_2^l(r)&=-(2l+1)\frac{q}{2la}\left(\frac{2a-r}{a}\right)^l\\
\Phi_2^0(r)\Big|_{q@0}&=\frac{q}{a}\\
\Phi_2^0(r)\Big|_{q@2a}&=-\frac{q}{a}+\frac{q}{2a-r}\\
E_2^l(r)&=(1+2l)\frac{q}{2a(2a-r)}\left(\frac{2a-r}{a}\right)^l\\
E_2^0(r)\Big|_{q@0}&=0\\
E_2^0(r)\Big|_{q@2a}&=\frac{q}{(2a-r)^2}
\end{align}
\end{subequations}

\begin{equation}
Check
\end{equation}

\end{document}

The last equation is meant as a way to check that all goes well.

enter image description here

With left alignment:

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amssymb}

\makeatletter
\newcommand{\stepsubequations}{%
  \ifmeasuring@
  \else
    \stepcounter{parentequation}\setcounter{equation}{0}%
    \xdef\theparentequation{\arabic{parentequation}}%
  \fi
}
\makeatother

\begin{document}

\begin{subequations}
\begin{align}
&\Phi_1^l(r)=-(2l+1)\frac{q}{2la}\left(\frac{r}{a}\right)^l\\
&\Phi_1^0(r)\Big|_{q@0}=\frac{q}{r}\\
&\Phi_1^0(r)\Big|_{q@2a}=0\\
&E_1^l(r)=-(2l+1)\frac{q}{2ar}\left(\frac{r}{a}\right)^l\\
&E_1^0(r)\Big|_{q@0}=-\frac{q}{r^2}\\
&E_1^0(r)\Big|_{q@2a}=0
\\% <---- change here the value
\stepsubequations
&\Phi_2^l(r)=-(2l+1)\frac{q}{2la}\left(\frac{2a-r}{a}\right)^l\\
&\Phi_2^0(r)\Big|_{q@0}=\frac{q}{a}\\
&\Phi_2^0(r)\Big|_{q@2a}=-\frac{q}{a}+\frac{q}{2a-r}\\
&E_2^l(r)=(1+2l)\frac{q}{2a(2a-r)}\left(\frac{2a-r}{a}\right)^l\\
&E_2^0(r)\Big|_{q@0}=0\\
&E_2^0(r)\Big|_{q@2a}=\frac{q}{(2a-r)^2}
\end{align}
\end{subequations}

\begin{equation}
Check
\end{equation}

\end{document}

enter image description here

| improve this answer | |

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.