[Tex/LaTex] Inserting arrays into semantic’s inference rules

arraysmath-modesemantics

I want to typeset inference rules containing tables (or arrays) in the premises. I'm using the semantic package, which sets the premises (and conclusion) in math mode, so I thought this might work:

\inference{\expr{axis} \in \left\{
    \begin{array}{l}
    \expr{child}\\ \expr{descendant}
    \end{array}
\right\} }{conclusion}

However, this gives me an error message I'm perplexed looking at:

ERROR: Missing \cr inserted.

--- TeX said ---
<inserted text> 
                \cr 
l.56 \right\} }
               {\expr{axis::node-test predicate*} : \<node-set>}
--- HELP ---
From the .log file...

I'm guessing that you meant to end an alignment here.

which is strange, because typesetting the premise alone in a math environment works fine:

$
\expr{axis} \in \left\{ \begin{array}{l}
\expr{child}\\\expr{descendant}
\end{array}
\right\}
$

Could you shed some light on why am I getting the error message above and how to get rid of it?

PS: \expr{} is basically \texttt{}.

Best Answer

You can "protect" the array from the \inference construction by using braces:

enter image description here

\documentclass{article}
\usepackage{semantic}% http://ctan.org/pkg/semantic
\newcommand{\expr}{\texttt}
\begin{document}
\inference{\expr{axis} \in \left\{
    {\begin{array}{l}
    \expr{child}\\ \expr{descendant}
    \end{array}}
\right\} }{conclusion}
\end{document}​

The reason for this being a problem is because, in a nested way, the \inference macro processes the premises (first argument) expecting a \\; actually, it expects <something>\\<something>\end, and the \\ in your array construction conflicts with this definition.

In this instance, you could also replace \\ with \cr to remove the conflict usage.

Related Question