複数行環境では if 条件は使用できませんか?

複数行環境では if 条件は使用できませんか?

Incomplete \ifx次の tex コードをコンパイルするとエラーが発生します。

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{multline} % <- Replacing `multline` with `equation` can fix the problem.
  \iftrue
    \begin{aligned} h \end{aligned} % <- Removing `aligned` can fix the problem.
  \fi
\end{multline}
\end{document}

答え1

これはおそらくグループ化の問題です。aligned環境を中括弧で囲むと、コードはコンパイルされます。

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{multline} % <- Replacing `multline` with `equation` can fix the problem.
  \iftrue {
    \begin{aligned} h \end{aligned} % <- Removing `aligned` can fix the problem.
      }
  \fi
\end{multline}
\end{document}

関連情報