方程式の整列を列挙する

方程式の整列を列挙する

ここに画像の説明を入力してください

思いつくのはintertext、カウンターを使用して手動で配置することだけです。これが本当に唯一の方法でしょうか?

答え1

以下を使用できます\intertext:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{enumerate}\mathtoolsset{above-intertext-sep=-\belowdisplayshortskip}
\item How can I align the equations
\begin{align*}
    a &= 2. \\
\intertext{
  \item Which appear in various items of \texttt{enumerate}?
}
  b &= a + 123.
\end{align*}
\end{enumerate}

\end{document}

ここに画像の説明を入力してください

答え2

を使用できますeqparbox

\documentclass{article}
\usepackage{amsmath}
\usepackage{eqparbox}
\begin{document}
\begin{enumerate}
 \item How can I align the equation
 \begin{align*}
  \eqmakebox[L][r]{$a$}&=\eqmakebox[R][l]{$2$}
 \end{align*}
 \item with the equation
 \begin{align*}
  \eqmakebox[L][r]{$b$}&=\eqmakebox[R][l]{$a+123$}
 \end{align*} 
 \item With \verb|eqparbox|.
\end{enumerate}
You can make it more structured by defining macros for that.
\newcommand{\LHS}[2][pft]{\eqmakebox[L#1][r]{$\displaystyle #2$}}
\newcommand{\RHS}[2][pft]{\eqmakebox[R][l]{$\displaystyle #2$}}
\begin{enumerate}
 \item Now you can align the equation
 \begin{align*}
  \LHS{a}&=\RHS{2}
 \end{align*}
 \item with the equation
 \begin{align*}
  \LHS{b+7c}&=\RHS{a+123}
 \end{align*} 
 \item using the macros \verb|\LHS| and \verb|\RHS|.
\end{enumerate}
The optional argument is an identifier. For each new set of mutually aligned
equations you need a distinct identifier. That is, all the left--hand sides and
all the right--hand sides with the same identifier have the same widths,
respectively.
\end{document}

ここに画像の説明を入力してください

付録: これは補遺ですegreg の素晴らしい(!)解決策enumitem( の上に)をロードすることを考慮するとmathtools、次のようにするとよりユーザーフレンドリーになります。

\setlist[enumerate]{before=\mathtoolsset{above-intertext-sep=-\belowdisplayshortskip}}

enumerateそうすれば、各環境に手動で追加する必要がなくなります。

\documentclass{article}
\usepackage{mathtools}
\usepackage{enumitem}
\setlist[enumerate]{before=\mathtoolsset{above-intertext-sep=-\belowdisplayshortskip}}
\begin{document}

\begin{enumerate}
\item How can I align the equations
\begin{align*}
    a &= 2 \;,\\
\intertext{
  \item which appear in various items of \texttt{enumerate},
}
  b &= a + 123\;,\\
\intertext{
  \item and without adding something by hand whenever I use \texttt{enumerate}?
}
  b &= c + d+\frac{7\pi}{2}\;.
\end{align*}
\end{enumerate}

\begin{align}
a &= 2 \;.\\
\intertext{We're back to normal.}
 b &= a + 123\;.
\end{align}
\end{document}

ここに画像の説明を入力してください

答え3

各方程式の左辺と右辺の最も幅の広い要素にアクセスでき、 と を\phantomping で組み合わせて使用​​する必要がありますlap。設定では、aは よりも広くba + 123は よりも広いので2.

ここに画像の説明を入力してください

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{enumerate}
  \item
  How can I align the equations
  \[
    a = \mathrlap{2.}\phantom{a + 123}% Widest RHS is "a + 123"
  \]

  \item
  Which appear in various items of \verb|enumerate|?
  \[
    \phantom{a}\mathllap{b} = a + 123 % Widest LHS is "a"
  \]
\end{enumerate}

\end{document}

上記のプロセスは、eqparbox(見るもう一つの答え) は、LaTeX の\label-\refシステムを使用して、最も広い要素の幅をキャプチャすることによって実現されます\eqmakebox[<tag>][<align>]{<stuff>}

関連情報