-
Notifications
You must be signed in to change notification settings - Fork 8
/
00.textpos.sty
419 lines (418 loc) · 12.5 KB
/
00.textpos.sty
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
%%
%% This is file `textpos.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% textpos.dtx (with options: `package')
%% Textpos: absolute positioning of text on the page
%%%% File: textpos.dtx
%%%% Copyright 1999-2020, Norman Gray
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% https://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Norman Gray <https://nxg.me.uk>
%%
%% This work consists of the files textpos.dtx and textpos.ins,
%% and the derived file textpos.sty.
%%
%% Author: Norman Gray, [email protected]
%% Department of Physics and Astronomy, University of Glasgow, UK
%%
%% See the file LICENCE for a copy of the LPPL.
%%
%% Mercurial ident: 1.10.1 (@VCSINFO)
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{textpos}[2022/07/23 v1.10.1]
\newif\ifTPshowboxes
\TPshowboxesfalse
\DeclareOption{showboxes}{\TPshowboxestrue}
\newif\ifTP@showtext
\TP@showtexttrue
\DeclareOption{noshowtext}{\TP@showtextfalse}
\newif\ifTP@abspos
\TP@absposfalse
\DeclareOption{absolute}{\TP@abspostrue}
\DeclareOption{relative}{\TP@absposfalse}
\newif\ifTP@overlay
\TP@overlayfalse
\DeclareOption{overlay}{\TP@overlaytrue}
\newif\ifTP@chatter
\TP@chattertrue
\DeclareOption{quiet}{\TP@chatterfalse}
\DeclareOption{verbose}{\TP@chattertrue}
\newif\ifTP@displayholdbox
\TP@displayholdboxtrue
\DeclareOption{discardcontent}{\TP@displayholdboxfalse}
\ProcessOptions
\newif\ifTP@Liii
\@ifl@t@r\fmtversion{2020/10/01}\TP@Liiitrue\TP@Liiifalse
\PackageInfo{textpos}{choosing support for \ifTP@Liii LaTeX3\else LaTeX2e\fi}
\ifTP@Liii\else
\ifTP@abspos
\RequirePackage{everyshi}
\fi
\fi
\RequirePackage{keyval}
\define@key{tp}{absolute}{\csname TP@abspos#1\endcsname}
\define@key{tp}{overlay}{\PackageWarning{textpos}{The overlay option
to TPoptions is not implemented and has been ignored}}
\define@key{tp}{verbose}{\csname TP@chatter#1\endcsname}
\define@key{tp}{showboxes}{\csname TPshowboxes#1\endcsname}
\define@key{tp}{showtext}{\csname TP@showtext#1\endcsname}
\define@key{tp}{discardcontent}{%
\csname @tempswa#1\endcsname
\if@tempswa\TP@displayholdboxfalse\else\TP@displayholdboxtrue\fi}
\def\TPoptions{\setkeys{tp}}
\def\TP@xfloat#1[#2]{
\par\def\@captype{#1}%
\@floatpenalty\z@
\color@vbox
\normalcolor
\vbox\bgroup
}
\def\TP@xympar{
\PackageError{textpos}
{You can't use \protect\marginpar\space within a textblock}
{You're using textpos because you _don't_ want things to float around, yes?}}
\newbox\TP@textbox
\newif\ifTP@vmode
\ifTP@abspos
\newbox\TP@holdbox % starts off void
\AtEndDocument{\ifTP@displayholdbox\ifvoid\TP@holdbox \else \hbox{}\fi\fi}
\fi
\newdimen\TPHorizModule
\newdimen\TPVertModule
\newdimen\TP@margin
\TP@margin=0pt
\newdimen\TP@absmargin
\TP@absmargin=0pt
\newcommand{\TPMargin}{%
\@ifstar\TPMargin@outer\TPMargin@inner
}
\newcommand{\TPMargin@inner}[1]{%
\TP@margin=#1\relax
\ifdim\TP@margin < 0pt
\PackageError{textpos}
{\protect\TPMargin\space must have a positive argument}
{\protect\TPMargin\space must have a positive argument}
\fi
\TP@absmargin=\TP@margin
}
\newcommand\TPMargin@outer[1]{%
\TP@margin=-#1\relax
\ifdim\TP@margin > 0pt
\PackageError{textpos}
{\protect\TPMargin*\space must have a positive argument}
{\protect\TPMargin*\space must have a positive argument}
\fi
\TP@absmargin=-\TP@margin
}
\def\TPGrid{%
\@ifnextchar[{\@tempswatrue\TP@Grid}{\@tempswafalse\TP@Grid[0pt,0pt]}}
\def\TP@Grid[#1,#2]#3#4{
\setlength{\@tempdima}{#1}
\multiply\@tempdima by 2
\TPHorizModule=\paperwidth
\advance\TPHorizModule by -\@tempdima
\divide\TPHorizModule by #3
\setlength{\@tempdima}{#2}
\multiply\@tempdima by 2
\TPVertModule=\paperheight
\advance\TPVertModule by -\@tempdima
\divide\TPVertModule by #4
\ifTP@chatter
\typeout{Grid set #3 x #4 = \the\TPHorizModule\space x \the\TPVertModule}%
\fi
\ifTP@abspos\if@tempswa \textblockorigin{#1}{#2}\fi\fi
}
\TPGrid{16}{16}
\newdimen\TPboxrulesize
\setlength{\TPboxrulesize}{0.4pt}
\def\showtextsize{\normalsize}
\def\TPShowGrid{\@ifstar{\@tempswatrue\@TPShowGrid}{\@tempswafalse\@TPShowGrid}}
\def\@TPShowGrid#1#2{
\begin{textblock}{#1}(0,0)
\lineskip=0pt % abut boxes directly
\setbox0=\hbox{(0)}%
\@tempdima=\TPVertModule
\advance\@tempdima -1.1\ht0
\@tempcnta=0
\hrule
\loop
\vbox to \TPVertModule{\noindent
\@tempcntb=0
\vrule
\loop
\hbox to \TPHorizModule{%
\if@tempswa\raise\@tempdima\hbox{(\the\@tempcntb,\the\@tempcnta)}\fi
\hfil \vrule height \TPVertModule}%
\advance\@tempcntb 1
\ifnum\@tempcntb<#1 \repeat
\vss \hrule}
\advance\@tempcnta 1
\ifnum\@tempcnta<#2 \repeat
\end{textblock}}
\ifTP@abspos
\newdimen\TP@ox
\newdimen\TP@oy
\fi
\def\textblockorigin#1#2{%
\ifTP@abspos
\TP@ox=-1in \addtolength\TP@ox{#1}
\TP@oy=-1in \addtolength\TP@oy{#2}
\ifTP@chatter\typeout{TextBlockOrigin set to #1 x #2}\fi
\else
\PackageError{textpos}
{The \protect\textblockorigin\space command\MessageBreak
may only be used if the package was given\MessageBreak
the`absolute' option when it was invoked}
{If you want to use the \protect\textblockorigin\space command, then
\MessageBreak
invoke the package with the syntax\MessageBreak
\protect\usepackage[absolute]{textpos}}
\fi
}
\def\textblocklabel#1{\gdef\TP@textblocklabel{#1}}
\def\textblockcolour#1{%
\@ifundefined{color}%
{\PackageWarning{textpos}{command textblockcolour used,\MessageBreak
but {color} package not loaded.\MessageBreak
Colour changes ignored.}}
{\gdef\TP@blockcolour{#1}
\ifx\TP@defaultblockcolour\@undefined
\gdef\TP@defaultblockcolour{#1}
\fi
}}
\def\TP@blockcolour{} % safe initial default
\let\textblockcolor\textblockcolour
\let\tekstblokkulur\textblockcolour
\def\textblockrulecolour#1{%
\@ifundefined{color}%
{\PackageWarning{textpos}{command textblockrulecolour used,\MessageBreak
but {color} package not loaded.\MessageBreak
Colour changes ignored.}}
{\gdef\TP@rulecolour{#1}}}
\def\TP@rulecolour{black}
\let\textblockrulecolor\textblockrulecolour
\let\tekstblokroolkulur\textblockrulecolour
\gdef\TP@color[#1]#2{}
\def\TP@dummycolorpackage{
\@ifundefined{color}
{\globaldefs=1
\DeclareRobustCommand\color[2][]{}
\def\color@block##1##2##3{}
\globaldefs=0 }
{}
}
\ifTP@Liii
\AddToHook{env/document/before}{\TP@dummycolorpackage}
\AddToHook{file/color.sty/after}{\let\TP@dummycolorpackage\relax}
\else
\AtBeginDocument{\TP@dummycolorpackage}
\fi
\def\TP@referenceposition{0,0}
\def\TPReferencePosition#1{\def\TP@referenceposition{#1}}
\def\textblock#1{%
\@tempdima=#1\TPHorizModule
\TP@begintextblock
}
\def\TP@textblockstar#1{%
\setlength{\@tempdima}{#1}%
\TP@begintextblock
}
\expandafter\let\csname textblock*\endcsname\TP@textblockstar
\def\TP@begintextblock{%
\ifvmode
\TP@vmodetrue
\else
\ifmmode
\PackageError{textpos}
{You cannot use textblock in maths mode}
{You may use the textblock environment only in \MessageBreak
vertical mode or horizontal mode. You cannot use it in maths mode.}
\else % in horizontal mode
\TP@vmodefalse
\@bsphack
\unskip
\fi
\fi
\@ifnextchar[{\TP@textblock}{\expandafter\TP@textblock\expandafter[\TP@referenceposition]}%] bracematch
}
\newtoks\TP@tbargs
\def\TP@textblock[#1,#2](#3,#4){%
\TP@tbargs={{#1}{#2}{#3}{#4}}%
\let\@xfloat\TP@xfloat
\let\@xympar\TP@xympar
\setbox\TP@textbox=\vbox\bgroup
\ifTPshowboxes
{\color{\TP@rulecolour}\hrule height0pt depth \TPboxrulesize }%
\vskip-\TPboxrulesize
\fi
\ifdim\TP@margin = 0pt
\hsize=\@tempdima
\textwidth\hsize \columnwidth\hsize \linewidth\hsize
\else
\vskip\TP@absmargin
\@tempdimb=\@tempdima % \@tempdimb is outer box width
\hsize=\@tempdima % \hsize is inner box width
\ifdim\TP@margin < 0pt
\advance\@tempdimb by 2\TP@absmargin % bigger box
\else
\advance\hsize by -2\TP@absmargin % narrower content
\fi
\hbox to \@tempdimb\bgroup
\hskip\TP@absmargin\vbox\bgroup
\textwidth\hsize \columnwidth\hsize \linewidth\hsize
\fi
}
\def\endtextblock{\global\@tempswatrue\TP@commonendtextblock}
\@namedef{endtextblock*}{\global\@tempswafalse\TP@commonendtextblock}
\def\TP@commonendtextblock{%
\ifdim\TP@margin = 0pt
\relax
\else
\egroup % end of inner vbox
\hskip\TP@absmargin % (just \hfil would work here, too)
\egroup % end of inner hbox
\vskip\TP@absmargin
\fi
\ifTPshowboxes
\vskip-\TPboxrulesize
{\color{\TP@rulecolour}\hrule depth 0pt height \TPboxrulesize}%
\fi
\egroup % end of \TP@textbox
\expandafter\TP@endtextblock\the\TP@tbargs
}
\def\TP@endtextblock#1#2#3#4{%
\if@tempswa % modular/unstarred endtextblock
\@tempdima=#3\TPHorizModule
\@tempdimb=#4\TPVertModule
\else % absolute/starred endtextblock
\setlength{\@tempdima}{#3}%
\setlength{\@tempdimb}{#4}%
\fi
\ifdim\TP@margin < 0pt
\advance\@tempdima \TP@margin
\advance\@tempdimb \TP@margin
\@tempdimc=\wd\TP@textbox
\advance\@tempdimc 2\TP@margin % now \@tempdimc is width of textblock
\multiply\@tempdimc #1
\advance\@tempdima -\@tempdimc
\@tempdimc=\ht\TP@textbox
\advance\@tempdimc 2\TP@margin % now \@tempdimc is height of textblock
\multiply\@tempdimc #2
\advance\@tempdimb -\@tempdimc
\else
\@tempdimc=#1\wd\TP@textbox
\advance\@tempdima -\@tempdimc
\@tempdimc=#2\ht\TP@textbox
\advance\@tempdimb -\@tempdimc
\fi
\ifTP@abspos
\advance\@tempdima by \TP@ox
\advance\@tempdimb by \TP@oy
\fi
\setbox0=\vbox to 0pt{\vskip\@tempdimb
\hbox to 0pt{\hskip\@tempdima
\ifx\TP@blockcolour\@empty \else
{\color{\TP@blockcolour}%
\color@block{\wd\TP@textbox}{\ht\TP@textbox}{\dp\TP@textbox}%
}%
\fi
\ifx\TP@defaultblockcolour\@undefined \else
\global\let\TP@blockcolour\TP@defaultblockcolour
\fi
\ifTPshowboxes
{\color{\TP@rulecolour}\vrule width \TPboxrulesize}%
\hskip -\TPboxrulesize
\fi
\ifTP@showtext
\box\TP@textbox
\else
\vbox to\ht\TP@textbox{%
\ifTPshowboxes
{\color{\TP@rulecolour}\hrule depth 0pt height \TPboxrulesize \vskip-\TPboxrulesize}%
\fi
\vskip\smallskipamount
\hbox to\wd\TP@textbox{%
\ifx\TP@textblocklabel\undefined
\hbox{}%
\else
\hskip\smallskipamount
\fbox{\showtextsize \TP@textblocklabel}%
\global\let\TP@textblocklabel\undefined
\fi
\hss
}%
\vss
\ifTPshowboxes
\vskip -\TPboxrulesize
{\color{\TP@rulecolour}\hrule depth 0pt height \TPboxrulesize}%
\fi
}%
\fi
\ifTPshowboxes
\hskip -\TPboxrulesize
{\color{\TP@rulecolour}\vrule width \TPboxrulesize}%
\fi
\hss}%
\vss
}% end of box0
\ifTP@abspos
\global\setbox\TP@holdbox\vbox{%
\unvbox\TP@holdbox
\box0
}%
\else
\ifTP@vmode
\@tempdima=\prevdepth
\prevdepth=-1000pt % = \nointerlineskip, supressing interline glue
\box0 % zero height+depth
\prevdepth=\@tempdima
\else
\vadjust{\box0}%
\@esphack
\fi
\fi
}
\ifTP@abspos
\ifTP@Liii
\ifTP@overlay
\AddToHook{shipout/foreground}{%
\ifTP@displayholdbox\put(\strip@pt\dimexpr1in,-\strip@pt\dimexpr1in){\box\TP@holdbox}\fi}
\else
\AddToHook{shipout/background}{%
\ifTP@displayholdbox\put(\strip@pt\dimexpr1in,-\strip@pt\dimexpr1in){\box\TP@holdbox}\fi}
\fi
\else
\ifTP@overlay
\EveryShipout{\ifTP@displayholdbox
\global\setbox\@cclv\vbox{%
\vbox to 0pt{\ifvbox\@cclv \unvbox\@cclv \else \box\@cclv \fi \vss}%
\unvbox\TP@holdbox % TP@holdbox is now void
}%
\fi}%
\else
\EveryShipout{\ifTP@displayholdbox
\global\setbox\@cclv\vbox{%
\unvbox\TP@holdbox
\ifvbox\@cclv \unvbox\@cclv \else \box\@cclv \fi
}%
\fi}%
\fi
\fi % ifTP@Liii
\textblockorigin{0pt}{0pt}%
\fi % ifTP@abspos
\endinput
%%
%% End of file `textpos.sty'.