我读过有关跨多个环境对齐的问题,但仍然不知道如何解决这种情况。
以下代码:
\section*{Solutions to Practice Problems}
\begin{enumerate}
\item Write down the meaning of the Commutative, Associative and Distributive properties. Create an example
that shows how each one works.\\[-2em]
\begin{align*}
\intertext{
\begin{description}[noitemsep, topsep=0pt]
\item[Commutative Property:] The order in which terms appear can be changed, but the
result remains unchanged.
\begin{example*} \end{example*}
\end{description}
}\\[-2em]
&&& \text{(Addition)} & 1,000 + x \ &= \ x + 1,000 &&&\\
&&& \text{(Multiplication)} & ab \ &= \ ba &&&
\intertext{
\begin{description}[noitemsep, topsep=0pt]
\item[Associative Property:] The order in which terms are \emph{grouped together} can be changed,
but the result remains unchanged.
\begin{example*} \end{example*}
\end{description}
}\\[-2em]
&&& \text{(Addition)} & (1,000 + 500) + y \ &= \ 1,000 + (500 + y) &&& \\
&&& \text{(Multiplication)} & a(bc) \ &= \ (ab)c &&&
\intertext{
\begin{description}[noitemsep, topsep=0pt]
\item[Distributive Property:] The product of the sums equals the sum of the products.
\begin{example*} \end{example*}
\end{description}
}\\[-2em]
&&& \text{(Numbers only)} & 3(40 - 2) \ &= \ 3 \cdot 40 - 3 \cdot 2 &&& \\
&&& \text{(With variables)} & 5(x - 12) \ &= \ 5x - 60 &&& \\
\end{align*}
\item Write down the meaning of the Additive and Multiplicative Identity properties. Create an example that
shows how each one works.
\begin{align*}
\intertext{
\begin{description}[noitemsep, topsep=0pt]
\item[Additive Identity:] There exists a number 0 such that addition with 0 and another term leaves the
term unchanged.
\begin{example*} \end{example*}
\end{description}
}\\[-2em]
&&& \text{(Numbers)} & 1,000 + 0 \ &= \ 1,000 &&&\\
&&& \text{(Variables)} & x + 0 \ &= \ x &&&
\intertext{
\begin{description}[noitemsep, topsep=0pt]
\item[Multiplicative Identity:] There exists a number 1 such that multiplication with 1 and another term
leaves the term unchanged.
\begin{example*} \end{example*}
\end{description}
}\\[-2em]
&&& \text{(Numbers)} & 12 \cdot 1 \ &= \ 12 &&& \\
&&& \text{(Variables)} & x \cdot 1 \ &= \ x &&&
\end{align*}
产生这样的结果:
我可以对此进行足够的修改,以使每个项目中的方程式对齐item
,但不能跨项目对齐。我所寻找的是统一性,即在每个项目中左对齐(数字)文本,理想情况下在项目间对齐每个方程式的符号=
。我发现最接近这个问题的问题是这里。如果可能的话,我只是希望对我这里的内容进行轻微的修改。
如果没有,那么有没有办法在整个文档中设置跨多个对齐环境的“全局”对齐参数?
答案1
为了代码的可读性,您最好使用特殊格式来设置内容array
:
\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{amsmath,array,enumitem}
\newlength{\LHS}
\newlength{\RHS}
\newenvironment{bigalign}
{\[% http://tex.stackexchange.com/q/31672/5764
%\renewcommand{\arraystretch}{1.5}% Stretch array vertically
\begin{array}{p{7em}>{\raggedleft$}p{\LHS}<{$}@{}>{${}}p{\RHS}<{$}}}
{\end{array}\]}
\begin{document}
\begin{enumerate}
\settowidth{\LHS}{$(1\,000 + 500) + y$}% Longest left-hand side
\settowidth{\RHS}{${}= 1\,000 + (500 + y)$}% Longest right-hand side
\item Write down the meaning of the Commutative, Associative and Distributive properties. Create an example
that shows how each one works.
\begin{description}[noitemsep, topsep=0pt]
\item[Commutative Property:] The order in which terms appear can be changed, but the
result remains unchanged.
\textbf{Example.}
\begin{bigalign}
\text{(Addition)} & 1\,000 + x &= x + 1\,000 \\
\text{(Multiplication)} & ab &= ba
\end{bigalign}
\item[Associative Property:] The order in which terms are \emph{grouped together} can be changed,
but the result remains unchanged.
\textbf{Example.}
\begin{bigalign}
\text{(Addition)} & (1\,000 + 500) + y &= 1\,000 + (500 + y) \\
\text{(Multiplication)} & a(bc) &= (ab)c
\end{bigalign}
\item[Distributive Property:] The product of the sums equals the sum of the products.
\textbf{Example.}
\begin{bigalign}
\text{(Numbers only)} & 3(40 - 2) &= 3 \cdot 40 - 3 \cdot 2 \\
\text{(With variables)} & 5(x - 12) &= 5x - 60 \\
\end{bigalign}
\end{description}
\item Write down the meaning of the Additive and Multiplicative Identity properties. Create an example that
shows how each one works.
\begin{description}[noitemsep, topsep=0pt]
\item[Additive Identity:] There exists a number 0 such that addition with 0 and another term leaves the
term unchanged.
\textbf{Example.}
\begin{bigalign}
\text{(Numbers)} & 1\,000 + 0 &= 1\,000 \\
\text{(Variables)} & x + 0 &= x
\end{bigalign}
\item[Multiplicative Identity:] There exists a number 1 such that multiplication with 1 and another term
leaves the term unchanged.
\textbf{Example.}
\begin{bigalign}
\text{(Numbers)} & 12 \cdot 1 &= 12 \\
\text{(Variables)} & x \cdot 1 &= x
\end{bigalign}
\end{description}
\end{enumerate}
\end{document}
array
(隐藏在 内)对每个组件使用固定宽度的列bigalign
。第一列是最左侧的符号。我之所以选择它,7em
是因为它在符号和其他内容之间提供了一个很好的间隙。第二列也是固定宽度的列,就像第三列一样,但以对齐(命令\settowidth
)中最宽的元素为单位。在左侧,最宽的元素是(1\,000 + 500) + y
,而右侧最宽的元素是= 1\,000 + (500 + y)
。
您可能需要增加\arraystretch
以满足您的需求。为了举例,我将其保留为 1。