我有以下乳胶代码:
\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}
我想做的是对齐两个对齐环境,同时保持子方程编号不变。我知道已经回答过有关对齐两个不同对齐环境的问题,但它们似乎对我的方程编号没有帮助,因为对齐环境位于子方程环境内。
答案1
这是软件包的解决方案nccmath
。您只需将两个align
和 subequations
环境插入到 中fleqn
,这是一个设计用于临时键入方程式的环境,作为fleqn
的选项amsmath
。此环境可以采用可选参数 - 方程式开始的左边距的距离。该值是通过反复试验选择的。
但我发现结果不太好。在我看来,在标志上对齐=
并不是教条。我建议使用相同的方法,但改为在左侧对齐。
以下是两种布局的图示,其中包含以下代码:
\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}
答案2
希望你不要有太多这样的对齐,
\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}
最后一个等式用于检查一切是否顺利。
左对齐:
\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}