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