\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{flalign}
& E=MC^2 \\
\begin{flalign}
& U = \frac{1}{2} + bh & V = \frac{1}{2} - bh & B=H \\ % want to have this sub equation indented\\
& H= \frac{1}{2}(S-X) & H1= \frac{1}{2}(S+X) & B=H \\ % want to have this sub equation indented
\end{flalign}
& Y=MX +b
\end{flalign}
\end{document}
如果有人能帮我在对齐环境中对齐我的子方程,我将不胜感激,子方程的编号为(2.1 a),主要方程的编号为(2.1)
答案1
像这样?
% arara: pdflatex
\documentclass{article}
\usepackage{mathtools}
\numberwithin{equation}{section} % for equation numbering section.equation
\usepackage{blindtext} % just for demo
\begin{document}
\blindtext
\setcounter{section}{2} % just for demo
\begin{align}
e&=mc^2 \\
&&U&= \frac{1}{2} + bh &V&= \frac{1}{2} - bh &B&=H \tag{\theequation{} a} \\
&&H&= \frac{1}{2}(S-X) &H_1&= \frac{1}{2}(S+X) &B&=H \tag{\theequation{} b} \\
Y&=mX +b
\end{align}
\blindtext
\end{document}
或者:
\begin{align}
\MoveEqLeft[3] e=mc^2 \\ % change the number [3] to other values in order to change the indent
U&= \frac{1}{2} + bh &V&= \frac{1}{2} - bh &B&=H \tag{\theequation{} a}\\
H&= \frac{1}{2}(S-X) &H_1&= \frac{1}{2}(S+X) &B&=H \tag{\theequation{} b}\\
\MoveEqLeft[3] Y=mX +b
\end{align}
或者第三种选择:
\begin{alignat}{7}
e&=mc^2 \\
& &&U&&= \frac{1}{2} + bh, &&V&&= \frac{1}{2} - bh, &&B&&=H \tag{\theequation{} a}\\
& &&H&&= \frac{1}{2}(S-X),\quad &&H_1&&= \frac{1}{2}(S+X),\quad &&B&&=H \tag{\theequation{} b}\\
Y&=mX +b
\end{alignat}
最后:
如果要更改最后一个示例中的缩进,只需更改第一行的字距:
\begin{alignat}{7}
e&=mc^2\mkern-20mu \\ % change this value to nevative or positive values in order to change the indent
& &&U&&= \frac{1}{2} + bh, &&V&&= \frac{1}{2} - bh, &&B&&=H \tag{\theequation{} a}\\
& &&H&&= \frac{1}{2}(S-X),\quad &&H_1&&= \frac{1}{2}(S+X),\quad &&B&&=H \tag{\theequation{} b}\\
Y&=mX +b\mkern-10000mu % leave this value
\end{alignat}