Debian Codegraph @

texmf-dist/tex/plain/graphics-pln/miniltx.tex

raw
1 %%%
2 %%%
3 %%% Parts of LaTeX: Slightly changed/simplified in places.
4 %%% Changes
5 %%% Copyright 1996-2022 David Carlisle LaTeX3 Project
6 %%% Original Code
7 %%% Copyright 1993-1996 LaTeX3 Project and original authors
8 %%%
9 %%% Problems relating to this fileshould not be sent to the LaTeX bugs address,
10 %%% or any other LaTeX related support address.
11 %%%
12 %%% Problems should be reported as issues at
13 %%% https://github.com/davidcarlisle/graphics-pln/issues
14 %%%
15 %%%
16 %%% This file may be distributed under the terms of the LPPL, see
17 %%% README.txt for details.
18
19 % 1996/01/29 initial version
20 % 1996/05/09 a few missing commands added
21 % 1996/11/21 fixed @ catcode handling
22 % 2010/01/02 import LaTeX's current \filename@parse [KB/DC]
23 % (http://sourceforge.net/projects/asymptote/forums/forum/409349/topic/3405573)
24 % 2010/01/07 import was incomplete [KB]
25 % 2010/02/03 accept *-form of \ProcessOptions [KB/DL]
26 % 2016/08/17 fix catcode @ handling (again), document github address [DC]
27 % 2017/06/01 assorted updates to cover updated latex drivers
28 % 2019/07/20 more updates for latex drivers
29 % 2020/03/02 move to own git repository and add newcommand fix from issue #2
30 % 2021/11/15 Define \@backslashchar for issue #4
31 % 2022/06/13 Define \@ehd error help (usedby color errors)
32 % Define fallback \mathcolor so color package does not require expl3
33 % 2022/09/28 Make \newdimen non-\outer for new .def files
34 % 2023/11/09Guard against \@hash@ already being let to #
35
36 \edef\resetatcatcode{\catcode`\noexpand\@\the\catcode`\@\relax}
37
38 \def\makeatletter{\catcode`\@11\relax}
39 \def\makeatother{\catcode`\@12\relax}
40 \makeatletter
41
42
43 % 2016/08/17 move after \makeatletter
44 % so \input graphicx \input color works.
45 \ifx\miniltx\undefined\else\endinput\fi
46 \let\miniltx\box
47
48 \def\@makeother#1{\catcode`#1=12\relax}
49
50
51 \def\@ifnextchar#1#2#3{%
52 \let\reserved@d=#1%
53 \def\reserved@a{#2}\def\reserved@b{#3}%
54 \futurelet\@let@token\@ifnch}
55 \def\@ifnch{%
56 \ifx\@let@token\@sptoken
57 \let\reserved@c\@xifnch
58 \else
59 \ifx\@let@token\reserved@d
60 \let\reserved@c\reserved@a
61 \else
62 \let\reserved@c\reserved@b
63 \fi
64 \fi
65 \reserved@c}
66 \begingroup
67 \def\:{\global\let\@sptoken= } \: % this makes \@sptoken a space token
68 \def\:{\@xifnch} \expandafter\gdef\: {\futurelet\@let@token\@ifnch}
69 \endgroup
70
71
72
73 \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}}
74 \long\def\@dblarg#1{\@ifnextchar[{#1}{\@xdblarg{#1}}}
75 \long\def\@xdblarg#1#2{#1[{#2}]{#2}}
76
77 \long\def \@gobble #1{}
78 \long\def \@gobbletwo #1#2{}
79 \long\def \@gobblefour #1#2#3#4{}
80 \long\def\@firstofone#1{#1}
81 \long\def\@firstoftwo#1#2{#1}
82 \long\def\@secondoftwo#1#2{#2}
83
84 \edef\@backslashchar{\expandafter\@gobble\string\\}
85
86 \def\NeedsTeXFormat#1{\@ifnextchar[\@needsf@rmat\relax}
87 \def\@needsf@rmat[#1]{}
88 \def\ProvidesPackage#1{\@ifnextchar[%
89 {\@pr@videpackage{#1}}{\@pr@videpackage#1[]}}
90 \def\@pr@videpackage#1[#2]{\wlog{#1: #2}}
91 \let\ProvidesFile\ProvidesPackage
92 \def\PackageInfo#1#2{{%
93 \newlinechar`\^^J\def\MessageBreak{^^J#1: }%
94 \wlog{#1: #2}}}
95
96 \let\DeclareOption\@gobbletwo
97 \def\ProcessOptions{\@ifstar\relax\relax}
98
99 \def\RequirePackage{%
100 \@fileswithoptions\@pkgextension}
101 \def\@fileswithoptions#1{%
102 \@ifnextchar[%]
103 {\@fileswith@ptions#1}%
104 {\@fileswith@ptions#1[]}}
105 \def\@fileswith@ptions#1[#2]#3{%
106 \@ifnextchar[%]
107 {\@fileswith@pti@ns#1[#2]#3}%
108 {\@fileswith@pti@ns#1[#2]#3[]}}
109
110 \def\@fileswith@pti@ns#1[#2]#3[#4]{%
111 \def\reserved@b##1,{%
112 \ifx\@nil##1\relax\else
113 \ifx\relax##1\relax\else
114 \noexpand\@onefilewithoptions##1[#2][#4]\noexpand\@pkgextension
115 \fi
116 \expandafter\reserved@b
117 \fi}%
118 \edef\reserved@a{\zap@space#3 \@empty}%
119 \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nil,}%
120 \reserved@a}
121
122 \def\zap@space#1 #2{%
123 #1%
124 \ifx#2\@empty\else\expandafter\zap@space\fi
125 #2}
126
127 \def\strip@prefix#1>{}
128
129 \let\@empty\empty
130 \def\@pkgextension{sty}
131
132 \def\@onefilewithoptions#1[#2][#3]#4{%
133 \input #1.#4 }
134
135
136
137 \def\typein{%
138 \let\@typein\relax
139 \@testopt\@xtypein\@typein}
140 \def\@xtypein[#1]#2{%
141 \message{#2}%
142 \advance\endlinechar\@M
143 \read\@inputcheck to#1%
144 \advance\endlinechar-\@M
145 \@typein}
146 \def\@namedef#1{\expandafter\def\csname #1\endcsname}
147 \def\@nameuse#1{\csname #1\endcsname}
148 \def\@cons#1#2{\begingroup\let\@elt\relax\xdef#1{#1\@elt #2}\endgroup}
149 \def\@car#1#2\@nil{#1}
150 \def\@cdr#1#2\@nil{#2}
151 \def\@carcube#1#2#3#4\@nil{#1#2#3}
152 \def\@preamblecmds{}
153
154 \def\@star@or@long#1{%
155 \@ifstar
156 {\let\l@ngrel@x\relax#1}%
157 {\let\l@ngrel@x\long#1}}
158
159 \let\l@ngrel@x\relax
160 \def\newcommand{\@star@or@long\new@command}
161 \def\new@command#1{%
162 \@testopt{\@newcommand#1}0}
163 \def\@newcommand#1[#2]{%
164 \@ifnextchar [{\@xargdef#1[#2]}%
165 {\@argdef#1[#2]}}
166 \long\def\@argdef#1[#2]#3{%
167 \@ifdefinable #1{\@yargdef#1\@ne{#2}{#3}}}
168 \long\def\@xargdef#1[#2][#3]#4{%
169 \@ifdefinable#1{%
170 \expandafter\def\expandafter#1\expandafter{%
171 \expandafter
172 \@protected@testopt
173 \expandafter
174 #1%
175 \csname\string#1\expandafter\endcsname
176 {#3}}%
177 \expandafter\@yargdef
178 \csname\string#1\endcsname
179 \tw@
180 {#2}%
181 {#4}}}
182 \def\@testopt#1#2{%
183 \@ifnextchar[{#1}{#1[#2]}}
184 \def\@protected@testopt#1{%%
185 \ifx\protect\@typeset@protect
186 \expandafter\@testopt
187 \else
188 \@x@protect#1%
189 \fi}
190 \let\@hash@\relax
191 \long\def\@yargdef#1#2#3{%
192 \@tempcnta#3\relax
193 \advance \@tempcnta \@ne
194 \let\@hash@\relax
195 \edef\reserved@a{\ifx#2\tw@ [\@hash@1]\fi}%
196 \@tempcntb #2%
197 \@whilenum\@tempcntb <\@tempcnta
198 \do{%
199 \edef\reserved@a{\reserved@a\@hash@\the\@tempcntb}%
200 \advance\@tempcntb \@ne}%
201 \let\@hash@##%
202 \l@ngrel@x\expandafter\def\expandafter#1\reserved@a}
203 \long\def\@reargdef#1[#2]#3{%
204 \@yargdef#1\@ne{#2}{#3}}
205 \def\renewcommand{\@star@or@long\renew@command}
206 \def\renew@command#1{%
207 {\escapechar\m@ne\xdef\@gtempa{{\string#1}}}%
208 \expandafter\@ifundefined\@gtempa
209 {\@latex@error{\string#1 undefined}\@ehc}%
210 {}%
211 \let\@ifdefinable\@rc@ifdefinable
212 \new@command#1}
213 \long\def\@ifdefinable #1#2{%
214 \edef\reserved@a{\expandafter\@gobble\string #1}%
215 \@ifundefined\reserved@a
216 {\edef\reserved@b{\expandafter\@carcube \reserved@a xxx\@nil}%
217 \ifx \reserved@b\@qend \@notdefinable\else
218 \ifx \reserved@a\@qrelax \@notdefinable\else
219 #2%
220 \fi
221 \fi}%
222 \@notdefinable}
223 \let\@@ifdefinable\@ifdefinable
224 \long\def\@rc@ifdefinable#1#2{%
225 \let\@ifdefinable\@@ifdefinable
226 #2}
227 \def\newenvironment{\@star@or@long\new@environment}
228 \def\new@environment#1{%
229 \@testopt{\@newenva#1}0}
230 \def\@newenva#1[#2]{%
231 \@ifnextchar [{\@newenvb#1[#2]}{\@newenv{#1}{[#2]}}}
232 \def\@newenvb#1[#2][#3]{\@newenv{#1}{[#2][#3]}}
233 \def\renewenvironment{\@star@or@long\renew@environment}
234 \def\renew@environment#1{%
235 \@ifundefined{#1}%
236 {\@latex@error{Environment #1 undefined}\@ehc
237 }{}%
238 \expandafter\let\csname#1\endcsname\relax
239 \expandafter\let\csname end#1\endcsname\relax
240 \new@environment{#1}}
241 \long\def\@newenv#1#2#3#4{%
242 \@ifundefined{#1}%
243 {\expandafter\let\csname#1\expandafter\endcsname
244 \csname end#1\endcsname}%
245 \relax
246 \expandafter\new@command
247 \csname #1\endcsname#2{#3}%
248 \l@ngrel@x\expandafter\def\csname end#1\endcsname{#4}}
249
250 \def\providecommand{\@star@or@long\provide@command}
251 \def\provide@command#1{%
252 {\escapechar\m@ne\xdef\@gtempa{{\string#1}}}%
253 \expandafter\@ifundefined\@gtempa
254 {\def\reserved@a{\new@command#1}}%
255 {\def\reserved@a{\renew@command\reserved@a}}%
256 \reserved@a}%
257
258 % Missing \x@protect definition added 2020/03/02
259 \def\x@protect#1{%
260 \ifx\protect\@typeset@protect\else
261 \@x@protect#1%
262 \fi
263 }
264 \def\@x@protect#1\fi#2#3{%
265 \fi\protect#1%
266 }
267 \let\@typeset@protect\relax
268
269 \def\@ifundefined#1{%
270 \expandafter\ifx\csname#1\endcsname\relax
271 \expandafter\@firstoftwo
272 \else
273 \expandafter\@secondoftwo
274 \fi}
275
276 \chardef\@xxxii=32
277 \mathchardef\@Mi=10001
278 \mathchardef\@Mii=10002
279 \mathchardef\@Miii=10003
280 \mathchardef\@Miv=10004
281
282 \newcount\@tempcnta
283 \newcount\@tempcntb
284 \newif\if@tempswa\@tempswatrue
285 \newdimen\@tempdima
286 \newdimen\@tempdimb
287 \newdimen\@tempdimc
288 \newbox\@tempboxa
289 \newskip\@tempskipa
290 \newskip\@tempskipb
291 \newtoks\@temptokena
292
293 \long\def\@whilenum#1\do #2{\ifnum #1\relax #2\relax\@iwhilenum{#1\relax
294 #2\relax}\fi}
295 \long\def\@iwhilenum#1{\ifnum #1\expandafter\@iwhilenum
296 \else\expandafter\@gobble\fi{#1}}
297 \long\def\@whiledim#1\do #2{\ifdim #1\relax#2\@iwhiledim{#1\relax#2}\fi}
298 \long\def\@iwhiledim#1{\ifdim #1\expandafter\@iwhiledim
299 \else\expandafter\@gobble\fi{#1}}
300 \long\def\@whilesw#1\fi#2{#1#2\@iwhilesw{#1#2}\fi\fi}
301 \long\def\@iwhilesw#1\fi{#1\expandafter\@iwhilesw
302 \else\@gobbletwo\fi{#1}\fi}
303 \def\@nnil{\@nil}
304 \def\@empty{}
305 \def\@fornoop#1\@@#2#3{}
306 \long\def\@for#1:=#2\do#3{%
307 \expandafter\def\expandafter\@fortmp\expandafter{#2}%
308 \ifx\@fortmp\@empty \else
309 \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}\fi}
310 \long\def\@forloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
311 #5\def#4{#2}\ifx #4\@nnil \else#5\@iforloop #3\@@#4{#5}\fi\fi}
312 \long\def\@iforloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
313 \expandafter\@fornoop \else
314 #4\relax\expandafter\@iforloop\fi#2\@@#3{#4}}
315 \def\@tfor#1:={\@tf@r#1 }
316 \long\def\@tf@r#1#2\do#3{\def\@fortmp{#2}\ifx\@fortmp\space\else
317 \@tforloop#2\@nil\@nil\@@#1{#3}\fi}
318 \long\def\@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
319 \expandafter\@fornoop \else
320 #4\relax\expandafter\@tforloop\fi#2\@@#3{#4}}
321 \long\def\@break@tfor#1\@@#2#3{\fi\fi}
322 \def\@removeelement#1#2#3{%
323 \def\reserved@a##1,#1,##2\reserved@a{##1,##2\reserved@b}%
324 \def\reserved@b##1,\reserved@b##2\reserved@b{%
325 \ifx,##1\@empty\else##1\fi}%
326 \edef#3{%
327 \expandafter\reserved@b\reserved@a,#2,\reserved@b,#1,\reserved@a}}
328
329 \let\ExecuteOptions\@gobble
330
331 \def\on@line{ on input line \the\inputlineno}
332 \ifx\@ehc\@undefined\def\@ehc{}\fi
333 % 2022/06/13
334 \ifx\@ehd\@undefined\def\@ehd{}\fi
335
336 \def\PackageError#1#2#3{{%
337 \newlinechar`\^^J\def\MessageBreak{^^J\space\space#1: }%
338 \errhelp{#3}\errmessage{#1: #2}}}
339 \def\@latex@error#1#2{\bgroup%
340 \newlinechar`\^^J\def\MessageBreak{^^J\space\space#1: }%
341 \edef\reserved@a{\egroup\errhelp{#2}\errmessage{#1}}%
342 \reserved@a}
343
344
345 \bgroup\uccode`\!`\%\uppercase{\egroup
346 \def\@percentchar{!}}
347
348 % protect against loops in formats other than plain. 1999/04/27
349 \ifx\@@input\@undefined
350 \let\@@input\input
351 \fi
352
353 \def\input{\@ifnextchar\bgroup\@iinput\@@input}
354 \def\@iinput#1{\@@input#1 }
355
356 \ifx\filename@parse\@undefined
357 \def\reserved@a{./}\ifx\@currdir\reserved@a
358 \wlog{^^JDefining UNIX/DOS style filename parser.^^J}
359 \def\filename@parse#1{%
360 \let\filename@area\@empty
361 \expandafter\filename@path#1/\\}
362 \def\filename@path#1/#2\\{%
363 \ifx\\#2\\%
364 \def\reserved@a{\filename@simple#1.\\}%
365 \else
366 \edef\filename@area{\filename@area#1/}%
367 \def\reserved@a{\filename@path#2\\}%
368 \fi
369 \reserved@a}
370 \else\def\reserved@a{[]}\ifx\@currdir\reserved@a
371 \wlog{^^JDefining VMS style filename parser.^^J}
372 \def\filename@parse#1{%
373 \let\filename@area\@empty
374 \expandafter\filename@path#1]\\}
375 \def\filename@path#1]#2\\{%
376 \ifx\\#2\\%
377 \def\reserved@a{\filename@simple#1.\\}%
378 \else
379 \edef\filename@area{\filename@area#1]}%
380 \def\reserved@a{\filename@path#2\\}%
381 \fi
382 \reserved@a}
383 \else\def\reserved@a{:}\ifx\@currdir\reserved@a
384 \wlog{^^JDefining Mac style filename parser.^^J}
385 \def\filename@parse#1{%
386 \let\filename@area\@empty
387 \expandafter\filename@path#1:\\}
388 \def\filename@path#1:#2\\{%
389 \ifx\\#2\\%
390 \def\reserved@a{\filename@simple#1.\\}%
391 \else
392 \edef\filename@area{\filename@area#1:}%
393 \def\reserved@a{\filename@path#2\\}%
394 \fi
395 \reserved@a}
396 \else
397 \wlog{^^JDefining generic filename parser.^^J}
398 \def\filename@parse#1{%
399 \let\filename@area\@empty
400 \expandafter\filename@simple#1.\\}
401 \fi\fi\fi
402 \def\filename@simple#1.#2\\{%
403 \ifx\\#2\\%
404 \let\filename@ext\relax
405 \else
406 \edef\filename@ext{\filename@dot#2\\}%
407 \fi
408 \edef\filename@base{#1}}
409 \def\filename@dot#1.\\{#1}
410 \else
411 \wlog{^^J^^J%
412 \noexpand\filename@parse was defined in texsys.cfg:^^J%
413 \expandafter\strip@prefix\meaning\filename@parse.^^J%
414 }
415 \fi
416
417 \long\def \IfFileExists#1#2#3{%
418 \openin\@inputcheck#1 %
419 \ifeof\@inputcheck
420 \ifx\input@path\@undefined
421 \def\reserved@a{#3}%
422 \else
423 \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
424 \fi
425 \else
426 \closein\@inputcheck
427 \edef\@filef@und{#1 }%
428 \def\reserved@a{#2}%
429 \fi
430 \reserved@a}
431 \long\def\@iffileonpath#1{%
432 \let\reserved@a\@secondoftwo
433 \expandafter\@tfor\expandafter\reserved@b\expandafter
434 :\expandafter=\input@path\do{%
435 \openin\@inputcheck\reserved@b#1 %
436 \ifeof\@inputcheck\else
437 \edef\@filef@und{\reserved@b#1 }%
438 \let\reserved@a\@firstoftwo%
439 \closein\@inputcheck
440 \@break@tfor
441 \fi}%
442 \reserved@a}
443 \long\def \InputIfFileExists#1#2{%
444 \IfFileExists{#1}%
445 {#2\@addtofilelist{#1}\@@input \@filef@und}}
446
447 \chardef\@inputcheck0
448
449 \let\@addtofilelist \@gobble
450
451
452 \def\@defaultunits{\afterassignment\remove@to@nnil}
453 \def\remove@to@nnil#1\@nnil{}
454
455 \newdimen\leftmarginv
456 \newdimen\leftmarginvi
457
458 \newdimen\@ovxx
459 \newdimen\@ovyy
460 \newdimen\@ovdx
461 \newdimen\@ovdy
462 \newdimen\@ovro
463 \newdimen\@ovri
464 \newdimen\@xdim
465 \newdimen\@ydim
466 \newdimen\@linelen
467 \newdimen\@dashdim
468
469
470 \long\def\mbox#1{\leavevmode\hbox{#1}}
471
472
473 \let\DeclareRobustCommand\newcommand
474 \let\@onlypreamble\@gobble
475
476
477 \def\AtBeginDocument#1{#1}
478 \let\protect\relax
479
480
481 \newdimen\fboxsep
482 \newdimen\fboxrule
483
484 \fboxsep = 3pt
485 \fboxrule = .4pt
486
487 \def\@height{height} \def\@depth{depth} \def\@width{width}
488 \def\@minus{minus}
489 \def\@plus{plus}
490 \def\hb@xt@{\hbox to}
491
492
493 \long\def\@begin@tempboxa#1#2{%
494 \begingroup
495 \setbox\@tempboxa#1{\color@begingroup#2\color@endgroup}%
496 \def\width{\wd\@tempboxa}%
497 \def\height{\ht\@tempboxa}%
498 \def\depth{\dp\@tempboxa}%
499 \let\totalheight\@ovri
500 \totalheight\height
501 \advance\totalheight\depth}
502 \let\@end@tempboxa\endgroup
503
504 \let\set@color\relax
505 \let\color@begingroup\relax
506 \let\color@endgroup\relax
507 \let\color@setgroup\relax
508 \let\normalcolor\relax
509 \let\color@hbox\relax
510 \let\color@vbox\relax
511 \let\color@endbox\relax
512
513 % 1996/05/09 \setlength and \strip@pt needed for some
514 % \includegraphics options (Thierry Bouche)
515
516 \def\setlength#1#2{#1#2\relax}
517
518 \begingroup
519 \catcode`P=12
520 \catcode`T=12
521 \lowercase{
522 \def\x{\def\rem@pt##1.##2PT{##1\ifnum##2>\z@.##2\fi}}}
523 \expandafter\endgroup\x
524 \def\strip@pt{\expandafter\rem@pt\the}
525
526 % 1996/11/13 \AtBeginDvi used in driver files for including headers.
527 % \@input added.
528
529
530 \def\AtBeginDvi#1{#1}
531
532 \def\@input#1{%
533 \IfFileExists{#1}{\@@input\@filef@und}{\message{No file #1.}}}
534
535 % 1996/11/21
536 \def\@warning{\immediate\write16}
537
538 % 2019/07/20
539 \def\quote@name#1{"\quote@@name#1\@gobble""}
540 \def\quote@@name#1"{#1\quote@@name}
541 \def\unquote@name#1{\quote@@name#1\@gobble"}
542
543 \ifx\set@curr@file\@undefined
544 \def\set@curr@file#1{\xdef\@curr@file{#1}}
545 \fi
546
547 % 2022/06/13
548 \ifx\mathcolor\@undefined
549 % simplified version of \mathcolor
550 % 2022/12/02
551 \csname protected\endcsname\def\mathcolor{\begingroup\@ifnextchar[\mlx@mathcolora\mlx@mathcolorb}
552 \long\def\mlx@mathcolora[#1]#2#3{\color[#1]{#2}#3\endgroup}
553 \long\def\mlx@mathcolorb#1#2{\color{#1}#2\endgroup}
554 \fi
555
556 % 2022/09/28
557 % remove outerness
558 \expandafter\def\expandafter\newdimen\expandafter{\newdimen}
559
560 % 2024/06/19
561 % more latex emulation
562 \providecommand\DeclareRelease[3]{}
563 \providecommand\DeclareCurrentRelease[2]{}
564 \providecommand\@spaces{\space\space\space\space}