
我正在編寫一個推導規則,我想將一個長公式分成多行。我正在使用套件inferrule
中的巨集mathpartir
來編寫推導規則。我的公式就像
\documentclass{article}
\usepackage{mathpartir}
\begin{document}
$$
\inferrule*{
\psi(aaa)
}{
\psi(xxx\land yyy\land zzz)
}
$$
\end{document}
但真正的公式更長,所以我想將其分成多行,並且我正在使用aligned
環境。
\documentclass{article}
\usepackage{mathpartir}
\begin{document}
$$
\inferrule*{
\psi(aaa)
}{
\psi(\begin{aligned}xxx\\\land yyy\\\land zzz\end{aligned})
}
$$
\end{document}
然後編譯失敗。我想問題是inferrule
重新定義了\\
所以aligned
確實有效。我怎樣才能讓它發揮作用?
答案1
我以前從未聽說過mathpartir
,所以我不能確切地說這裡發生了什麼。我唯一確定的是它與(這實際上是我的第一個猜測)無關amsmath
,因為片段
% FAILS TOO
\newenvironment{foo}{}{}
\[
\inferrule*{
\psi(aaa)
}{
\psi(\begin{foo}xxx\\\land yyy\\\land zzz\end{foo})
}
\]
失敗。我想這與如何\inferrule
查找和處理其參數有關。現在我沒有時間瀏覽它的程式碼,但在許多類似的情況下,它有助於透過將其括在大括號中來「保護」內部環境。在你的情況下代碼
\documentclass{article}
\usepackage{amsmath,mathpartir}
\begin{document}
\[
\inferrule*{
\psi(aaa)
}{
\psi({\begin{aligned}xxx\\\land yyy\\\land zzz\end{aligned}})
}
\]
\end{document}
運行沒有問題。請注意,$$
在 LaTeX 中應避免使用,請參閱為什麼\[ … \]
優於$$ … $$
?。