summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/midnight
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-12 23:46:03 +0000
committerKarl Berry <karl@freefriends.org>2006-01-12 23:46:03 +0000
commit873660d1a83ece926fe7206288dda9c36b349c1b (patch)
treea48f77125c309a355b5d0eb58d6b24446abe9d62 /Master/texmf-dist/tex/generic/midnight
parent2939242967231097459df0fc3150fabc2f639111 (diff)
generic 1
git-svn-id: svn://tug.org/texlive/trunk@613 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/midnight')
-rw-r--r--Master/texmf-dist/tex/generic/midnight/answers.tex0
-rw-r--r--Master/texmf-dist/tex/generic/midnight/border.tex319
-rw-r--r--Master/texmf-dist/tex/generic/midnight/dolines.tex180
-rw-r--r--Master/texmf-dist/tex/generic/midnight/gloss.tex122
-rw-r--r--Master/texmf-dist/tex/generic/midnight/index.tex0
-rw-r--r--Master/texmf-dist/tex/generic/midnight/labels.tex358
-rw-r--r--Master/texmf-dist/tex/generic/midnight/loop.tex105
-rw-r--r--Master/texmf-dist/tex/generic/midnight/quire.tex541
-rw-r--r--Master/texmf-dist/tex/generic/midnight/styledef.tex208
9 files changed, 1833 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/midnight/answers.tex b/Master/texmf-dist/tex/generic/midnight/answers.tex
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/answers.tex
diff --git a/Master/texmf-dist/tex/generic/midnight/border.tex b/Master/texmf-dist/tex/generic/midnight/border.tex
new file mode 100644
index 00000000000..87403f021ae
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/border.tex
@@ -0,0 +1,319 @@
+\ifx\BORDER\relax\endinput\else\let\BORDER=\relax\fi % \input only once
+%
+% border.tex: Macros to typeset borders.
+% version: 1.0 release: 21 October 1991
+%
+% copyright (c) 1991 Marcel R. van der Goot
+% You can use these macros to typeset documents. You may
+% distribute this file freely, provided that you also distribute
+% the accompanying documentation.
+% You may make changes to this file, or extract portions
+% of it for inclusion in other files, provided that
+% (1) you change the name of the file;
+% (2) you give proper credit and include copyright
+% information where applicable;
+% (3) explain how an unchanged version can be obtained; and
+% (4) document the usage of your macros/changes (if usage
+% of your macros is not worth documenting, they must not
+% be worth using).
+% You are not allowed to use the name ``Midnight Macros'' for
+% any changed files.
+% The above rules for making changes do not apply where it
+% is explicitly noted in this file that something can be changed
+% to conform to your local installation.
+%
+% USAGE:
+% See the file border.doc
+%
+% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
+% (use anonymous ftp). Also in various archives.
+%
+% Caltech, Pasadena --- Marcel van der Goot
+% marcel@cs.caltech.edu
+% Caltech 256--80
+% Pasadena, CA 91125
+% USA
+% (818) 356--4603
+%
+
+% update history:
+% version 1.0: This one.
+% release 21 Oct 1991: The original
+%
+
+%%%%%% CODE: (you don't need to read this to use the macros)
+
+\edef\borderelm{\the\catcode`\_} % minor trick to remember the catcode
+\catcode`\_=11% letter, to make private macros
+
+% Note: we use \box0, \box2, \box4, \dimen0, \dimen2, and \count2, rather than
+% allocating new boxes, dimensions, and counts. That is usually ok because all
+% assignments are done within \hbox{...} or \vbox{...}, which provides
+% grouping.
+
+%%%%%%% exactly fitting border with overlaps
+% \border makes a border of the specified dimensions, by overlapping some
+% of the elements when necessary.
+% \hborder takes four arguments, the width, and the indices of the left
+% element, the middle element, and the right element. It makes an horizontal
+% border of the form \hbox to wd{ l m+ r }, where there is at least one m.
+% If wd is large enough to set at least {l m r}, all overlap is between
+% elements of type m. In the unusual case where wd is too small, the overlap
+% is necessarily with the corner elements.
+
+\def\hborder#1#2#3#4% wd, l, m, r
+ {\hbox to#1
+ {\setbox0=\hbox{\borderelm#3}%
+ \borderelm#2%
+ \hskip0pt minus1fil %
+ \copy0\kern-.5\wd0 %
+ \cleaders\copy0\hskip0pt plus1fil %
+ \kern-.5\wd0\copy0 %
+ \hskip0pt minus1fil %
+ \borderelm#4%
+ }%
+ }
+
+% \border does the vertical equivalent of \hborder: the top and bottom
+% elements are hboxes generated with \hborder, and the middle element is
+% an \hbox{ l \hss r }. This middle element is again used at least once,
+% and if possible all overlap will be among middle elements.
+% The \kern0sp at the end is to get depth 0, rather than the depth of
+% the last hbox. (\boxmaxdepth is set to the largest possible value to make
+% sure that the depth is indeed 0, not negative.)
+
+\def\border#1#2% ht, wd
+ {\vbox to#1
+ {\offinterlineskip\boxmaxdepth=\maxdimen
+ \dimen2=#2
+ \setbox0=\hbox to\dimen2{\borderelm3\hss\borderelm4}
+ \dimen0=\ht0 \advance\dimen0 by\dp0
+ \hborder{\dimen2}012
+ \vskip0pt minus1fil
+ \copy0\kern-.5\dimen0
+ \cleaders\copy0\vskip0pt plus1fil
+ \kern-.5\dimen0\copy0
+ \vskip0pt minus1fil
+ \hborder{\dimen2}567
+ \kern0sp
+ }%
+ }
+
+%%%%%%% exactly fitting border with spaces
+% \xborder also makes a border of the specified dimensions, but rather than
+% overlapping elements, it leaves space between the elements.
+% \xhborder makes a horizontal border. Unlike \hborder, there are zero (not
+% one) or more middle elements. The extra space is equally distributed
+% between all the elements.
+
+\def\hxborder#1#2#3#4% wd, l, m, r
+ {\hbox to#1
+ {\setbox0=\hbox{\borderelm#3}%
+ \borderelm#2%
+ \xleaders\copy0\hskip0pt plus1fil minus1fil %
+ \borderelm#4%
+ }%
+ }
+
+% \xborder is to \hxborder as \border is to \hborder.
+
+\def\xborder#1#2% ht, wd
+ {\vbox to#1
+ {\offinterlineskip\boxmaxdepth=\maxdimen
+ \dimen2=#2
+ \setbox0=\hbox to\dimen2{\borderelm3\hss\borderelm4}
+ \hxborder{\diemn2}012
+ \xleaders\copy0\vskip0pt plus1fil minus1fil
+ \hxborder{\dimen2}567
+ \kern0sp
+ }%
+ }
+
+%%%%%%% rounded border with abutting elements
+% \plusborder and \minusborder make borders with abutted elements (no
+% overlaps, no spaces). To make this possible, the border dimensions are
+% rounded so that an integral number of elements fits. \plusborder rounds
+% up, \minusborder rounds down. \plusgray and \minusgray are similiar, except
+% that \borderelm8 is used as center element (normally the center is white).
+% \plus_border and \minus_border are used for both, where the 3rd argument
+% indicates whether there is a center element.
+
+% The computation consists of determining the space D that has to be
+% filled with middle elements. If the width of the middle element is d,
+% there fit (D div d) middle element in a `minus border.'
+% To avoid minor inaccuracies in the arithmetic, what we actually do is
+% (D+100sp) div d. 100sp is so small as to be invisible.
+
+\def\hminusborder#1#2#3#4% wd, l, m, r
+ {\hbox
+ {\dimen0=#1\count2=\dimen0 %
+ \setbox0=\hbox{\borderelm#2}\advance\count2 by-\wd0 %
+ \setbox0=\hbox{\borderelm#4}\advance\count2 by-\wd0 %
+ \setbox0=\hbox{\borderelm#3}%
+ \advance\count2 by100 %
+ \divide\count2 by\wd0 %
+ \borderelm#2%
+ \cleaders\copy0\hskip\count2\wd0 %
+ \borderelm#4%
+ }%
+ }
+
+\def\minus_border#1#2#3% ht, wd, #3=empty ==> no center element
+ {\vbox
+ {\offinterlineskip\boxmaxdepth=\maxdimen
+ \dimen2=#2\relax
+ \dimen0=#1\count2=\dimen0
+ \setbox0=\hminusborder{\dimen2}012
+ \advance\count2 by-\ht0 \advance\count2 by-\dp0
+ \setbox2=\hminusborder{\dimen2}567
+ \advance\count2 by-\ht2 \advance\count2 by-\dp2
+ \if.#3.\setbox4=\hbox to\wd0{\borderelm3\hss\borderelm4}
+ \else \setbox4=\hminusborder{\dimen2}384
+ \fi
+ \advance\count2 by100
+ \dimen0=\ht4\advance\dimen0 by\dp4
+ \divide\count2 by\dimen0
+ \box0
+ \cleaders\copy4\vskip\count2\dimen0
+ \box2
+ \kern0sp
+ }%
+ }
+
+\def\minusborder#1#2{\minus_border{#1}{#2}{}}
+
+\def\minusgray#1#2{\minus_border{#1}{#2}{1}}
+
+
+% Rounding upwards is achieved with (D + d - 1) div d, but again, we
+% actually do (D + d - 100sp) div d.
+
+\def\hplusborder#1#2#3#4% wd, l, m, r
+ {\hbox
+ {\dimen0=#1\count2=\dimen0 %
+ \setbox0=\hbox{\borderelm#2}\advance\count2 by-\wd0 %
+ \setbox0=\hbox{\borderelm#4}\advance\count2 by-\wd0 %
+ \setbox0=\hbox{\borderelm#3}%
+ \advance\count2 by\wd0\advance\count2 by-100 %
+ \divide\count2 by\wd0 %
+ \borderelm#2%
+ \cleaders\copy0\hskip\count2\wd0 %
+ \borderelm#4%
+ }%
+ }
+
+\def\plus_border#1#2#3% ht, wd, #3=empty ==> no center element
+ {\vbox
+ {\offinterlineskip\boxmaxdepth=\maxdimen
+ \dimen2=#2\relax
+ \dimen0=#1\relax\count2=\dimen0
+ \setbox0=\hplusborder{\dimen2}012
+ \advance\count2 by-\ht0 \advance\count2 by-\dp0
+ \setbox2=\hplusborder{\dimen2}567
+ \advance\count2 by-\ht2 \advance\count2 by-\dp2
+ \if.#3.\setbox4=\hbox to\wd0{\borderelm3\hss\borderelm4}
+ \else\setbox4=\hplusborder{\dimen2}384
+ \fi
+ \dimen0=\ht4\advance\dimen0 by\dp4
+ \advance\count2 by\dimen0\advance\count2 by-100
+ \divide\count2 by\dimen0
+ \box0
+ \cleaders\copy4\vskip\count2\dimen0
+ \box2
+ \kern0sp
+ }%
+ }
+
+\def\plusborder#1#2{\plus_border{#1}{#2}{}}
+
+\def\plusgray#1#2{\plus_border{#1}{#2}{1}}
+
+%%%%%%% border example (rounded corners)
+% This example creates a border with rounded corners. The corners are taken
+% from the manfnt font, as described in The TeXbook, p.389. However, we
+% reposition them in their boxes, as their original position is inconvenient:
+% We want tight-fitting boxes, because the boxes determine the border width
+% and height. The original position is described in The TeXbook.
+
+% If \manfnt is already defined, we do not redefine it.
+\ifx\manfnt\UNDEFINED
+\font\manfnt=manfnt
+\fi
+
+% \roundcorners is a bit messy, but that is not so important.
+% Just so that you can use \minusgray and \plusgray, we added a center
+% character (just some random character from the font). That meant that the
+% left and right character had to be given widths equal to the corner elements.
+% \roundcorners scales properly with \manfnt.
+
+\def\roundcorners#1% use as \borderelm
+ {{\manfnt
+ \setbox2=\hbox{\char'44}% for demonstration purposes
+ \ifcase#1
+ \setbox0=\hbox{d}% lu
+ \hbox to\ht0{\vbox to\fontdimen8\font{\vss\box0}\hss}%
+ \or\hbox{\vrule width\wd2 height\fontdimen8\font depth0pt\hss}% u=d
+ \or\setbox0=\hbox{a}% ru
+ \hbox to\ht0{\kern\dp0\vbox to\fontdimen8\font{\vss\box0}\hss}%
+ \or\setbox0=\hbox{d}%
+ \hbox to\ht0{\vrule width\fontdimen8\font height\ht2 depth\dp2\hss}% l
+ \or\setbox0=\hbox{d}%
+ \hbox to\ht0{\hss\vrule width\fontdimen8\font height\ht2 depth\dp2}% r
+ \or\setbox0=\hbox{c}% ld
+ \hbox to\ht0{\vbox{\copy0\kern-\dp0}\hss}%
+ \or\hbox{\vrule width\wd2 height\fontdimen8\font depth0pt\hss}% d=u
+ \or\setbox0=\hbox{b}% rd
+ \hbox to\ht0{\kern\dp0\vbox{\copy0\kern-\dp0}\hss}%
+ \or\box2 % center character
+ \fi
+ }}
+
+%%%%%%% centering text within a border
+% \setborder[bwd, hspace, vspace]\bordermacro uses \bordermacro (one of
+% \border, \xborder, etc.) to typeset a border. The width of the border is bwd,
+% the height of the border depends on the amount of text within the border.
+% This text is read and typeset in a vbox, with the hsize set so that the
+% width has the appropriate value. This is done in a somewhat convoluted way
+% with \afterassignment to set the hsize, and \aftergroup to create the border.
+% The reason is that now the text is not read as an argument of \setborder,
+% which is important, for instance, if the text contains catcode changes.
+% We did not write \setborder[#1,#2,#3]#4#{ , which would have ensured that a
+% brace follows: that would have required an explicit brace, whereas now you
+% can also use \bgroup (useful if you want to put \setborder in some other
+% macro).
+
+\newbox\brd_txt
+\newbox\brd_box
+
+\def\setborder[#1,#2,#3]#4% wd, hspace, vspace, bordermacro
+ {\def\brd_inbox
+ {\hsize=#1
+ \advance\hsize by-#2
+ \advance\hsize by-#2
+ \aftergroup\set_border
+ }%
+ \def\set_border
+ {\setbox\brd_txt=\vbox
+ {\vskip#3
+ \box\brd_txt
+ \vskip#3
+ }%
+ \setbox\brd_box=#4{\ht\brd_txt}{#1}%
+ \vbox to\ht\brd_box
+ {\copy\brd_box \kern-\ht\brd_box
+ \vss
+ \hbox to\wd\brd_box{\hss\box\brd_txt\hss}
+ \vss
+ }%
+ }%
+ \afterassignment\brd_inbox
+ \setbox\brd_txt=\vbox
+ }
+
+
+%%%%%%% initialization
+
+\catcode`\_=\borderelm % restore catcode
+
+\let\borderelm=\roundcorners % only reasonable initialization
+
diff --git a/Master/texmf-dist/tex/generic/midnight/dolines.tex b/Master/texmf-dist/tex/generic/midnight/dolines.tex
new file mode 100644
index 00000000000..1147fe92752
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/dolines.tex
@@ -0,0 +1,180 @@
+\ifx\DOLINES\relax\endinput\else\let\DOLINES=\relax\fi % \input only once
+%
+% dolines.tex: Meta-macros to separate arguments by newlines and by
+% empty lines.
+% version: 1.0 release: 15 April 1991
+%
+% copyright (c) 1991 Marcel R. van der Goot
+% You can use these macros to typeset documents. You may
+% distribute this file freely, provided that you also distribute
+% the accompanying documentation.
+% You may make changes to this file, or extract portions
+% of it for inclusion in other files, provided that
+% (1) you change the name of the file;
+% (2) you give proper credit and include copyright
+% information where applicable;
+% (3) explain how an unchanged version can be obtained; and
+% (4) document the usage of your macros/changes (if usage
+% of your macros is not worth documenting, they must not
+% be worth using).
+% You are not allowed to use the name ``Midnight Macros'' for
+% any changed files.
+% The above rules for making changes do not apply where it
+% is explicitly noted in this file that something can be changed
+% to conform to your local installation.
+%
+% USAGE:
+% See the file dolines.doc
+% You need Midnight/loop.tex to use these macros.
+%
+% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
+% (use anonymous ftp). Also in various archives.
+%
+% Caltech, Pasadena --- Marcel van der Goot
+% marcel@cs.caltech.edu
+% Caltech 256--80
+% Pasadena, CA 91125
+% USA
+% (818) 356--4603
+%
+
+% update history:
+% version 1.0: This one.
+% release 15 April 1991: This one.
+% release 8 February 1991: Used \next instead of \do_next, which
+% occasionally conflicted with use of \next in other macros.
+
+%%%%%% CODE: (you don't need to read this to use the macros)
+
+\input loop % CHANGE this filename to correspond to your installation
+
+%%%%%%% Reading from a different file
+% This is relatively simple, it can be done with a loop. The read function
+% reads a single line (that is what \read does). A file that is being
+% \read always ends with an empty line, therefore no test for eof(lines_in)
+% is needed in the inner loop.
+%
+% while (!eof(lines_in))
+% {
+% read(lines_in, _ln);
+% if (_ln != empty_ln)
+% {
+% beforelines();
+% do { everyline(_ln);
+% read(lines_in, _ln);
+% } while (_ln != empty_ln);
+% afterlines();
+% }
+% }
+%
+
+{\catcode`\^^M=12 \endlinechar=-1 % 12 = other
+\catcode`\_=11 % 11 = letter (used to make macros private)
+
+\newread\lines_in
+
+\globaldefs=1
+
+\def\empty_ln{\par}
+
+\def\filedolines#1%
+ {{\openin\lines_in=#1 %
+ \ifeof\lines_in\message{File #1 not found.}\fi
+ \Loop\ifeof\lines_in \Break1 \fi
+ \read\lines_in to\_ln
+ \ifx\_ln\empty_ln
+ \else {\beforelines
+ \Loop\everyline{\_ln}%
+ \read\lines_in to\_ln
+ \ifx\_ln\empty_ln \Break1 \fi
+ \Pool
+ \afterlines
+ }%
+ \fi
+ \Pool
+ \closein\lines_in
+ }}
+
+} % restore \catcode`\^^M, \catcode`\_, etc.
+
+
+%%%%%%% Reading from the current file
+% This is more complicated. The problem is that a line can only be
+% read at the end of a macro, because otherwise a part of the macro
+% itself will be read. Therefore, the above solution with \Loop cannot
+% be used. Instead, this is implemented as a finite state machine. The
+% FSM has two major states, outer_loop and inner_loop, corresponding to the
+% program above. In these states, the value of _ln is used to determine
+% what actions to take, and what the next state is. The next state
+% is indicated by the control-sequence \do_next.
+% There are two minor states, get_out and get_in. In each of them
+% the next line is read into _ln. After get_out, the next state is always
+% outer_loop; after get_in it is always inner_loop.
+% Here is a ``picure.'' `(...)' is a state, `...?' denotes the value
+% of _ln, and other texts are actions. ctrl-M stands for an empty line.
+%
+% /---<----\
+% (get_out) |
+% \ ctrl-M?
+% begindolines V /
+% \->bgroup -> (get_out) -> (outer_loop) -> enddolines? -> egroup
+% ^ | ^ \-> (finish)
+% / | \
+% afterlines --/ other? \-- afterlines
+% ^ V ^
+% | beforelines |
+% ctrl-M? <--\ | /--> enddolines?
+% \ V /
+% (inner_loop)
+% / ^
+% other? \
+% | (get_in)
+% V |
+% \-everyline->/
+%
+
+
+{\catcode`\^^M=12 \endlinechar=-1 % 12 = other
+\catcode`\_=11 % 11 = letter (used to make macros private)
+\globaldefs=1
+
+
+\long\def\get_out#1^^M% here a line is read (as #1)
+ {\gdef\_ln{#1}%
+ \outer_loop
+ }
+
+\long\def\get_in#1^^M% here a line is read (as #1)
+ {\gdef\_ln{#1}%
+ \inner_loop
+ }
+
+\def\outer_loop
+ {\ifx\_ln\enddolines \egroup\let\do_next=\finishdolines
+ \else\ifx\_ln\empty \let\do_next=\get_out
+ \else \beforelines\let\do_next=\inner_loop
+ \fi \fi
+ \do_next
+ }
+
+\def\inner_loop
+ {\ifx\_ln\enddolines \afterlines\let\do_next=\outer_loop
+ \else\ifx\_ln\empty \afterlines\let\do_next=\outer_loop
+ \else \everyline\_ln\let\do_next=\get_in
+ \fi \fi
+ \do_next
+ }
+
+\def\begindolines
+ {\bgroup
+ \catcode`\^^M=12 %
+ \get_out
+ }
+
+} % restore \catcode`\^^M, \catcode`\_, etc.
+
+% We define \finishdolines and \enddolines, in case someone forgets:
+
+\let\finishdolines=\relax
+\def\enddolines{\enddolines}
+
diff --git a/Master/texmf-dist/tex/generic/midnight/gloss.tex b/Master/texmf-dist/tex/generic/midnight/gloss.tex
new file mode 100644
index 00000000000..2fa5352d2ee
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/gloss.tex
@@ -0,0 +1,122 @@
+\ifx\GLOSS\relax\endinput\else\let\GLOSS=\relax\fi % \input only once
+%
+% gloss.tex: Macros for vertically aligning words in consecutive sentences.
+% version: 1.0 release: 26 November 1990
+%
+% copyright (c) 1991 Marcel R. van der Goot
+% You can use these macros to typeset documents. You may
+% distribute this file freely, provided that you also distribute
+% the accompanying documentation.
+% You may make changes to this file, or extract portions
+% of it for inclusion in other files, provided that
+% (1) you change the name of the file;
+% (2) you give proper credit and include copyright
+% information where applicable;
+% (3) explain how an unchanged version can be obtained; and
+% (4) document the usage of your macros/changes (if usage
+% of your macros is not worth documenting, they must not
+% be worth using).
+% You are not allowed to use the name ``Midnight Macros'' for
+% any changed files.
+% The above rules for making changes do not apply where it
+% is explicitly noted in this file that something can be changed
+% to conform to your local installation.
+%
+% USAGE:
+% See the file gloss.doc
+%
+% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
+% (use anonymous ftp). Also in various archives.
+%
+% I wrote these macros after reading a request for something like this
+% from Robert Malouf (SUNY Buffalo) on usenet in comp.text.tex.
+%
+% Caltech, Pasadena --- Marcel van der Goot
+% marcel@cs.caltech.edu
+% Caltech 256--80
+% Pasadena, CA 91125
+% (818) 356--4603
+%
+
+% update history:
+% version 1.0: This one.
+% release 9 Nov 1990: used % instead of \endlinechar (no functional
+% changes involved).
+% release 26 Nov 1990: This one.
+% version 8 Nov 1990: Same as this, but with less readable documentation.
+% version 7 Nov 1990: Used the names \fontone and \fonttwo instead of
+% \eachwordone and \eachwordtwo.
+% version 6 Nov 1990: Could not easily typeset a '+', handled
+% linespacing incorrectly.
+
+%%%%%% CODE: (you don't need to read this to use the macros)
+
+\newbox\lineone % boxes with words from first line
+\newbox\linetwo
+\newbox\wordone % a word from the first line (hbox)
+\newbox\wordtwo
+\newbox\gline % the constructed double line (hbox)
+\newskip\glossglue % extra glue between glossed pairs
+\glossglue = 0pt plus 2pt minus 1pt % allow stretch/shrink between words
+\newif\ifnotdone
+
+\let\eachwordone=\it
+\let\eachwordtwo=\rm
+
+
+\def\lastword#1#2#3% #1 = \each, #2 = line box, #3 = word box
+ {\setbox#2=\vbox{\unvbox#2%
+ \global\setbox#3=\lastbox
+ }%
+ \ifvoid#3\global\setbox#3=\hbox{#1\strut{} }\fi
+ % extra space following \strut in case #1 needs a space
+ }
+
+\def\testdone
+ {\ifdim\ht\lineone=0pt
+ \ifdim\ht\linetwo=0pt \notdonefalse % tricky space after pt
+ \else\notdonetrue
+ \fi
+ \else\notdonetrue
+ \fi
+ }
+
+{\catcode`\^^M=12 \endlinechar=-1 % 12 = other
+\gdef\getwords(#1,#2)#3 #4^^M% #1=linebox, #2=\each, #3=1st word, #4=remainder
+ {\setbox#1=\vbox{\hbox{#2\strut#3 }% adds space
+ \unvbox#1%
+ }%
+ \def\more{#4}%
+ \ifx\more\empty\let\more=\donewords
+ \else\let\more=\getwords
+ \fi
+ \more(#1,#2)#4^^M%
+ }
+
+\gdef\donewords(#1,#2)^^M{}%
+
+\gdef\twosent#1^^M#2^^M% #1 = first line, #2 = second line
+ {\getwords(\lineone,\eachwordone)#1 ^^M%
+ \getwords(\linetwo,\eachwordtwo)#2 ^^M%
+ \loop\lastword{\eachwordone}{\lineone}{\wordone}%
+ \lastword{\eachwordtwo}{\linetwo}{\wordtwo}%
+ \global\setbox\gline=\hbox{\unhbox\gline
+ \hskip\glossglue
+ \vbox{\box\wordone
+ \nointerlineskip
+ \box\wordtwo
+ }%
+ }%
+ \testdone
+ \ifnotdone
+ \repeat
+ \egroup % matches \bgroup in \gloss
+ }
+} % restore \catcode`\^^M
+
+\def\gloss
+ {\bgroup
+ \catcode`\^^M=12
+ \twosent
+ }
+
diff --git a/Master/texmf-dist/tex/generic/midnight/index.tex b/Master/texmf-dist/tex/generic/midnight/index.tex
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/index.tex
diff --git a/Master/texmf-dist/tex/generic/midnight/labels.tex b/Master/texmf-dist/tex/generic/midnight/labels.tex
new file mode 100644
index 00000000000..8b3b75bc008
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/labels.tex
@@ -0,0 +1,358 @@
+\ifx\LABELS\relax\endinput\else\let\LABELS=\relax\fi % \input only once
+%
+% labels.tex: Macros to print address labels (and bulk letters).
+% version: 1.0 release: 24 October 1991
+%
+% copyright (c) 1991 Marcel R. van der Goot
+% You can use these macros to typeset documents. You may
+% distribute this file freely, provided that you also distribute
+% the accompanying documentation.
+% You may make changes to this file, or extract portions
+% of it for inclusion in other files, provided that
+% (1) you change the name of the file;
+% (2) you give proper credit and include copyright
+% information where applicable;
+% (3) explain how an unchanged version can be obtained; and
+% (4) document the usage of your macros/changes (if usage
+% of your macros is not worth documenting, they must not
+% be worth using).
+% You are not allowed to use the name ``Midnight Macros'' for
+% any changed files.
+% The above rules for making changes do not apply where it
+% is explicitly noted in this file that something can be changed
+% to conform to your local installation.
+%
+% USAGE:
+% See the file labels.doc
+% You need Midnight/dolines.tex and Midnight/loop.tex to use these
+% macros.
+%
+% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
+% (use anonymous ftp). Also in various archives.
+%
+% Caltech, Pasadena --- Marcel van der Goot
+% marcel@cs.caltech.edu
+% Caltech 256--80
+% Pasadena, CA 91125
+% USA
+% (818) 356--4603
+%
+
+% update history:
+% version 1.0: This one.
+% release 24 Oct 1991: I undid the change from 6 Aug 1991: Matthias
+% Feyerabend suggested a more elegant change that has the
+% same result (involving \the\expandafter\lbl_txt#1).
+% release 6 Aug 1991: Dolines.tex was changed since the previous
+% release: it now calls \everyline with a single macro rather
+% than with the text of the line. This required a change in
+% the creation of \lbl_txt; \addlbl_txt was added.
+% release 14 Feb 1991: The original
+%
+
+%%%%%% CODE: (you don't need to read this to use the macros)
+
+\input dolines % CHANGE this filename to correspond to
+ % your installation
+
+%%%%%%% Registers
+% All user-accessible registers. Some private registers are declared
+% later.
+% Individual labels:
+\newdimen\vlblsize
+\newdimen\hlblsize
+\newskip\vindent
+\newskip\hindent
+\newdimen\lbloutline
+\newtoks\beforelbl
+\newtoks\afterlbl
+
+% Labels on a page:
+\newcount\vlbls
+\newcount\hlbls
+\newdimen\vfirst
+\newdimen\hfirst
+\newdimen\vinter
+\newdimen\hinter
+
+% We make `_' into a letter to make macros private
+\vlbls=\catcode`\_ % minor trick to remember old value
+\catcode`\_=11
+
+\newbox\lbl_ % box in which a label is constructed
+
+
+%%%%%%% Error message
+% If a label is too large, we give an error message. \err_dim is the
+% excess size of the label, \lbl_txt is the text of the label. \lbl_txt
+% is set while reading the label, so that we can report which label is
+% too large. Depending on the value of \err_act, more action is
+% taken: 0 --> nothing, 1 --> print label anyway, others --> print
+% this label on \lbl_log=lblerror.tex as well. \lbl_log is closed
+% and an appropriate message printed by \close_log.
+
+\newdimen\err_dim
+\newtoks\lbl_txt
+\newcount\err_act
+\newcount\err_cnt
+\newwrite\lbl_log
+
+\let\erroraction=\err_act
+
+\def\err_lbl#1% #1 = "wide" or "high"
+ {{\global\advance\err_cnt by 1
+ \newlinechar=`\^^J
+ \immediate\write16{^^J**** Label is \the\err_dim\space too #1:}%
+ \immediate\write16{\the\lbl_txt}%
+ \ifcase\err_act
+ \or\make_lbl
+ \else\immediate\write\lbl_log{\the\lbl_txt}%
+ \fi
+ }}
+
+\def\close_msg#1%
+ {\ifnum\err_cnt>0 \immediate\write16{#1}%
+ \fi
+ }
+
+\def\close_log
+ {\ifcase\err_act
+ \close_msg{**** \the\err_cnt\space error(s) ****}%
+ \or \close_msg{**** \the\err_cnt\space label(s) with errors %
+ are included in the dvi file ****}%
+ \else\immediate\closeout\lbl_log
+ \close_msg{**** \the\err_cnt\space error(s): see lblerror.tex ****}%
+ \fi
+ }
+
+%%%%%%% Reading a label
+% Every group of lines is set in a vbox, using dolines.tex (see dolines.doc).
+% \lbl_before corresponds to \beforelines (see dolines), etc.
+% Every line itself is set in an hbox. The sizes of the hboxes and
+% vboxes are not specified here, because we want to do our own checking
+% rather than rely on TeX's checking and error messages. The computation
+% in \lbl_before is used to position the baseline of the first line
+% independently of the height of that line. \vindent is similar to TeX's
+% \topskip.
+
+\def\lbl_before
+ {\global\lbl_txt={}%
+ \setbox\lbl_=\vbox\bgroup
+ \advance\vindent by -\baselineskip
+ \ifdim\vindent<0sp \vindent=0sp \fi
+ \vskip\vindent
+ \prevdepth=0sp
+ \the\beforelbl
+ }
+
+% #1 is always equal to `\_ln', which in turn expands to the line of text.
+% That works fine with \hbox, but we must somehow expand \_ln first before
+% we put it in \lbl_txt. That is what the second expandafter is for. The
+% first expandafter is to expand \the\lbl_txt (and \_ln) before the '{' is
+% read. Otherwise no expansion is done: TeX does not expand the tokens in
+% the text of a token variable.
+% --- thanks for this solution to Matthias Feyerabend.
+
+\def\lbl_every#1%
+ {\hbox{#1}%
+ \global\lbl_txt=\expandafter{\the\expandafter\lbl_txt#1^^J}%
+ }
+
+\def\lbl_after
+ {\the\afterlbl
+ \egroup % closes \lbl_=\vbox{...}
+ \check_lbl
+ }
+
+%%%%%%% Making a label
+% \check_lbl checks whether the label is not too large, and, if not,
+% calls \make_lbl. (\make_lbl can also be called from \err_lbl.)
+% Note that \check_lbl only checks for the natural size of the label;
+% if \hindent or \vindent have shrink components, the label may
+% actually fit.
+
+\def\check_lbl
+ {\err_dim=\wd\lbl_ \advance\err_dim by \hindent
+ \ifdim\err_dim>\hlblsize
+ \advance\err_dim by -\hlblsize
+ \err_lbl{wide}%
+ \else\err_dim=\ht\lbl_ \advance\err_dim by \dp\lbl_
+ \ifdim\err_dim>\vlblsize
+ \advance\err_dim by -\vlblsize
+ \err_lbl{high}%
+ \else\make_lbl
+ \fi \fi
+ }
+
+\def\make_lbl
+ {\setbox\lbl_=\vbox to \vlblsize{\unvbox\lbl_ \vss}%
+ \setbox\lbl_=\hbox to \hlblsize
+ {\kern -\lbloutline \vrule width\lbloutline
+ \hskip\hindent \box\lbl_ \hss
+ \vrule width\lbloutline \kern -\lbloutline
+ }%
+ \setbox\lbl_=\vbox
+ {\kern -\lbloutline \hrule height\lbloutline
+ \box\lbl_
+ \hrule height\lbloutline \kern -\lbloutline
+ }%
+ \add_to_row
+ }
+
+%%%%%%% Making a page
+% \lbl_out takes the label constructed in \lbl_ and adds it to the current
+% row. If the row is full, as counted by \h_cnt, the row is added
+% to the current page. Similarly, if \v_cnt indicates a full page,
+% the page is shipped out. (Note: There is no interline glue between
+% rows because of the way \unvbox does (not) affect \prevdepth.)
+% \finish_page ships out any remaining incomplete page.
+% \count1 is used to count the labels (this is only used to report
+% to the user when a page is shipped out).
+
+\newbox\lbl_page
+\newbox\lbl_row
+\newcount\v_cnt
+\newcount\h_cnt
+
+\def\add_to_row
+ {\ifnum\h_cnt=0
+ \global\setbox\lbl_row=\hbox{\kern\hfirst \box\lbl_}%
+ \else\global\setbox\lbl_row=
+ \hbox{\unhbox\lbl_row \kern\hinter \box\lbl_}%
+ \fi
+ \global\advance\h_cnt by 1 \global\advance\count1 by 1
+ \ifnum\h_cnt<\hlbls
+ \else\add_to_page \global\h_cnt=0
+ \fi
+ }
+
+\def\add_to_page
+ {\ifnum\v_cnt=0
+ \global\setbox\lbl_page=\vbox{\kern\vfirst \box\lbl_row}%
+ \else\global\setbox\lbl_page=
+ \vbox{\unvbox\lbl_page \kern\vinter \box\lbl_row}%
+ \fi
+ \global\advance\v_cnt by 1
+ \ifnum\v_cnt<\vlbls
+ \else\shipout\box\lbl_page \global\v_cnt=0 \global\advance\count0 by 1
+ \fi
+ }
+
+\def\finish_page
+ {\ifnum\h_cnt>0 \add_to_page \fi
+ \ifnum\v_cnt>0 \shipout\box\lbl_page \global\advance\count0 by1 \fi
+ }
+
+%%%%%%% Typesetting labels
+% In \setup_lbl the \bgroup is to prevent some changes from continuing
+% after \endlabels (e.g., catcode changes). Of course, we could also have
+% reset them to the (presumed) old values in \endlabels. And anyway,
+% it is a rather unnecessary refinement, since it doesn't make much
+% sence to combine typesetting labels with other things in the same
+% TeX run. We prevent changes of \erroraction while labels are being
+% typeset, since such changes would cause confusion with respect to
+% the log file. (Another unnecessary refinement: if you change the
+% action you deserve what you get.)
+% The \hsize is set properly in case \beforelbl or \afterlbl contains
+% horizontal material (this will be typeset as a normal paragraph).
+% It also allows the use of \line in these token registers.
+
+\def\catcode_lbl{\catcode`\&=12 \catcode`\#=12 }
+
+\def\setup_lbl
+ {\vfill\supereject
+ \ifcase\err_act\or\else
+ \immediate\openout\lbl_log=lblerror.tex %<- significant space
+ \fi
+ \let\beforelines=\lbl_before \let\afterlines=\lbl_after
+ \let\everyline=\lbl_every
+ \let\finishdolines=\endlabels \def\enddolines{\endlabels}%
+ \bgroup
+ \dimen0=\hlblsize \advance\dimen0 by-\hindent
+ \hsize=\dimen0
+ \let\erroraction=\relax \err_cnt=0
+ \h_cnt=0 \v_cnt=0 \global\count1=0
+ \voffset=-1in \hoffset=-1in
+ \catcode_lbl
+ }
+
+\def\endlabels
+ {\finish_page
+ \egroup
+ \close_log
+ }
+
+\def\beginlabels{\setup_lbl \begindolines}
+
+\def\labelfile#1{\setup_lbl \filedolines{#1}\endlabels}
+
+
+%%%%%%% Typesetting bulk letters
+% This is kept quite simple: Labels are read one by one from a file,
+% and consist of a vbox with an hbox for each line. No extra indentations
+% or other frills. After each label has been read, we simply \input the
+% bulk letter. In the letter, \bulkaddress will typeset the label.
+% Just before we input the letter, we set \end=\relax, just in case the
+% letter ends with \bye. (This is better than setting \bye=\relax, since
+% \bye may insert extra material.) The grouping from \filedolines will
+% restore the original \end.
+
+\def\bulk_before{\setbox\lbl_=\vbox\bgroup}
+\def\bulk_every#1{\hbox{#1\strut}}
+
+\def\bulk_after
+ {\egroup % closes \setbox\lbl_=\vbox\bgroup
+ \catcode_plain
+ \let\end=\relax
+ \input\bulk_in %
+ \vfill\supereject
+ \catcode_lbl
+ }
+
+\def\bulkaddress{\copy\lbl_}
+
+\def\bulk#1#2% addresses, letter
+ {\vfill\supereject
+ \edef\catcode_plain{\catcode`\noexpand\&=\the\catcode`\&%
+ \catcode`\noexpand\#=\the\catcode`\#}%
+ \let\beforelines=\bulk_before \let\afterlines=\bulk_after
+ \let\everyline=\bulk_every
+ \catcode_lbl
+ \def\bulk_in{#2}%
+ \filedolines{#1}%
+ \catcode_plain
+ }
+
+
+%%%%%%% Initial values
+% \errorcontextlines (exists in TeX 3.0 and later versions) is set in
+% order to not unnecessarily confuse unexperienced users. Supposedly,
+% the macros above don't cause errors. Any errors are most likely
+% caused by something in \beforelines or \afterlines.
+
+\catcode`\_=\vlbls % restore catcode
+
+\ifx\errorcontextlines\undefined % \then old TeX version
+\else\errorcontextlines=-1
+\fi
+
+\erroraction=2
+\lbloutline=0sp
+\beforelbl={}
+\afterlbl={}
+
+% The following defaults are rather arbitrary, in practice the user
+% always has to set these values.
+\vlblsize=5cm
+\hlblsize=10cm
+\vindent=1.3\baselineskip
+\hindent=0.5cm
+
+\vlbls=5
+\hlbls=2
+\vfirst=1cm
+\hfirst=5mm
+\vinter=2mm
+\hinter=2mm
+
+%%%%%%%
diff --git a/Master/texmf-dist/tex/generic/midnight/loop.tex b/Master/texmf-dist/tex/generic/midnight/loop.tex
new file mode 100644
index 00000000000..aa6670f14ea
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/loop.tex
@@ -0,0 +1,105 @@
+\ifx\LOOP\relax\endinput\else\let\LOOP=\relax\fi % \input only once
+%
+% loop.tex: A simple looping construct (meta-macros).
+% version: 1.0 release: 26 June 1991
+%
+% copyright (c) 1991 Marcel R. van der Goot
+% You can use these macros to typeset documents. You may
+% distribute this file freely, provided that you also distribute
+% the accompanying documentation.
+% You may make changes to this file, or extract portions
+% of it for inclusion in other files, provided that
+% (1) you change the name of the file;
+% (2) you give proper credit and include copyright
+% information where applicable;
+% (3) explain how an unchanged version can be obtained; and
+% (4) document the usage of your macros/changes (if usage
+% of your macros is not worth documenting, they must not
+% be worth using).
+% You are not allowed to use the name ``Midnight Macros'' for
+% any changed files.
+% The above rules for making changes do not apply where it
+% is explicitly noted in this file that something can be changed
+% to conform to your local installation.
+%
+% USAGE:
+% See the file loop.doc
+%
+% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
+% (use anonymous ftp). Also in various archives.
+%
+% Caltech, Pasadena --- Marcel van der Goot
+% marcel@cs.caltech.edu
+% Caltech 256--80
+% Pasadena, CA 91125
+% USA
+% (818) 356--4603
+%
+
+% update history:
+% version 1.0: This one.
+% release 26 April 1991: This one.
+% release 15 April 1991: Did not have \long in \Loop, \_break, and
+% \_continue.
+% release 8 Feb 1991: Used \next instead of \Lp_next.
+%
+
+%%%%%% CODE: (you don't need to read this to use the macros)
+
+{
+\catcode`\_=11 % 11 = letter; to make macros private
+\globaldefs=1
+
+% Code to supply \fi's:
+
+\def\do_fi{\fi\finish_ifs}
+
+\def\finish_ifs
+ {\ifnum\count255>0 %
+ \let\Lp_next=\do_fi
+ \else\let\Lp_next=\relax
+ \fi
+ \advance\count255 by-1 %
+ \Lp_next
+ }
+
+% The loop (tail-recursion does not clog memory):
+
+\long\def\Loop#1\Pool%
+ {\def\Pool{#1\Pool}%
+ \Pool
+ }
+
+% \Break could have been defined as
+% \def\Break#1#2\Pool{{\count255=#1 \finish_ifs}}
+% but this fails if you do
+% \ifnum\count0>5\Break
+% without space after the 5: \Break wil be expanded to see if there
+% are more digits (and expanding \Break means reading its 2nd argument).
+% With the solution below, only \Break is expanded because it starts
+% with \relax which is not a number. Using \afterassignment rather
+% than passing the number as argument gives better error messages.
+
+\def\Break
+ {\relax\afterassignment\_break
+ \bgroup\count255=
+ }
+
+\long\def\_break#1\Pool%
+ {\finish_ifs
+ \egroup
+ }
+
+\def\Continue
+ {\relax\afterassignment\_continue
+ \bgroup\count255=
+ }
+
+\long\def\_continue#1\Pool%
+ {\finish_ifs
+ \egroup
+ \Pool
+ }
+
+} % restore \catcode`\_, \globaldefs
+
diff --git a/Master/texmf-dist/tex/generic/midnight/quire.tex b/Master/texmf-dist/tex/generic/midnight/quire.tex
new file mode 100644
index 00000000000..f9218581a76
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/quire.tex
@@ -0,0 +1,541 @@
+\ifx\QUIRE\relax\endinput\else\let\QUIRE=\relax\fi % \input only once
+%
+% quire.tex: Macros for making booklets, printing double pages, and
+% printing outlines and crop marks.
+% version: 1.0 release: 19 January 1991
+%
+% copyright (c) 1991 Marcel R. van der Goot
+% You can use these macros to typeset documents. You may
+% distribute this file freely, provided that you also distribute
+% the accompanying documentation.
+% You may make changes to this file, or extract portions
+% of it for inclusion in other files, provided that
+% (1) you change the name of the file;
+% (2) you give proper credit and include copyright
+% information where applicable;
+% (3) explain how an unchanged version can be obtained; and
+% (4) document the usage of your macros/changes (if usage
+% of your macros is not worth documenting, they must not
+% be worth using).
+% You are not allowed to use the name ``Midnight Macros'' for
+% any changed files.
+% The above rules for making changes do not apply where it
+% is explicitly noted in this file that something can be changed
+% to conform to your local installation.
+%
+% USAGE:
+% See the file quire.doc
+%
+% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
+% (use anonymous ftp). Also in various archives.
+%
+% Caltech, Pasadena --- Marcel van der Goot
+% marcel@cs.caltech.edu
+% Caltech 256--80
+% Pasadena, CA 91125
+% USA
+% (818) 356--4603
+%
+
+% update history:
+% version 1.0: This one.
+% release 19 Jan 1991: This one.
+%
+
+%%%%%% CODE: (you don't need to read this to use the macros)
+
+%%%%%%%%%%%%%%% registers accessible by the user
+
+% dimens related to pages:
+\newdimen\vorigin
+\newdimen\horigin
+\newdimen\vtotal
+\newdimen\htotal
+% also used: dimens \voffset, \hoffset
+
+% dimens related to sheets
+\newdimen\shoutline
+\newdimen\shstaplewidth
+\newdimen\shstaplelength
+\newdimen\shcrop
+\newdimen\shvoffset
+\newdimen\shhtotal
+\newdimen\shthickness
+\newdimen\shvcorrection
+\newdimen\shhcorrection
+
+% token register related to sheets
+\newtoks\shfootline
+
+%%%%%%%%%%%%%%% the implementation
+
+% Private identifiers are prefixed with `q_'; in the comments below,
+% this prefix is omitted for readability.
+
+\shoutline=\catcode`_ sp % minor trick to remember the original catcode
+\catcode`_=11 % letter
+
+%%%%% The stack
+% A stack of boxes is needed to store pages that cannot be printed yet.
+% The stack is formed by \stackbox, an hbox storing the stacked boxes,
+% and \stacktop, the top box on the stack. The stack top can be accessed
+% by \copy\stacktop or \box\stacktop, but the latter should only be
+% used if the next stack operation is \pop. There is no stackcounter
+% implemented, because we don't need it here.
+
+\newbox\q_stackbox % an hbox keeping the stacked boxes but one
+\newbox\q_stacktop % the topmost box
+
+\def\q_push#1% #1 = a box
+ {\global\setbox\q_stackbox=
+ \hbox{\unhbox\q_stackbox \box\q_stacktop}%
+ \global\setbox\q_stacktop=#1%
+ }
+
+\def\q_pop
+ {\global\setbox\q_stackbox=
+ \hbox{\unhbox\q_stackbox \global\setbox\q_stacktop=\lastbox}%
+ }
+
+
+%%%%% Handling pages
+% \makepage takes a box representing the printed material (this box is the
+% argument of \shipout), and makes it into a page. A page is represented
+% by an hbox with height \vtotal, width \htotal, and depth 0.
+
+\def\q_makepage#1% #1 = textpage, return = an hbox (\vtotal+0)*\htotal
+ {\hbox to\htotal
+ {\boxmaxdepth=0pt
+ \advance\vorigin by\voffset
+ \advance\horigin by\hoffset
+ \kern\horigin
+ \vbox to\vtotal
+ {\kern\vorigin
+ #1%
+ \vss
+ }%
+ \hss
+ }%
+ }
+
+% \doublepage takes two pages produced by \makepage, and puts them next
+% to each other in a vbox. Between the two pages there is two times the
+% space specified by \thickoffset. \doublepage draws lines around the
+% produced vbox, and draws `staples' in the center.
+
+\newdimen\q_thickoffset
+
+\def\q_doublepage#1#2% #1 and #2 are page boxes,
+ % return = vbox ((\vtotal+2\shoutline)+0)*
+ % (2(\htotal+\thickoffset+\shoutline))
+ {\vbox{\vbox to0pt{\vss\q_vcrop\kern3mm}%
+ \hrule height\shoutline depth0pt
+ \hbox{\hbox to0pt{\hss\q_hcrop\kern3mm}%
+ \vrule width\shoutline
+ #1%
+ \kern\q_thickoffset
+ \q_fold
+ \kern\q_thickoffset
+ #2%
+ \vrule width\shoutline
+ \hbox to0pt{\kern3mm\q_hcrop\hss}%
+ }%
+ \hrule height\shoutline depth0pt
+ \vbox to0pt{\kern3mm\q_vcrop\vss}%
+ }%
+ }
+
+% \fold returns an hbox containing the two `staples'. The hbox has
+% width 0 so that it does not interfere with the separation between
+% double pages.
+
+\def\q_fold % return = an hbox (\vtotal+0)*0
+ {\hbox to0pt
+ {\divide\vtotal by 4
+ \advance\vtotal by-0.5\shstaplelength
+ \hss
+ \vbox{\kern\vtotal
+ \hrule width\shstaplewidth height\shstaplelength depth0pt
+ \kern 2\vtotal
+ \hrule width\shstaplewidth height\shstaplelength depth0pt
+ \kern\vtotal
+ }%
+ \hss
+ }%
+ }
+
+% \vcrop returns an hbox containing the three vertical crop marks,
+% \hcrop a vbox with the two horizontal marks.
+
+\def\q_vcrop % return = an hbox (15mm+0)*(2(\htotal+\thickoffset+\shoutline))
+ {\hbox{\kern\shoutline
+ \hbox to0pt{\vrule height15mm depth0pt width\shcrop\hss}%
+ \kern\htotal \kern\q_thickoffset
+ \hbox to0pt{\hss\vrule height15mm depth0pt width\shcrop\hss}%
+ \kern\q_thickoffset \kern\htotal
+ \hbox to0pt{\hss\vrule height15mm depth0pt width\shcrop}%
+ \kern\shoutline
+ }%
+ }
+
+\def\q_hcrop % return = a vbox (vtotal+0)*15mm
+ {\vbox{\vbox to0pt{\hrule width15mm height\shcrop depth0pt\vss}%
+ \nointerlineskip
+ \kern\vtotal
+ \vbox to0pt{\vss\hrule width15mm height\shcrop depth0pt}%
+ }%
+ }
+
+
+%%%%% Shipout routines
+% Suppose Q is the number of pages per quire (rounded upwards to the
+% nearest multiple of 4), then there are Q/2 sheets per quire. The first
+% Q/2 pages have to be stacked, which is done by the shipout routine
+% \collect. The next Q/2 pages have to be combined with the stacked ones
+% into double pages, which are then printed. This is done by the shipout
+% routine \combine. \goal is the number Q/2, \sheetnr is used to count the
+% sheets of the current quire, \qnr counts sheets in completed quires
+% (\count0 is set to the actual sheet number when a sheet is shipped out).
+% The current shipout routine is held in \ship, \shipbox is the box
+% that must be shipped out. \oldship is the original \shipout.
+% In order to print partial quires if there is not enough memory to
+% store Q/2 pages, the user can specify a range of sheets that should
+% be printed. This range is tested with \ifrange; sheets that fall
+% outside the range are counted, but otherwise ignored.
+%
+% Normally, \shipout resets \deadcycles to 0 and a call of the output
+% routine (by TeX's page-breaking mechanism) increments it. We do not
+% want to reset \deadcycles until enough pages for a quire have been
+% collected, because as long as \deadcycles is not 0, TeX will produce
+% more pages. We cannot allow it to be continuously incremented either,
+% since TeX gives an error message if it becomes too high. Therefore,
+% we set it to 1 if we need more pages. (Actually, the algorithm below
+% always requires a full quire, even if only a partial one is printed.)
+%
+% In \shfootline we want to be able to print the page number of the
+% actual pages. To save the page number, we use a ``dirty trick''
+% (the only one in these macros, as far as I can tell): we push a box
+% with the pagenumber as width on the stack. We recover the pagenumber by
+% using that width as a count, which replaces the dimen (\wd) by its
+% value in sp. The pagenumbers are also shipped out as \count1 and 2.
+
+\newcount\q_sheetnr
+\newcount\q_qnr
+
+\newif\ifq_range
+
+\newbox\q_shipbox
+
+\def\q_collect
+ {\message{[(\the\count0)]}%
+ \global\advance\q_sheetnr by1 \q_checkrange
+ \ifq_range
+ \q_push{\q_makepage{\box\q_shipbox}}%
+ \q_push{\hbox to\count0 sp{}}% dirty trick
+ \fi
+ \global\deadcycles=1
+ \ifnum\q_sheetnr=\q_goal
+ \global\q_thickoffset=0pt
+ \global\let\q_ship=\q_combine
+ \fi
+ }
+
+\def\q_combine
+ {{\ifq_range
+ \count1=\wd\q_stacktop \q_pop % \firstpageno
+ \count2=\count0 % \secondpageno
+ \ifodd\q_sheetnr % stacktop is an odd page
+ \q_print{\q_makepage{\box\q_shipbox}}{\box\q_stacktop}%
+ \else\q_print{\box\q_stacktop}{\q_makepage{\box\q_shipbox}}%
+ \fi
+ \q_pop
+ \else\message{[(\the\count0)]}%
+ \fi
+ \ifodd\q_sheetnr\global\advance\q_thickoffset by\shthickness\fi
+ \global\advance\q_sheetnr by-1 \q_checkrange
+ \ifnum\q_sheetnr=0
+ \global\advance\q_qnr by\q_goal
+ \global\let\q_ship=\q_collect
+ \global\deadcycles=\q_cycles
+ \else\global\deadcycles=1
+ \fi
+ }}
+
+\def\q_print#1#2% two page boxes
+ {{\count0=\q_qnr \advance\count0 by\q_sheetnr
+ \setbox0=\hbox to\shhtotal
+ {\hss
+ \boxmaxdepth=0pt
+ \vbox{\offinterlineskip
+ \q_doublepage{#1}{#2}%
+ \kern1pc
+ \hbox{\kern\q_thickoffset
+ \hbox to 2\htotal{\the\shfootline}%
+ }%
+ }%
+ \hss
+ }%
+ \hoffset=-1truein % defeat the annoying 1 inch offset
+ \voffset=\shvoffset
+ \ifodd\count0
+ \advance\hoffset by\shhcorrection
+ \advance\voffset by\shvcorrection
+ \fi
+ \q_oldship\box0
+ \xdef\q_cycles{\the\deadcycles}%
+ }}
+
+
+%%%%% shipout
+% This is perhaps the most obscure part, although it actually has little
+% to do with the problem at hand.
+% What I would have liked to do is define the above \collect and \combine
+% as taking a parameter #1 and then use #1 instead of \shipbox. Then
+% we could just say \let\shipout=\collect etc. Unfortunately, that doesn't
+% work: The actual \shipout is not a macro but a built-in command that
+% must be followed by a <box>. As a result, \shipout\box0 works
+% fine, but \shipout{\box0} generates an error (because the first `{' is
+% not the start of a <box>). On the other hand, \collect\box0 would make
+% #1 -> \box instead of \box0, and therefore wouldn't work; only
+% \collect{\box0} would work. It really seemed highly preferrable to make
+% the shipout replacements work in the same way as the original. Therefore,
+% \boat will read a box and put it in \shipbox, and then call \ship.
+% This has the additional advantage that the box is actually constructed
+% before the shipout replacement does anything (if you do
+% \collect{\hbox {...}} the box is only constructed when #1 is used).
+% The routine \boat must be followed by a <box> because of the \setbox.
+% Again, I would have liked to do
+% \def\boat{\afterassignment\ship\setbox\shipbox=}
+% but \afterassignment behaves different for a <box> of the form
+% \hbox {...} than for one of the form \box0. \tstship tests whether
+% the assignment has actually taken place, or whether we are at the
+% beginning of an \hbox {<here> ...} etc. This way of testing
+% is not perfect, it doesn't work if you try to ship out a void box. However,
+% that is a strange thing to do, and this is by far the easiest solution
+% I could come up with.
+
+\def\q_boat
+ {{\setbox255=\box\q_shipbox}% makes \shipbox void
+ \afterassignment\q_tstship
+ \global\setbox\q_shipbox= % \boat must be followed by a <box>
+ }
+
+\def\q_tstship
+ {\ifvoid\q_shipbox\aftergroup\q_ship
+ \else\q_ship
+ \fi
+ }
+
+%%%%% Public routines for making quires
+% The routine that sets up printing quires is \makequire. It takes 3
+% arguments, the number of pages per quire (Q before rounding), the
+% number of the first sheet in the printing range, and the extend
+% (in sheet numbers) of the printing range. It uses these numbers to
+% define \checkrange, used by the output routines.
+% If there is sufficient memory to print a full quire, then \quire
+% can be used instead of \makequire. \quire only takes the number of
+% pages.
+
+\def\q_init
+ {\global\q_sheetnr=0\global\q_qnr=0
+ \global\let\q_oldship=\shipout
+ \global\let\shipout=\q_boat
+ \xdef\q_cycles{\the\deadcycles}%
+ \global\let\endquire=\q_endquire
+ }
+
+\def\makequire#1#2#3% #1 = nr of pages, #2 = first sheet, #3 = size of range
+ {{\count0=#1%
+ \advance\count0 by3 \divide\count0 by4 \multiply\count0 by2
+ \xdef\q_goal{\the\count0}%
+ \count0=#2%
+ \count1=#3\advance\count1 by\count0 \advance\count1 by-1
+ \let\nox=\noexpand
+ \xdef\q_checkrange
+ {\nox\ifnum \q_sheetnr < \the\count0
+ \nox\global\nox\q_rangefalse
+ \nox\else\nox\ifnum \the\count1 < \q_sheetnr
+ \nox\global\nox\q_rangefalse
+ \nox\else \nox\global\nox\q_rangetrue
+ \nox\q_parity
+ \nox\fi\nox\fi
+ }%
+ \q_init
+ \global\let\q_ship=\q_collect
+ }}
+
+\def\quire#1% #1 = nr of pages
+ {\makequire{#1}{0}{1000}%
+ }
+
+% \endquire can be used to finish the quire before the end of the
+% input is reached. It ships out the current page, then ships out empty
+% boxes until the quire is finished.
+
+\let\endquire=\relax % if \endquire is used when \quire is not
+
+\def\q_endquire
+ {{\vfill\supereject
+ \loop
+ \ifnum\q_sheetnr>0 \shipout\vbox{}%
+ \repeat
+ \global\let\shipout=\q_oldship
+ }}
+
+% Normally both even and odd sheets are printed. However, one can surpress
+% one class by using \shonly#1. If #1 = 0, both are printed. Otherwise
+% only sheets with the same parity as #1 are printed.
+
+\def\shonly#1% a number
+ {\ifnum #1=0
+ \gdef\q_parity{}%
+ \else\ifodd#1%
+ \gdef\q_parity{\ifodd\q_sheetnr\else\global\q_rangefalse\fi}%
+ \else\gdef\q_parity{\ifodd\q_sheetnr\global\q_rangefalse\fi}%
+ \fi\fi
+ }
+
+% In LaTeX, \end is redefined to set \deadcycles to 0 before it does the
+% actual \end. This means that the quire is not actually finished if the
+% text doesn't have enough pages (see the earlier discussion about
+% \deadcycles). You cannot solve this by using \endquire, because then
+% not all output is actually finished (also because of various LaTeX
+% definitions). Therefore, in \latexquire, we redefine \@@end, which is
+% what LaTeX thinks is the original \end, to do an \endquire just before
+% the actual \end.
+
+{
+\catcode`@=11
+\gdef\latexquire
+ {\global\let\q_end=\@@end
+ \gdef\@@end{\endquire\q_end}%
+ }
+}
+
+%%%%% Some extras
+% Quires are not so easy to preview. Therefore we also define
+% \qtwopages for printing double pages (without reordening them) and
+% \qonepage for printing single pages (with outlines etc.). Most of
+% the needed routines were already there anyway.
+% \two is the shipout routine used for \qtwopages. It uses \qnr to
+% count pages, \sheetnr to distinguish between the first and the second
+% page of a pair. (We count with \qnr because \endquire wants \sheetnr
+% to be 0 at the end. But note that \parity looks at \sheetnr to determine
+% whether the page must be printed.
+
+\def\q_two
+ {{\ifodd\q_sheetnr % second page
+ \global\q_sheetnr=0
+ \ifq_range
+ \count1=\wd\q_stacktop \q_pop % \firstpageno
+ \count2=\count0 % \secondpageno
+ \q_print{\box\q_stacktop}{\q_makepage{\box\q_shipbox}}%
+ \q_pop
+ \else\message{[(\the\count0)]}%
+ \fi
+ \global\deadcycles=\q_cycles
+ \else % first page
+ \message{[(\the\count0)]}%
+ \global\advance\q_qnr by1
+ \global\q_sheetnr=\q_qnr
+ \global\q_rangetrue \q_parity
+ \ifq_range
+ \q_push{\q_makepage{\box\q_shipbox}}%
+ \q_push{\hbox to\count0 sp{}}% that same dirty trick again
+ \fi
+ \global\deadcycles=1
+ \global\q_sheetnr=1
+ \fi
+ }}
+
+\def\qtwopages
+ {\q_init
+ \global\let\q_ship=\q_two
+ \global\q_thickoffset=0pt
+ }
+
+% \one is the output routine for \qonepage. \qnr is used to count
+% the pages (again because of \endquire).
+
+\def\q_one
+ {{\global\advance\q_qnr by1
+ \global\q_sheetnr=\q_qnr
+ \global\q_rangetrue \q_parity
+ \global\q_sheetnr=0
+ \ifq_range
+ \count1=\count0 \count2=0
+ \divide\htotal by2
+ \q_print{\q_makepage{\box\q_shipbox}}{\q_makepage{}}%
+ \else\message{[(\the\count0)]}%
+ \fi
+ \global\deadcycles=\q_cycles
+ }}
+
+\def\qonepage
+ {\q_init
+ \global\let\q_ship=\q_one
+ \global\q_thickoffset=0pt
+ \global\let\q_fold=\relax
+ }
+
+% restore \catcode`_ to whatever it was
+
+\catcode`_=\shoutline
+
+\countdef\firstpageno=1
+\countdef\secondpageno=2
+
+\shonly0 % to make sure that \parity is defined
+
+%%%%% Initial values for user parameters
+
+\shfootline={\tenrm\qquad\jobname\qquad\number\count0{} (\number\count1,
+ \number\count2)\hfil}
+
+\shhtotal=22in
+\shthickness=.2mm
+\shvcorrection=0pt
+\shhcorrection=0pt
+
+\shvoffset=0pt
+\shoutline=1.5pt
+\shstaplewidth=1.5pt
+\shstaplelength=2cm
+\shcrop=3pt
+
+\vorigin=1in
+\horigin=1in
+
+\htotal=8.5in
+\vtotal=11in
+
+%%%%% Local definitions
+% The above is the standard file quire.tex.
+% CHANGE: What follows are local definitions; you should replace them with
+% appropriate values for your own installation.
+
+\def\Pmaser
+ {\shhtotal=220.02true mm
+ \shthickness=0.21true mm
+ \message{maser: flip paper so that short sides remain in place, %
+ align closest right-hand corner in tray.}%
+ }
+
+\def\Pmaserlandscape
+ {\shhtotal=281true mm
+ \shthickness=0.21true mm
+ \message{maser landscape: flip paper so that long sides remain in place, %
+ align closest right-hand corner in tray.}%
+ }
+
+\def\Phaser
+ {\shhtotal=216.4truemm
+ \shthickness=0.21truemm
+ \message{haser: rotate (but do not flip) pages 180 degrees, and reorder.}
+ }
+
+\def\Phaserlandscape
+ {\shhtotal=283truemm
+ \shthickness=0.21truemm
+ \message{haser landscape: do not flip or rotate pages, but reorder them.}
+ }
diff --git a/Master/texmf-dist/tex/generic/midnight/styledef.tex b/Master/texmf-dist/tex/generic/midnight/styledef.tex
new file mode 100644
index 00000000000..0bb95cbc27d
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/midnight/styledef.tex
@@ -0,0 +1,208 @@
+\ifx\STYLEDEF\relax\endinput\else\let\STYLEDEF=\relax\fi % \input only once
+%
+% styledef.tex: Macros to selectively input parts of a file.
+% version: 1.0 release: 16 April 1991
+%
+% copyright (c) 1991 Marcel R. van der Goot
+% You can use these macros to typeset documents. You may
+% distribute this file freely, provided that you also distribute
+% the accompanying documentation.
+% You may make changes to this file, or extract portions
+% of it for inclusion in other files, provided that
+% (1) you change the name of the file;
+% (2) you give proper credit and include copyright
+% information where applicable;
+% (3) explain how an unchanged version can be obtained; and
+% (4) document the usage of your macros/changes (if usage
+% of your macros is not worth documenting, they must not
+% be worth using).
+% You are not allowed to use the name ``Midnight Macros'' for
+% any changed files.
+% The above rules for making changes do not apply where it
+% is explicitly noted in this file that something can be changed
+% to conform to your local installation.
+%
+% USAGE:
+% See the file styledef.doc.
+% You need Midnight/dolines.tex and Midnight/loop.tex to use these macros.
+%
+% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
+% (use anonymous ftp). Also in various archives.
+%
+% Caltech, Pasadena --- Marcel van der Goot
+% marcel@cs.caltech.edu
+% Caltech 256--80
+% Pasadena, CA 91125
+% USA
+% (818) 356--4603
+%
+
+% update history:
+% version 1.0: This one.
+% release 16 April 1991: the original (this one)
+%
+
+%%%%%% CODE: (you don't need to read this to use the macros)
+
+\edef\next{\the\catcode`\_} % to remember that catcode
+\catcode`\_=11 % 11=letter (for private macros)
+
+%%%%%%%%%%%%%%%%%%%% the current style list
+% A style list is represented by a token register. The register is either
+% empty or contains a sequence of words separated by single commas (no spaces).
+% A non-empty list starts with a comma. A list denotation is a list of words
+% separated by commas and spaces.
+% \setstyle#1#2. makes style list reg #1 equal to #2 (a list denotation),
+% \addstyle#1#2. adds the list #2 to the list register #1.
+
+\let\newstyle=\newtoks
+
+\def\setstyle#1#2% #1 a token reg, #2 a list denotation
+ {#1={}%
+ \make_stylelist#1#2 .% space before the dot
+ }
+
+\def\addstyle#1#2% #1 a token reg, #2 a list denotation
+ {\make_stylelist#1#2 .% space before the dot
+ }
+
+%%%%%%%%%%%%%%%%%%%% reading a style list denotation
+% \make_stylelist takes as first argument the name of a token register.
+% Following that name there should be a list of words separated by spaces
+% and/or commas, terminated by ` .' (a space and a dot). It constructs
+% the corresponding style list in #1.
+% \make_stylelist takes the sequence up till the first space, calls
+% \nocomma_stylelist with that sequence, and recurses with the sequence after
+% the first space. \nocomma_stylelist works similarly, but strips a comma
+% rather than a space. (Note: separation by single commas without spaces
+% is slightly more efficient.)
+
+\def\eat_style#1.{} % skip everything till first dot
+
+\def\make_stylelist#1#2 #3.% #1=name of list; #2#3=list ending in ` .'
+ {\if.#2.\else\nocomma_stylelist#1#2,.\fi
+ \if.#3.\let\style_tmp=\eat_style
+ \else\let\style_tmp=\make_stylelist
+ \fi
+ \style_tmp#1#3.%
+ }
+
+\def\nocomma_stylelist#1#2,#3.% #1=name of list; #2#3=list ending in `,.'
+ {\if.#2.\else#1=\expandafter{\the#1,#2}\fi
+ \if.#3.\let\style_tmp=\eat_style
+ \else\let\style_tmp=\nocomma_stylelist
+ \fi
+ \style_tmp#1#3.%
+ }
+
+%%%%%%%%%%%%%%%%%%%% determining whether lists intersect
+% \isect_style is used to check whether two lists have a non-empty
+% intersection. The switch \if_style will be set to indicate whether
+% the lists intersect.
+% \style_member takes two arguments, a style list register and a word.
+% It sets the switch if the word is in the style list. This check is done
+% by TeX's pattern match mechanism rather than through word-by-word comparison:
+% To check for the presence of word `xyz' a macro `\style_tmp#1,xyz,#2.' is
+% defined. If it is called as `\style_tmp<list>,xyz,.' where <list> is the
+% contents of the style list, then #2 will not be empty if and only if the
+% pattern `,xyz,' is part of <list>, i.e., iff `xyz' is in the list.
+% \doisect_style calls \style_member repeatedly for each word in the second
+% list.
+
+\newif\if_style
+
+\def\style_member#1#2% #1 a style list (token reg), #2 a word
+ {\def\style_tmp##1,#2,##2.{\check_style{##2}}%
+ \expandafter\style_tmp\the#1,#2,.%
+ }
+
+\def\check_style#1% check whether #1 is empty
+ {\if.#1.\else\_styletrue\fi
+ }
+
+\def\doisect_style#1,#2,#3.% #1=reg, #2#3=expansion of list reg ending in ,.
+ {\if.#2.\else\style_member#1{#2}\fi
+ \if_style\let\style_tmp=\eat_style
+ \else\if.#3.\let\style_tmp=\eat_style
+ \else\let\style_tmp=\doisect_style
+ \fi \fi
+ \style_tmp#1,#3.%
+ }
+
+\def\isect_style#1#2% two list regs
+ {\_stylefalse
+ \expandafter\doisect_style\expandafter#1\the#2,,.% extra comma for #2={}
+ }
+
+%%%%%%%%%%%%%%%%%%%% including a style
+% \readstyle takes a style list register and a filename. It puts the style list
+% in \style_list, then inputs the file.
+% \skip_style skips everything till the next \endstyle. It uses
+% dolines.tex to read the input line-by-line. To make that possible,
+% the grouping characters are disabled (because they must balance on a line),
+% the comment char is disabled (because it causes wraparound), the argument
+% character is disabled (because a macro is defined that has the line as
+% body --- it should not have undeclared arguments in the body), and the
+% escape character is disabled (not to prevent expansion, but to prevent lines
+% containing an `outer' control sequence). Note: If you wanted a real
+% ``comment environment,'' you should set all catcodes of all characters to
+% 11 or 12.
+% \styledef and \negstyledef have list denotations as arguments. They create
+% a list \style_other, then skip based on the intersection of \style_other
+% and \style_list. If no skip is done, \endstyle is equivalent to \relax.
+% \savereadstyle and \setreadstyle serve to access the protected \style_list
+% register.
+
+\input dolines
+
+\newtoks\style_list
+\newtoks\style_other
+
+\def\readstyle#1#2% #1 a token reg, #2 a filename
+ {\style_list=#1%
+ \input#2 % significant space (sometimes)
+ }
+
+\def\savereadstyle#1% a style (token) reg
+ {#1=\style_list}
+
+\def\setreadstyle#1% a style reg
+ {\style_list=#1}
+
+{\catcode`\/=0 /catcode`/\=12 % see dolines.doc
+ /gdef/end_style{\endstyle}
+}
+
+\let\endstyle=\relax
+
+\def\skip_style
+ {\begingroup
+ \let\beforelines=\relax
+ \let\afterlines=\relax
+ \def\everyline##1{}%
+ \let\enddolines=\end_style
+ \let\finishdolines=\endgroup
+ \catcode`\{=12 \catcode`\}=12 \catcode`\%=12
+ \catcode`\#=12 \catcode`\\=12
+ \begindolines
+ }
+
+\def\styledef#1% #1 a list denotation
+ {\style_other={}%
+ \make_stylelist\style_other#1 .% space before dot
+ \isect_style\style_list\style_other
+ \if_style
+ \else\expandafter\skip_style
+ \fi
+ }
+
+\def\negstyledef#1% #1 a list denotation
+ {\style_other={}%
+ \make_stylelist\style_other#1 .% space before dot
+ \isect_style\style_list\style_other
+ \if_style\expandafter\skip_style\fi
+ }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\catcode`\_=\next