3

I am writing an deduction rule, and I want to break a long formula into multiple lines. I am using inferrule macro from mathpartir package to write the deduction rule. And my formula is like

\documentclass{article}
\usepackage{mathpartir}
\begin{document}
$$
    \inferrule*{
        \psi(aaa)
    }{
        \psi(xxx\land yyy\land zzz)
    }
$$
\end{document}

But the real formula is longer, so I want to break it into multiple lines and I am using aligned environment.

\documentclass{article}
\usepackage{mathpartir}
\begin{document}
$$
    \inferrule*{
        \psi(aaa)
    }{
        \psi(\begin{aligned}xxx\\\land yyy\\\land zzz\end{aligned})
    }
$$
\end{document}

Then the compilation fails. I guess the problem is that inferrule redefined \\ so aligned does work. How can I make it work?

1 Answers1

3

I never heard of mathpartir before so I cannot say exactly what is going on here. The only thing I am sure of is that it has nothing to do with amsmath (which was actually my first guess), because also the snippet

% FAILS TOO
\newenvironment{foo}{}{}
\[
\inferrule*{
        \psi(aaa)
    }{
    \psi(\begin{foo}xxx\\\land yyy\\\land zzz\end{foo})
}
\]

fails. I guess it has to do with how \inferrule looks for and processes its arguments. Right now I haven't time to go through its code, but in many similar cases it helps to "protect" the inner environment by enclosing it in braces. In your case the code

\documentclass{article}
\usepackage{amsmath,mathpartir}
\begin{document}
\[
    \inferrule*{
        \psi(aaa)
    }{
        \psi({\begin{aligned}xxx\\\land yyy\\\land zzz\end{aligned}})
    }
\]
\end{document}

runs without problems. Please note that $$ should be avoided in LaTeX, see Why is \[ … \] preferable to $$ … $$?.

campa
  • 31,130
  • 1
    And it does work perfectly for my actual code. Thanks! – Qinshi Wang Dec 05 '19 at 21:17
  • 1
    But for some reason, it appears that there has to be some character (if only a space) in between the { that opens the second argument of \inferrule and the { that opens the new group protecting the aligned. \inferrule*{aaa}{{\begin{aligned}xxx\\yyy\end{aligned}}} yields an error, but \inferrule*{aaa}{ {\begin{aligned}xxx\\yyy\end{aligned}}} doesn't. – Mike Shulman Feb 10 '21 at 23:46
  • 1
    @MikeShulman Uhm, I've managed to track the error to a line of code which is followed by the comment "last bug fix not extensively checked", so I guess it has to do with that... :-). As far as I see the trouble comes from a redefinition of \\. If you use an aligned without \\ then it works with or without space after the opening brace. I'll try to look into it (but surely not before the weekend). – campa Feb 11 '21 at 08:24