Debian Codegraph @

texmf-dist/source/latex/pagegrid/pagegrid.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: pagegrid.dtx
4 % Version: 2022-09-21 v1.6
5 % Info: Print page grid in background
6 %
7 % Copyright (C)
8 % 2009 Heiko Oberdiek
9 % 2016-2022 Oberdiek Package Support Group
10 % https://github.com/ho-tex/pagegrid/issues
11 %
12 % This work may be distributed and/or modified under the
13 % conditions of the LaTeX Project Public License, either
14 % version 1.3c of this license or (at your option) any later
15 % version. This version of this license is in
16 % https://www.latex-project.org/lppl/lppl-1-3c.txt
17 % and the latest version of this license is in
18 % https://www.latex-project.org/lppl.txt
19 % and version 1.3 or later is part of all distributions of
20 % LaTeX version 2005/12/01 or later.
21 %
22 % This work has the LPPL maintenance status "maintained".
23 %
24 % The Current Maintainers of this work are
25 % Heiko Oberdiek and the Oberdiek Package Support Group
26 % https://github.com/ho-tex/pagegrid/issues
27 %
28 % This work consists of the main source file pagegrid.dtx
29 % and the derived files
30 % pagegrid.sty, pagegrid.pdf, pagegrid.ins, pagegrid.drv,
31 % pagegrid-test1.tex.
32 %
33 % Distribution:
34 % CTAN:macros/latex/contrib/pagegrid/pagegrid.dtx
35 % CTAN:macros/latex/contrib/pagegrid/pagegrid.pdf
36 %
37 % Unpacking:
38 % (a) If pagegrid.ins is present:
39 % tex pagegrid.ins
40 % (b) Without pagegrid.ins:
41 % tex pagegrid.dtx
42 % (c) If you insist on using LaTeX
43 % latex \let\install=y\input{pagegrid.dtx}
44 % (quote the arguments according to the demands of your shell)
45 %
46 % Documentation:
47 % (a) If pagegrid.drv is present:
48 % latex pagegrid.drv
49 % (b) Without pagegrid.drv:
50 % latex pagegrid.dtx; ...
51 % The class ltxdoc loads the configuration file ltxdoc.cfg
52 % if available. Here you can specify further options, e.g.
53 % use A4 as paper format:
54 % \PassOptionsToClass{a4paper}{article}
55 %
56 % Programm calls to get the documentation (example):
57 % pdflatex pagegrid.dtx
58 % makeindex -s gind.ist pagegrid.idx
59 % pdflatex pagegrid.dtx
60 % makeindex -s gind.ist pagegrid.idx
61 % pdflatex pagegrid.dtx
62 %
63 % Installation:
64 % TDS:tex/latex/pagegrid/pagegrid.sty
65 % TDS:doc/latex/pagegrid/pagegrid.pdf
66 % TDS:source/latex/pagegrid/pagegrid.dtx
67 %
68 %<*ignore>
69 \begingroup
70 \catcode123=1 %
71 \catcode125=2 %
72 \def\x{LaTeX2e}%
73 \expandafter\endgroup
74 \ifcase 0\ifx\install y1\fi\expandafter
75 \ifx\csname processbatchFile\endcsname\relax\else1\fi
76 \ifx\fmtname\x\else 1\fi\relax
77 \else\csname fi\endcsname
78 %</ignore>
79 %<*install>
80 \input docstrip.tex
81 \Msg{************************************************************************}
82 \Msg{* Installation}
83 \Msg{* Package: pagegrid 2022-09-21 v1.6 Print page grid in background (HO)}
84 \Msg{************************************************************************}
85
86 \keepsilent
87 \askforoverwritefalse
88
89 \let\MetaPrefix\relax
90 \preamble
91
92 This is a generated file.
93
94 Project: pagegrid
95 Version: 2022-09-21 v1.6
96
97 Copyright (C)
98 2009 Heiko Oberdiek
99 2016-2022 Oberdiek Package Support Group
100
101 This work may be distributed and/or modified under the
102 conditions of the LaTeX Project Public License, either
103 version 1.3c of this license or (at your option) any later
104 version. This version of this license is in
105 https://www.latex-project.org/lppl/lppl-1-3c.txt
106 and the latest version of this license is in
107 https://www.latex-project.org/lppl.txt
108 and version 1.3 or later is part of all distributions of
109 LaTeX version 2005/12/01 or later.
110
111 This work has the LPPL maintenance status "maintained".
112
113 The Current Maintainers of this work are
114 Heiko Oberdiek and the Oberdiek Package Support Group
115 https://github.com/ho-tex/pagegrid/issues
116
117
118 This work consists of the main source file pagegrid.dtx
119 and the derived files
120 pagegrid.sty, pagegrid.pdf, pagegrid.ins, pagegrid.drv,
121 pagegrid-test1.tex.
122
123 \endpreamble
124 \let\MetaPrefix\DoubleperCent
125
126 \generate{%
127 \file{pagegrid.ins}{\from{pagegrid.dtx}{install}}%
128 \file{pagegrid.drv}{\from{pagegrid.dtx}{driver}}%
129 \usedir{tex/latex/pagegrid}%
130 \file{pagegrid.sty}{\from{pagegrid.dtx}{package}}%
131 % \usedir{doc/latex/pagegrid/test}%
132 % \file{pagegrid-test1.tex}{\from{pagegrid.dtx}{test1}}%
133 }
134
135 \catcode32=13\relax% active space
136 \let =\space%
137 \Msg{************************************************************************}
138 \Msg{*}
139 \Msg{* To finish the installation you have to move the following}
140 \Msg{* file into a directory searched by TeX:}
141 \Msg{*}
142 \Msg{* pagegrid.sty}
143 \Msg{*}
144 \Msg{* To produce the documentation run the file `pagegrid.drv'}
145 \Msg{* through LaTeX.}
146 \Msg{*}
147 \Msg{* Happy TeXing!}
148 \Msg{*}
149 \Msg{************************************************************************}
150
151 \endbatchfile
152 %</install>
153 %<*ignore>
154 \fi
155 %</ignore>
156 %<*driver>
157 \NeedsTeXFormat{LaTeX2e}
158 \ProvidesFile{pagegrid.drv}%
159 [2022-09-21 v1.6 Print page grid in background (HO)]%
160 \documentclass{ltxdoc}
161 \usepackage{holtxdoc}[2011/11/22]
162 \begin{document}
163 \DocInput{pagegrid.dtx}%
164 \end{document}
165 %</driver>
166 % \fi
167 %
168 %
169 %
170 % \GetFileInfo{pagegrid.drv}
171 %
172 % \title{The \xpackage{pagegrid} package}
173 % \date{2022-09-21 v1.6}
174 % \author{Heiko Oberdiek\thanks
175 % {Please report any issues at \url{https://github.com/ho-tex/pagegrid/issues}}}
176 %
177 % \maketitle
178 %
179 % \begin{abstract}
180 % The \LaTeX\ package prints a page grid in the background.
181 % \end{abstract}
182 %
183 % \tableofcontents
184 %
185 % \section{Documentation}
186 %
187 % The package puts a grid on the paper. It was written for
188 % developers of a class or package
189 % who have to put elements on definite locations on a page
190 % (e.g. letter class). The grid allows a faster optical check,
191 % whether the positions are correct. If the previewer already
192 % offers features for measuring, the package might be obsolete.
193 % Otherwise it saves the developer from printing the page and
194 % measuring by hand.
195 %
196 % \subsection{Options}
197 %
198 % Options are evaluated in the following order:
199 % \begin{enumerate}
200 % \item
201 % Configuration file \xfile{pagegrid.cfg} using \cs{pagegridsetup}
202 % if the file exists.
203 % \item
204 % Package options given for \cs{usepackage}.
205 % \item
206 % Later calls of \cs{pagegridsetup}.
207 % \end{enumerate}
208 % \begin{declcs}{pagegridsetup}\M{option list}
209 % \end{declcs}
210 % The options are key value options. Boolean options are enabled by
211 % default (without value) or by using the explicit value \texttt{true}.
212 % Value \texttt{false} disable the option.
213 %
214 % \subsubsection{Options \xoption{enable}, \xoption{disable}}
215 %
216 % \begin{description}
217 % \item[\xoption{enable}:] This boolean option controls whether the page grid
218 % is drawn. As default the page grid drawing is activated.
219 % \item[\xoption{disable}:] It is the opposite
220 % of option \xoption{enable}. It was added for convenience and
221 % allows the abbreviation \texttt{disable} for \texttt{enable=false}.
222 % \end{description}
223 %
224 % \subsubsection{Grid origins}
225 %
226 % The package supports up to two grids on a page allowing
227 % measurement from opposite directions. As default two grids are drawn,
228 % the first from bottom left to top right. The origin of the second
229 % grid is at the opposite top right corner.
230 % The origins are controlled by the following options.
231 % The number of grids (one or two) depend on the number of these options
232 % in one call of \cs{pagegridsetup}.
233 % The following frame shows a paper and in its corners are the
234 % corresponding options. At the left and right side alias names
235 % are given for the options inside the paper.
236 % \begin{quote}
237 % \begin{tabular}{@{}r|@{\,}l@{\qquad}r@{\,}|l@{}}
238 % \cline{2-3}
239 % \xoption{left-top}, \xoption{lt}, \xoption{top-left}
240 % & \vphantom{\"U}\xoption{tl} & \xoption{tr}
241 % & \xoption{top-right}, \xoption{rt}, \xoption{right-top}\\
242 % &&&\\
243 % \xoption{left-bottom}, \xoption{lb}, \xoption{bottom-left}
244 % & \xoption{bl} & \xoption{br}
245 % & \xoption{bottom-right}, \xoption{rb}, \xoption{right-bottom}\\
246 % \cline{2-3}
247 % \end{tabular}
248 % \end{quote}
249 % Examples:
250 % \begin{quote}
251 % |\pagegridsetup{bl,tr}|
252 % \end{quote}
253 % This is the default setting with two grids as described previously.
254 % The following setups one grid only. Its origin is the upper left
255 % corner:
256 % \begin{quote}
257 % |\pagegridsetup{top-left}|
258 % \end{quote}
259 %
260 % \subsubsection{Grid unit}
261 %
262 % \begin{description}
263 % \item[\xoption{step}] This option takes a length and
264 % setups the unit for the grid. The page width and page height
265 % should be multiples of this unit.
266 % Currently the default is \texttt{1mm}. But this might change
267 % later by a heuristic based on the paper size.
268 % \end{description}
269 %
270 % \subsubsection{Color options}
271 %
272 % The basic grid lines are drawn as ultra thin help lines and is only
273 % drawn for the first grid.
274 % Each tenth and fiftyth line of the basic net is drawn thicker in a special
275 % color for the two grids.
276 % \begin{description}
277 % \item[\xoption{firstcolor}:] Color for the thicker lines and the arrows
278 % of the first grid. Default value is \texttt{red}.
279 % \item[\xoption{secondcolor}:] Color for the thicker lines and the arrows
280 % of the second grid. Default value is \texttt{blue}.
281 % \end{description}
282 % Use a color specification that package \xpackage{tikz} understands.
283 % (The grid is drawn with \xpackage{pgf}/\xpackage{tikz}.)
284 %
285 % \subsubsection{Arrow options}
286 %
287 % Arrows are put at the origin at the grid to show the grid start
288 % and the direction of the grid.
289 % \begin{description}
290 % \item[\xoption{arrows}:] This boolean option turns the arrows on or off.
291 % As default arrows are enabled.
292 % \item[\xoption{arrowlength}:] The length given as value is the
293 % length of the edge of a square at the origin within the
294 % arrow is put as diagonal. Default is 10 times the grid unit (10\,mm).
295 % The real arrow length is this length multiplied by $\sqrt2$.
296 % \end{description}
297 %
298 % \subsubsection{Miscellaneous options}
299 %
300 % \begin{description}
301 % \item[\xoption{double}:] The output page is doubled, one without page
302 % grid and the other with page grid. Possible values are shown in the
303 % following table:
304 % \begin{quote}
305 % \begin{tabular}{ll}
306 % Option & Meaning\\
307 % \hline
308 % |false| & Turns option off.\\
309 % |first| & Grid page comes first.\\
310 % |last| & Grid page comes after the page without grid.\\
311 % |true| & Same as |last|.\\
312 % \meta{no value} & Same as |true|.\\
313 % \end{tabular}
314 % \end{quote}
315 % \textbf{Note:}
316 % The double output of the page has side effects.
317 % All whatsits are executed twice, for example: file writing
318 % and anchor setting. Some unwanted actions are catched such
319 % as multiple \cs{label} definitions, duplicate entries in
320 % the table of contents. For bookmarks, use package \xpackage{bookmarks}.
321 % \item[\xoption{foreground}:] Boolean option, default is \texttt{false}.
322 % Sometimes there might be elements on the page (e.g. large images)
323 % that hide the grid. Then option \xoption{foreground} puts the grids
324 % over the current output page.
325 % \end{description}
326 %
327 % \StopEventually{
328 % }
329 %
330 % \section{Implementation}
331 % \begin{macrocode}
332 %<*package>
333 % \end{macrocode}
334 % Reload check, especially if the package is not used with \LaTeX.
335 % \begin{macrocode}
336 \begingroup\catcode61\catcode48\catcode32=10\relax%
337 \catcode13=5 % ^^M
338 \endlinechar=13 %
339 \catcode35=6 % #
340 \catcode39=12 % '
341 \catcode44=12 % ,
342 \catcode45=12 % -
343 \catcode46=12 % .
344 \catcode58=12 % :
345 \catcode64=11 % @
346 \catcode123=1 % {
347 \catcode125=2 % }
348 \expandafter\let\expandafter\x\csname [email protected]\endcsname
349 \ifx\x\relax % plain-TeX, first loading
350 \else
351 \def\empty{}%
352 \ifx\x\empty % LaTeX, first loading,
353 % variable is initialized, but \ProvidesPackage not yet seen
354 \else
355 \expandafter\ifx\csname PackageInfo\endcsname\relax
356 \def\x#1#2{%
357 \immediate\write-1{Package #1 Info: #2.}%
358 }%
359 \else
360 \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
361 \fi
362 \x{pagegrid}{The package is already loaded}%
363 \aftergroup\endinput
364 \fi
365 \fi
366 \endgroup%
367 % \end{macrocode}
368 % Package identification:
369 % \begin{macrocode}
370 \begingroup\catcode61\catcode48\catcode32=10\relax%
371 \catcode13=5 % ^^M
372 \endlinechar=13 %
373 \catcode35=6 % #
374 \catcode39=12 % '
375 \catcode40=12 % (
376 \catcode41=12 % )
377 \catcode44=12 % ,
378 \catcode45=12 % -
379 \catcode46=12 % .
380 \catcode47=12 % /
381 \catcode58=12 % :
382 \catcode64=11 % @
383 \catcode91=12 % [
384 \catcode93=12 % ]
385 \catcode123=1 % {
386 \catcode125=2 % }
387 \expandafter\ifx\csname ProvidesPackage\endcsname\relax
388 \def\x#1#2#3[#4]{\endgroup
389 \immediate\write-1{Package: #3 #4}%
390 \xdef#1{#4}%
391 }%
392 \else
393 \def\x#1#2[#3]{\endgroup
394 #2[{#3}]%
395 \ifx#1\@undefined
396 \xdef#1{#3}%
397 \fi
398 \ifx#1\relax
399 \xdef#1{#3}%
400 \fi
401 }%
402 \fi
403 \expandafter\x\csname [email protected]\endcsname
404 \ProvidesPackage{pagegrid}%
405 [2022-09-21 v1.6 Print page grid in background (HO)]%
406 % \end{macrocode}
407 %
408 % \begin{macrocode}
409 \begingroup\catcode61\catcode48\catcode32=10\relax%
410 \catcode13=5 % ^^M
411 \endlinechar=13 %
412 \catcode123=1 % {
413 \catcode125=2 % }
414 \catcode64=11 % @
415 \def\x{\endgroup
416 \expandafter\edef\csname pagegrid@AtEnd\endcsname{%
417 \endlinechar=\the\endlinechar\relax
418 \catcode13=\the\catcode13\relax
419 \catcode32=\the\catcode32\relax
420 \catcode35=\the\catcode35\relax
421 \catcode61=\the\catcode61\relax
422 \catcode64=\the\catcode64\relax
423 \catcode123=\the\catcode123\relax
424 \catcode125=\the\catcode125\relax
425 }%
426 }%
427 \x\catcode61\catcode48\catcode32=10\relax%
428 \catcode13=5 % ^^M
429 \endlinechar=13 %
430 \catcode35=6 % #
431 \catcode64=11 % @
432 \catcode123=1 % {
433 \catcode125=2 % }
434 \def\TMP@EnsureCode#1#2{%
435 \edef\pagegrid@AtEnd{%
436 \pagegrid@AtEnd
437 \catcode#1=\the\catcode#1\relax
438 }%
439 \catcode#1=#2\relax
440 }
441 \TMP@EnsureCode{9}{10}% (tab)
442 \TMP@EnsureCode{10}{12}% ^^J
443 \TMP@EnsureCode{33}{12}% !
444 \TMP@EnsureCode{34}{12}% "
445 \TMP@EnsureCode{36}{3}% $
446 \TMP@EnsureCode{38}{4}% &
447 \TMP@EnsureCode{39}{12}% '
448 \TMP@EnsureCode{40}{12}% (
449 \TMP@EnsureCode{41}{12}% )
450 \TMP@EnsureCode{42}{12}% *
451 \TMP@EnsureCode{43}{12}% +
452 \TMP@EnsureCode{44}{12}% ,
453 \TMP@EnsureCode{45}{12}% -
454 \TMP@EnsureCode{46}{12}% .
455 \TMP@EnsureCode{47}{12}% /
456 \TMP@EnsureCode{58}{12}% :
457 \TMP@EnsureCode{59}{12}% ;
458 \TMP@EnsureCode{60}{12}% <
459 \TMP@EnsureCode{62}{12}% >
460 \TMP@EnsureCode{63}{12}% ?
461 \TMP@EnsureCode{91}{12}% [
462 \TMP@EnsureCode{93}{12}% ]
463 \TMP@EnsureCode{94}{7}% ^ (superscript)
464 \TMP@EnsureCode{95}{8}% _ (subscript)
465 \TMP@EnsureCode{96}{12}% `
466 \TMP@EnsureCode{124}{12}% |
467 \edef\pagegrid@AtEnd{\pagegrid@AtEnd\noexpand\endinput}
468 % \end{macrocode}
469 %
470 % \begin{macrocode}
471 \RequirePackage{tikz}
472 \RequirePackage{atbegshi}[2009/12/02]
473 \RequirePackage{kvoptions}[2009/07/17]
474 % \end{macrocode}
475 % \begin{macrocode}
476 \def\pagegrid@width{\paperwidth}%
477 \def\pagegrid@height{\paperheight}%
478 \@ifundefined{stockwidth}{}
479 {%
480 \ifdim \stockwidth > 0pt\relax
481 \ifdim \stockheight > 0pt \relax
482 \def\pagegrid@width{\stockwidth}%
483 \def\pagegrid@height{\stockheight}%
484 \fi
485 \fi
486 }
487 % \end{macrocode}
488 %
489 % \begin{macrocode}
490 \SetupKeyvalOptions{%
491 family=pagegrid,%
492 prefix=pagegrid@,%
493 }
494 \def\pagegrid@init{%
495 \let\pagegrid@origin@a\@empty
496 \let\pagegrid@origin@b\@empty
497 \let\pagegrid@init\relax
498 }
499 \let\pagegrid@@init\pagegrid@init
500 \def\pagegrid@origin@a{bl}
501 \def\pagegrid@origin@b{tr}
502 \def\pagegrid@SetOrigin#1{%
503 \pagegrid@init
504 \ifx\pagegrid@origin@a\@empty
505 \def\pagegrid@origin@a{#1}%
506 \else
507 \ifx\pagegrid@origin@b\@empty
508 \else
509 \let\pagegrid@origin@a\pagegrid@origin@b
510 \fi
511 \def\pagegrid@origin@b{#1}%
512 \fi
513 }
514 \def\pagegrid@temp#1{%
515 \DeclareVoidOption{#1}{\pagegrid@SetOrigin{#1}}%
516 \@namedef{pagegrid@N@#1}{#1}%
517 }
518 \pagegrid@temp{bl}
519 \pagegrid@temp{br}
520 \pagegrid@temp{tl}
521 \pagegrid@temp{tr}
522 \def\pagegrid@temp#1#2{%
523 \DeclareVoidOption{#2}{\pagegrid@SetOrigin{#1}}%
524 }%
525 \pagegrid@temp{bl}{lb}
526 \pagegrid@temp{br}{rb}
527 \pagegrid@temp{tl}{lt}
528 \pagegrid@temp{tr}{rt}
529 \pagegrid@temp{bl}{bottom-left}
530 \pagegrid@temp{br}{bottom-right}
531 \pagegrid@temp{tl}{top-left}
532 \pagegrid@temp{tr}{top-right}
533 \pagegrid@temp{bl}{left-bottom}
534 \pagegrid@temp{br}{right-bottom}
535 \pagegrid@temp{tl}{left-top}
536 \pagegrid@temp{tr}{right-top}
537 % \end{macrocode}
538 % \begin{macrocode}
539 \DeclareBoolOption[true]{enable}
540 \DeclareComplementaryOption{disable}{enable}
541 % \end{macrocode}
542 % \begin{macrocode}
543 \DeclareBoolOption{foreground}
544 % \end{macrocode}
545 % \begin{macrocode}
546 \newlength{\pagegrid@step}
547 \define@key{pagegrid}{step}{%
548 \setlength{\pagegrid@step}{#1}%
549 }
550 % \end{macrocode}
551 % \begin{macrocode}
552 \DeclareStringOption[red]{firstcolor}
553 \DeclareStringOption[blue]{secondcolor}
554 % \end{macrocode}
555 % \begin{macrocode}
556 \DeclareBoolOption[true]{arrows}
557 \newlength\pagegrid@arrowlength
558 \pagegrid@arrowlength=\z@
559 \define@key{pagegrid}{arrowlength}{%
560 \setlength{\pagegrid@arrowlength}{#1}%
561 }
562 % \end{macrocode}
563 % \begin{macrocode}
564 \define@key{pagegrid}{double}[true]{%
565 \@ifundefined{pagegrid@double@#1}{%
566 \PackageWarning{pagegrid}{%
567 Unsupported value `#1' for option `double'.\MessageBreak
568 Known values are:\MessageBreak
569 `false', `first', `last', `true'.\MessageBreak
570 Now `false' is used%
571 }%
572 \chardef\pagegrid@double\z@
573 }{%
574 \chardef\pagegrid@double\csname pagegrid@double@#1\endcsname\relax
575 }%
576 }
577 \@namedef{pagegrid@double@false}{0}
578 \@namedef{pagegrid@double@first}{1}
579 \@namedef{pagegrid@double@last}{2}
580 \@namedef{pagegrid@double@true}{2}
581 \chardef\pagegrid@double\z@
582 % \end{macrocode}
583 % \begin{macrocode}
584 \newcommand*{\pagegridsetup}{%
585 \let\pagegrid@init\pagegrid@@init
586 \setkeys{pagegrid}%
587 }
588 % \end{macrocode}
589 % \begin{macrocode}
590 \pagegridsetup{%
591 step=1mm%
592 }
593 \InputIfFileExists{pagegrid.cfg}{}%
594 \ProcessKeyvalOptions*\relax
595 \AtBeginDocument{%
596 \ifdim\pagegrid@arrowlength>\z@
597 \else
598 \pagegrid@arrowlength=10\pagegrid@step
599 \fi
600 }
601 % \end{macrocode}
602 %
603 % \begin{macrocode}
604 \def\pagegridShipoutDoubleBegin{%
605 \begingroup
606 \let\newlabel\@gobbletwo
607 \let\zref@newlabel\@gobbletwo
608 \let\@writefile\@gobbletwo
609 \let\select@language\@gobble
610 }
611 \def\pagegridShipoutDoubleEnd{%
612 \endgroup
613 }
614 \def\pagegrid@WriteDouble#1#2{%
615 \immediate\write#1{%
616 \@backslashchar csname %
617 pagegridShipoutDouble#2%
618 \@backslashchar endcsname%
619 }%
620 }
621 \def\pagegrid@ShipoutDouble#1{%
622 \begingroup
623 \if@filesw
624 \pagegrid@WriteDouble\@mainaux{Begin}%
625 \ifx\@auxout\@partaux
626 \pagegrid@WriteDouble\@partaux{Begin}%
627 \def\pagegrid@temp{%
628 \pagegrid@WriteDouble\@mainaux{End}%
629 \pagegrid@WriteDouble\@partaux{End}%
630 }%
631 \else
632 \def\pagegrid@temp{%
633 \pagegrid@WriteDouble\@mainaux{End}%
634 }%
635 \fi
636 \else
637 \def\pagegrid@temp{}%
638 \fi
639 \let\protect\noexpand
640 \AtBeginShipoutOriginalShipout\copy#1\relax
641 \pagegrid@temp
642 \endgroup
643 }
644 % \end{macrocode}
645 %
646 % \begin{macrocode}
647 \AtBeginShipout{%
648 \ifdim\pagegrid@step>\z@
649 \else
650 \pagegrid@enablefalse
651 \fi
652 \ifpagegrid@enable
653 \ifnum\pagegrid@double=\@ne
654 \pagegrid@ShipoutDouble\AtBeginShipoutBox
655 \else
656 \ifnum\pagegrid@double=\tw@
657 \@ifundefined{pagegrid@DoubleBox}{%
658 \newbox\pagegrid@DoubleBox
659 }{}%
660 \setbox\pagegrid@DoubleBox=\copy\AtBeginShipoutBox
661 \fi
662 \fi
663 \ifpagegrid@foreground
664 \expandafter\AtBeginShipoutUpperLeftForeground
665 \else
666 \expandafter\AtBeginShipoutUpperLeft
667 \fi
668 {%
669 \put(0,0){%
670 \makebox(0,0)[lt]{%
671 \begin{tikzpicture}[%
672 bl/.style={},%
673 br/.style={xshift=\pagegrid@width,xscale=-1},%
674 tl/.style={yshift=\pagegrid@height,yscale=-1},%
675 tr/.style={xshift=\pagegrid@width,%
676 yshift=\pagegrid@height,scale=-1}%
677 ]%
678 \useasboundingbox
679 (0mm,\pagegrid@height) rectangle (0mm,\pagegrid@height);%
680 \draw[%
681 \pagegrid@origin@a,%
682 step=\pagegrid@step,%
683 style=help lines,%
684 ultra thin%
685 ] (0mm,0mm) grid (\pagegrid@width,\pagegrid@height);%
686 \ifx\pagegrid@origin@b\@empty
687 \else
688 \draw[%
689 \pagegrid@origin@b,%
690 step=10\pagegrid@step,%
691 {\pagegrid@secondcolor},%
692 very thin%
693 ] (0mm,0mm) grid (\pagegrid@width,\pagegrid@height);%
694 \fi
695 \draw[%
696 \pagegrid@origin@a,%
697 step=10\pagegrid@step,%
698 {\pagegrid@firstcolor},%
699 very thin%
700 ] (0mm,0mm) grid (\pagegrid@width,\pagegrid@height);%
701 \ifx\pagegrid@origin@b\@empty
702 \else
703 \draw[%
704 \pagegrid@origin@b,%
705 step=50\pagegrid@step,%
706 {\pagegrid@secondcolor},%
707 thick%
708 ] (0mm,0mm) grid (\pagegrid@width,\pagegrid@height);%
709 \fi
710 \draw[%
711 \pagegrid@origin@a,%
712 step=50\pagegrid@step,%
713 {\pagegrid@firstcolor},%
714 thick%
715 ] (0mm,0mm) grid (\pagegrid@width,\pagegrid@height);%
716 \ifpagegrid@arrows
717 \ifx\pagegrid@origin@b\@empty
718 \else
719 \draw[%
720 \pagegrid@origin@b,%
721 {\pagegrid@secondcolor},%
722 stroke,%
723 line width=1pt,%
724 line cap=round%
725 ] (0mm,0mm) %
726 -- (\pagegrid@arrowlength,\pagegrid@arrowlength) %
727 (\pagegrid@arrowlength,.5\pagegrid@arrowlength) %
728 -- (\pagegrid@arrowlength,\pagegrid@arrowlength) %
729 -- (.5\pagegrid@arrowlength,\pagegrid@arrowlength);%
730 \fi
731 \draw[%
732 \pagegrid@origin@a,%
733 {\pagegrid@firstcolor},%
734 stroke,%
735 line width=1pt,%
736 line cap=round%
737 ] (0mm,0mm) %
738 -- (\pagegrid@arrowlength,\pagegrid@arrowlength) %
739 (\pagegrid@arrowlength,.5\pagegrid@arrowlength) %
740 -- (\pagegrid@arrowlength,\pagegrid@arrowlength) %
741 -- (.5\pagegrid@arrowlength,\pagegrid@arrowlength);%
742 \fi
743 \end{tikzpicture}%
744 }%
745 }%
746 }%
747 \ifnum\pagegrid@double=\tw@
748 \pagegrid@ShipoutDouble\pagegrid@DoubleBox
749 \fi
750 \fi
751 }
752 % \end{macrocode}
753 %
754 % \begin{macrocode}
755 \pagegrid@AtEnd%
756 %</package>
757 % \end{macrocode}
758 %% \section{Installation}
759 %
760 % \subsection{Download}
761 %
762 % \paragraph{Package.} This package is available on
763 % CTAN\footnote{\CTANpkg{pagegrid}}:
764 % \begin{description}
765 % \item[\CTAN{macros/latex/contrib/pagegrid/pagegrid.dtx}] The source file.
766 % \item[\CTAN{macros/latex/contrib/pagegrid/pagegrid.pdf}] Documentation.
767 % \end{description}
768 %
769 %
770 %
771 % \subsection{Package installation}
772 %
773 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
774 % \docstrip\ archive. The files are extracted by running the
775 % \xfile{.dtx} through \plainTeX:
776 % \begin{quote}
777 % \verb|tex pagegrid.dtx|
778 % \end{quote}
779 %
780 % \paragraph{TDS.} Now the different files must be moved into
781 % the different directories in your installation TDS tree
782 % (also known as \xfile{texmf} tree):
783 % \begin{quote}
784 % \def\t{^^A
785 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
786 % pagegrid.sty & tex/latex/pagegrid/pagegrid.sty\\
787 % pagegrid.pdf & doc/latex/pagegrid/pagegrid.pdf\\
788 % pagegrid.dtx & source/latex/pagegrid/pagegrid.dtx\\
789 % \end{tabular}^^A
790 % }^^A
791 % \sbox0{\t}^^A
792 % \ifdim\wd0>\linewidth
793 % \begingroup
794 % \advance\linewidth by\leftmargin
795 % \advance\linewidth by\rightmargin
796 % \edef\x{\endgroup
797 % \def\noexpand\lw{\the\linewidth}^^A
798 % }\x
799 % \def\lwbox{^^A
800 % \leavevmode
801 % \hbox to \linewidth{^^A
802 % \kern-\leftmargin\relax
803 % \hss
804 % \usebox0
805 % \hss
806 % \kern-\rightmargin\relax
807 % }^^A
808 % }^^A
809 % \ifdim\wd0>\lw
810 % \sbox0{\small\t}^^A
811 % \ifdim\wd0>\linewidth
812 % \ifdim\wd0>\lw
813 % \sbox0{\footnotesize\t}^^A
814 % \ifdim\wd0>\linewidth
815 % \ifdim\wd0>\lw
816 % \sbox0{\scriptsize\t}^^A
817 % \ifdim\wd0>\linewidth
818 % \ifdim\wd0>\lw
819 % \sbox0{\tiny\t}^^A
820 % \ifdim\wd0>\linewidth
821 % \lwbox
822 % \else
823 % \usebox0
824 % \fi
825 % \else
826 % \lwbox
827 % \fi
828 % \else
829 % \usebox0
830 % \fi
831 % \else
832 % \lwbox
833 % \fi
834 % \else
835 % \usebox0
836 % \fi
837 % \else
838 % \lwbox
839 % \fi
840 % \else
841 % \usebox0
842 % \fi
843 % \else
844 % \lwbox
845 % \fi
846 % \else
847 % \usebox0
848 % \fi
849 % \end{quote}
850 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
851 % TDS installing feature, then some files can already be in the right
852 % place, see the documentation of \docstrip.
853 %
854 % \subsection{Refresh file name databases}
855 %
856 % If your \TeX~distribution
857 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
858 % these. For example, \TeX\,Live\ users run \verb|texhash| or
859 % \verb|mktexlsr|.
860 %
861 % \subsection{Some details for the interested}
862 %
863 % \paragraph{Unpacking with \LaTeX.}
864 % The \xfile{.dtx} chooses its action depending on the format:
865 % \begin{description}
866 % \item[\plainTeX:] Run \docstrip\ and extract the files.
867 % \item[\LaTeX:] Generate the documentation.
868 % \end{description}
869 % If you insist on using \LaTeX\ for \docstrip\ (really,
870 % \docstrip\ does not need \LaTeX), then inform the autodetect routine
871 % about your intention:
872 % \begin{quote}
873 % \verb|latex \let\install=y\input{pagegrid.dtx}|
874 % \end{quote}
875 % Do not forget to quote the argument according to the demands
876 % of your shell.
877 %
878 % \paragraph{Generating the documentation.}
879 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
880 % the documentation. The process can be configured by the
881 % configuration file \xfile{ltxdoc.cfg}. For instance, put this
882 % line into this file, if you want to have A4 as paper format:
883 % \begin{quote}
884 % \verb|\PassOptionsToClass{a4paper}{article}|
885 % \end{quote}
886 % An example follows how to generate the
887 % documentation with pdf\LaTeX:
888 % \begin{quote}
889 %\begin{verbatim}
890 %pdflatex pagegrid.dtx
891 %makeindex -s gind.ist pagegrid.idx
892 %pdflatex pagegrid.dtx
893 %makeindex -s gind.ist pagegrid.idx
894 %pdflatex pagegrid.dtx
895 %\end{verbatim}
896 % \end{quote}
897 %
898 % \section{Acknowledgement}
899 %
900 % \begin{description}
901 % \item[Klaus Braune:]
902 % He provided the idea and the first \xpackage{tikz} code.
903 % \end{description}
904 %
905 % \begin{History}
906 % \begin{Version}{2009/11/06 v1.0}
907 % \item
908 % The first version.
909 % \end{Version}
910 % \begin{Version}{2009/11/06 v1.1}
911 % \item
912 % Option \xoption{foreground} added.
913 % \end{Version}
914 % \begin{Version}{2009/12/02 v1.2}
915 % \item
916 % Color options, arrow options added.
917 % \item
918 % Names for origin options changed.
919 % \end{Version}
920 % \begin{Version}{2009/12/03 v1.3}
921 % \item
922 % Option \xoption{double} added.
923 % \item
924 % First CTAN release.
925 % \end{Version}
926 % \begin{Version}{2009/12/04 v1.4}
927 % \item
928 % Option \xoption{double}: Some unwanted side effects removed.
929 % \end{Version}
930 % \begin{Version}{2016/05/16 v1.5}
931 % \item
932 % Documentation updates.
933 % \end{Version}
934 % \begin{Version}{2022-09-21 v1.6}
935 % \item Adapted the test for stockwidth/stockheight to a change in the \LaTeX\ kernel.
936 % \end{Version}
937 % \end{History}
938 %
939 % \PrintIndex
940 %
941 % \Finale
942 \endinput