doc-src/Functions/mathpartir.sty
author Walther Neuper <neuper@ist.tugraz.at>
Thu, 12 Aug 2010 15:03:34 +0200
branchisac-from-Isabelle2009-2
changeset 37913 20e3616b2d9c
parent 30209 2f4684e2ea95
permissions -rw-r--r--
prepare reactivation of isac-update-Isa09-2
krauss@23004
     1
%  Mathpartir --- Math Paragraph for Typesetting Inference Rules
krauss@23004
     2
%
krauss@23004
     3
%  Copyright (C) 2001, 2002, 2003, 2004, 2005 Didier Rémy
krauss@23004
     4
%
krauss@23004
     5
%  Author         : Didier Remy 
krauss@23004
     6
%  Version        : 1.2.0
krauss@23004
     7
%  Bug Reports    : to author
krauss@23004
     8
%  Web Site       : http://pauillac.inria.fr/~remy/latex/
krauss@23004
     9
% 
krauss@23004
    10
%  Mathpartir is free software; you can redistribute it and/or modify
krauss@23004
    11
%  it under the terms of the GNU General Public License as published by
krauss@23004
    12
%  the Free Software Foundation; either version 2, or (at your option)
krauss@23004
    13
%  any later version.
krauss@23004
    14
%  
krauss@23004
    15
%  Mathpartir is distributed in the hope that it will be useful,
krauss@23004
    16
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
krauss@23004
    17
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
krauss@23004
    18
%  GNU General Public License for more details 
krauss@23004
    19
%  (http://pauillac.inria.fr/~remy/license/GPL).
krauss@23004
    20
%
krauss@23004
    21
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
krauss@23004
    22
%  File mathpartir.sty (LaTeX macros)
krauss@23004
    23
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
krauss@23004
    24
krauss@23004
    25
\NeedsTeXFormat{LaTeX2e}
krauss@23004
    26
\ProvidesPackage{mathpartir}
krauss@23004
    27
    [2005/12/20 version 1.2.0 Math Paragraph for Typesetting Inference Rules]
krauss@23004
    28
krauss@23004
    29
%%
krauss@23004
    30
krauss@23004
    31
%% Identification
krauss@23004
    32
%% Preliminary declarations
krauss@23004
    33
krauss@23004
    34
\RequirePackage {keyval}
krauss@23004
    35
krauss@23004
    36
%% Options
krauss@23004
    37
%% More declarations
krauss@23004
    38
krauss@23004
    39
%% PART I: Typesetting maths in paragraphe mode
krauss@23004
    40
krauss@23004
    41
\newdimen \mpr@tmpdim
krauss@23004
    42
krauss@23004
    43
% To ensure hevea \hva compatibility, \hva should expands to nothing 
krauss@23004
    44
% in mathpar or in inferrule
krauss@23004
    45
\let \mpr@hva \empty
krauss@23004
    46
krauss@23004
    47
%% normal paragraph parametters, should rather be taken dynamically
krauss@23004
    48
\def \mpr@savepar {%
krauss@23004
    49
  \edef \MathparNormalpar
krauss@23004
    50
     {\noexpand \lineskiplimit \the\lineskiplimit
krauss@23004
    51
      \noexpand \lineskip \the\lineskip}%
krauss@23004
    52
  }
krauss@23004
    53
krauss@23004
    54
\def \mpr@rulelineskip {\lineskiplimit=0.3em\lineskip=0.2em plus 0.1em}
krauss@23004
    55
\def \mpr@lesslineskip {\lineskiplimit=0.6em\lineskip=0.5em plus 0.2em}
krauss@23004
    56
\def \mpr@lineskip  {\lineskiplimit=1.2em\lineskip=1.2em plus 0.2em}
krauss@23004
    57
\let \MathparLineskip \mpr@lineskip
krauss@23004
    58
\def \mpr@paroptions {\MathparLineskip}
krauss@23004
    59
\let \mpr@prebindings \relax
krauss@23004
    60
krauss@23004
    61
\newskip \mpr@andskip \mpr@andskip 2em plus 0.5fil minus 0.5em
krauss@23004
    62
krauss@23004
    63
\def \mpr@goodbreakand
krauss@23004
    64
   {\hskip -\mpr@andskip  \penalty -1000\hskip \mpr@andskip}
krauss@23004
    65
\def \mpr@and {\hskip \mpr@andskip}
krauss@23004
    66
\def \mpr@andcr {\penalty 50\mpr@and}
krauss@23004
    67
\def \mpr@cr {\penalty -10000\mpr@and}
krauss@23004
    68
\def \mpr@eqno #1{\mpr@andcr #1\hskip 0em plus -1fil \penalty 10}
krauss@23004
    69
krauss@23004
    70
\def \mpr@bindings {%
krauss@23004
    71
  \let \and \mpr@andcr
krauss@23004
    72
  \let \par \mpr@andcr
krauss@23004
    73
  \let \\\mpr@cr
krauss@23004
    74
  \let \eqno \mpr@eqno
krauss@23004
    75
  \let \hva \mpr@hva
krauss@23004
    76
  } 
krauss@23004
    77
\let \MathparBindings \mpr@bindings
krauss@23004
    78
krauss@23004
    79
% \@ifundefined {ignorespacesafterend}
krauss@23004
    80
%    {\def \ignorespacesafterend {\aftergroup \ignorespaces}
krauss@23004
    81
krauss@23004
    82
\newenvironment{mathpar}[1][]
krauss@23004
    83
  {$$\mpr@savepar \parskip 0em \hsize \linewidth \centering
krauss@23004
    84
     \vbox \bgroup \mpr@prebindings \mpr@paroptions #1\ifmmode $\else
krauss@23004
    85
     \noindent $\displaystyle\fi
krauss@23004
    86
     \MathparBindings}
krauss@23004
    87
  {\unskip \ifmmode $\fi\egroup $$\ignorespacesafterend}
krauss@23004
    88
krauss@23004
    89
% \def \math@mathpar #1{\setbox0 \hbox {$\displaystyle #1$}\ifnum
krauss@23004
    90
%     \wd0 < \hsize  $$\box0$$\else \bmathpar #1\emathpar \fi}
krauss@23004
    91
krauss@23004
    92
%%% HOV BOXES
krauss@23004
    93
krauss@23004
    94
\def \mathvbox@ #1{\hbox \bgroup \mpr@normallineskip 
krauss@23004
    95
  \vbox \bgroup \tabskip 0em \let \\ \cr
krauss@23004
    96
  \halign \bgroup \hfil $##$\hfil\cr #1\crcr \egroup \egroup
krauss@23004
    97
  \egroup}
krauss@23004
    98
krauss@23004
    99
\def \mathhvbox@ #1{\setbox0 \hbox {\let \\\qquad $#1$}\ifnum \wd0 < \hsize
krauss@23004
   100
      \box0\else \mathvbox {#1}\fi}
krauss@23004
   101
krauss@23004
   102
krauss@23004
   103
%% Part II -- operations on lists
krauss@23004
   104
krauss@23004
   105
\newtoks \mpr@lista
krauss@23004
   106
\newtoks \mpr@listb
krauss@23004
   107
krauss@23004
   108
\long \def\mpr@cons #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter
krauss@23004
   109
{#2}\edef #2{\the \mpr@lista \the \mpr@listb}}
krauss@23004
   110
krauss@23004
   111
\long \def\mpr@snoc #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter
krauss@23004
   112
{#2}\edef #2{\the \mpr@listb\the\mpr@lista}}
krauss@23004
   113
krauss@23004
   114
\long \def \mpr@concat#1=#2\mpr@to#3{\mpr@lista \expandafter {#2}\mpr@listb
krauss@23004
   115
\expandafter {#3}\edef #1{\the \mpr@listb\the\mpr@lista}}
krauss@23004
   116
krauss@23004
   117
\def \mpr@head #1\mpr@to #2{\expandafter \mpr@head@ #1\mpr@head@ #1#2}
krauss@23004
   118
\long \def \mpr@head@ #1#2\mpr@head@ #3#4{\def #4{#1}\def#3{#2}}
krauss@23004
   119
krauss@23004
   120
\def \mpr@flatten #1\mpr@to #2{\expandafter \mpr@flatten@ #1\mpr@flatten@ #1#2}
krauss@23004
   121
\long \def \mpr@flatten@ \\#1\\#2\mpr@flatten@ #3#4{\def #4{#1}\def #3{\\#2}}
krauss@23004
   122
krauss@23004
   123
\def \mpr@makelist #1\mpr@to #2{\def \mpr@all {#1}%
krauss@23004
   124
   \mpr@lista {\\}\mpr@listb \expandafter {\mpr@all}\edef \mpr@all {\the
krauss@23004
   125
   \mpr@lista \the \mpr@listb \the \mpr@lista}\let #2\empty 
krauss@23004
   126
   \def \mpr@stripof ##1##2\mpr@stripend{\def \mpr@stripped{##2}}\loop
krauss@23004
   127
     \mpr@flatten \mpr@all \mpr@to \mpr@one
krauss@23004
   128
     \expandafter \mpr@snoc \mpr@one \mpr@to #2\expandafter \mpr@stripof
krauss@23004
   129
     \mpr@all \mpr@stripend  
krauss@23004
   130
     \ifx \mpr@stripped \empty \let \mpr@isempty 0\else \let \mpr@isempty 1\fi
krauss@23004
   131
     \ifx 1\mpr@isempty
krauss@23004
   132
   \repeat
krauss@23004
   133
}
krauss@23004
   134
krauss@23004
   135
\def \mpr@rev #1\mpr@to #2{\let \mpr@tmp \empty
krauss@23004
   136
   \def \\##1{\mpr@cons ##1\mpr@to \mpr@tmp}#1\let #2\mpr@tmp}
krauss@23004
   137
krauss@23004
   138
%% Part III -- Type inference rules
krauss@23004
   139
krauss@23004
   140
\newif \if@premisse
krauss@23004
   141
\newbox \mpr@hlist
krauss@23004
   142
\newbox \mpr@vlist
krauss@23004
   143
\newif \ifmpr@center \mpr@centertrue
krauss@23004
   144
\def \mpr@htovlist {%
krauss@23004
   145
   \setbox \mpr@hlist
krauss@23004
   146
      \hbox {\strut
krauss@23004
   147
             \ifmpr@center \hskip -0.5\wd\mpr@hlist\fi
krauss@23004
   148
             \unhbox \mpr@hlist}%
krauss@23004
   149
   \setbox \mpr@vlist
krauss@23004
   150
      \vbox {\if@premisse  \box \mpr@hlist \unvbox \mpr@vlist
krauss@23004
   151
             \else \unvbox \mpr@vlist \box \mpr@hlist
krauss@23004
   152
             \fi}%
krauss@23004
   153
}
krauss@23004
   154
% OLD version
krauss@23004
   155
% \def \mpr@htovlist {%
krauss@23004
   156
%    \setbox \mpr@hlist
krauss@23004
   157
%       \hbox {\strut \hskip -0.5\wd\mpr@hlist \unhbox \mpr@hlist}%
krauss@23004
   158
%    \setbox \mpr@vlist
krauss@23004
   159
%       \vbox {\if@premisse  \box \mpr@hlist \unvbox \mpr@vlist
krauss@23004
   160
%              \else \unvbox \mpr@vlist \box \mpr@hlist
krauss@23004
   161
%              \fi}%
krauss@23004
   162
% }
krauss@23004
   163
krauss@23004
   164
\def \mpr@item #1{$\displaystyle #1$}
krauss@23004
   165
\def \mpr@sep{2em}
krauss@23004
   166
\def \mpr@blank { }
krauss@23004
   167
\def \mpr@hovbox #1#2{\hbox
krauss@23004
   168
  \bgroup
krauss@23004
   169
  \ifx #1T\@premissetrue
krauss@23004
   170
  \else \ifx #1B\@premissefalse
krauss@23004
   171
  \else
krauss@23004
   172
     \PackageError{mathpartir}
krauss@23004
   173
       {Premisse orientation should either be T or B}
krauss@23004
   174
       {Fatal error in Package}%
krauss@23004
   175
  \fi \fi
krauss@23004
   176
  \def \@test {#2}\ifx \@test \mpr@blank\else
krauss@23004
   177
  \setbox \mpr@hlist \hbox {}%
krauss@23004
   178
  \setbox \mpr@vlist \vbox {}%
krauss@23004
   179
  \if@premisse \let \snoc \mpr@cons \else \let \snoc \mpr@snoc \fi
krauss@23004
   180
  \let \@hvlist \empty \let \@rev \empty
krauss@23004
   181
  \mpr@tmpdim 0em
krauss@23004
   182
  \expandafter \mpr@makelist #2\mpr@to \mpr@flat
krauss@23004
   183
  \if@premisse \mpr@rev \mpr@flat \mpr@to \@rev \else \let \@rev \mpr@flat \fi
krauss@23004
   184
  \def \\##1{%
krauss@23004
   185
     \def \@test {##1}\ifx \@test \empty
krauss@23004
   186
        \mpr@htovlist
krauss@23004
   187
        \mpr@tmpdim 0em %%% last bug fix not extensively checked
krauss@23004
   188
     \else
krauss@23004
   189
      \setbox0 \hbox{\mpr@item {##1}}\relax
krauss@23004
   190
      \advance \mpr@tmpdim by \wd0
krauss@23004
   191
      %\mpr@tmpdim 1.02\mpr@tmpdim
krauss@23004
   192
      \ifnum \mpr@tmpdim < \hsize
krauss@23004
   193
         \ifnum \wd\mpr@hlist > 0
krauss@23004
   194
           \if@premisse
krauss@23004
   195
             \setbox \mpr@hlist 
krauss@23004
   196
                \hbox {\unhbox0 \hskip \mpr@sep \unhbox \mpr@hlist}%
krauss@23004
   197
           \else
krauss@23004
   198
             \setbox \mpr@hlist
krauss@23004
   199
                \hbox {\unhbox \mpr@hlist  \hskip \mpr@sep \unhbox0}%
krauss@23004
   200
           \fi
krauss@23004
   201
         \else 
krauss@23004
   202
         \setbox \mpr@hlist \hbox {\unhbox0}%
krauss@23004
   203
         \fi
krauss@23004
   204
      \else
krauss@23004
   205
         \ifnum \wd \mpr@hlist > 0
krauss@23004
   206
            \mpr@htovlist 
krauss@23004
   207
            \mpr@tmpdim \wd0
krauss@23004
   208
         \fi
krauss@23004
   209
         \setbox \mpr@hlist \hbox {\unhbox0}%
krauss@23004
   210
      \fi
krauss@23004
   211
      \advance \mpr@tmpdim by \mpr@sep
krauss@23004
   212
   \fi
krauss@23004
   213
   }%
krauss@23004
   214
   \@rev
krauss@23004
   215
   \mpr@htovlist
krauss@23004
   216
   \ifmpr@center \hskip \wd\mpr@vlist\fi \box \mpr@vlist
krauss@23004
   217
   \fi
krauss@23004
   218
   \egroup
krauss@23004
   219
}
krauss@23004
   220
krauss@23004
   221
%%% INFERENCE RULES
krauss@23004
   222
krauss@23004
   223
\@ifundefined{@@over}{%
krauss@23004
   224
    \let\@@over\over % fallback if amsmath is not loaded
krauss@23004
   225
    \let\@@overwithdelims\overwithdelims
krauss@23004
   226
    \let\@@atop\atop \let\@@atopwithdelims\atopwithdelims
krauss@23004
   227
    \let\@@above\above \let\@@abovewithdelims\abovewithdelims
krauss@23004
   228
  }{}
krauss@23004
   229
krauss@23004
   230
%% The default
krauss@23004
   231
krauss@23004
   232
\def \mpr@@fraction #1#2{\hbox {\advance \hsize by -0.5em
krauss@23004
   233
    $\displaystyle {#1\mpr@over #2}$}}
krauss@23004
   234
\let \mpr@fraction \mpr@@fraction
krauss@23004
   235
krauss@23004
   236
%% A generic solution to arrow
krauss@23004
   237
krauss@23004
   238
\def \mpr@make@fraction #1#2#3#4#5{\hbox {%
krauss@23004
   239
     \def \mpr@tail{#1}%
krauss@23004
   240
     \def \mpr@body{#2}%
krauss@23004
   241
     \def \mpr@head{#3}%
krauss@23004
   242
     \setbox1=\hbox{$#4$}\setbox2=\hbox{$#5$}%
krauss@23004
   243
     \setbox3=\hbox{$\mkern -3mu\mpr@body\mkern -3mu$}%
krauss@23004
   244
     \setbox3=\hbox{$\mkern -3mu \mpr@body\mkern -3mu$}%
krauss@23004
   245
     \dimen0=\dp1\advance\dimen0 by \ht3\relax\dp1\dimen0\relax
krauss@23004
   246
     \dimen0=\ht2\advance\dimen0 by \dp3\relax\ht2\dimen0\relax
krauss@23004
   247
     \setbox0=\hbox {$\box1 \@@atop \box2$}%
krauss@23004
   248
     \dimen0=\wd0\box0
krauss@23004
   249
     \box0 \hskip -\dimen0\relax
krauss@23004
   250
     \hbox to \dimen0 {$%
krauss@23004
   251
       \mathrel{\mpr@tail}\joinrel
krauss@23004
   252
       \xleaders\hbox{\copy3}\hfil\joinrel\mathrel{\mpr@head}%
krauss@23004
   253
     $}}}
krauss@23004
   254
krauss@23004
   255
%% Old stuff should be removed in next version
krauss@23004
   256
\def \mpr@@reduce #1#2{\hbox
krauss@23004
   257
    {$\lower 0.01pt \mpr@@fraction {#1}{#2}\mkern -15mu\rightarrow$}}
krauss@23004
   258
\def \mpr@@rewrite #1#2#3{\hbox
krauss@23004
   259
    {$\lower 0.01pt \mpr@@fraction {#2}{#3}\mkern -8mu#1$}}
krauss@23004
   260
\def \mpr@infercenter #1{\vcenter {\mpr@hovbox{T}{#1}}}
krauss@23004
   261
krauss@23004
   262
\def \mpr@empty {}
krauss@23004
   263
\def \mpr@inferrule
krauss@23004
   264
  {\bgroup
krauss@23004
   265
     \ifnum \linewidth<\hsize \hsize \linewidth\fi
krauss@23004
   266
     \mpr@rulelineskip
krauss@23004
   267
     \let \and \qquad
krauss@23004
   268
     \let \hva \mpr@hva
krauss@23004
   269
     \let \@rulename \mpr@empty
krauss@23004
   270
     \let \@rule@options \mpr@empty
krauss@23004
   271
     \let \mpr@over \@@over
krauss@23004
   272
     \mpr@inferrule@}
krauss@23004
   273
\newcommand {\mpr@inferrule@}[3][]
krauss@23004
   274
  {\everymath={\displaystyle}%       
krauss@23004
   275
   \def \@test {#2}\ifx \empty \@test
krauss@23004
   276
      \setbox0 \hbox {$\vcenter {\mpr@hovbox{B}{#3}}$}%
krauss@23004
   277
   \else 
krauss@23004
   278
   \def \@test {#3}\ifx \empty \@test
krauss@23004
   279
      \setbox0 \hbox {$\vcenter {\mpr@hovbox{T}{#2}}$}%
krauss@23004
   280
   \else
krauss@23004
   281
   \setbox0 \mpr@fraction {\mpr@hovbox{T}{#2}}{\mpr@hovbox{B}{#3}}%
krauss@23004
   282
   \fi \fi
krauss@23004
   283
   \def \@test {#1}\ifx \@test\empty \box0
krauss@23004
   284
   \else \vbox 
krauss@23004
   285
%%% Suggestion de Francois pour les etiquettes longues
krauss@23004
   286
%%%   {\hbox to \wd0 {\RefTirName {#1}\hfil}\box0}\fi
krauss@23004
   287
      {\hbox {\RefTirName {#1}}\box0}\fi
krauss@23004
   288
   \egroup}
krauss@23004
   289
krauss@23004
   290
\def \mpr@vdotfil #1{\vbox to #1{\leaders \hbox{$\cdot$} \vfil}}
krauss@23004
   291
krauss@23004
   292
% They are two forms
krauss@23004
   293
% \inferrule [label]{[premisses}{conclusions}
krauss@23004
   294
% or
krauss@23004
   295
% \inferrule* [options]{[premisses}{conclusions}
krauss@23004
   296
%
krauss@23004
   297
% Premisses and conclusions are lists of elements separated by \\
krauss@23004
   298
% Each \\ produces a break, attempting horizontal breaks if possible, 
krauss@23004
   299
% and  vertical breaks if needed. 
krauss@23004
   300
% 
krauss@23004
   301
% An empty element obtained by \\\\ produces a vertical break in all cases. 
krauss@23004
   302
%
krauss@23004
   303
% The former rule is aligned on the fraction bar. 
krauss@23004
   304
% The optional label appears on top of the rule
krauss@23004
   305
% The second form to be used in a derivation tree is aligned on the last
krauss@23004
   306
% line of its conclusion
krauss@23004
   307
% 
krauss@23004
   308
% The second form can be parameterized, using the key=val interface. The
krauss@23004
   309
% folloiwng keys are recognized:
krauss@23004
   310
%       
krauss@23004
   311
%  width                set the width of the rule to val
krauss@23004
   312
%  narrower             set the width of the rule to val\hsize
krauss@23004
   313
%  before               execute val at the beginning/left
krauss@23004
   314
%  lab                  put a label [Val] on top of the rule
krauss@23004
   315
%  lskip                add negative skip on the right
krauss@23004
   316
%  left                 put a left label [Val]
krauss@23004
   317
%  Left                 put a left label [Val],  ignoring its width 
krauss@23004
   318
%  right                put a right label [Val]
krauss@23004
   319
%  Right                put a right label [Val], ignoring its width
krauss@23004
   320
%  leftskip             skip negative space on the left-hand side
krauss@23004
   321
%  rightskip            skip negative space on the right-hand side
krauss@23004
   322
%  vdots                lift the rule by val and fill vertical space with dots
krauss@23004
   323
%  after                execute val at the end/right
krauss@23004
   324
%  
krauss@23004
   325
%  Note that most options must come in this order to avoid strange
krauss@23004
   326
%  typesetting (in particular  leftskip must preceed left and Left and
krauss@23004
   327
%  rightskip must follow Right or right; vdots must come last 
krauss@23004
   328
%  or be only followed by rightskip. 
krauss@23004
   329
%  
krauss@23004
   330
krauss@23004
   331
%% Keys that make sence in all kinds of rules
krauss@23004
   332
\def \mprset #1{\setkeys{mprset}{#1}}
krauss@23004
   333
\define@key {mprset}{flushleft}[]{\mpr@centerfalse}
krauss@23004
   334
\define@key {mprset}{center}[]{\mpr@centertrue}
krauss@23004
   335
\define@key {mprset}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite}
krauss@23004
   336
\define@key {mprset}{myfraction}[]{\let \mpr@fraction #1}
krauss@23004
   337
\define@key {mprset}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}}
krauss@23004
   338
krauss@23004
   339
\newbox \mpr@right
krauss@23004
   340
\define@key {mpr}{flushleft}[]{\mpr@centerfalse}
krauss@23004
   341
\define@key {mpr}{center}[]{\mpr@centertrue}
krauss@23004
   342
\define@key {mpr}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite}
krauss@23004
   343
\define@key {mpr}{myfraction}[]{\let \mpr@fraction #1}
krauss@23004
   344
\define@key {mpr}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}}
krauss@23004
   345
\define@key {mpr}{left}{\setbox0 \hbox {$\TirName {#1}\;$}\relax
krauss@23004
   346
     \advance \hsize by -\wd0\box0}
krauss@23004
   347
\define@key {mpr}{width}{\hsize #1}
krauss@23004
   348
\define@key {mpr}{sep}{\def\mpr@sep{#1}}
krauss@23004
   349
\define@key {mpr}{before}{#1}
krauss@23004
   350
\define@key {mpr}{lab}{\let \RefTirName \TirName \def \mpr@rulename {#1}}
krauss@23004
   351
\define@key {mpr}{Lab}{\let \RefTirName \TirName \def \mpr@rulename {#1}}
krauss@23004
   352
\define@key {mpr}{narrower}{\hsize #1\hsize}
krauss@23004
   353
\define@key {mpr}{leftskip}{\hskip -#1}
krauss@23004
   354
\define@key {mpr}{reduce}[]{\let \mpr@fraction \mpr@@reduce}
krauss@23004
   355
\define@key {mpr}{rightskip}
krauss@23004
   356
  {\setbox \mpr@right \hbox {\unhbox \mpr@right \hskip -#1}}
krauss@23004
   357
\define@key {mpr}{LEFT}{\setbox0 \hbox {$#1$}\relax
krauss@23004
   358
     \advance \hsize by -\wd0\box0}
krauss@23004
   359
\define@key {mpr}{left}{\setbox0 \hbox {$\TirName {#1}\;$}\relax
krauss@23004
   360
     \advance \hsize by -\wd0\box0}
krauss@23004
   361
\define@key {mpr}{Left}{\llap{$\TirName {#1}\;$}}
krauss@23004
   362
\define@key {mpr}{right}
krauss@23004
   363
  {\setbox0 \hbox {$\;\TirName {#1}$}\relax \advance \hsize by -\wd0
krauss@23004
   364
   \setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}}
krauss@23004
   365
\define@key {mpr}{RIGHT}
krauss@23004
   366
  {\setbox0 \hbox {$#1$}\relax \advance \hsize by -\wd0
krauss@23004
   367
   \setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}}
krauss@23004
   368
\define@key {mpr}{Right}
krauss@23004
   369
  {\setbox \mpr@right \hbox {\unhbox \mpr@right \rlap {$\;\TirName {#1}$}}}
krauss@23004
   370
\define@key {mpr}{vdots}{\def \mpr@vdots {\@@atop \mpr@vdotfil{#1}}}
krauss@23004
   371
\define@key {mpr}{after}{\edef \mpr@after {\mpr@after #1}}
krauss@23004
   372
krauss@23004
   373
\newdimen \rule@dimen
krauss@23004
   374
\newcommand \mpr@inferstar@ [3][]{\setbox0
krauss@23004
   375
  \hbox {\let \mpr@rulename \mpr@empty \let \mpr@vdots \relax
krauss@23004
   376
         \setbox \mpr@right \hbox{}%
krauss@23004
   377
         $\setkeys{mpr}{#1}%
krauss@23004
   378
          \ifx \mpr@rulename \mpr@empty \mpr@inferrule {#2}{#3}\else
krauss@23004
   379
          \mpr@inferrule [{\mpr@rulename}]{#2}{#3}\fi
krauss@23004
   380
          \box \mpr@right \mpr@vdots$}
krauss@23004
   381
  \setbox1 \hbox {\strut}
krauss@23004
   382
  \rule@dimen \dp0 \advance \rule@dimen by -\dp1
krauss@23004
   383
  \raise \rule@dimen \box0}
krauss@23004
   384
krauss@23004
   385
\def \mpr@infer {\@ifnextchar *{\mpr@inferstar}{\mpr@inferrule}}
krauss@23004
   386
\newcommand \mpr@err@skipargs[3][]{}
krauss@23004
   387
\def \mpr@inferstar*{\ifmmode 
krauss@23004
   388
    \let \@do \mpr@inferstar@
krauss@23004
   389
  \else 
krauss@23004
   390
    \let \@do \mpr@err@skipargs
krauss@23004
   391
    \PackageError {mathpartir}
krauss@23004
   392
      {\string\inferrule* can only be used in math mode}{}%
krauss@23004
   393
  \fi \@do}
krauss@23004
   394
krauss@23004
   395
krauss@23004
   396
%%% Exports
krauss@23004
   397
krauss@23004
   398
% Envirnonment mathpar
krauss@23004
   399
krauss@23004
   400
\let \inferrule \mpr@infer
krauss@23004
   401
krauss@23004
   402
% make a short name \infer is not already defined
krauss@23004
   403
\@ifundefined {infer}{\let \infer \mpr@infer}{}
krauss@23004
   404
krauss@23004
   405
\def \TirNameStyle #1{\small \textsc{#1}}
krauss@23004
   406
\def \tir@name #1{\hbox {\small \TirNameStyle{#1}}}
krauss@23004
   407
\let \TirName \tir@name
krauss@23004
   408
\let \DefTirName \TirName
krauss@23004
   409
\let \RefTirName \TirName
krauss@23004
   410
krauss@23004
   411
%%% Other Exports
krauss@23004
   412
krauss@23004
   413
% \let \listcons \mpr@cons
krauss@23004
   414
% \let \listsnoc \mpr@snoc
krauss@23004
   415
% \let \listhead \mpr@head
krauss@23004
   416
% \let \listmake \mpr@makelist
krauss@23004
   417
krauss@23004
   418
krauss@23004
   419
krauss@23004
   420
krauss@23004
   421
\endinput