"Fossies" - the Fresh Open Source Software Archive

Member "hevea-2.35/html/mathpartir.hva" (16 Jan 2021, 7171 Bytes) of package /linux/www/hevea-2.35.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 %  Mathpartir --- Math Paragraph for Typesetting Inference Rules
    2 %
    3 %  Copyright (C) 2001--2005 Didier Rémy
    4 %  Hevea version by Luc Maranget
    5 %
    6 %  Author         : Didier Remy 
    7 %  Version        : 1.2
    8 %  Bug Reports    : to author
    9 %  Web Site       : http://pauillac.inria.fr/~remy/latex/
   10 % 
   11 %  WhizzyTeX is free software; you can redistribute it and/or modify
   12 %  it under the terms of the GNU General Public License as published by
   13 %  the Free Software Foundation; either version 2, or (at your option)
   14 %  any later version.
   15 %  
   16 %  Mathpartir is distributed in the hope that it will be useful,
   17 %  but WITHOUT ANY WARRANTY; without even the implied warranty of
   18 %  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19 %  GNU General Public License for more details 
   20 %  (http://pauillac.inria.fr/~remy/license/GPL).
   21 %
   22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   23 %  File mathpartir.hva (LaTeX macros)
   24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   25 
   26 
   27 % See the interface of mathpartir.sty
   28 % However, by default \\ does a vertical break in mathpar and a horizontal cut
   29 % in mathrule
   30 % 
   31 % Preceeding \\ by \hva \\ does a horizontal break in mathpar and a vertical
   32 % break in mathrule.
   33 %
   34 % \hva is ignored in latex more.
   35 
   36 \usepackage {keyval}
   37 \let\latexcr\\
   38 %%% Styles for mathpar
   39 \newcommand{\mp@row@style}
   40   {border-collapse:separate;border-spacing:2ex;width:100\%;margin:0ex;}
   41 \newstyle{.mprow}{\mp@row@style}
   42 \newstyle{.vmprow}{\mp@row@style empty-cells:show; border:solid \@magenta{} 2px}
   43 \newcommand{\mp@cell@style}{padding:0px;width:auto;}
   44 \newstyle{.mprcell}{\mp@cell@style}
   45 \newstyle{.vmprcell}{\mp@cell@style border:dotted \@magenta{} 2px;}
   46 \setenvclass{mathpar}{mathpar}
   47 \ifverbd
   48 \setenvclass{mprow}{vmprow}
   49 \setenvclass{mprcell}{vmprcell}
   50 \else
   51 \setenvclass{mprow}{mprow}
   52 \setenvclass{mprcell}{mprcell}
   53 \fi
   54 %% Open/close table elements
   55 \def\open@mathpar@table{\@open{table}{\envclass@attr{mprow}}}
   56 \def\open@mprow{\@open{tr}{style="vertical-align:middle"}}
   57 \def\close@mprow{\@close{tr}}
   58 \def\open@mpcell{\@open{td}{\@addstyle{text-align:center}{\envclass@attr[ ]{mprcell}}}\displaymath}
   59 \def\close@mpcell{\enddisplaymath\@close{td}}
   60 \def\force@mpcell{\enddisplaymath\@force{td}}
   61 \def\open@mpfstcell{\open@mpcell}
   62 \def\close@mplstcell{\force@mpcell}
   63 \def\mathpar@hspace{\push@styles\close@mpcell\open@mpcell\pop@styles\@skip@blanks}
   64 \def\mathpar@vspace
   65 {\push@styles\close@mplstcell\close@mprow\@close{table}%
   66 \open@mathpar@table\open@mprow\open@mpfstcell\pop@styles\@skip@blanks}%
   67 \def\mathpar@hva#1{\ifx#1\and\mathpar@vspace\else\mathpar@hspace\fi}%
   68 %%exported mathpar
   69 \newenvironment{mathpar}[1][]
   70   {\@open{div}{\envclass@attr{mathpar}}
   71   \let\and\mathpar@hspace\let\par\mathpar@vspace\let\\\mathpar@vspace\let\hva\mathpar@hva%
   72   \open@mathpar@table\open@mprow\open@mpfstcell}
   73   {\close@mplstcell\close@mprow\@close{table}\@close{div}}
   74 %%%% Type Inference Rules (TIR)
   75 \newsavebox{\mpr@save@arg}%
   76 \newcommand{\mpr@globle}[1]{}
   77 \newcommand {\@mpr@name}[1]{\@tir@name{#1}\let\mpr@name\mpr@globle}
   78 \def \mpr@line@hva #1{\mpr@break@display}
   79 \def \mpr@break@display
   80 {\sbox{\mpr@save@arg}{\mpr@line@arg}%
   81 \endmpr@line\mpr@line{\usebox{\mpr@save@arg}}}
   82 %%% this may not be robust (if nextchar is special char)
   83 %%% also may not want this semantics
   84 \def \@latexcr #1{%
   85 \def \@test {#1}\ifx \@test \@latexcr@char \latexcr \else
   86 \qquad #1\fi}
   87 \newcommand{\mpr@valign}[1]
   88 {\ifthenelse{\equal{#1}{}}{}{style="vertical-align:#1"}}
   89 \newcommand{\mpr@line}[1]
   90 {\@open{tr}{\mpr@valign{#1}}%
   91 \ifx\mpr@label\mpr@L\@open{td}{}\mpr@name{\@rule@name}~\@force{td}\fi
   92 \@open{td}{style="whitespace:nowrap;text-align:\ifmpr@center{}center\else{}left\fi"}%
   93 \bgroup\def\mpr@line@arg{#1}%
   94 \@open{display}{\mpr@valign{#1}}%
   95 \def\\{\@latexcr{\qquad}}\def\and{\@latexcr{\qquad}}%
   96 \let\hva\mpr@line@hva}
   97 \newcommand{\endmpr@line}
   98 {\@close{display}\egroup\@force{td}%
   99 \ifx\mpr@label\mpr@R\@open{td}{}~\mpr@name{\@rule@name}\@force{td}\fi
  100 \@close{tr}}
  101 \def \mpr@empty {}
  102 \newif \ifmpr@center \mpr@centertrue
  103 \newif \ifmpr@vdots \mpr@vdotsfalse
  104 \newcounter{mpr@count}
  105 \newcommand{\mpr@output@vdots}
  106 {\vdots%
  107 \setcounter{mpr@count}{\@lengthtonchar{\mpr@vdots}}%
  108 \whiledo{\value{mpr@count}>1}{\@br\vdots\addtocounter{mpr@count}{-1}}}
  109 \def\mpr@emptyL{\ifx\mpr@label\mpr@L\@open{td}{}\@force{td}\fi}
  110 \def\mpr@emptyR{\ifx\mpr@label\mpr@R\@open{td}{}\@force{td}\fi}
  111 \newcommand{\@mpr@table}{\@open{table}{style="border:0;border-spacing:1px;border-collapse:separate" class="cellpadding0"}}
  112 \newcommand {\@inferrule}[2]
  113    {\bgroup
  114     \let \\ \latexcr%
  115     \@mpr@table%
  116     \ifx\mpr@label\mpr@C
  117       \@open{tr}{}\@open{td}{style="text-align:left"}%
  118       \mpr@name{\@rule@name}%
  119       \@close{td}\@close{tr}%
  120     \fi
  121     \def \@@arg{#1}\ifx \@@arg \mpr@empty%
  122       \mpr@line{}#2\endmpr@line%
  123     \else
  124       \def \@@arg{#2}\ifx \@@arg \mpr@empty%
  125       \mpr@line{}#1\endmpr@line%
  126     \else
  127       \mpr@line{bottom}#1\endmpr@line%
  128       \@hhline%
  129       \mpr@line{top}#2\endmpr@line%
  130     \fi\fi%
  131     \ifmpr@vdots%
  132       \@open{tr}{style="vertical-align:middle"}%
  133       \mpr@emptyL
  134       \@open{td}{style="text-align:center"}\mpr@output@vdots\@force{td}%
  135       \mpr@emptyR
  136       \@close{tr}%
  137     \fi
  138     \@force{table}%
  139     \egroup%
  140 }
  141 \def\mpr@hhline@color{green}
  142 \def \@hhline
  143 {\@open{tr}{}%
  144 \mpr@emptyL
  145 \@open{td}{style="background-color:\mpr@hhline@color;height:3px"}\@force{td}%
  146 \mpr@emptyR
  147 \@force{tr}}
  148 
  149 \newcommand {\inferrule*}[3][]{%
  150    \bgroup\let\@tir@name\RefTirName%
  151    \mpr@vdotsfalse\let\mpr@label\mpr@N\let\mpr@name\@mpr@name%Default
  152    \@setkeys {mpr}{#1}%
  153    \@inferrule{#2}{#3}%
  154    \egroup}
  155 \newcommand {\inferrule}[3][]{%
  156    \def\mpr@arg{#1}\ifx\mpr@arg\mpr@empty
  157    \inferrule*{#2}{#3}\else
  158    \inferrule*[before={\let\@tir@name\TirName},lab=#1,center]{#2}{#3}\fi}
  159 
  160 \def \mprset {\setkeys{mprset}}
  161 \define@key {mprset}{flushleft}[]{\mpr@centerfalse}
  162 \define@key {mprset}{center}[]{\mpr@centertrue}
  163 \define@key {mpr}{flushleft}[]{\mpr@centerfalse}
  164 \define@key {mpr}{center}[]{\mpr@centertrue}
  165 \define@key {mpr}{width}{}
  166 \define@key {mpr}{before}{#1}
  167 \define@key {mpr}{narrower}{}
  168 \define@key {mpr}{leftskip}{}
  169 \define@key {mpr}{rightskip}{}
  170 \def\mpr@N{N}\def\mpr@C{C}\def\mpr@R{R}\def\mpr@L{L}\let\mpr@label\mpr@N
  171 \def\mpr@set@name#1{\def \@rule@name {\mpr@name{#1}}}
  172 \define@key {mpr}{lab}{\let\mpr@label\mpr@C\mpr@set@name{#1}}
  173 \define@key {mpr}{Lab}{\let\mpr@label\mpr@C\mpr@set@name{#1}}
  174 \define@key {mpr}{left}{\let\mpr@label\mpr@L\mpr@set@name{#1}}
  175 \define@key {mpr}{Left}{\let\mpr@label\mpr@L\mpr@set@name{#1}}
  176 \define@key {mpr}{Right}{\let\mpr@label\mpr@R\mpr@set@name{#1}}
  177 \define@key {mpr}{right}{\let\mpr@label\mpr@R\mpr@set@name{#1}}
  178 \define@key {mpr}{vdots}{\mpr@vdotstrue\def\mpr@vdots{#1}}
  179 \define@key {mpr}{after}{}
  180 \define@key {mpr}{fraction}{\hva@warn{fraction key ignored (mathpartir)}}
  181 \define@key {mpr}{myfraction}{\hva@warn{myfraction key ignored (mathpartir)}}
  182 %%%%Synonyms
  183 \@ifundefined{infer}{\let\infer\inferrule}{}
  184 \@ifundefined{infer*}{\let\infer*\inferrule*}{}
  185 %%%Label formatting
  186 \newcommand {\tir@name}[1]{\textsc{\scriptsize {#1}}}
  187 \let\RefTirName\tir@name
  188 \let\TirName\tir@name
  189 \endinput