5

I'm trying to write a bi-directional inference rule with a double horizontal line, using mathpartir. The documentation says I should be able to use \mprset{fraction={===}} as follows:

\documentclass{article}

\usepackage{mathpartir}

\begin{document}
\begin{mathpar}
\mprset{fraction={===}}
\inferrule*
{
}
{
  C \rightarrow C'
}
\and
\inferrule*
{
  C \rightarrow C
}
{
  C \rightarrow C'
}
\and
\inferrule*
{
  C \rightarrow C_{\beta}
}
{
  C \rightarrow C'
}
\end{mathpar}
\end{document}

This does indeed format the rule with a double horizontal line, but it also breaks the vertical alignment, so that, in the last example above, the C \rightarrow C' now overlaps with the double line.

See also here, Frac or inference rule with dotted line, but I would like a solution based on inferrule if possible.

2
  • Since mathpartir is not on CTAN, could you add a link where finding it?
    – egreg
    Aug 27, 2013 at 19:30
  • @egreg Ok, done.
    – Roly
    Aug 27, 2013 at 19:32

2 Answers 2

3

Three parameters to tune:

\eqgap distance between double rule lines;

\overgap separation between the text and the rules; and

\inferrulerule thickness of two rule lines.

This MWE shows it used in math mode, but it works outside of math mode, too. I don't know enough about inference rules to know, but if the math axis is aligned with the "denominator", then this MWE would work.

\documentclass{article}
\usepackage{stackengine}
\def\eqgap{.2ex}
\def\overgap{.4ex}
\def\inferrulerule{.2pt}

\newlength\rulelength
\newlength\toplength
\newlength\bottomlength

\newcommand\myinferrule[2]{%
  \stackMath%
  \setlength\bottomlength{\widthof{$#1$}}%
  \setlength\toplength{\widthof{$#2$}}%
  \ifdim\toplength>\bottomlength%
    \setlength\rulelength{\the\toplength}%
  \else%
    \setlength\rulelength{\the\bottomlength}%
  \fi%
  \mathrel{%
  \stackon[\overgap]{\stackon[\eqgap]{\stackon[\overgap]{#1}%
    {\rule{\the\rulelength}{\inferrulerule}}}%
    {\rule{\the\rulelength}{\inferrulerule}}}{#2}%
  }%
}
\begin{document}
\[
\mathrm{Math~Axis} \myinferrule{C \rightarrow C'}{C \rightarrow C_{\beta}}
\]
\end{document}

enter image description here

If the math axis is supposed to align with the rule, then this MWE would apply:

\documentclass{article}
\usepackage{stackengine}
\def\eqgap{.2ex}
\def\overgap{.4ex}
\def\inferrulerule{.2pt}

\newlength\rulelength
\newlength\toplength
\newlength\bottomlength

\newcommand\myinferrule[2]{%
  \stackMath%
  \setlength\bottomlength{\widthof{$#1$}}%
  \setlength\toplength{\widthof{$#2$}}%
  \ifdim\toplength>\bottomlength%
    \setlength\rulelength{\the\toplength}%
  \else%
    \setlength\rulelength{\the\bottomlength}%
  \fi%
  \mathrel{%
    \stackunder[\overgap]{%
      \stackon[\overgap]{%
        \stackanchor[\eqgap]%
          {\rule{\the\rulelength}{\inferrulerule}}%
        {\rule{\the\rulelength}{\inferrulerule}}%
      }{#2}%
    }{#1}%
  }%
}
\begin{document}
\[
\mathrm{Math~Axis} \myinferrule{C \rightarrow C'}{C \rightarrow C_{\beta}}
\]
\end{document}

enter image description here

With these parameters, the following

\[
\myinferrule{C \rightarrow C'}{C \rightarrow C_{\beta}} ~
\myinferrule{\scriptstyle C \rightarrow C'}{\scriptstyle C \rightarrow C_{\beta}} ~
\myinferrule{\scriptscriptstyle C \rightarrow C'}{\scriptscriptstyle C \rightarrow C_{\beta}}
\]

typesets to different math styles:

enter image description here

If you need to regularly set this to different math styles, I can make it (at the expense of extra coding) so that the style need not be set within the arguments themselves, as it is here. So let me know if that's the case.

3
  • This looks promising, but is it possible to customize inferrule* in a similar way? It provides other features which I would like to use (e.g. the ability to specify additional text that will appear to the left or right of the rule). Minor point: as defined, myinterrule only takes a single argument, whereas inferrule* accepts two. However I assume it would be easy to change your solution to accommodate text above and below the line.)
    – Roly
    Aug 27, 2013 at 21:07
  • @Roly Where should the horizontal axis of the expression be? At the baseline of the denominator, or between the double line?? Aug 27, 2013 at 22:39
  • Steven: I've updated my question with two more examples that include a formula above the line.
    – Roly
    Aug 28, 2013 at 7:39
3

The best thing to do is pick up the new version of mathpartir, in which this problem as been fixed. In reponse to my bug report, the author of mathpartir responded as follows:

I pushed a new version 1.2.1 where the fraction macro is handled a bit differently and I hope behaves much better with respect to vertical spacing.

http://cristal.inria.fr/~remy/latex/mathpartir.sty
http://cristal.inria.fr/~remy/latex/mathpartir.tex
http://cristal.inria.fr/~remy/latex/mathpartir.pdf

I also added options to adjust vertical spacing in case it does not work properly.

This seems to work as I would expect, and improves on either solution proposed above. The author does not have a Stack Exchange account.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .