继续http://tex.stackexchange.com/a/656192那么,如何将带有名称或附加条件的推理规则集中\[…\]
在较窄的列中呢?例如,
\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}
latex
或编译后产生的pdflatex
输出中,名称和条件的推理规则不居中:
有时它们甚至会伸出到边缘,尽管如果整个规则连同名称和附加条件都居中的话会有空间。
有什么方法可以使规则居中,包括其左侧和右侧的内容?
PS. 事实证明,Left
and的这种语义Right
是经过设计的,正如 mathpartir 文档中所述。这不是一个错误。
答案1
推论是居中,但不考虑侧面材料。
您也可以使用LEFT
和RIGHT
来代替,但是您需要明确地表明该材料处于文本模式。
\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}
不同的方法可能是定义新的键Left*
和,Right*
它们的作用与Left
和相同,Right
但不适用于零宽度框。
\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}
答案2
不是错误:Left
表示“将标签升在规则的左边[…]但就像标签一样升宽度为零。” 类似地Right
。
至于手头的最小示例,left
并且right
可以完成工作(但仅限于最小示例):
\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}
但请注意,左侧的文本是正常大小(如 OP 中所示),而右侧的文本是小写大写(如 OP 中所示)。不确定这是否是故意的。