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}

相關內容