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