Debian Codegraph @

texmf-dist/source/latex/eso-pic/eso-pic.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1998-2015 by Rolf Niepraschk <[email protected]>
4 % -------------------------------------------------------------------
5 %
6 % This file may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in:
10 %
11 % http://www.latex-project.org/lppl.txt
12 %
13 % and version 1.3 or later is part of all distributions of LaTeX
14 % version 2003/12/01 or later.
15 %
16 % This work has the LPPL maintenance status "author-maintained".
17 %
18 % Please send error reports and suggestions for improvements to
19 % Rolf Niepraschk <[email protected]>.
20 %
21 % \fi
22 %
23 % \iffalse
24 %<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01]
25 %<package>\ProvidesPackage{eso-pic}
26 %<package> [2025/12/10 v3.0d eso-pic (RN)]
27 %
28 %<*driver>
29 \documentclass[a4paper]{ltxdoc}
30 \usepackage{eso-pic,array}
31 \EnableCrossrefs\CodelineIndex\RecordChanges
32 \begin{document}
33 \DocInput{eso-pic.dtx}
34 \end{document}
35 %</driver>
36 % \fi
37 %
38 % \CheckSum{756}
39 %
40 % \CharacterTable
41 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
42 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
43 % Digits \0\1\2\3\4\5\6\7\8\9
44 % Exclamation \! Double quote \" Hash (number) \#
45 % Dollar \$ Percent \% Ampersand \&
46 % Acute accent \' Left paren \( Right paren \)
47 % Asterisk \* Plus \+ Comma \,
48 % Minus \- Point \. Solidus \/
49 % Colon \: Semicolon \; Less than \<
50 % Equals \= Greater than \> Question mark \?
51 % Commercial at \@ Left bracket \[ Backslash \\
52 % Right bracket \] Circumflex \^ Underscore \_
53 % Grave accent \` Left brace \{ Vertical bar \|
54 % Right brace \} Tilde \~}
55 %
56 %
57 % \providecommand\env[1]{\textsf{#1}}
58 % \providecommand\clsname[1]{\textsf{#1}}
59 % \providecommand\pkgname[1]{\textsf{#1}}
60 % \providecommand\optname[1]{\textsf{#1}}
61 % \providecommand\progname[1]{\textsf{#1}}
62 %
63 % \setlength\emergencystretch{3em}
64 %
65 % \changes{v0.4}{1998/06/02}{Initial version}
66 % \changes{v0.5}{1998/07/11}{Some bug corrections}
67 % \changes{v0.6}{2000/05/13}{Some corrections for compatibility with
68 % the \pkgname{html} package suggested by Ross Moore and a licence note}
69 % \changes{v0.7}{2001/07/20}{New command \cmd{\AddToShipoutPicture*}}
70 % \changes{v1.0}{2002/07/03}{New commands \cmd{\LenToUnit},%
71 % \cmd{\AtPageUpperLeft}, \cmd{\AtPageCenter}, \cmd{\AtTextUpperLeft},
72 % and \cmd{\AtTextCenter}.}
73 % \changes{v1.0c}{2002/10/30}{New command \cmd{\AtTextLowerLeft} and
74 % corrections to \cmd{\AtTextUpperLeft}.}
75 % \changes{v1.1}{2002/11/07}{New commands and package options for
76 % background grids.}
77 % \changes{v1.1b}{2002/11/16}{New package options "texcoord" and "pscoord"}
78 % \changes{v1.1b}{2002/11/16}{New command \cmd{\AtPageLowerLeft}}
79 %
80 % \GetFileInfo{eso-pic.sty}
81 %
82 % \DoNotIndex{\newcommand,\newenvironment}
83 %
84 % \title{The \pkgname{eso-pic} package\thanks{This document
85 % corresponds to \pkgname{eso-pic}~\fileversion, dated \filedate.}}
86 % \author{Rolf Niepraschk \\ \texttt{[email protected]}}
87 %
88 % \date{}
89 %
90 % \maketitle
91 %
92 % \section{Introduction}
93 %
94 % This package makes it easy to add some picture commands to every page
95 % at absolute positions.
96 % \section{Usage}
97 % See also the example \LaTeX\ documents (|eso-*.tex|).
98 %
99 % \subsection{Basic commands for adding \LaTeX{} stuff to the page background}
100 % \DescribeMacro{\AddToShipoutPictureBG} All the picture commands which are
101 % parameters of an \cs{AddToShipoutPictureBG} command will be added to the
102 % internal macro \cs{ESO@HookIBG}. This macro is part of a
103 % zero-length \texttt{picture} environment with basepoint at the lower left
104 % corner of the page (default) or at the upper left corner
105 % (package option ``texcoord''). The \texttt{picture} environment will be
106 % shipped out at every new page.
107 %
108 % \DescribeMacro{\AddToShipoutPictureBG*} \cs{AddToShipoutPictureBG*} works like
109 % \cs{AddToShipoutPictureBG} but only for the current page. It used the internal
110 % macro \cs{ESO@HookIIBG} which contents will be removed
111 % automatically.
112 %
113 % For compatibility the macros \cs{AddToShipoutPicture} and
114 % \cs{AddToShipoutPicture*} are aliases for \cs{AddToShipoutPictureBG}
115 % and \cs{AddToShipoutPictureBG*}.
116 %
117 % \DescribeMacro{\AddToShipoutPictureFG}
118 % \DescribeMacro{\AddToShipoutPictureFG*} Works like
119 % \cs{AddToShipoutPictureBG} but the picture commands are on the top
120 % of the normal document content.
121 %
122 % \DescribeMacro{\ClearShipoutPictureBG} A call of
123 % \cs{ClearShipoutPictureBG}
124 % clears the contents of \cs{ESO@HookIBG}.
125 %
126 % For compatibility the macro \cs{ClearShipoutPicture}
127 % is an alias for \cs{ClearShipoutPictureBG}.
128 %
129 % \DescribeMacro{\ClearShipoutPictureFG} A call of
130 % \cs{ClearShipoutPictureFG}
131 % clears the contents of \cs{ESO@HookIFG}.
132 %
133 % \DescribeMacro{\LenToUnit} [Allows a length as parameter to a picture
134 % command.] Note that this macro exist only for compatibility to older
135 % versions of this package. A recent \LaTeX\ version allows dimensions
136 % in picture commands.
137 %
138 % \DescribeMacro{\gridSetup}
139 % \cmd{\gridSetup}\oarg{gridunitname}\marg{gridunit}\marg{labelfactor}^^A
140 % \marg{griddelta} \marg{gridDelta}\marg{gap}. For details see the
141 % implementation section.\par\clearpage
142 % \DescribeMacro{\AtPageUpperLeft}
143 % \DescribeMacro{\AtPageLowerLeft}
144 % \DescribeMacro{\AtPageCenter}
145 % \DescribeMacro{\AtTextUpperLeft}
146 % \DescribeMacro{\AtTextLowerLeft}
147 % \DescribeMacro{\AtTextCenter}
148 % \DescribeMacro{\AtStockUpperLeft}
149 % \DescribeMacro{\AtStockLowerLeft}
150 % \DescribeMacro{\AtStockCenter}
151 % Helper macros for easier positioning on the page.
152 %
153 % \subsection{Package options}
154 % \begin{center}
155 % \begin{tabular}{@{}>{\ttfamily}llp{.5\textwidth}@{}}
156 % \textnormal{Option} & Value & Comments \\ \hline
157 % pscoord & empty or \textit{true}, \textit{false} & The zero point of
158 % the coordinate system is the lower left corner of the page
159 % (the default). \\
160 % texcoord & empty or \textit{true}, \textit{false} & The zero point of
161 % the coordinate system is the upper left corner of the page. \\
162 % grid & empty or \textit{true}, \textit{false} & A grid is drawing;
163 % default: false. \\
164 % gridBG & empty or \textit{true}, \textit{false} & Put the grid in the
165 % background; default: false.\\
166 % gridunit & \textit{mm}, \textit{in}, \textit{bp}, \textit{pt} & Distance
167 % between gridlines are multiples of \texttt{gridunit}. default: mm.\\
168 % gridcolor & a valid color name & Color of the main gridlines;
169 % default: black \\
170 % subgridcolor & a valid color name & Color of the subgridlines;
171 % default: black. \\
172 % subgridstyle & \textit{solid} or \textit{dotted} & `dotted' is very slow!
173 % default: solid. \\
174 % colorgrid & empty or \textit{true}, \textit{false} & Shortcut for
175 % `grid=true', `gridcolor=red' and `subgridcolor=green';
176 % default: false.\\
177 % dvips & empty or \textit{true}, \textit{false} & Is also true
178 % if the package option \texttt{dvips} is
179 % used by \pkgname{color} or \pkgname{graphics}. If true package
180 % \pkgname{eepic} is loaded for better performance of dotted lines.
181 %
182 % \end{tabular}
183 % \end{center}
184 %
185 % \StopEventually{\PrintChanges\PrintIndex}
186 %
187 % \section{Implementation}
188 %
189 % \subsection{The main functionality}
190 %
191 % \begin{macro}{\LenToUnit}
192 % \changes{v1.0d}{2006/07/14}{Using \cmd{\providecommand} instead of
193 % \cmd{\newcommand} for \cmd{\LenToUnit}}
194 % \changes{v2.0f}{2015/07/14}{Changed definition for better compatibility
195 % with package \pkgname{curve2e} suggested by Claudio Beccari.}
196 % Only for compatibility
197 % \changes{v3.0a}{2020/10/14}{No more used. (RN).}
198 % \begin{macrocode}
199 \providecommand*\LenToUnit[1]{#1}
200 % \end{macrocode}
201 % \end{macro}
202 % \begin{macrocode}
203 \newdimen\ESO@tempdima
204 \newdimen\ESO@tempdimb
205 % \end{macrocode}
206 % \begin{macro}{\ESO@isMEMOIR}
207 % Support for the \clsname{memoir} class.
208 % \begin{macrocode}
209 \newcommand\ESO@isMEMOIR[2]{#2}
210 \@ifclassloaded{memoir}{\renewcommand\ESO@isMEMOIR[2]{#1}}{}
211 % \end{macrocode}
212 % \end{macro}
213 % \begin{macro}{\AtPageUpperLeft}
214 % \begin{macrocode}
215 \newcommand\AtPageUpperLeft[1]{%
216 \put(0,-\ESO@yoffsetI){#1}%
217 }
218 % \end{macrocode}
219 % \end{macro}
220 % \begin{macro}{\AtPageLowerLeft}
221 % \begin{macrocode}
222 \newcommand\AtPageLowerLeft[1]{\AtPageUpperLeft{%
223 \put(0,-\paperheight){#1}}}
224 % \end{macrocode}
225 % \end{macro}
226 % \begin{macro}{\AtPageCenter}
227 % \begin{macrocode}
228 \newcommand\AtPageCenter[1]{\AtPageUpperLeft{%
229 \put(.5\paperwidth,-.5\paperheight){#1}}%
230 }
231 % \end{macrocode}
232 % \end{macro}
233 % \begin{macro}{\AtStockLowerLeft}
234 % \changes{v2.0a}{2009/10/07}{New}
235 % \begin{macrocode}
236 \newcommand\AtStockLowerLeft{}
237 \ESO@isMEMOIR{%
238 \renewcommand\AtStockLowerLeft[1]{%
239 \begingroup
240 \ESO@tempdima=-\stockwidth
241 \advance\ESO@tempdima\trimedge
242 \advance\ESO@tempdima\paperwidth
243 \if@twoside\ifodd\c@page\else
244 \ESO@tempdima=-\trimedge
245 \fi\fi
246 \ESO@tempdimb=-\stockheight
247 \advance\ESO@tempdimb\paperheight
248 \advance\ESO@tempdimb\trimtop
249 \AtPageLowerLeft{%
250 \put(\ESO@tempdima,\ESO@tempdimb){#1}%
251 }%
252 \endgroup
253 }
254 }{%
255 \let\AtStockLowerLeft=\AtPageLowerLeft
256 }
257 % \end{macrocode}
258 % \end{macro}
259 % \begin{macro}{\AtStockUpperLeft}
260 % \changes{v2.0a}{2009/10/07}{New}
261 % \begin{macrocode}
262 \newcommand\AtStockUpperLeft{}
263 \ESO@isMEMOIR{%
264 \renewcommand\AtStockUpperLeft[1]{%
265 \AtStockLowerLeft{%
266 \put(0,\stockheight){#1}%
267 }%
268 }%
269 }{%
270 \let\AtStockUpperLeft=\AtPageUpperLeft
271 }
272 % \end{macrocode}
273 % \end{macro}
274 % \begin{macro}{\AtStockCenter}
275 % \changes{v2.0a}{2009/10/07}{New}
276 % \begin{macrocode}
277 \newcommand\AtStockCenter{}
278 \ESO@isMEMOIR{%
279 \renewcommand\AtStockCenter[1]{%
280 \AtStockLowerLeft{%
281 \put(.5\stockwidth,.5\stockheight){#1}%
282 }%
283 }%
284 }{%
285 \let\AtStockCenter=\AtPageCenter
286 }
287 % \end{macrocode}
288 % \end{macro}
289 % \begin{macro}{\AtTextUpperLeft}
290 % \changes{v2.0a}{2009/10/07}{Works now for class \clsname{memoir}}
291 % \changes{v2.0e}{2014/04/20}{Wrong horizontal position in one-column mode}
292 % \changes{v3.0c}{2023/05/03}{Wrong horizontal position in memoir one-side
293 % mode (issue \#5)}
294 % \begin{macrocode}
295 \ESO@isMEMOIR{%
296 \newcommand\AtTextUpperLeft[1]{%
297 \begingroup
298 \if@twoside
299 \ifodd\c@page
300 \ESO@tempdima=\spinemargin
301 \else
302 \ESO@tempdima=\paperwidth
303 \advance\ESO@tempdima-\textwidth
304 \advance\ESO@tempdima-\spinemargin
305 \fi
306 \else
307 \ESO@tempdima=\spinemargin
308 \fi
309 \ESO@tempdimb=-\uppermargin
310 \AtPageUpperLeft{%
311 \put(\ESO@tempdima,\ESO@tempdimb){#1}%
312 }%
313 \endgroup
314 }%
315 }{%
316 \newcommand\AtTextUpperLeft[1]{%
317 \begingroup
318 \ESO@tempdima=1in\relax
319 \if@twoside
320 \ifodd\c@page
321 \advance\ESO@tempdima\oddsidemargin
322 \else
323 \advance\ESO@tempdima\evensidemargin
324 \fi
325 \else
326 \advance\ESO@tempdima\oddsidemargin
327 \fi
328 \ESO@tempdimb=-1in\relax
329 \advance\ESO@tempdimb-\topmargin
330 \advance\ESO@tempdimb-\headheight
331 \advance\ESO@tempdimb-\headsep
332 \AtPageUpperLeft{%
333 \put(\ESO@tempdima,\ESO@tempdimb){#1}%
334 }%
335 \endgroup
336 }
337 }
338 % \end{macrocode}
339 % \end{macro}
340 % \begin{macro}{\AtTextLowerLeft}
341 % \begin{macrocode}
342 \newcommand\AtTextLowerLeft[1]{\AtTextUpperLeft{%
343 \put(0,-\textheight){#1}}}
344 % \end{macrocode}
345 % \end{macro}
346 % \begin{macro}{\AtTextCenter}
347 % \begin{macrocode}
348 \newcommand\AtTextCenter[1]{\AtTextUpperLeft{%
349 \put(.5\textwidth,-.5\textheight){#1}}}
350 % \end{macrocode}
351 % \end{macro}
352 % \DescribeMacro{\ESO@HookIBG}\DescribeMacro{\ESO@HookIIBG}
353 % \DescribeMacro{\ESO@HookIIIBG}\DescribeMacro{\ESO@HookIFG}
354 % \DescribeMacro{\ESO@HookIIFG}\DescribeMacro{\ESO@HookIIIFG}
355 % \changes{v2.0g}{2015/07/21}{New macro \cmd{\ESO@HookIIIFG} for foreground grid.}
356 % \begin{macrocode}
357 \newcommand{\ESO@HookIBG}{}
358 \newcommand{\ESO@HookIIBG}{}
359 \newcommand{\ESO@HookIIIBG}{}
360 \newcommand{\ESO@HookIFG}{}
361 \newcommand{\ESO@HookIIFG}{}
362 \newcommand{\ESO@HookIIIFG}{}
363 \newcommand{\ESO@HookI}{}
364 \newcommand{\ESO@HookII}{}
365 \newcommand{\ESO@HookIII}{}
366 \let\ESO@HookI=\ESO@HookIBG
367 \let\ESO@HookII=\ESO@HookIIBG
368 \let\ESO@HookIII=\ESO@HookIIIBG
369 % \end{macrocode}
370 % \begin{macro}{\AddToShipoutPictureBG}
371 % \begin{macro}{\AddToShipoutPictureFG}
372 % \changes{v2.0b}{2010/06/08}{New command \cmd{\AddToShipoutPictureFG}}
373 % \begin{macrocode}
374 \newcommand{\AddToShipoutPictureBG}{%
375 \@ifstar{\g@addto@macro\ESO@HookIIBG}{\g@addto@macro\ESO@HookIBG}}
376 \newcommand{\AddToShipoutPicture}{}
377 \let\AddToShipoutPicture=\AddToShipoutPictureBG
378 % \end{macrocode}
379 % \end{macro}
380 % \end{macro}
381 % \begin{macro}{\AddToShipoutPictureFG}
382 % \begin{macrocode}
383 \newcommand{\AddToShipoutPictureFG}{%
384 \@ifstar{\g@addto@macro\ESO@HookIIFG}{\g@addto@macro\ESO@HookIFG}}
385 % \end{macrocode}
386 % \end{macro}
387 % \changes{v3.0a}{2020/10/14}{LaTeX's shipout hooks instead of `atbegshi' (RN).}
388 % \begin{macro}{\ClearShipoutPictureBG}
389 % \begin{macro}{\ClearShipoutPicture}
390 % \begin{macro}{\ClearShipoutPictureFG}
391 % \changes{v1.0a}{2002/10/07}{Changed \cmd{\let} to
392 % \cmd{\global}\cmd{\let} (suggested by Alberto Lusiani).}
393 % \begin{macrocode}
394 \newcommand{\ClearShipoutPictureBG}{\global\let\ESO@HookIBG\@empty}
395 \newcommand{\ClearShipoutPicture}{}
396 \let\ClearShipoutPicture=\ClearShipoutPictureBG
397 \newcommand{\ClearShipoutPictureFG}{\global\let\ESO@HookIFG\@empty}
398 % \end{macrocode}
399 % \end{macro}
400 % \end{macro}
401 % \end{macro}
402 % \changes{v2.0c}{2010/10/06}{bugfix for memoir class
403 % (reported by YI Hoze)}
404 % \begin{macrocode}
405 \ESO@isMEMOIR{%
406 \newcommand*\ESO@MEMOIR@corr{%
407 \ESO@tempdima=-\trimedge
408 \advance\ESO@tempdima-\paperwidth
409 \advance\ESO@tempdima\stockwidth
410 \if@twoside\ifodd\c@page\else
411 \advance\ESO@tempdima2\trimedge
412 \advance\ESO@tempdima\paperwidth
413 \advance\ESO@tempdima-\stockwidth
414 \fi\fi
415 \ESO@tempdimb=\ESO@yoffsetI
416 \advance\ESO@tempdimb-\trimtop
417 }
418 \AddToHook{shipout/background}{%
419 \ESO@MEMOIR@corr
420 \put(\ESO@tempdima,\ESO@tempdimb){%
421 \ESO@HookIIIBG\ESO@HookIBG\ESO@HookIIBG
422 \global\let\ESO@HookIIBG\@empty
423 }%
424 }%
425 \AddToHook{shipout/foreground}{%
426 \ESO@MEMOIR@corr
427 \put(\ESO@tempdima,\ESO@tempdimb){%
428 \ESO@HookIFG\ESO@HookIIFG\ESO@HookIIIFG
429 \global\let\ESO@HookIIFG\@empty
430 }%
431 }%
432 }{%
433 \AddToHook{shipout/background}{%
434 \put(0,\ESO@yoffsetI){%
435 \ESO@HookIIIBG\ESO@HookIBG\ESO@HookIIBG
436 \global\let\ESO@HookIIBG\@empty
437 }%
438 }%
439 \AddToHook{shipout/foreground}{%
440 \put(0,\ESO@yoffsetI){%
441 \ESO@HookIFG\ESO@HookIIFG\ESO@HookIIIFG
442 \global\let\ESO@HookIIFG\@empty
443 }%
444 }%
445 }
446 % \end{macrocode}
447 % \subsection{The background grid}
448 % \begin{macrocode}
449 \RequirePackage{keyval}
450 % \end{macrocode}
451 % Initialising some macros
452 % \changes{v2.0g}{2015/07/21}{New \cmd{\ifESO@gridBG} for foreground/background grid.}
453 % \begin{macrocode}
454 \newif\ifESO@dvips\ESO@dvipsfalse \newif\ifESO@grid\ESO@gridfalse
455 \newif\ifESO@texcoord\ESO@texcoordfalse \newif\ifESO@gridBG\ESO@gridBGfalse
456 \newcommand*\ESO@gridunitname{}
457 \newcommand*\ESO@gridunit{}
458 \newcommand*\ESO@labelfactor{}
459 \newcommand*\ESO@griddelta{}\newcommand*\ESO@griddeltaY{}
460 \newcommand*\ESO@gridDelta{}\newcommand*\ESO@gridDeltaY{}
461 \newcommand*\ESO@gridcolor{}
462 \newcommand*\ESO@subgridcolor{}
463 \newcommand*\ESO@subgridstyle{dotted}% ???
464 \newcommand*\ESO@gap{}
465 \newcommand*\ESO@yoffsetI{}\newcommand*\ESO@yoffsetII{}
466 \newcommand*\ESO@gridlines{\thinlines}
467 \newcommand*\ESO@subgridlines{\thinlines}
468 \newcommand*\ESO@hline[1]{\ESO@subgridlines\line(1,0){#1}}
469 \newcommand*\ESO@vline[1]{\ESO@subgridlines\line(0,1){#1}}
470 \newcommand*\ESO@Hline[1]{\ESO@gridlines\line(1,0){#1}}
471 \newcommand*\ESO@Vline[1]{\ESO@gridlines\line(0,1){#1}}
472 \newcommand\ESO@fcolorbox[3]{\fbox{#3}}
473 \newcommand\ESO@color[1]{}
474 \newcommand\ESO@colorbox[2]{%
475 \begingroup
476 \fboxrule=\z@\fbox{#2}%
477 \endgroup
478 }
479 % \end{macrocode}
480 % \begin{macro}{\gridSetup}
481 % \begin{macrocode}
482 \newcommand\gridSetup[6][]{%
483 \edef\ESO@gridunitname{#1}\edef\ESO@gridunit{#2}
484 \edef\ESO@labelfactor{#3}\edef\ESO@griddelta{#4}
485 \edef\ESO@gridDelta{#5}\edef\ESO@gap{#6}}
486 % \end{macrocode}
487 % \end{macro}
488 % All the key-value options
489 % \changes{v2.0g}{2015/07/21}{New option `gridBG'.}
490 % \begin{macrocode}
491 \define@key{ESO}{texcoord}[true]{\csname ESO@texcoord#1\endcsname}
492 \define@key{ESO}{pscoord}[true]{\csname @tempswa#1\endcsname
493 \if@tempswa\ESO@texcoordfalse\else\ESO@texcoordtrue\fi}
494 \define@key{ESO}{dvips}[true]{\csname ESO@dvips#1\endcsname}
495 \define@key{ESO}{grid}[true]{\csname ESO@grid#1\endcsname
496 \setkeys{ESO}{gridcolor=black,subgridcolor=black}}
497 \define@key{ESO}{gridBG}[true]{\csname ESO@gridBG#1\endcsname}
498 \define@key{ESO}{colorgrid}[true]{\csname ESO@grid#1\endcsname
499 \setkeys{ESO}{gridcolor=red,subgridcolor=green}}
500 \define@key{ESO}{gridcolor}{\def\ESO@gridcolor{#1}}
501 \define@key{ESO}{subgridcolor}{\def\ESO@subgridcolor{#1}}
502 \define@key{ESO}{subgridstyle}{\def\ESO@subgridstyle{#1}}%
503 \define@key{ESO}{gridunit}{%
504 \def\@tempa{#1}
505 \def\@tempb{bp}
506 \ifx\@tempa\@tempb
507 \gridSetup[\@tempa]{1bp}{1}{10}{50}{2}
508 \else
509 \def\@tempb{pt}
510 \ifx\@tempa\@tempb
511 \gridSetup[\@tempa]{\p@}{1}{10}{50}{2}
512 \else
513 \def\@tempb{in}
514 \ifx\@tempa\@tempb
515 \gridSetup[\@tempa]{.1in}{.1}{2}{10}{.5}
516 \else
517 \gridSetup[mm]{1mm}{1}{5}{20}{1}
518 \fi
519 \fi
520 \fi
521 }
522 \setkeys{ESO}{subgridstyle=solid,pscoord=true,gridunit=mm}
523 % \end{macrocode}
524 % \changes{v2.0h}{2018/04/12}{\cmd\@classoptionslist must not be \cmd\relax}
525 % \begin{macrocode}
526 \providecommand*\@classoptionslist{}
527 % \end{macrocode}
528 % \begin{macro}{\ProcessOptionsWithKV}
529 % This macro can process package options using `key=value' syntax.
530 % \begin{macrocode}
531 \def\ProcessOptionsWithKV#1{%
532 \let\@tempc\@empty
533 \@for\CurrentOption:=\@classoptionslist\do{%
534 \@ifundefined{KV@#1@\CurrentOption}%
535 {}{\edef\@tempc{\@tempc,\CurrentOption,}}}%
536 \edef\@tempc{%
537 \noexpand\setkeys{#1}{\@tempc\@ptionlist{\@currname.\@currext}}}%
538 \@tempc
539 \AtEndOfPackage{\let\@unprocessedoptions\relax}}%
540 % \end{macrocode}
541 % \end{macro}
542 % \begin{macrocode}
543 \ProcessOptionsWithKV{ESO}%
544 % \end{macrocode}
545 % \begin{macro}{\ESO@div}
546 % Divides length |#1| by |#2| \(\times\) \cmd{\ESO@gridunit} and adds one.
547 % Result is in \cmd{\@tempcnta}.
548 % \begin{macrocode}
549 \newcommand\ESO@div[2]{%
550 \ESO@tempdima=#1\relax\ESO@tempdimb=\ESO@gridunit\relax
551 \ESO@tempdimb=#2\ESO@tempdimb\divide\ESO@tempdima by \ESO@tempdimb
552 \@tempcnta\ESO@tempdima\advance\@tempcnta\@ne}
553 % \end{macrocode}
554 % \end{macro}
555 % \changes{v1.1c}{2005/12/24}{Remove the disadvantageous check of
556 % `pdfTeX'. Now using with Xe\LaTeX\ should be possible.}
557 % \changes{v2.0a}{2009/10/07}{Better test of color/xcolor}
558 % \changes{v2.0d}{2013/10/06}{Improved color commands}
559 % \changes{v3.0b}{2023/03/23}{More code inside \cmd{\AtBeginDocument}}
560 % \begin{macrocode}
561 \@ifundefined{colorbox}{%
562 \IfFileExists{xcolor.sty}{\RequirePackage{xcolor}}%
563 {\RequirePackage{color}}%
564 }{}%
565 \let\ESO@color=\color
566 \renewcommand\ESO@colorbox[2]{%
567 \begingroup
568 \fboxsep=.4ex %
569 \colorbox{#1}{#2}%
570 \endgroup
571 }
572 \renewcommand\ESO@fcolorbox[3]{%
573 \begingroup
574 \fboxsep=.5ex %
575 \fcolorbox{#1}{#2}{#3}%
576 \endgroup
577 }
578 \AtBeginDocument{%
579 \ESO@dvipsfalse
580 \@ifundefined{Gin@driver}{}%
581 {%
582 \ifx\Gin@driver\@empty\else%
583 \filename@parse{\Gin@driver}\def\reserved@a{dvips}%
584 \ifx\filename@base\reserved@a\ESO@dvipstrue\fi
585 \fi
586 }%
587 \ifESO@dvips\def\@tempb{eepic}\else\def\@tempb{epic}\fi
588 \def\@tempa{dotted}%\def\ESO@gap{6\@wholewidth}%
589 \ifx\@tempa\ESO@subgridstyle
590 \IfFileExists{\@tempb.sty}%
591 {%
592 \RequirePackage{\@tempb}
593 \renewcommand*\ESO@hline[1]{\ESO@subgridlines\dottedline{\ESO@gap}%
594 (0,0)(##1,0)}
595 \renewcommand*\ESO@vline[1]{\ESO@subgridlines\dottedline{\ESO@gap}%
596 (0,0)(0,##1)}
597 }{}
598 \else
599 \ifx\ESO@gridcolor\ESO@subgridcolor
600 \renewcommand*\ESO@gridlines{\thicklines}
601 \fi
602 \fi
603 % \changes{v3.0b}{2023/03/23}{More code inside \cmd{\AtBeginDocument}}
604 \ifESO@texcoord
605 \def\ESO@yoffsetI{\z@}\def\ESO@yoffsetII{-\paperheight}
606 \edef\ESO@griddeltaY{-\ESO@griddelta}\edef\ESO@gridDeltaY{-\ESO@gridDelta}
607 \else
608 \def\ESO@yoffsetI{-\paperheight}\def\ESO@yoffsetII{\z@}
609 \edef\ESO@griddeltaY{\ESO@griddelta}\edef\ESO@gridDeltaY{\ESO@gridDelta}
610 \fi
611 }
612 % \end{macrocode}
613 % \begin{macro}{\ESO@gridpicture}
614 % \begin{macrocode}
615 \newcommand\ESO@gridpicture{%
616 \begingroup
617 \setlength\unitlength{\ESO@gridunit}%
618 \ESO@color{\ESO@subgridcolor}%
619 % \end{macrocode}
620 % --- horizontal subgrid lines ---
621 % \begin{macrocode}
622 \ESO@div{\paperheight}{\ESO@griddelta}%
623 \multiput(0,0)(0,\ESO@griddeltaY){\@tempcnta}%
624 {\ESO@hline{\paperwidth}}%
625 % \end{macrocode}
626 % --- vertical subgrid lines ---
627 % \begin{macrocode}
628 \ESO@div{\paperwidth}{\ESO@griddelta}%
629 \multiput(0,\ESO@yoffsetII)(\ESO@griddelta,0){\@tempcnta}%
630 {\ESO@vline{\paperheight}}%
631 \ESO@color{\ESO@gridcolor}%
632 % \end{macrocode}
633 % --- horizontal grid lines ---
634 % \begin{macrocode}
635 \ESO@div{\paperheight}{\ESO@gridDelta}%
636 \multiput(0,0)(0,\ESO@gridDeltaY){\@tempcnta}%
637 {\ESO@Hline{\paperwidth}}%
638 % \end{macrocode}
639 % --- vertical grid lines ---
640 % \begin{macrocode}
641 \ESO@div{\paperwidth}{\ESO@gridDelta}%
642 \multiput(0,\ESO@yoffsetII)(\ESO@gridDelta,0){\@tempcnta}%
643 {\ESO@Vline{\paperheight}}%
644 % \end{macrocode}
645 % --- horizontal numbers ---
646 % \changes{v1.1a}{2002/11/09}{Font setting added.}
647 % \begin{macrocode}
648 \fontsize{10}{12}\normalfont%
649 \ESO@div{\paperwidth}{\ESO@gridDelta}%
650 \multiput(0,\ESO@gridDeltaY)(\ESO@gridDelta,0){\@tempcnta}{%
651 \@tempcntb=\@tempcnta\advance\@tempcntb-\@multicnt
652 \ifnum\@tempcntb>1\relax
653 \multiply\@tempcntb by \ESO@gridDelta\relax
654 \ESO@tempdima=\@tempcntb sp\ESO@tempdima=\ESO@labelfactor\ESO@tempdima
655 \@tempcntb=\ESO@tempdima%
656 \makebox(0,0)[c]{\ESO@colorbox{white}{\the\@tempcntb}}%
657 \fi}%
658 % \end{macrocode}
659 % --- vertical numbers ---
660 % \begin{macrocode}
661 \ifx\ESO@gridunitname\@empty\def\@tempa{0}\else\def\@tempa{1}\fi
662 \ESO@div{\paperheight}{\ESO@gridDelta}%
663 \multiput(\ESO@gridDelta,0)(0,\ESO@gridDeltaY){\@tempcnta}{%
664 \@tempcntb=\@tempcnta\advance\@tempcntb-\@multicnt%
665 \ifnum\@tempcntb>\@tempa\relax
666 \multiply\@tempcntb by \ESO@gridDelta\relax%
667 \ESO@tempdima=\@tempcntb sp\ESO@tempdima=\ESO@labelfactor\ESO@tempdima
668 \@tempcntb=\ESO@tempdima
669 \makebox(0,0)[c]{\ESO@colorbox{white}{\the\@tempcntb}}%
670 \fi
671 }%
672 % \end{macrocode}
673 % --- the unit label ---
674 % \begin{macrocode}
675 \ifx\ESO@gridunitname\@empty\else
676 \thicklines\fboxrule=\@wholewidth
677 \put(\ESO@gridDelta,\ESO@gridDeltaY){\makebox(0,0)[c]{%
678 \ESO@fcolorbox{\ESO@gridcolor}{white}{%
679 \textbf{\ESO@gridunitname}}}}%
680 \fi
681 \normalcolor%
682 \endgroup
683 }
684 % \end{macrocode}
685 % \end{macro}
686 % Add the grid to the shipout picture (\cmd{\ESO@HookIIIFG} or
687 % \cmd{\ESO@HookIIIBG}) is independent from the user commands
688 % \cmd{\AddToShipoutPictureBG} and \cmd{\AddToShipoutPictureBG*}).
689 % \changes{v2.0d}{2013/10/06}{grid should be in foreground}
690 % \changes{v2.0g}{2015/07/21}{Foreground/background grid.}
691 % \begin{macrocode}
692 \ifESO@grid
693 \ifESO@gridBG
694 \g@addto@macro\ESO@HookIIIBG{\ESO@gridpicture}%
695 \else
696 \g@addto@macro\ESO@HookIIIFG{\ESO@gridpicture}%
697 \fi
698 \fi
699 % \end{macrocode}
700 %
701 % \Finale
702 \endinput