2

Continuing http://tex.stackexchange.com/a/656192, how to center the inference rules carrying names or side conditions in the scope of \[…\] in narrow columns? For example,

\documentclass[twocolumn]{article}
\pagestyle{empty}
\usepackage{mathpartir}
\begin{document}
\noindent A sentence introducing the first rule, which has a name and protrudes to the left:
\[%\quad\ \,\qquad%%% Ad-hoc, manually added space would mitigate the problem.
  \inferrule*[Left=RULE\_NAME,Right=.]%
  {\mathrm{an\ extensive\ list\ of\ antecedences}}%
  {\mathrm{an\ extensive\ consequent}}
\]%
\noindent A long, extensive, lengthy, and boring text explaining the first rule in detail.\par

\noindent A sentence introducing the second rule, which has a side condition and protrudes to the right:
\[
  \inferrule*[Right=a\ side\ condition.]%
  {\mathrm{an\ extensive\ list\ of\ antecedences}}%
  {\mathrm{an\ extensive\ consequent}}
  %\qquad\qquad\qquad\qquad%%% Ad-hoc, manually added space would mitigate the problem.
\]%
\noindent A long, extensive, lengthy, and boring text explaining the second rule in detail.

\noindent A sentence introducing the third rule, which has both a name and a side condition and is not centered:
\[
  \inferrule*[Left=RULE,Right=formula.]%
  {\mathrm{an\ extensive\ list\ of\ antecedences}}%
  {\mathrm{an\ extensive\ consequent}}
  %%% Here, some unknown amount of space should be added so that the rule is really centered.
\]%
\noindent A long, extensive, lengthy, and boring text explaining the third rule in detail.
\end{document}

compiled by latex or pdflatex yields an output in which the inference rules with names and conditions are not centered:

output

Sometimes they even stick out to the margins although there would be space if the whole rule together with the name and side condition were centered.

Any way to center the rule including the stuff to its left and right?

PS. It turned out that this semantics of Left and Right is by design, as explained in the documentation of mathpartir. Not a bug.

2
  • not related to the question, but don't start every paragraph with \noindent May 4 at 13:00
  • @DavidCarlisle Yes. This was only to have a better visible indication of the left margin (otherwise the readers here at TeX.SE would have to subtract the first-line indent in their own minds) and thus a clearer contrast between the main text and the stuff protruding to the left.
    – AlMa0
    May 4 at 13:26

2 Answers 2

2

The inferences are centered, but without taking into account the side material.

You can use LEFT and RIGHT instead, but you need to explicitly tell that the material is in text mode.

\documentclass[twocolumn]{article}
\usepackage{mathpartir}

\makeatletter
% fix a long standing bug
\define@key {mprset}{style}[1]{\def\TirNameStyle{#1}}
\makeatother

\begin{document}

\noindent A sentence introducing the first rule, which has a name and protrudes to the left:
\[
  \inferrule*[Left=RULE\_NAME,Right=.]
  {\textrm{an extensive list of antecedences}}
  {\textrm{an extensive consequent}}
\]
A long, extensive, lengthy, and boring text explaining the first rule in detail.
\[
  \inferrule*[LEFT=\textrm{RULE\_NAME },Right=.]
  {\textrm{an extensive list of antecedences}}
  {\textrm{an extensive consequent}}
\]
A sentence introducing the third rule, which has both a name and a side 
condition and is not centered:
\[
  \inferrule*[LEFT=\textrm{RULE },RIGHT=\textrm{ formula.}]
  {\textrm{an extensive list of antecedences}}
  {\textrm{an extensive consequent}}
  %%% Here, some unknown amount of space should be added so that the rule is really centered.
\]
A long, extensive, lengthy, and boring text explaining the third rule in detail.

\end{document}

enter image description here

A different approach could be to define new keys Left* and Right* that do the same as Left and Right but not with zero width boxes.

\documentclass[twocolumn]{article}
\usepackage{mathpartir}

\makeatletter
% fix a long standing bug
\define@key {mprset}{style}[1]{\def\TirNameStyle{#1}}
% define new keys Right* and Left*
\define@key {mpr}{Left*}{\hbox{$\LeftTirName {#1}\;$}}
\define@key {mpr}{Right*}
  {\setbox \mpr@right \hbox {\unhbox \mpr@right $\;\RightTirName {#1}$}}
\makeatother

\begin{document}

\noindent A sentence introducing the first rule, which has a name and protrudes to the left:
\[
  \inferrule*[Left=RULE\_NAME,Right=.]
  {\textrm{an extensive list of antecedences}}
  {\textrm{an extensive consequent}}
\]
A long, extensive, lengthy, and boring text explaining the first rule in detail.
\[
  \inferrule*[Left*=RULE\_NAME,Right=.]
  {\textrm{an extensive list of antecedences}}
  {\textrm{an extensive consequent}}
\]
A sentence introducing the third rule, which has both a name and a side 
condition and is not centered:
\[
  \inferrule*[Left*=RULE,Right*=formula.]
  {\textrm{an extensive list of antecedences}}
  {\textrm{an extensive consequent}}
  %%% Here, some unknown amount of space should be added so that the rule is really centered.
\]
A long, extensive, lengthy, and boring text explaining the third rule in detail.

\end{document}

enter image description here

6
  • In my non-minimal examples (not shown), the left material (a rule name) is sometimes in the text mode, say, a text-mode Init or even \textscr{Init}, but sometimes in math-mode, say, \mathrm{Pre}^{\#}_{i,j}. The right material is most often either punctuation (a comma or a period) or a math-mode side condition, say, i\neq j.
    – AlMa0
    May 4 at 13:23
  • 1
    @AlMa0 If it's in math mode, use LEFT.
    – egreg
    May 4 at 13:27
  • So LEFT=\mathrm{Pre}^{\#}_{i,j}, for example? How about the punctuation to the right: better RIGHT=., RIGHT=\text{.}, your Right*=., or something else? After all, even small punctuation marks should count as having non-zero width for better centering.
    – AlMa0
    May 4 at 13:31
  • It seems that LEFT and RIGHT typeset stuff in normal size (which is NOT what we want), whereas Left and Right and, most importantly, your Left* and Right* typeset stuff in \small (which is what we want).
    – AlMa0
    May 4 at 16:45
  • @AlMa0 Look for the definition of the keys LEFT and RIGHT and copy them adding \small before the first $. But you can also say simply Right*=$abc$
    – egreg
    May 4 at 17:04
0

Not a bug: Left means “Put label l on the left of the rule […] but as if label l had zero width.” Similar for Right.

As for the minimal example at hand, left and right would do the job (but just for the minimal example):

\documentclass[twocolumn]{article}
\pagestyle{empty}
\usepackage{mathpartir}
\begin{document}
\noindent A sentence introducing the first rule, which has a name and protrudes to the left:
\[
  \inferrule*[left=RULE\_NAME,right=.]%
  {\mathrm{an\ extensive\ list\ of\ antecedences}}%
  {\mathrm{an\ extensive\ consequent}}
\]%
\noindent A long, extensive, lengthy, and boring text explaining the first rule in detail.\par

\noindent A sentence introducing the second rule, which has a side condition and protrudes to the right:
\[
  \inferrule*[right=a\ side\ condition.]%
  {\mathrm{an\ extensive\ list\ of\ antecedences}}%
  {\mathrm{an\ extensive\ consequent}}
  %\qquad\qquad\qquad\qquad%%% Ad-hoc, manually added space would mitigate the problem.
\]%
\noindent A long, extensive, lengthy, and boring text explaining the second rule in detail.

\noindent A sentence introducing the third rule, which has both a name and a side condition and is not centered:
\[
  \inferrule*[left=RULE,right=formula.]%
  {\mathrm{an\ extensive\ list\ of\ antecedences}}%
  {\mathrm{an\ extensive\ consequent}}
  %%% Here, some unknown amount of space should be added so that the rule is really centered.
\]%
\noindent A long, extensive, lengthy, and boring text explaining the third rule in detail.
\end{document}

output

Notice, however, that the text to the left is normal size (as in the OP), and the text to the right is in small capitals (as in the OP). Not sure whether this is intended.

You must log in to answer this question.

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