结合逐项列举/枚举列表并对齐环境

结合逐项列举/枚举列表并对齐环境

我有 2 个部分 (i) 和 (ii) 需要写出来,但我似乎无法让 (i) 和 (ii) 看起来很漂亮,即逐项列出。我尝试使用命令,\begin{enumerate}但它似乎无法与align环境协同工作?我该如何让这两个部分逐项列出/看起来很漂亮?(关于 (i) 和 (ii))。

\documentclass{report}
\usepackage{amsmath,amsthm,enumitem}% http://ctan.org/pkg/{amsmath,amsthm}
\theoremstyle{definition}
\newtheorem{defn}{Definition} % definition numbers are dependent on theorem numbers

\begin{document}
\begin{defn}
Let $x, y$ be some unknowns, we let:

\begin{align*}
(i) x^2 + y^2 &:= (x+y)(x-y) \\
    &:= (1+2)(3+4) \\
    &:= (3\times 7) \\
    &\phantom{:}= 21 \\
    &\phantom{:}= 42/2\\ \\
(ii) x^2 + y^2 &:= (x+y)(x-y) \\
    &:= (1+2)(3+4)(3+4)(3+4)(3+4) \\
    &:= (3\times 7)(3\times 7)(3\times 7) \\
    &\phantom{:}= 123456789 \\
    &\phantom{:}= 42/2
\end{align*}

\end{defn}

\end{document}

答案1

aligned与 一起使用enumerate

下面我使用calc包装并扩展了案例来展示如何处理左侧宽度不一致但仍然希望对齐的情况全部元素aligned。为了便于阅读,我将其分为两步进行,首先将设置\WidestLHS为整个列表中最宽的左侧,然后将宏应用于\FormatLHS等式的每个左侧。

如果所有左侧的宽度都相同,或者您不希望它们:=在列表项中对齐,则不需要使用这两个宏。

在此处输入图片描述

笔记:

  • 问题中的数学仍然是错误的,这里已将其更正。

代码:

\documentclass{report}
\usepackage{amsmath,amsthm,enumitem}%
% http://ctan.org/pkg/{amsmath,amsthm}
\usepackage{calc}%

\theoremstyle{definition}
\newtheorem{defn}{Definition} % definition numbers are dependent on theorem numbers

\begin{document}
\begin{defn}
Let $x, y$ be some unknowns, we let:

% Do this is two steps for readability
\newcommand*{\WidestLHS}{x^2 +2xy + y^2}%
\newcommand*{\FormatLHS}[1]{\makebox[\widthof{$\WidestLHS$}][r]{$#1$}}%
\begin{enumerate}[label={(\roman*)}]
\item $\begin{aligned}[t]
\FormatLHS{x^2 - y^2} &:= (x+y)(x-y) \\
    &:= (1+2)(3+4) \\
    &:= (3\times 7) \\
    &\phantom{:}= 21 \\
    &\phantom{:}= 42/2
\end{aligned}$
\item $\begin{aligned}[t]
\FormatLHS{x^2 - y^2} &:= (x+y)(x-y) \\
    &:= (1+2)(3+4)(3+4)(3+4)(3+4) \\
    &:= (3\times 7)(3\times 7)(3\times 7) \\
    &\phantom{:}= 123456789 \\
    &\phantom{:}= 42/2
\end{aligned}$
\item $\begin{aligned}[t]
\FormatLHS{x^2 +2xy + y^2} &:= (x+y)^2
\end{aligned}$
\end{enumerate}
\end{defn}
\end{document}

答案2

这是一个带有左对齐方程编号的选项(通过将leqno选项传递给amsmath或文档类):

在此处输入图片描述

\documentclass{report}
\usepackage[leqno]{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{amsthm}% http://ctan.org/pkg/amsthm
\theoremstyle{definition}
\newtheorem{defn}{Definition} % definition numbers are dependent on theorem numbers

\begin{document}
\begin{defn}
Let $x, y$ be some unknowns, we let:

\begin{align*}
x^2 - y^2 &:= (x+y)(x-y) \tag{\textit{i}} \label{eq:first} \\
    &:= (1+2)(3+4) \\
    &:= (5\times 6) \\
    &\phantom{:}= 30 \\
    &\phantom{:}= 60/2 \\ \\
x^2 - y^2 &:= (x+y)(x-y) \tag{\textit{ii}} \label{eq:second} \\
    &:= (1+2)(3+4)(5+6)(7+8)(9+0) \\
    &:= (1\times 2)(3\times 4)(5\times 6) \\
    &\phantom{:}= 123456789 \\
    &\phantom{:}= 42/2
\end{align*}
It is obvious that the mathematics in~\eqref{eq:first} and~\eqref{eq:second} is incorrect.
\end{defn}

\end{document}

\tag可用于覆盖常规编号和/或格式。

请注意,这将影响全局的方程编号。

相关内容