A condição If não pode ser usada em ambiente multilinha?

A condição If não pode ser usada em ambiente multilinha?

Incomplete \ifxerro surge ao compilar o seguinte código 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}

Responder1

Presumivelmente, é um problema de agrupamento. Se você colocar o alignedambiente entre colchetes, o código será compilado:

\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}

informação relacionada