我正在努力对齐我的方程式并为它们提供一个数字。我在谷歌上搜索,但没有找到数组环境的解决方案。我尝试了 env align
。但只使用array
env。我设法得到了我想要的结果。现在我想在行末标记两个对话方程式(最好垂直居中)。
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{amsmath}
\usepackage{amssymb,amsthm}
\begin{document}
\begin{equation}
\begin{array}{lrcl}
\textbf{Conservation of energy} & E_{kin} &=& E'_{kin} \\
& m_1 v_1^2 + m_2 v_2^2 &=& m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
& m_1 (v_1^2 - {v'}_1^2) &=& m_2 ({v'}_2^2 - v_2^2) \\
& m_1 (v_1 + {v'}_1) (v_1 - {v'}_1) &=& m_2 ({v'}_2 + v_2) ({v'}_2 - v_2) \\
\\
\textbf{Conservation of momentum} & p &=& p' \\
& m_1 v_1 + m_2 v_2 &=& m_1 {v'}_1 + m_2 {v'}_2\\
& m_1 (v_1 - {v'}_1) &=& m_2 ({v'}_2 - v_2)\\
\end{array}
\end{equation}
\end{document}
为了更清楚起见:我希望黑色数字消失并出现红色数字:
答案1
amsmath 有几种环境用于对每行进行编号,或者像这里一样对整个组进行编号。不要将array
此类显示结构用于此类显示结构,因为间距和样式不是为此设计的。
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{amsmath}
\usepackage{amssymb,amsthm}
\begin{document}
\textbf{Conservation of energy}
\begin{equation}
\begin{split}
E_{\mathrm{kin}} &= E'_{\mathrm{kin}} \\
m_1 v_1^2 + m_2 v_2^2 &= m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
m_1 (v_1^2 - {v'}_1^2) &= m_2 ({v'}_2^2 - v_2^2) \\
m_1 (v_1 + {v'}_1) (v_1 - {v'}_1) &= m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)
\end{split}
\end{equation}
\textbf{Conservation of momentum}
\begin{equation}
\begin{split}
p &= p' \\
m_1 v_1 + m_2 v_2 &= m_1 {v'}_1 + m_2 {v'}_2 \\
m_1 (v_1 - {v'}_1) &= m_2 ({v'}_2 - v_2)
\end{split}
\end{equation}
\end{document}
答案2
你可以这样做:
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{amsmath}
\usepackage{amssymb,amsthm}
\begin{document}
\begin{align}
& \textbf{Conservation of energy}
& E_{kin} &= E'_{kin} \notag\\
&& m_1 v_1^2 + m_2 v_2^2 &= m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
&& m_1 (v_1^2 - {v'}_1^2) &= m_2 ({v'}_2^2 - v_2^2) \notag\\
&& m_1 (v_1 + {v'}_1) (v_1 - {v'}_1)&= m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)\notag\\[2ex]
& \textbf{Conservation of momentum}
& p &= p' \notag\\
&& m_1 v_1 + m_2 v_2 &= m_1 {v'}_1 + m_2 {v'}_2 \\
&& m_1 (v_1 - {v'}_1) &= m_2 ({v'}_2 - v_2) \notag
\end{align}
\end{document}
答案3
您可以使用alignedat
,但需要一些手动工作来在两个部分之间共享列宽;我们在全局对齐中确定最宽的列并在进行显示之前设置三个尺寸。
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{amsmath,mathtools,amssymb,amsthm}
\usepackage{lipsum} % just for the example
\newlength{\izA}\newlength{\izB}\newlength{\izC}
\newcommand{\mmb}[3]{\mathmakebox[#1][#2]{\displaystyle#3}}
\begin{document}
\lipsum*[2]
%%% settings for the display
\settowidth{\izA}{\textbf{Conservation of momentum}}%
\settowidth{\izB}{$\displaystyle m_1 (v_1 + {v'}_1) (v_1 - {v'}_1)$}%
\settowidth{\izC}{$\displaystyle m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)$}%
%%%
\begin{gather}
\begin{alignedat}{2}
&\mmb{\izA}{l}{\textbf{Conservation of energy}}
& \mmb{\izB}{r}{E_{\mathrm{kin}}} &= \mmb{\izC}{l}{E'_{\mathrm{kin}}} \\
&& m_1 v_1^2 + m_2 v_2^2 &= m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
&& m_1 (v_1^2 - {v'}_1^2) &= m_2 ({v'}_2^2 - v_2^2) \\
&& m_1 (v_1 + {v'}_1) (v_1 - {v'}_1) &= m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)
\end{alignedat}
\\
\begin{alignedat}{2}
&\textbf{Conservation of momentum}
& \mmb{\izB}{r}{p} &= \mmb{\izC}{l}{p'} \\
&& m_1 v_1 + m_2 v_2 &= m_1 {v'}_1 + m_2 {v'}_2 \\
&& m_1 (v_1 - {v'}_1) &= m_2 ({v'}_2 - v_2)
\end{alignedat}
\end{gather}
\lipsum[3]
\end{document}
替代解决方案是split
,因此我们需要更少的测量。
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{amsmath,mathtools,amssymb,amsthm}
\usepackage{lipsum} % just for the example
\newlength{\lefthandside}
\newcommand{\leftbox}[2][]{%
\makebox[\lefthandside][s]{#1\hfill$\displaystyle#2$}%
}
\begin{document}
\lipsum*[2]
%%% settings for the display
\settowidth{\lefthandside}{%
\textbf{Conservation of momentum}%
\quad
$\displaystyle m_1 (v_1 + {v'}_1) (v_1 - {v'}_1)$%
}%
%%%
\begin{align}
\begin{split}
\leftbox[\textbf{Conservation of energy}]
{E_{\mathrm{kin}}} &= E'_{\mathrm{kin}} \\
\leftbox{m_1 v_1^2 + m_2 v_2^2} &= m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
\leftbox{m_1 (v_1^2 - {v'}_1^2)} &= m_2 ({v'}_2^2 - v_2^2) \\
\leftbox{m_1 (v_1 + {v'}_1) (v_1 - {v'}_1)} &= m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)
\end{split}
\\
\begin{split}
\leftbox[\textbf{Conservation of momentum}]
{p} &= p' \\
\leftbox{m_1 v_1 + m_2 v_2} &= m_1 {v'}_1 + m_2 {v'}_2 \\
\leftbox{m_1 (v_1 - {v'}_1)} &= m_2 ({v'}_2 - v_2)
\end{split}
\end{align}
\lipsum[3]
\end{document}
答案4
如果您希望标题与左边距对齐,这里有两个解决方案,基于命令\shortintertext
和mathtools
环境flalign
。每个解决方案都有两种变体,具体取决于符号组是否=
对齐。这些变体在方程编号的位置也有所不同:
\documentclass[12pt,a4paper]{scrartcl}
\usepackage{mathtools}
\usepackage{amssymb,amsthm}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.2pt}
\begin{document}
\begin{align}
\shortintertext{\bfseries Conservation of energy}
E_\mathrm{kin} & = E'_\mathrm{kin} \notag \\
m_1 v_1^2 + m_2 v_2^2 & = m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
m_1 (v_1^2 - {v'}_1^2) & = m_2 ({v'}_2^2 - v_2^2) \notag \\
m_1 (v_1 + {v'}_1) (v_1 - {v'}_1) & = m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)\notag \\[2ex]
\shortintertext{\bfseries Conservation of momentum}
p & = p' \notag \\
m_1 v_1 + m_2 v_2 & = m_1 {v'}_1 + m_2 {v'}_2 \\
m_1 (v_1 - {v'}_1) & = m_2 ({v'}_2 - v_2) \notag
\end{align}
\vspace{1cm}
\begin{flalign}
& \textbf{Conservation \rlap{of energy}}
& E_\mathrm{kin} &= E'_\mathrm{kin} & & \notag\\
&& m_1 v_1^2 + m_2 v_2^2 &= m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \raisetag{1cm} \\
&& m_1 (v_1^2 - {v'}_1^2) &= m_2 ({v'}_2^2 - v_2^2) \notag\\
&& m_1 (v_1 + {v'}_1) (v_1 - {v'}_1)&= m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)\notag\\[2ex]
& \textbf{Conservation \rlap{of momentum}}
& p &= p' \notag\\
&& m_1 v_1 + m_2 v_2 &= m_1 {v'}_1 + m_2 {v'}_2 \\
&& m_1 (v_1 - {v'}_1) &= m_2 ({v'}_2 - v_2) \notag
\end{flalign}
\newpage
\begin{gather}
\shortintertext{\bfseries Conservation of energy}
\begin{aligned}
E_\mathrm{kin} & = E'_\mathrm{kin} \\
m_1 v_1^2 + m_2 v_2^2 & = m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
m_1 (v_1^2 - {v'}_1^2) & = m_2 ({v'}_2^2 - v_2^2) \\
m_1 (v_1 + {v'}_1) (v_1 - {v'}_1) & = m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)
\end{aligned}\\[2ex]
\shortintertext{\bfseries Conservation of momentum}
\begin{aligned}
p & = p' \\
m_1 v_1 + m_2 v_2 & = m_1 {v'}_1 + m_2 {v'}_2 \\
m_1 (v_1 - {v'}_1) & = m_2 ({v'}_2 - v_2)
\end{aligned}
\end{gather}
\vspace{1cm}
\begin{flalign}
& \textbf{Conservation of energy }
& & \begin{aligned}[t]
E_\mathrm{kin} &= E'_\mathrm{kin} \\
m_1 v_1^2 + m_2 v_2^2 &= m_1 {v'}_{1}^{2} + m_2 {v'}_{2}^{2} \\
m_1 (v_1^2 - {v'}_1^2) &= m_2 ({v'}_2^2 - v_2^2) \\
m_1 (v_1 + {v'}_1) (v_1 - {v'}_1)&= m_2 ({v'}_2 + v_2) ({v'}_2 - v_2)
\end{aligned}
& &
\\[2ex]
& \textbf{Conservation of momentum}
& & \begin{aligned}[t]
p &= p' \\
m_1 v_1 + m_2 v_2 &= m_1 {v'}_1 + m_2 {v'}_2 \\
m_1 (v_1 - {v'}_1) &= m_2 ({v'}_2 - v_2)
\end{aligned}
& &
\end{flalign}
\end{document}