考虑以下 MWE:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\setcounter{equation}{42}
\begin{align}
a & = b + c \label{label1} \\
\alpha_{i,j,k} & = \theta^2 + \phi^2 \label{label2} \\
M_\text{res} & = a + \alpha_{i,j,k} \label{label3}
\end{align}
\end{document}
我该如何枚举这三个方程式?将align
环境包裹在enumerate
环境中,并用 开始每条方程式行是\item
行不通的。
方程式应该像平常一样枚举,因此将取决于align
相关环境之前的内容。我随意将方程式计数器设置为 42 来表示之前的内容align
。我还需要像平常一样引用方程式标签。
答案1
使用alignat
宏\step
:
\documentclass{article}
\usepackage{amsmath}
\newcounter{step}
\newcommand{\step}{\stepcounter{step}\thestep.\quad}
\begin{document}
\setcounter{equation}{42}
\setcounter{step}{0} % do this when you want to reset the numbering
\begin{alignat}{2}
\step&& a & = b + c \label{label1} \\
\step&& \alpha_{i,j,k} & = \theta^2 + \phi^2 \label{label2} \\
\step&& M_\text{res} & = a + \alpha_{i,j,k} \label{label3}
\end{alignat}
\end{document}
答案2
使用环境的解决方案flalign
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\newcounter{algostep}
\newcommand\step{\stepcounter{algostep}\hskip\parindent\thealgostep.}
\usepackage{etoolbox}
\BeforeBeginEnvironment{flalign}{\setcounter{algostep}{0}}
\begin{document}
\setcounter{equation}{42}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{flalign}
&\step & a & = b + c \label{label1} & \\
&\step & q & = e + f \label{label2} \\
&\step & z & = a + d \label{label3}
\end{flalign}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{flalign}
&\step & z & = a + d \label{label3} & \\
&\step & q & = e + f \label{label2} \\
&\step & a & = b + c \label{label1}
\end{flalign}
\end{document}