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