summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/plain/zztex/zzhmodeb.tex
blob: 69c92d9c1e7ae72fa5f312579a799d298b55e79a (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Module:    ZzTeX Horizontal Mode Facilities
%
% Synopsis:  This module provides various facilities that operate in
%            horizontal mode, within a paragraph.  See also ZZHMODE.
%
% Author:    Paul C. Anagnostopoulos
% Created:   11 January 1994
%
% Copyright 1989--2020 by Paul C. Anagnostopoulos
% under The MIT License (opensource.org/licenses/MIT)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%                       Basic Tools
%                       ----- -----


\def \llap #1{\hbox to 0pt{\hss #1}}%                   {text}
\def \rlap #1{\hbox to 0pt{#1\hss}}%                    {text}
\def \clap #1{\hbox to 0pt{\hss #1\hss}}%               {text}

\def \minhbox to #1#2#3#4{%             to width{text}{space-in}{space-out}
  \measuretextwidth{\tdimena}{#2\hspace{#3}}%
  \if \dimgtrp{\tdimena}{#1}%
    {#2}\hspace{#4}%
  \else
    \hbox to #1{#2\hfil}%
  \fi}

%                       Drop Capitals
%                       ---- --------


\def \dropcapital #1#2#3{%                      {height}{lines}{text}
  \setbox \zboxa = \hbox{#3}%
  \tdimena = \ht\zboxa
  \advance \tdimena by -#1\relax
  \setbox \zboxa = \hbox{\lower \tdimena \box\zboxa}%
  \dp\zboxa = 0pt
  \def \zdropshape {0pt,\naturalwidth}%
  \tcounta = #2\relax
  \loop
     \decrement \tcounta
     \if \posp{\tcounta}%
       \edef \zdropshape {\zdropshape ,\the\wd\zboxa,\naturalwidth}%
  \repeat
  \expandafter\shapepar\expandafter{\zdropshape,0pt,\naturalwidth}%
  \noindent \box\zboxa}

%                       Enclosing Text
%                       --------- ----


\def \enclose #1#2#3{%                          {thickness}{separation}{text}
  \ensurepar
  \hbox{\vrule width #1%
        \vtop{\vbox{\hrule height #1%
                    \kern #2%
                    \hbox{\kern #2#3\kern #2}}%
              \kern #2%
              \hrule height #1}%
        \vrule width #1}}

\def \colorenclose #1#2#3#4{%           {color}{thickness}{separation}{text}
  \ensurepar
  \hbox{\color{#1}\vrule width #2 \endcolor
        \vtop{\vbox{\color{#1}\hrule height #2 \endcolor
                    \kern #3%
                    \hbox{\kern #3#4\kern #3}}%
              \kern #3%
              \color{#1}\hrule height #2 \endcolor}%
        \color{#1}\vrule width #2 \endcolor}}

%                       Fractions
%                       ---------


% This macro is specifically designed to work in math mode, too.

\def \piecefraction #1{%
  \ztfrac #1/}

\def \ztfrac #1/#2/{%
  \ensurepar
  {\measuretextwidth{\tdimena}{/}%
   \raise .5ex \hbox{$\scriptstyle #1$}%
   \kern -.2\tdimena \raise .3ex \hbox{$\scriptstyle /$}\kern -.2\tdimena%
   \hbox{$\scriptstyle #2$}}}

\let \textfraction = \piecefraction             % For compatibility.

%                       Leaders
%                       -------


\def \alignedleaders #1{%                       {box-or-rule}
  \leaders #1\hfill}

\def \dotleaders {%
  \alignedleaders{\hbox to 1em{\hss.\hss}}}

\def \ruleleaders #1{%                          {rule}
  \alignedleaders{#1}}

\def \centeredleaders #1{%                      {box-or-rule}
  \cleaders #1\hfill}

\def \spreadleaders #1{%                        {box-or-rule}
  \xleaders #1\hfill}

%                       Paragraph Dingbats
%                       --------- --------


\def \pardingbat #1#2{%                         {space}{dingbat}
  {\unskip \unbreakable\hfil \allowbreak
   \hspace{#1}\retain\unbreakable\hfill
   #2%
   \finalhyphendemerits = 0 \par}}

%                       Rules
%                       -----


\def \rule #1{%                                 {dimensions}
  \if \vmodep
    \hrule #1\relax
  \else
    \vrule #1\relax
  \fi}

\def \colorrule #1#2{%                          {color}{dimensions}
  \if \vmodep
    \color{#1}
    \nobreak
    \hrule #2\relax
    \endcolor
  \else
    \color{#1}\vrule #2\relax\endcolor
  \fi}

\def \slug #1#2{%                               {width}{height}
  \rule{height #2 depth 0pt width #1}}

%                       Shapes
%                       ------


\def \rectangle #1#2#3#4{%              {rise}{width}{height}{thickness}
  {\tdimena = #2\relax
   \advance \tdimena by -#4\relax
   \advance \tdimena by -#4\relax
   \raise #1 \hbox{%
     \vrule height #3 depth 0pt width #4\relax
     \vbox to #3{%
       \hrule height #4 depth 0pt width \tdimena\relax
       \vfil
       \hrule height #4 depth 0pt width \tdimena\relax}%
     \vrule height #3 depth 0pt width #4}}}

%                       Underlining & Overstriking
%                       ----------- - ------------


\def \fakebold #1{%                                     {text}
  \hbox{\rlap{#1}%
        \rlap{\lower .009em \hbox{\kern .009em #1}}%
        \lower .018em \hbox{\kern .018em #1}}}

\def \multiunderline #1#2#3#4#5{%       {count}{drop1}{drop2}{thickness}{text}
  \ensurepar
  {\setbox\zboxa = \hbox{#5}%
   \rlap{\lower #2 \hbox{\vrule height #4 depth 0pt width \the\wd\zboxa}}%
   \tcounta = #1\relax
   \tdimena = #2\relax
   \loop
     \decrement \tcounta
     \if \posp{\tcounta}%
       \advance \tdimena by #3\relax
       \rlap{\lower \tdimena \hbox{\vrule height #4 depth 0pt
                                          width \the\wd\zboxa}}%
   \repeat
   \box\zboxa}}
  
\def \overstrike #1#2{%                                 {text1}{text2} 
  \ensurepar
  {\setbox\zboxa = \hbox{#1}%
   \setbox\zboxb = \hbox{#2}%
   \tdimena = \wd\zboxa
   \advance \tdimena by -\wd\zboxb
   \divide \tdimena by 2
   \rlap{\kern \tdimena \box\zboxb}\box\zboxa}}

\def \strikethrough #1{%                                    {text}
  \ensurepar
  {\setbox\zboxa = \hbox{#1}%
   \rlap{\raise .45ex \hbox{\vrule height .1ex depth 0pt
                                   width \the\wd\zboxa}}%
   \box\zboxa}}

\let \zunline = \underline

\def \underline #1{%                                            {text}
  \relax
  \if \mathmodep
    \zunline{#1}%
  \else
    \multiunderline{1}{.4ex}{0pt}{.1ex}{#1}%
  \fi}

%                       Vertical Centering
%                       -------- ---------


\def \centeroncapheight #1{%                            {text}
  \ensurepar
  {\setbox\zboxa = \hbox{#1}%
   \measurecapheight{\tdimena}%                 % Calculate ht(CAP) - ht(text)
   \advance \tdimena by -\ht\zboxa              %           ------------------
   \divide \tdimena by 2                        %                   2
   \raise \tdimena \box\zboxa}}

\def \centerondigitheight #1{%                          {text}
  \ensurepar
  {\setbox\zboxa = \hbox{#1}%
   \measuredigitheight{\tdimena}%               % Calculate ht(123) - ht(text)
   \advance \tdimena by -\ht\zboxa              %           ------------------
   \divide \tdimena by 2                        %                   2
   \raise \tdimena \box\zboxa}}

\def \centeronxheight #1{%                              {text}
  \ensurepar
  {\setbox\zboxa = \hbox{#1}%
   \tdimena = 1ex                               % Calculate 1ex - ht(text)
   \advance \tdimena by -\ht\zboxa              %           --------------
   \divide \tdimena by 2                        %                  2
   \raise \tdimena \box\zboxa}}