Нельзя ли использовать условие 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}

Связанный контент