Debian Codegraph @

texmf-dist/source/latex/mathpartir/mathpartir.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2015 by Didier Remy <didier.remy(at)inria(dot)fr>
4 %
5 % The file is part of mathpartir
6 %
7 % mathpartir is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 2 of the License, or
10 % (at your option) any later version.
11 %
12 % mathpartir is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License for more details.
16 %
17 % You should have received a copy of the GNU General Public License
18 % along with mathpartir. If not, see <http://www.gnu.org/licenses/>.
19 %
20 % \fi
21 %
22 % \iffalse
23 %<*driver>
24 \ProvidesFile{mathpartir.dtx}
25 %</driver>
26 %<package>\NeedsTeXFormat{LaTeX2e}
27 %<package>\ProvidesPackage{mathpartir}
28 %<*package>
29 [2016/02/24 version 1.3.2 Math Paragraph for Typesetting Inference Rules]
30 %</package>
31 %
32 %<hevea>\documentclass {article}
33 %<*driver>
34 \documentclass{ltxdoc}
35 %</driver>
36 %<*(driver|hevea)>
37 \usepackage {mathpartir}
38 \usepackage {listings}
39 \usepackage {array}
40 \usepackage {url}
41 %<hevea>\usepackage {hevea}
42
43 \lstset {basicstyle=\tt}
44 \let \lst \verb
45
46 \title {
47 %<hevea>\begin{tabular}{>{\huge}c}
48 \textbf{MATH} formulas in \\
49 \textbf{PAR}ragraph mode\\[-1ex]
50 %<*!hevea>
51 \hskip 0em\hbox to 12em {\hrulefill}\\
52 %</!hevea>
53 %<hevea>\hline
54 \textbf Typesetting \textbf Inference \textbf Rules \\
55 %<hevea>\end{tabular}
56 }
57 \author {Didier R{\'{e}}my}
58 \date {(Version 1.3.2, last modified 24/02/2016)}
59
60 \begin{document}
61
62 \maketitle
63
64 %<*!hevea>
65 \DeleteShortVerb{\|}
66 \section{Introduction}
67 %</!hevea>
68 %<hevea>\begin{abstract}
69 The package mathpartir provides macros for
70 displaying formulas and lists of formulas that are typeset in mixed
71 horizontal and vertical modes.
72
73 The environment \verb"mathpar" generalizes the math display mode to allow
74 several formulas on the same line, and several lines in the same
75 display. The arrangement of the sequence of formulas into lines is automatic
76 depending on the line width and on a minimum inter-formula space alike words
77 are displayed in a paragraphs (in centerline mode). A typical application
78 is displaying a set of type inference rules.
79
80 The macro \verb"inferrule" typesets inference rules. Both premises and
81 conclusions are presented as lists of formulas and are typeset in paragraph
82 mode and wrapped into multiple lines whenever necessary.
83 %<hevea> \end{abstract}
84
85 %<hevea>\section {License}
86 %<hevea>
87 %<hevea>Mathpartir is Copyright (C) 2001-2005, 2015, 2016 INRIA. Mathpartir
88 %<hevea>has been developed by Didier R{\'{e}}my. Mathpartir is free software; you
89 %<hevea>can redistribute it and/or modify it under the terms of the GNU General
90 %<hevea>Public License as published by the Free Software Foundation; either version
91 %<hevea>2, or (at your option) any later version. See the GNU General Public
92 %<hevea>License for more details (\url{http://pauillac.inria.fr/~remy/license/GPL}).
93 %<hevea>Mathpartir is distributed in the hope that it will be useful, but without
94 %<hevea>any warranty.
95
96 \section {The mathpar environment}
97
98 The mathpar environment is a ``paragraph mode for formulas''.
99 It allows to typeset long list of formulas putting as
100 many as possible on the same line:
101 $$
102 \begin{tabular}{m{0.45\hsize}m{0.45\hsize}}
103 \begin{lstlisting}{Ocaml}
104 \begin{mathpar}
105 A-Formula \and
106 Longer-Formula \and
107 And \and The-Last-One
108 \end{mathpar}
109 \end{lstlisting}
110 &
111 \begin{mathpar}
112 A-Formula
113 \and
114 Longer-Formula
115 \and
116 And
117 \and
118 The-Last-One
119 \end{mathpar}
120 \end{tabular}
121 $$
122 Formulas are separated by \verb"\and" (or equivalently by a blank line).
123 To enforce a vertical break it suffices to replace \verb"\and" by
124 \verb"\\".
125
126 The implementation of \verb"mathpar" entirely relies on the paragraph mode
127 for text. It starts a new paragraph, and a math formula within a paragraph,
128 after adjusting the spacing and penalties for breaks. Then, it simply binds
129 \verb"\and" to something like \verb"\goodbreak".
130
131 \section {The inferrule macro}
132
133 The inferrule macro is designed to typeset inference rules. It should
134 only\footnote {Even though the basic version may work in text mode,
135 we discourage its use in text mode; the star-version cannot be used in
136 text-mode} be used in math mode (or display math mode).
137
138 The basic use of the rule is
139 \begin{verbatim}
140 \inferrule
141 {one \\ two \\ three \\ or \\ more \\ premisses}
142 {and \\ any \\ number \\ of \\ conclusions \\ as \\ well}
143 \end{verbatim}
144 This is the rendering on a large page
145 \def \one {\inferrule
146 {one \\ two \\ three \\ or \\ more \\ premises}
147 {and \\ any \\ number \\ of \\ conclusions \\ as \\ well}
148 }
149 $$
150 %<hevea>\one
151 %<*!hevea>
152 \fbox {\vbox {\advance \hsize by -2\fboxsep \advance \hsize by -2\fboxrule
153 \linewidth\hsize
154 $$\one$$}}
155 %</!hevea>
156 $$
157 However, the same formula on a narrower page will automatically be typeset
158 like that:
159 $$
160 %<hevea>\one
161 %<*!hevea>
162 \fbox {\hsize 0.33 \hsize \vbox {$$\one$$}}
163 %</!hevea>
164 $$
165 An inference rule is mainly composed of a premise and a conclusion.
166 The premise and the conclusions are both list of formulas where the
167 elements are separated by \verb"\\".
168
169 Note the asymmetry between typesetting of the premises and of
170 conclusions where lines closer to the center are fit first.
171
172 A newline can be forced by adding an empty line \verb"\\\\"
173
174 \begin{tabular}{m{0.44\hsize}m{0.44\hsize}}
175 \begin{lstlisting}{Ocaml}
176 \inferrule
177 {aa \\\\ bb}
178 {dd \\ ee \\ ff}
179 \end{lstlisting}
180 &
181 $\inferrule {aa \\\\bb}{dd \\ ee \\ ff}$
182 \\
183 \end{tabular}
184
185 \subsection {Single rules}
186
187 Single rules are the default mode.
188 Rules are aligned on their fraction bar, as illustrated below:
189 $$
190 \inferrule {aa \\ bb}{ee} \hspace {4em} \inferrule {aa \\\\ bb \\ ee}{ee}
191 $$
192 If the premise or the conclusion is empty, then the fraction bar is not
193 typeset and the premise or the conclusion is centered:
194 $$
195 \begin{tabular}{m{0.45\hsize}m{0.45\hsize}}
196 \begin{lstlisting}{Ocaml}
197 \inferrule {}{aa} +
198 \inferrule {aa \\\\ aa}{}
199 \end{lstlisting}
200 &
201 $
202 \inferrule {}{aa} +
203 \inferrule {aa \\\\ aa}{}
204 $
205 \\
206 \end{tabular}
207 $$
208 Use use \verb"{ }" instead of \verb"{}" to get an axiom for instance:
209 $$
210 \begin{tabular}{m{0.45\hsize}m{0.45\hsize}}
211 \begin{lstlisting}{Ocaml}
212 \inferrule { }{aa} +
213 \inferrule {aa}{ }
214 \end{lstlisting}
215 &
216 \mbox {$
217 \inferrule { }{aa} +
218 \inferrule {aa}{ }
219 $}
220 \\
221 \end{tabular}
222 $$
223
224 The macro \lst"\inferrule" accepts a label as optional argument, which will
225 be typeset on the top left corner of the rule:
226 \par
227 \begin{tabular}{m{0.45\hsize}m{0.45\hsize}}
228 \begin{lstlisting}{Ocaml}
229 \inferrule [yop]
230 {aa \\ bb}
231 {cc}
232 \end{lstlisting}
233 &
234 $\inferrule [Yop]{aa \\ bb}{cc}$
235 \\
236 \end{tabular}
237 \par\noindent
238 See section~\ref {options} for changing typesetting of labels.
239 A label can also be placed next to the rule directly, since the rule is
240 centered:
241 \par
242 \begin{tabular}{m{0.45\hsize}m{0.45\hsize}}
243 \begin{lstlisting}{Ocaml}
244 \inferrule
245 {aa \\ bb}
246 {cc}
247 \quad (\textsc {Yop})
248 \end{lstlisting}
249 &
250 $\inferrule{aa \\ bb}{cc} \quad (\textsc {Yop})$
251 \\
252 \end{tabular}
253
254 \subsection {Customizing presentation}
255
256 By default, lines are centered in inference rules.
257 However, this can be changed by either \lst"\mprset{flushleft}"
258 or \lst"\mprset{center}". For instance,
259
260 \begin{tabular}{m{0.44\hsize}m{0.44\hsize}}
261 \begin{lstlisting}{Ocaml}
262 $$\mprset{flushleft}
263 \inferrule
264 {a \\ bbb \\\\ ccc \\ dd}
265 {dd \\ ee \\ ff}$$
266 \end{lstlisting}
267 &
268 $$\mprset{flushleft}
269 \hsize 0.45\hsize
270 \inferrule {a \\ bb \\ ccc \\ dddd}{e \\ ff \\ gg}$$
271 \\
272 \end{tabular}
273
274 \noindent
275 Note that lines are aligned independently in the premise and the
276 conclusion, which are both themselves centered. In particular,
277 left alignment will not affect a single-line premise or conclusion.
278
279 \subsection {Customizing rules}
280
281 One may wish to change use rules for rewriting rule or implications, etc.
282 There is a generic way of definition new rules by providing three parts:
283 a tail, a body, and a head. The rule will then be built by joining
284 all three components in this order and filling the body with leaders to
285 extend as much as necessary. Here are examples
286
287 \begin{tabular}{m{0.54\hsize}m{0.44\hsize}}
288 \begin{lstlisting}{Ocaml}
289 $$\mprset{fraction={===}}
290 \inferrule {a \\ bbb} {cc}$$
291 \end{lstlisting}
292 &
293 $$\mprset{fraction={===}}
294 \inferrule {a \\ bbb} {cc}$$
295
296 \\
297 \begin{lstlisting}{Ocaml}
298 $$\mprset
299 {fraction={\models=\Rightarrow}}
300 \inferrule {a \\ bbb} {cc}$$
301 \end{lstlisting}
302 &
303 $$\mprset
304 {fraction={\models=\Rightarrow}}
305 \inferrule {a \\ bbb} {cc}$$
306 \\
307 \end{tabular}
308 The height and depth of the \emph{body} are used to adjust vertical space.
309 One, may ``smash'' the body to reduce the vertical space
310
311 \begin{tabular}{m{0.54\hsize}m{0.44\hsize}}
312 \begin{lstlisting}{Ocaml}
313 $$\mprset
314 {fraction={%
315 {\scriptstyle\vdash}%
316 {\smash-}%
317 {\rightarrow\!\!}%
318 }}
319 \inferrule {a \\ bbb} {cc}\,\,$$
320 \end{lstlisting}
321 &
322 $$\mprset
323 {fraction={{\scriptstyle\vdash}{\smash-}{\rightarrow\!\!}}}
324 \inferrule {a \\ bbb} {cc}$$
325 \\
326 \begin{lstlisting}{Ocaml}
327 $$\mprset {fraction={\cdot\cdots\cdot}}
328 \inferrule {a \\ bbb} {cc}$$
329 \end{lstlisting}
330 &
331 $$\mprset {fraction={{}{\,\smash\cdot\,}{}}}
332 \inferrule {a \\ bbb} {cc}$$
333 \\
334 \end{tabular}
335 Since vertical skip does not take header and footer into account, which is
336 usually better but sometimes odd, this can be adjusted explicitly:
337
338 \begin{tabular}{m{0.54\hsize}m{0.44\hsize}}
339 \begin{lstlisting}{Ocaml}
340 $$\mprset
341 {fraction={|=/},
342 fractionaboveskip=0.6ex,
343 fractionbelowskip=0.4ex}
344 \inferrule
345 {a \\ bbb_{\downarrow}}
346 {cc^{\T\uparrow}}$$
347 \end{lstlisting}
348 &
349 $$\mprset
350 {fraction={|=/},
351 fractionaboveskip=0.6ex,
352 fractionbelowskip=0.4ex}
353 \inferrule
354 {a \\ bbb_{\downarrow}}
355 {cc^{\uparrow}}$$
356 \\
357 \end{tabular}
358 Finally, it is also possible to provide its own definition
359 of fraction by
360
361 \begin{tabular}{m{0.54\hsize}m{0.44\hsize}}
362 \begin{lstlisting}{Ocaml}
363 \def \Over #1#2{\hbox{$#1 \over #2$}}
364 $$\mprset{myfraction=\Over}
365 \inferrule {a \\ bbb} {cc}$$
366 \end{lstlisting}
367 &
368 \def \Over #1#2{\hbox{$#1 \over #2$}}
369 $$\mprset{myfraction=\Over}
370 \inferrule {a \\ bbb} {cc}$$
371 \\
372 \end{tabular}
373
374 \paragraph{Customizing the horizontal skip between premises}
375 (default value is 2em).
376 \begin{quote}
377 \begin{lstlisting}{Ocaml}
378 $$\mprset {sep=6em}
379 \inferrule {a \\ bbb} {cc}$$
380 \end{lstlisting}
381 $$\mprset {sep=6em}
382 \inferrule {a \\ bbb} {cc}$$
383 \end{quote}
384
385 \paragraph{Customizing the vertical space between premises}
386 (default value is empty). Notice that leaving it empty and setting vskip to
387 0em is not quite equivalent as show below between the third and fourth rules
388 (because the typesetting cannot use the primitive typesetting of
389 fractions).
390 \begin{quote}
391 \begin{lstlisting}{Ocaml}
392 $$\def\R{\inferrule {aa\\aa\\\\bbb\\bbb} {cc}
393 \hspace{3em}}
394 \R \mprset{vskip=0ex}\R \mprset{vskip=1ex}\R$$
395 \end{lstlisting}
396 $$\def \R{\inferrule {aa \\ aa \\\\ bbb \\ bbb} {cc}\hspace{3em}}
397 \R \mprset{vskip={}}
398 \R \mprset{vskip=0ex}\R \mprset{vskip=1ex}\R$$
399 \end{quote}
400
401
402
403 \subsection {Tabulars in inference rules}
404
405 Although you probably do not want to do that, you may still use tabular
406 or minipages inside inference rules, but between braces, as follows:
407 $$
408 \begin{tabular}{m{0.50\hsize}m{0.50\hsize}}
409 \begin{lstlisting}{Ocaml}
410 \infer [Tabular-Rule]
411 {some \\ math \\ and \\
412 {\begin{tabular}[b]{|l|r|}
413 \hline Ugly & and
414 \\[1ex]\hline
415 table & text
416 \\\hline
417 \end{tabular}} \\
418 {\begin{minipage}[b]{6em}
419 Do you really wish
420 to do that?
421 \end{minipage}} \\
422 }
423 {some \\ conclusions}
424 \end{lstlisting}
425 &
426 \infer [Tabular-Rule]
427 {some \\ math \\ and \\
428 {\begin{tabular}[b]{|l|r|}
429 \hline Ugly & and
430 \\[1ex]\hline
431 table & text
432 \\\hline
433 \end{tabular}} \\
434 {\begin{minipage}[b]{6em}
435 Do you really wish
436 to do that?
437 \end{minipage}} \\
438 }
439 {some \\ conclusions}
440 \\
441 \end{tabular}
442 $$
443
444
445 \subsection {Derivation trees}
446
447 To help writing cascades of rules forming a derivation tree, inference rules
448 can also be aligned on their bottom line. For this, we use the star-version:
449 $$
450 \begin{tabular}{m{0.65\hsize}m{0.45\hsize}}
451 \begin{lstlisting}{Ocaml}
452 \inferrule*
453 {\inferrule* {aa \\ bb}{cc}
454 \\ dd}
455 {ee}
456 \end{lstlisting}
457 &
458 $
459 \inferrule*
460 {\inferrule* {aa \\ bb}{cc}
461 \\ dd}
462 {ee}
463 $
464 \\
465 \end{tabular}
466 $$
467 The star version can also take an optional argument,
468 but with a different semantics. The optional argument is parsed by the
469 \verb"keyval" package, so as to offer a set of record-like options:
470 $$
471 \def \arraystretch {1.4}
472 \begin{tabular}{|>{\tt}c|>{$}c<{$}|p{0.6\hsize}|}
473 \hline
474 \bf key & \bf arg & \bf Effect
475 \\\hline
476 before & tex & Execute $tex$ before typesetting the rule.
477 Useful for instance to change the maximal width of the rule.
478 \\\hline
479 width & d & Set the width of the rule to $d$
480 \\\hline
481 narrower & d & Set the width of the rule to $d$ times \verb"\hsize".
482 \\\hline
483 lab & \ell & Put label $\ell$ on the top of the rule as with the
484 non-start version.
485 \\\hline
486 Lab & \ell & same as lab
487 \\\hline
488 left & \ell & Put label $\ell$ on the left of the rule
489 \\\hline
490 Left & \ell & Idem, but as if label $\ell$ had zero width.
491 \\\hline
492 Right & \ell & As \verb"Left", but on the right of the rule.
493 \\\hline
494 right & \ell & As \verb"left", but on the right of the rule.
495 \\\hline
496 leftskip & d & Cheat by (skip negative space) $d$ on the left side.
497 \\\hline
498 rightskip & d & Cheat by $d$ on the right side of the rule.
499 \\\hline
500 vdots & d & Raise the rule by $d$ and insert vertical dots.
501 \\\hline
502 \end{tabular}
503 $$
504
505 We remind at the end the global options that we've seen above that can
506 also be set locally in derivation trees:
507 \begin{mathpar}
508 \def \arraystretch {1.4}
509 \begin{tabular}{|>{\tt}c|>{$}c<{$}|p{0.6\hsize}|}
510 \hline
511 \\\hline\hline
512 sep & d & Set the separation between premises and conclusions to $s$.
513 \\\hline
514 flushleft & - & flush premises to the left hand side
515 \\\hline
516 center & - & center premises on each line.
517 \\\hline
518 rewrite & d &
519 \\\hline
520 myfraction & tex & set fraction to $tex$ command
521 \\\hline
522 fraction & lmr & set fraction pattern to $lm...mr$ with leaders.
523 \\\hline
524 vskip & d & Set the vertical skip between premises and conclusions to $h$.
525 \\\hline
526 vcenter && Make the rule centered around the fraction line as the non-star
527 version
528 \\\hline
529 \end{tabular}
530 \end{mathpar}
531
532 Here is an example of a complex derivation:
533 $$
534 \inferrule* [left=Total,rightstyle=\em,right={(when $n > 0$)}]
535 {\inferrule* [Left=Foo]
536 {\inferrule* [rightstyle={\bf},Right=Bar,vskip=1ex,
537 leftskip=2em,rightskip=2em,vdots=1.5em]
538 {a \\ a \\\\ bb \\ cc \\ dd}
539 {ee}
540 \\ ff \\ gg}
541 {hh}
542 \\
543 \inferrule* [lab=XX,sep=4em]{uu \\ vv}{ww}}
544 {(1)}
545 $$
546 and its code
547 \begin{lstlisting}{Ocaml}
548 \inferrule* [left=Total]
549 {\inferrule* [Left=Foo]
550 {\inferrule* [Right=Bar,rightstyle=\bf,
551 leftskip=2em,rightskip=2em,vdots=1.5em]
552 {a \\ a \\\\ bb \\ cc \\ dd}
553 {ee}
554 \\ ff \\ gg}
555 {hh}
556 \\
557 \inferrule* [lab=XX]{uu \\ vv}{ww}}
558 {(1)}
559 \end{lstlisting}
560
561 \def \L#1{\lower 0.4ex \hbox {#1}}
562 \def \R#1{\raise 0.4ex \hbox {#1}}
563 \def \hevea {H\L{E}\R{V}\L{E}A}
564 \def \hevea {$\mbox {H}\!_{\mbox {E}}\!\mbox {V}\!_{\mbox {E}}\!\mbox {A}$}
565
566 \subsection {Label styles}
567
568 \label {options}
569
570 The package uses
571 \verb"\DefTirNameStyle",
572 \verb"\LabTirNameStyle",
573 \verb"\LeftTirNameStyle",
574 and \verb"\RightTirNameStyle"
575 to typeset labels introduced with the default option,
576 \verb"Lab-",
577 \verb"Left-", or
578 \verb"Right-", respectively (or their uncapitablized variants).
579 This can safely be redefined by the user.
580 \verb"\DefTirName" is normally used for defining
581 occurrences ({\em i.e.} in rule \lst"\inferrule") while the three other forms
582 are used for referencing names ({\em i.e.} in the star-version). The styles
583 can also be redefined using labeled-arguments of the star-version of
584 {\tt\string\inferrule} as described in table below.
585
586 Instead of just changing the style, the whole
587 typesetting of labels may be changed by redefining
588 \verb"\DefTirName",
589 \verb"\LabTirName",
590 \verb"\LeftTirName",
591 and \verb"\RightTirName", each of which receives the label to be typeset as
592 argument.
593
594 Finally, the vertical skip
595
596 \begin{mathpar}
597 \def \arraystretch {1.4}
598 \begin{tabular}{|>{\tt}c|>{$}c<{$}|p{0.6\hsize}|}
599 \hline
600 \bf key & \bf arg & \bf Effect
601 \\\hline\hline
602 style & tex & set the default style for labels to $tex$
603 \\\hline
604 leftstyle & tex & idem for labels
605 \\\hline
606 rightstyle & tex& idem for right labels
607 \\\hline
608 \end{tabular}
609 \end{mathpar}
610
611 \subsection {Star \emph{v.s.} non-star version}
612
613 The package also defines \verb"\infer" as a shortcut for \verb"\inferrule"
614 but only if it is not previously defined.
615
616 There are two differences between the plain and star versions of
617 \verb"\inferrule".
618 The plain version centers the rule on the fraction line, while the
619 star one centers the rule on the last conclusion, so as to be used in
620 derivation trees.
621
622 Another difference is that the optional argument of the plain version is a
623 label to always be placed on top of the rule, while the $\ast$-version takes
624 a record of arguments. Hence, it can be parameterized in many more ways.
625
626 One may recover the plain version from the start version by passing the
627 extra argument \texttt{vcenter} as illustrated below (the base line is
628 aligned with the dotted line):
629 \begin{mathpar}
630 \cdots\cdots
631 \cdots\cdots
632 \inferrule*
633 {aa aa \\\\ aa \\ bb}{cc \\ cc \\\\ dd}
634 \cdots\cdots
635 \cdots\cdots
636 \inferrule* [vcenter]
637 {aa aa \\\\ aa \\ bb}{cc \\ cc \\\\ dd}
638 \cdots\cdots
639 \cdots\cdots
640 \end{mathpar}
641 This is convenient, for instance to typeset rules with side conditions
642 and keep them attached to the rule:
643 \begin{mathpar}
644 \def \RightTirName #1{\rm\hbox {\hskip 1ex (#1)}}
645 \inferrule*[lab=Pos,right={if $n>0$}]
646 {aa \\ aa}
647 {cc}
648
649 \inferrule*[lab=Neg,right={if $n<0$}]
650 {aa \\ aa}
651 {cc}
652 \end{mathpar}
653 Or differently,
654 \begin{mathpar}
655 \def \LabTirName #1{\hbox {(#1)}}
656 \def \LeftTirName #1{\textsc{#1}}
657 \inferrule*[Left=Pos,lab={if $n>0$}]
658 {aaa \\ aaa}
659 {cc}
660
661 \inferrule*[Left=Neg,lab={if $n<0$}]
662 {aaa \\ aaa}
663 {cc}
664 \end{mathpar}
665
666
667 \subsection {Implementation}
668
669 The main macro in the implementation of inference rules is the one that
670 either premises and conclusions. The macros uses two box-registers one
671 \verb"hbox" for typesetting each line and one \verb"vbox" for collecting
672 lines. The premise appears as a list with
673 \verb"\\" as separator. Each element is considered in turn typeset in a
674 \verb"hbox" in display math mode. Its width is compare to the space left on
675 the current line. If the box would not fit, the current horizontal line is
676 transferred to the vertical box and emptied. Then, the current formula can
677 safely be added to the horizontal line (if it does not fit, nothing can be
678 done). When moved to the vertical list, lines are aligned on their center
679 (as if their left-part was a left overlapped). At the end the vbox is
680 readjusted on the right.
681
682 This description works for conclusions. For premises, the elements must be
683 processes in reverse order and the vertical list is simply built upside
684 down.
685
686 \section {Other Options for the {\tt mathpar} environment}
687
688 The vertical space in \verb"mathpar" is adjusted by
689 \verb"\MathparLineskip". To restore the normal paragraph parameters in mathpar
690 mode (for instance for some inner paragraph), use the command
691 \verb"\MathparNormalpar".
692 The environment uses \verb"\MathparBindings" to
693 rebind \verb"\\", \verb"and", and \verb"\par". You can redefine thus command
694 to change the default bindings or add your own.
695
696
697 \section {Examples}
698
699 See the source of this documentation ---the file \lst"mathpartir.tex"---
700 for full examples.
701
702 \section {{\hevea} compatibility}
703
704 The package also redefines \verb"\hva" to do nothing in \lst"mathpar"
705 environment and in inference rules.
706
707 In HeVeA, \verb"\and" will always produce a vertical break in mathpar
708 environment; to obtain a horizontal break, use \verb"\hva \and" instead.
709 Conversely, \verb"\\" will always produce a horizontal break in type
710 inference rules; to obtain a vertical break, use \verb"\hva \\" instead.
711
712 For instance, by default the following code,
713 \begin{lstlisting}{Ocaml}
714 \begin{mathpar}
715 \inferrule* [Left=Foo]
716 {\inferrule* [Right=Bar,width=8em,
717 leftskip=2em,rightskip=2em,vdots=1.5em]
718 {a \\ a \\ bb \\ cc \\ dd}
719 {ee}
720 \\ ff \\ gg}
721 {hh}
722 \and
723 \inferrule* [lab=XX]{uu \\ vv}{ww}
724 \end{mathpar}
725 \end{lstlisting}
726 which typesets in {\TeX} as follows,
727 \begin{mathpar}
728 \inferrule* [Left=Foo]
729 {\inferrule* [Right=Bar,width=8em,
730 leftskip=2em,rightskip=2em,vdots=1.5em]
731 {a \\ a \\ bb \\ cc \\ dd}
732 {ee}
733 \\ ff \\ gg}
734 {hh}
735 \and
736 \inferrule* [lab=XX]{uu \\ vv}{ww}
737 \end{mathpar}
738 would appear as follows with the compatible {\hevea} mode:
739 \begin{mathpar}
740 \inferrule* [left=Foo]
741 {\inferrule* [right=Bar]
742 {a \\ a \\ bb \\ cc \\ dd}
743 {ee}
744 \\ ff \\ gg}
745 {hh}
746 \\
747 \inferrule* [lab=XX]{uu \\ vv}{ww}
748 \end{mathpar}
749 To obtain (almost) the same rendering as in {\TeX}, it could be typed as
750 \begin{lstlisting}[escapechar=\%]{Ocaml}
751 \begin{mathpar}
752 \inferrule* [Left=Foo]
753 {\inferrule* [Right=Bar,width=8em,
754 leftskip=2em,rightskip=2em,vdots=1.5em]
755 {a \\ a \hva \\ bb \\ cc \\ dd}
756 {ee}
757 \\ ff \\ gg}
758 {hh}
759 \hva \and
760 \inferrule* [lab=XX]{uu \\ vv}{ww}
761 \end{mathpar}
762 \end{lstlisting}
763 Actually, it would be typeset and follows with the compatible {\hevea} mode:
764 \begin{mathpar}
765 \inferrule* [left=Foo]
766 {\inferrule* [right=Bar]
767 {a \\ a \\\\ bb \\ cc \\ dd}
768 {ee}
769 \\ ff \\ gg}
770 {hh}
771 \and
772 \inferrule* [lab=XX]{uu \\ vv}{ww}
773 \end{mathpar}
774
775 %<*!hevea>
776 \DocInput{mathpartir.dtx}
777 %</!hevea>
778
779 \end{document}
780 %</(driver|hevea)>
781 % \fi
782 %
783 % \CheckSum{0}
784 %
785 % \CharacterTable
786 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
787 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
788 % Digits \0\1\2\3\4\5\6\7\8\9
789 % Exclamation \! Double quote \" Hash (number) \#
790 % Dollar \$ Percent \% Ampersand \&
791 % Acute accent \' Left paren \( Right paren \)
792 % Asterisk \* Plus \+ Comma \,
793 % Minus \- Point \. Solidus \/
794 % Colon \: Semicolon \; Less than \<
795 % Equals \= Greater than \> Question mark \?
796 % Commercial at \@ Left bracket \[ Backslash \\
797 % Right bracket \] Circumflex \^ Underscore \_
798 % Grave accent \` Left brace \{ Vertical bar \|
799 % Right brace \} Tilde \~}
800 %
801 %
802 % \changes{v1.3.1}{2015/11/06}{First version on CTAN}
803 %
804 % \GetFileInfo{mathpartir.dtx}
805 %
806 % \DoNotIndex{\newcommand,\newenvironment}
807 %
808 % \StopEventually{}
809 %
810 % \section{Implementation}
811 %
812 % \begin{macrocode}
813 %% Identification
814 %% Preliminary declarations
815
816 \RequirePackage {keyval}
817
818 %% Options
819 %% More declarations
820
821 %% PART I: Typesetting maths in paragraphe mode
822
823 %% \newdimen \mpr@tmpdim
824 %% Dimens are a precious ressource. Uses seems to be local.
825 \let \mpr@tmpdim \@tempdima
826
827 % To ensure hevea \hva compatibility, \hva should expands to nothing
828 % in mathpar or in inferrule
829 \let \mpr@hva \empty
830
831 %% normal paragraph parametters, should rather be taken dynamically
832 \def \mpr@savepar {%
833 \edef \MathparNormalpar
834 {\noexpand \lineskiplimit \the\lineskiplimit
835 \noexpand \lineskip \the\lineskip}%
836 }
837
838 \def \mpr@rulelineskip {\lineskiplimit=0.3em\lineskip=0.2em plus 0.1em}
839 \def \mpr@lesslineskip {\lineskiplimit=0.6em\lineskip=0.5em plus 0.2em}
840 \def \mpr@lineskip {\lineskiplimit=1.2em\lineskip=1.2em plus 0.2em}
841 \let \MathparLineskip \mpr@lineskip
842 \def \mpr@paroptions {\MathparLineskip}
843 \let \mpr@prebindings \relax
844
845 \newskip \mpr@andskip \mpr@andskip 2em plus 0.5fil minus 0.5em
846
847 \def \mpr@goodbreakand
848 {\hskip -\mpr@andskip \penalty -1000\hskip \mpr@andskip}
849 \def \mpr@and {\hskip \mpr@andskip}
850 \def \mpr@andcr {\penalty 50\mpr@and}
851 \def \mpr@cr {\penalty -10000\mpr@and}
852 %\def \mpr@cr {\penalty -10000\vadjust{\vbox{}}\mpr@and}
853 \def \mpr@eqno #1{\mpr@andcr #1\hskip 0em plus -1fil \penalty 10}
854
855 \def \mpr@bindings {%
856 \let \and \mpr@andcr
857 \let \par \mpr@andcr
858 \let \\\mpr@cr
859 \let \eqno \mpr@eqno
860 \let \hva \mpr@hva
861 }
862 \let \MathparBindings \mpr@bindings
863
864 % \@ifundefined {ignorespacesafterend}
865 % {\def \ignorespacesafterend {\aftergroup \ignorespaces}
866
867 \newenvironment{mathpar}[1][]
868 {$$\mpr@savepar \parskip 0em \hsize \linewidth \centering
869 \vbox \bgroup \mpr@prebindings \mpr@paroptions #1\ifmmode $\else
870 \noindent $\displaystyle\fi
871 \MathparBindings}
872 {\unskip \ifmmode $\fi\egroup $$\ignorespacesafterend}
873
874 \newenvironment{mathparpagebreakable}[1][]
875 {\begingroup
876 \par
877 \mpr@savepar \parskip 0em \hsize \linewidth \centering
878 \mpr@prebindings \mpr@paroptions #1%
879 \vskip \abovedisplayskip \vskip -\lineskip%
880 \ifmmode \else $\displaystyle\fi
881 \MathparBindings
882 }
883 {\unskip
884 \ifmmode $\fi \par\endgroup
885 \vskip \belowdisplayskip
886 \noindent
887 \ignorespacesafterend}
888
889 % \def \math@mathpar #1{\setbox0 \hbox {$\displaystyle #1$}\ifnum
890 % \wd0 < \hsize $$\box0$$\else \bmathpar #1\emathpar \fi}
891
892 %%% HOV BOXES
893
894 \def \mathvbox@ #1{\hbox \bgroup \mpr@normallineskip
895 \vbox \bgroup \tabskip 0em \let \\ \cr
896 \halign \bgroup \hfil $##$\hfil\cr #1\crcr \egroup \egroup
897 \egroup}
898
899 \def \mathhvbox@ #1{\setbox0 \hbox {\let \\\qquad $#1$}\ifnum \wd0 < \hsize
900 \box0\else \mathvbox {#1}\fi}
901
902
903 %% Part II -- operations on lists
904
905 \newtoks \mpr@lista
906 \newtoks \mpr@listb
907
908 \long \def\mpr@cons #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter
909 {#2}\edef #2{\the \mpr@lista \the \mpr@listb}}
910
911 \long \def\mpr@snoc #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter
912 {#2}\edef #2{\the \mpr@listb\the\mpr@lista}}
913
914 \long \def \mpr@concat#1=#2\mpr@to#3{\mpr@lista \expandafter {#2}\mpr@listb
915 \expandafter {#3}\edef #1{\the \mpr@listb\the\mpr@lista}}
916
917 \def \mpr@head #1\mpr@to #2{\expandafter \mpr@head@ #1\mpr@head@ #1#2}
918 \long \def \mpr@head@ #1#2\mpr@head@ #3#4{\def #4{#1}\def#3{#2}}
919
920 \def \mpr@flatten #1\mpr@to #2{\expandafter \mpr@flatten@ #1\mpr@flatten@ #1#2}
921 \long \def \mpr@flatten@ \\#1\\#2\mpr@flatten@ #3#4{\def #4{#1}\def #3{\\#2}}
922
923 \def \mpr@makelist #1\mpr@to #2{\def \mpr@all {#1}%
924 \mpr@lista {\\}\mpr@listb \expandafter {\mpr@all}\edef \mpr@all {\the
925 \mpr@lista \the \mpr@listb \the \mpr@lista}\let #2\empty
926 \def \mpr@stripof ##1##2\mpr@stripend{\def \mpr@stripped{##2}}\loop
927 \mpr@flatten \mpr@all \mpr@to \mpr@one
928 \expandafter \mpr@snoc \mpr@one \mpr@to #2\expandafter \mpr@stripof
929 \mpr@all \mpr@stripend
930 \ifx \mpr@stripped \empty \let \mpr@isempty 0\else \let \mpr@isempty 1\fi
931 \ifx 1\mpr@isempty
932 \repeat
933 }
934
935 \def \mpr@rev #1\mpr@to #2{\let \mpr@tmp \empty
936 \def \\##1{\mpr@cons ##1\mpr@to \mpr@tmp}#1\let #2\mpr@tmp}
937
938 %% Part III -- Type inference rules
939
940 \newif \if@premisse
941 \newbox \mpr@hlist
942 \newbox \mpr@vlist
943 \newif \ifmpr@center \mpr@centertrue
944 \def \mpr@vskip {}
945 \def \mpr@htovlist {%
946 \setbox \mpr@hlist
947 \hbox {\strut
948 \ifmpr@center \hskip -0.5\wd\mpr@hlist\fi
949 \unhbox \mpr@hlist}%
950 \setbox \mpr@vlist
951 \vbox {\if@premisse
952 \box \mpr@hlist
953 \ifx \mpr@vskip \empty \else
954 \hrule height 0em depth \mpr@vskip width 0em
955 \fi
956 \unvbox \mpr@vlist
957 \else
958 \unvbox \mpr@vlist
959 \ifx \mpr@vskip \empty \else
960 \hrule height 0em depth \mpr@vskip width 0em
961 \fi
962 \box \mpr@hlist
963 \fi}%
964 }
965 % OLD version
966 % \def \mpr@htovlist {%
967 % \setbox \mpr@hlist
968 % \hbox {\strut \hskip -0.5\wd\mpr@hlist \unhbox \mpr@hlist}%
969 % \setbox \mpr@vlist
970 % \vbox {\if@premisse \box \mpr@hlist \unvbox \mpr@vlist
971 % \else \unvbox \mpr@vlist \box \mpr@hlist
972 % \fi}%
973 % }
974
975 \def \mpr@item #1{$\displaystyle #1$}
976 \def \mpr@sep{2em}
977 \def \mpr@blank { }
978 \def \mpr@hovbox #1#2{\hbox
979 \bgroup
980 \ifx #1T\@premissetrue
981 \else \ifx #1B\@premissefalse
982 \else
983 \PackageError{mathpartir}
984 {Premisse orientation should either be T or B}
985 {Fatal error in Package}%
986 \fi \fi
987 \def \@test {#2}\ifx \@test \mpr@blank\else
988 \setbox \mpr@hlist \hbox {}%
989 \setbox \mpr@vlist \vbox {}%
990 \if@premisse \let \snoc \mpr@cons \else \let \snoc \mpr@snoc \fi
991 \let \@hvlist \empty \let \@rev \empty
992 \mpr@tmpdim 0em
993 \expandafter \mpr@makelist #2\mpr@to \mpr@flat
994 \if@premisse \mpr@rev \mpr@flat \mpr@to \@rev \else \let \@rev \mpr@flat \fi
995 \def \\##1{%
996 \def \@test {##1}\ifx \@test \empty
997 \mpr@htovlist
998 \mpr@tmpdim 0em %%% last bug fix not extensively checked
999 \else
1000 \setbox0 \hbox{\mpr@item {##1}}\relax
1001 \advance \mpr@tmpdim by \wd0
1002 %\mpr@tmpdim 1.02\mpr@tmpdim
1003 \ifnum \mpr@tmpdim < \hsize
1004 \ifnum \wd\mpr@hlist > 0
1005 \if@premisse
1006 \setbox \mpr@hlist
1007 \hbox {\unhbox0 \hskip \mpr@sep \unhbox \mpr@hlist}%
1008 \else
1009 \setbox \mpr@hlist
1010 \hbox {\unhbox \mpr@hlist \hskip \mpr@sep \unhbox0}%
1011 \fi
1012 \else
1013 \setbox \mpr@hlist \hbox {\unhbox0}%
1014 \fi
1015 \else
1016 \ifnum \wd \mpr@hlist > 0
1017 \mpr@htovlist
1018 \mpr@tmpdim \wd0
1019 \fi
1020 \setbox \mpr@hlist \hbox {\unhbox0}%
1021 \fi
1022 \advance \mpr@tmpdim by \mpr@sep
1023 \fi
1024 }%
1025 \@rev
1026 \mpr@htovlist
1027 \ifmpr@center \hskip \wd\mpr@vlist\fi \box \mpr@vlist
1028 \fi
1029 \egroup
1030 }
1031
1032 %%% INFERENCE RULES
1033
1034 \@ifundefined{@@over}{%
1035 \let\@@over\over % fallback if amsmath is not loaded
1036 \let\@@overwithdelims\overwithdelims
1037 \let\@@atop\atop \let\@@atopwithdelims\atopwithdelims
1038 \let\@@above\above \let\@@abovewithdelims\abovewithdelims
1039 }{}
1040
1041 %% The default
1042
1043 \def \mpr@@fraction #1#2{\hbox {\advance \hsize by -0.5em
1044 $\displaystyle {#1\mpr@over #2}$}}
1045 \def \mpr@@nofraction #1#2{\hbox {\advance \hsize by -0.5em
1046 $\displaystyle {#1\@@atop #2}$}}
1047
1048 \let \mpr@fraction \mpr@@fraction
1049
1050 %% A generic solution to arrow
1051
1052 \def \mpr@@fractionaboveskip {0ex}
1053 \def \mpr@@fractionbelowskip {0.22ex}
1054
1055 \def \mpr@make@fraction #1#2#3#4#5{\hbox {%
1056 \def \mpr@tail{#1}%
1057 \def \mpr@body{#2}%
1058 \def \mpr@head{#3}%
1059 \setbox1=\hbox{$#4$}\setbox2=\hbox{$#5$}%
1060 \setbox3=\hbox{$\mkern -3mu\mpr@body\mkern -3mu$}%
1061 \dimen0\ht3\advance\dimen0 by \dp3\relax
1062 \dimen0 0.5\dimen0\relax
1063 \advance \dimen0 by \mpr@@fractionaboveskip
1064 \setbox1=\hbox {\raise \dimen0 \box1}\relax
1065 \dimen0 -\dimen0\advance \dimen0 \mpr@@fractionaboveskip\dimen0 -\dimen0
1066 \advance \dimen0 by \mpr@@fractionbelowskip
1067 \setbox2=\hbox {\lower \dimen0 \box2}\relax
1068 \setbox0=\hbox {$\displaystyle {\box1 \atop \box2}$}%
1069 \dimen0=\wd0\box0
1070 \box0 \hskip -\dimen0\relax
1071 \hbox to \dimen0 {$%\color{blue}
1072 \mathrel{\mpr@tail}\joinrel
1073 \xleaders\hbox{\copy3}\hfil\joinrel\mathrel{\mpr@head}%
1074 $}}}
1075
1076 %% Old stuff should be removed in next version
1077 \def \mpr@@nothing #1#2
1078 {$\lower 0.01pt \mpr@@nofraction {#1}{#2}$}
1079 \def \mpr@@reduce #1#2{\hbox
1080 {$\lower 0.01pt \mpr@@fraction {#1}{#2}\mkern -15mu\rightarrow$}}
1081 \def \mpr@@rewrite #1#2#3{\hbox
1082 {$\lower 0.01pt \mpr@@fraction {#2}{#3}\mkern -8mu#1$}}
1083 \def \mpr@infercenter #1{\vcenter {\mpr@hovbox{T}{#1}}}
1084
1085 \def \mpr@empty {}
1086 \def \mpr@inferrule
1087 {\bgroup
1088 \ifnum \linewidth<\hsize \hsize \linewidth\fi
1089 \mpr@rulelineskip
1090 \let \and \qquad
1091 \let \hva \mpr@hva
1092 \let \@rulename \mpr@empty
1093 \let \@rule@options \mpr@empty
1094 \let \mpr@over \@@over
1095 \mpr@inferrule@}
1096 \newcommand {\mpr@inferrule@}[3][]
1097 {\everymath={\displaystyle}%
1098 \def \@test {#2}\ifx \empty \@test
1099 \setbox0 \hbox {$\vcenter {\mpr@hovbox{B}{#3}}$}%
1100 \else
1101 \def \@test {#3}\ifx \empty \@test
1102 \setbox0 \hbox {$\vcenter {\mpr@hovbox{T}{#2}}$}%
1103 \else
1104 \setbox0 \mpr@fraction {\mpr@hovbox{T}{#2}}{\mpr@hovbox{B}{#3}}%
1105 \fi \fi
1106 \def \@test {#1}\ifx \@test\empty \box0
1107 \else \vbox
1108 %%% Suggestion de Francois pour les etiquettes longues
1109 %%% {\hbox to \wd0 {\RefTirName {#1}\hfil}\box0}\fi
1110 {\hbox {\DefTirName {#1}}\box0}\fi
1111 \egroup}
1112
1113 \def \mpr@vdotfil #1{\vbox to #1{\leaders \hbox{$\cdot$} \vfil}}
1114
1115 % They are two forms
1116 % \inferrule [label]{[premisses}{conclusions}
1117 % or
1118 % \inferrule* [options]{[premisses}{conclusions}
1119 %
1120 % Premisses and conclusions are lists of elements separated by \\
1121 % Each \\ produces a break, attempting horizontal breaks if possible,
1122 % and vertical breaks if needed.
1123 %
1124 % An empty element obtained by \\\\ produces a vertical break in all cases.
1125 %
1126 % The former rule is aligned on the fraction bar.
1127 % The optional label appears on top of the rule
1128 % The second form to be used in a derivation tree is aligned on the last
1129 % line of its conclusion
1130 %
1131 % The second form can be parameterized, using the key=val interface. The
1132 % folloiwng keys are recognized:
1133 %
1134 % width set the width of the rule to val
1135 % narrower set the width of the rule to val\hsize
1136 % before execute val at the beginning/left
1137 % lab put a label [Val] on top of the rule
1138 % lskip add negative skip on the right
1139 % left put a left label [Val]
1140 % Left put a left label [Val], ignoring its width
1141 % right put a right label [Val]
1142 % Right put a right label [Val], ignoring its width
1143 % leftskip skip negative space on the left-hand side
1144 % rightskip skip negative space on the right-hand side
1145 % vdots lift the rule by val and fill vertical space with dots
1146 % after execute val at the end/right
1147 %
1148 % Note that most options must come in this order to avoid strange
1149 % typesetting (in particular leftskip must preceed left and Left and
1150 % rightskip must follow Right or right; vdots must come last
1151 % or be only followed by rightskip.
1152 %
1153
1154 %% Keys that make sence in all kinds of rules
1155 \def \mprset #1{\setkeys{mprset}{#1}}
1156 \define@key {mprset}{andskip}[]{\mpr@andskip=#1}
1157 \define@key {mprset}{lineskip}[]{\lineskip=#1}
1158 \define@key {mprset}{lessskip}[]{\lineskip=0.5\lineskip}
1159 \define@key {mprset}{flushleft}[]{\mpr@centerfalse}
1160 \define@key {mprset}{center}[]{\mpr@centertrue}
1161 \define@key {mprset}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite}
1162 \define@key {mprset}{atop}[]{\let \mpr@fraction \mpr@@nofraction}
1163 \define@key {mprset}{myfraction}[]{\let \mpr@fraction #1}
1164 \define@key {mprset}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}}
1165 % To be documented.
1166 \define@key {mprset}{defaultfraction}[]{\let \mpr@fraction \mpr@@fraction}
1167 \define@key {mprset}{sep}{\def\mpr@sep{#1}}
1168 \define@key {mprset}{fractionaboveskip}{\def\mpr@@fractionaboveskip{#1}}
1169 \define@key {mprset}{fractionbelowskip}{\def\mpr@@fractionbelowskip{#1}}
1170 \define@key {mprset}{style}[1]{\def\TirNameStyle{#1}def}
1171 \define@key {mprset}{rightstyle}[1]{\def\RightTirNameStyle{#1}}
1172 \define@key {mprset}{leftstyle}[1]{\def\LeftTirNameStyle{#1}}
1173 \define@key {mprset}{vskip}[1]{\def \mpr@vskip{#1}}
1174
1175 \newbox \mpr@right
1176 \define@key {mpr}{flushleft}[]{\mpr@centerfalse}
1177 \define@key {mpr}{center}[]{\mpr@centertrue}
1178 \define@key {mpr}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite}
1179 \define@key {mpr}{myfraction}[]{\let \mpr@fraction #1}
1180 \define@key {mpr}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}}
1181 \define@key {mpr}{width}{\hsize #1}
1182 \define@key {mpr}{sep}{\def\mpr@sep{#1}}
1183 \define@key {mpr}{before}{#1}
1184 \define@key {mpr}{lab}{\let \DefTirName \LabTirName \def \mpr@rulename {#1}}
1185 \define@key {mpr}{Lab}{\let \DefTirName \LabTirName \def \mpr@rulename {#1}}
1186 \define@key {mpr}{style}[1]{\def\TirNameStyle{#1}def}
1187 \define@key {mpr}{rightstyle}[1]{\def\RightTirNameStyle{#1}}
1188 \define@key {mpr}{leftstyle}[1]{\def\LeftTirNameStyle{#1}}
1189 \define@key {mpr}{vskip}[1]{\def \mpr@vskip{#1}}
1190 \define@key {mpr}{narrower}{\hsize #1\hsize}
1191 \define@key {mpr}{leftskip}{\hskip -#1}
1192 \define@key {mpr}{reduce}[]{\let \mpr@fraction \mpr@@reduce}
1193 \define@key {mpr}{rightskip}
1194 {\setbox \mpr@right \hbox {\unhbox \mpr@right \hskip -#1}}
1195 \define@key {mpr}{LEFT}{\setbox0 \hbox {$#1$}\relax
1196 \advance \hsize by -\wd0\box0}
1197
1198 \define@key {mpr}{left}{\setbox0 \hbox {$\LeftTirName {#1}\;$}\relax
1199 \advance \hsize by -\wd0\box0}
1200 \define@key {mpr}{Left}{\llap{$\LeftTirName {#1}\;$}}
1201 \define@key {mpr}{right}
1202 {\setbox0 \hbox {$\;\RightTirName {#1}$}\relax \advance \hsize by -\wd0
1203 \setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}}
1204 \define@key {mpr}{RIGHT}
1205 {\setbox0 \hbox {$#1$}\relax \advance \hsize by -\wd0
1206 \setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}}
1207 \define@key {mpr}{Right}
1208 {\setbox \mpr@right \hbox {\unhbox \mpr@right \rlap {$\;\RightTirName {#1}$}}}
1209 \define@key {mpr}{vdots}{\def \mpr@vdots {\@@atop \mpr@vdotfil{#1}}}
1210 \define@key {mpr}{after}{\edef \mpr@after {\mpr@after #1}}
1211 \define@key {mpr}{vcenter}[]{\mpr@vcentertrue}
1212
1213 \newif \ifmpr@vcenter \mpr@vcenterfalse
1214 \newcommand \mpr@inferstar@ [3][]{\begingroup
1215 \setbox0 \hbox
1216 {\let \mpr@rulename \mpr@empty \let \mpr@vdots \relax
1217 \setbox \mpr@right \hbox{}%
1218 \setkeys{mpr}{#1}%
1219 $\ifx \mpr@rulename \mpr@empty \mpr@inferrule {#2}{#3}\else
1220 \mpr@inferrule [{\mpr@rulename}]{#2}{#3}\fi
1221 \box \mpr@right \mpr@vdots$
1222 \ifmpr@vcenter \aftergroup \mpr@vcentertrue \fi}
1223 \ifmpr@vcenter
1224 \box0
1225 \else
1226 \setbox1 \hbox {\strut}
1227 \@tempdima \dp0 \advance \@tempdima by -\dp1
1228 \raise \@tempdima \box0
1229 \fi
1230 \endgroup}
1231
1232 \def \mpr@infer {\@ifnextchar *{\mpr@inferstar}{\mpr@inferrule}}
1233 \newcommand \mpr@err@skipargs[3][]{}
1234 \def \mpr@inferstar*{\ifmmode
1235 \let \@do \mpr@inferstar@
1236 \else
1237 \let \@do \mpr@err@skipargs
1238 \PackageError {mathpartir}
1239 {\string\inferrule* can only be used in math mode}{}%
1240 \fi \@do}
1241
1242
1243 %%% Exports
1244
1245 % Envirnonment mathpar
1246
1247 \let \inferrule \mpr@infer
1248
1249 % make a short name \infer is not already defined
1250 \@ifundefined {infer}{\let \infer \mpr@infer}{}
1251
1252 \def \TirNameStyle #1{\small \textsc{#1}}
1253 \def \LeftTirNameStyle #1{\TirNameStyle {#1}}
1254 \def \RightTirNameStyle #1{\TirNameStyle {#1}}
1255
1256 \def \lefttir@name #1{\hbox {\small \LeftTirNameStyle{#1}}}
1257 \def \righttir@name #1{\hbox {\small \RightTirNameStyle{#1}}}
1258 \let \TirName \lefttir@name
1259 \let \LeftTirName \lefttir@name
1260 \let \DefTirName \lefttir@name
1261 \let \LabTirName \lefttir@name
1262 \let \RightTirName \righttir@name
1263
1264 %%% Other Exports
1265
1266 % \let \listcons \mpr@cons
1267 % \let \listsnoc \mpr@snoc
1268 % \let \listhead \mpr@head
1269 % \let \listmake \mpr@makelist
1270 % \end{macrocode}
1271 %
1272 % \Finale
1273 \endinput