summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/midnight/gloss.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/midnight/gloss.tex')
-rw-r--r--Master/texmf-dist/tex/generic/midnight/gloss.tex122
1 files changed, 122 insertions, 0 deletions
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
+ }
+