垂直方向の配置ネスト align とaligned の問題

垂直方向の配置ネスト align とaligned の問題

amsmath を使用して LaTeX で見栄えの良い最適化問題を記述しようとしています。MWE は次のとおりです。

\documentclass[letter, 10pt, conference]{article} 

\usepackage{amsmath}

\begin{document}

\begin{align*}
    & \underset{x,u}{\text{minimize}} & & \frac{1}{2} \sum_{k=0}^{N-1} 
    \text{some looooooooooooooooooooooooong function of } x,u \\
    & \text{subject to} & &
    \begin{aligned}
        & \text{constraint 1}, & & k = 0,\ldots,N{-}1, \\
        & \text{constraint 2}, & & k = 0,\ldots,N{-}1\\
    \end{aligned}
\end{align*}

\end{document}

MWEの出力

ここで、align 環境内にaligned 環境をネストしました。これは、「k = ...」を互いに水平に揃える必要があり、目的関数 (合計記号の後のもの) に整列文字を導入したくないためです。

問題は、「subject to」が「constraint 1」と一致していないことです。これを修正する簡単な方法はありますか?

答え1

1つできたalignedをTABstack に置き換えます。align 環境内にネストされている場合、タブと EOL 文字が変更されています。

[t]または、のオプションを使用することもできますaligned

\documentclass[letter, 10pt, conference]{article} 

\usepackage{amsmath,tabstackengine}
\stackMath
\setstackTAB{\&}
\setstackEOL{\#}
\begin{document}

\begin{align*}
& \underset{x,u}{\text{minimize}} & & \frac{1}{2} \sum_{k=0}^{N-1} 
\text{some looooooooooooooooooooooooong function of } x,u \\
& \text{subject to} & &
\alignLongunderstack{%
\& \text{constraint 1}, \& \& k = 0,\ldots,N{-}1, \#
\& \text{constraint 2}, \& \& k = 0,\ldots,N{-}1
}
\end{align*}
\end{document}

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

ここでは、[t]aligned のオプションを使用して同じ結果を取得します。

\documentclass[letter, 10pt, conference]{article} 

\usepackage{amsmath}
\begin{document}

\begin{align*}
    & \underset{x,u}{\text{minimize}} & & \frac{1}{2} \sum_{k=0}^{N-1} 
    \text{some looooooooooooooooooooooooong function of } x,u \\
    & \text{subject to} & &
    \begin{aligned}[t]
        & \text{constraint 1}, & & k = 0,\ldots,N{-}1, \\
        & \text{constraint 2}, & & k = 0,\ldots,N{-}1\\
    \end{aligned}
\end{align*}

\end{document}

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

関連情報