blob: 2ab853e35f0211eeb6a5cce8e4c4e010ba7d407a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
%%
%% This is file `dvgloss.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% dvgloss.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2013 by Dan Bridges Velleman
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.2 of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.2 or later is part of all distributions of
%% LaTeX version 1999/12/01 or later.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dvgloss}[2012/08/06 v0.1 Flexible glossing commands]
\newtoks\ta\newtoks\tb
\newdimen\glhangindent\glhangindent=2em
\newdimen\betweenglskip\betweenglskip=1\jot
\newdimen\withinglskip\withinglskip=0pt
\newdimen\aboveglftskip\aboveglftskip=2\jot
\newdimen\aboveglskip\aboveglftskip=2\jot
\newdimen\glstrutheight\newdimen\glstrutdepth
\def\glspace{\penalty0\hspace{1ex plus 2em minus 2pt}}
\def\everygla{\itshape}
\def\everyglb{}
\def\glescape{!}
\long\def\addtokens#1\to#2{\ta={#1}\tb=\expandafter{#2}\edef#2{\the\tb\the\ta}}
\def\pop#1\to#2{\expandafter\popoff#1\to#2\remainderin#1}
\long\def\popoff#1 #2\to#3\remainderin#4{#3={#1}\def#4{#2}}
\long\def\split#1{\expandafter\ssplit#1\xyzzy}
\long\def\ssplit#1#2\xyzzy{\gdef\istchar{#1}\gdef\restchars{#2}}
\def\ifnotin#1#2{%
\def\@ifnotin##1#1##2##3\zyzzy{\ifx\ifnotfound##2}%
\expandafter\@ifnotin#2#1\notfound\zyzzy}
\newif\ifspecial
\def\dvglspecials{}
\def\checkspecial#1{%
\ifnotin#1{\dvglspecials}\specialfalse\else\specialtrue\fi}
\def\makespecial#1{%
\xdef\dvglspecials{\dvglspecials#1}}
\def\glossword#1#2{%
\mbox{\vtop{\halign{##\hfil\cr\everygla#1\strut\cr\everyglb#2\strut\cr}}}%
\glstrut\glspace}
\def\zipper#1\and#2\to#3{%
\ifx\empty#1\else%
\pop#1\to\ta%
\def\istchar{}\def\restchar{}%
\edef\temp{\the\ta}\split\temp%
\ifx\istchar\glescape\expandafter\addtokens\restchars\to#3%
\else%
\expandafter\checkspecial\istchar\ifspecial%
\expandafter\addtokens\csname gl\istchar\endcsname\to#3%
\expandafter\addtokens\expandafter<\restchars>\to#3%
\else
\ifx\empty#2\else%
\pop#2\to\tb%
\edef\temp{\noexpand\glossword{\the\ta}{\the\tb}}%
\expandafter\addtokens\temp\to#3%
\fi%
\fi%
\fi%
\zipper#1\and#2\to#3%
\fi%
}
\long\def\gl#1#2{%
\begingroup%
\def\x{#1 }\def\y{#2 }\def\z{}%
\zipper\x\and\y\to\z%
\fixglstrut%
\ifvmode\vskip\aboveglskip\fi\z%
\endgroup%
}
\def\fixglstrut{%
\def\glstrut{}%
\setbox0=\hbox{\glossword{}{}}%
\glstrutheight=\ht0%
\glstrutdepth=\dp0%
\advance\glstrutdepth by \betweenglskip%
\global\edef\glstrut{\vrule height\glstrutheight width0pt depth\glstrutdepth}}
\def\noglstrut{\def\glstrut{}}
\def\ft#1{\nobreak\par\nobreak\vskip-\betweenglskip\vskip\aboveglftskip #1}
\def\lb#1{{\unskip\nobreak\hfil\penalty0\hskip2em\mbox{}\nobreak\hfill\mbox{#1}}}
\long\def\makeglshortcut#1#2{%
\makespecial{#1}%
\expandafter\gdef\csname gl#1\endcsname<##1>{#2}}
\makeglshortcut/{\par\ifx#1\empty\else\vskip{#1}\fi}
\makeglshortcut[{[$_\textrm{\footnotesize#1}$\thinspace}
\makeglshortcut]{\unskip\thinspace]$_\textrm{\footnotesize#1}$\glspace}
\long\def\makeglsurround#1#2#3{%
\xdef\dvglspecials{\dvglspecials#1#2}%
\ta=\expandafter{\csname gl#1\endcsname}%
\tb=\expandafter{\csname gl#2\endcsname}%
\expandafter\expandafter\expandafter\gdef%
\expandafter\expandafter\the\ta%
\expandafter<\expandafter##\expandafter1\expandafter>%
\expandafter##\expandafter2\the\tb<##3>{#3}}
\makeglsurround ** {%
\rlap{\raisebox{1.5em}{\footnotesize\sf#3}}%
\fbox{\noglstrut#2\unskip}\glspace}
\endinput
%%
%% End of file `dvgloss.sty'.
|