Debian Codegraph @

texmf-dist/source/latex/tile-graphic/tile-graphic.dtx

raw
1 %\iffalse
2 %<*copyright>
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %% tile-graphic.sty package, %%
5 %% Copyright (C) 2020 %%
6 %% [email protected] %%
7 %% [email protected] %%
8 %% %%
9 %% This program can redistributed and/or modified under %%
10 %% the terms of the LaTeX Project Public License %%
11 %% Distributed from CTAN archives in directory %%
12 %% macros/latex/base/lppl.txt; either version 1.2 of the %%
13 %% License, or (at your option) any later version. %%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 %</copyright>
16 %<package>\NeedsTeXFormat{LaTeX2e}[1997/12/01]
17 %<package>\ProvidesPackage{tile-graphic}
18 %<package> [2020/05/27 v1.0.1 Tile a graphic (dps)]
19 %<*driver>
20 \documentclass{ltxdoc}
21 \usepackage[colorlinks,hyperindex=false]{hyperref}
22 \usepackage{array,calc}
23 \usepackage{fancyvrb}
24 \usepackage{graphicx}
25 %\def\texorpdfstring#1#2{#1}
26 %\pdfstringdefDisableCommands{\let\\\textbackslash}
27 \EnableCrossrefs
28 \CodelineIndex
29 \RecordChanges
30 \InputIfFileExists{aebdocfmt.def}{\PackageInfo{tile-graphic}{Inputting aebdocfmt.def}}
31 {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax
32 \PackageInfo{tile-graphic}{aebdocfmt.def cannot be found}}
33 %\pdfstringdefDisableCommands{\let\\\textbackslash}
34 %\EnableCrossrefs \CodelineIndex
35 \RecordChanges
36 \let\pkg\textsf
37 \let\opt\texttt
38 \let\key\texttt
39 \let\app\textsf
40 \bgroup\ttfamily
41 \gdef\brpr#1{\char123\relax#1\char125\relax}\egroup
42 \let\darg\brpr
43 \def\ameta#1{\ensuremath{\langle\textsl{\texttt{#1}}\rangle}}
44 \def\meta#1{\textsl{\texttt{#1}}}
45 \def\SUB#1{\ensuremath{{}_{\mbox{\scriptsize\ttfamily#1}}}}
46 \def\cs#1{\texttt{\bslash#1}}
47 \def\EXCL{!}
48 \let\tops\texorpdfstring
49 \DeclareRobustCommand{\tmspace}[3]{%
50 \ifmmode\mskip#1#2\else\kern#1#3\fi\relax}
51 \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}}
52 \let\thinspace\,
53 \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}}
54 \let\negthinspace\!
55 \renewcommand{\:}{\tmspace+\medmuskip{.2222em}}
56 \let\medspace\:
57 \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}}
58 \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}}
59 \let\thickspace\;
60 \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}}
61 \makeatletter
62 \renewcommand{\paragraph}
63 {\@startsection{paragraph}{4}{0pt}{6pt}{-3pt}
64 {\normalfont\normalsize\bfseries}}
65 \renewcommand{\subparagraph}
66 {\@startsection{subparagraph}{5}{\parindent}{6pt}{-3pt}{\bfseries}}
67 \renewenvironment{quote}[1][]
68 {\def\@rgi{#1}\ifx\@rgi\@empty
69 \let\rghtm\@empty\else\def\rghtm{\rightmargin\leftmargin}\fi
70 \list{}{\rghtm} %{\rightmargin\leftmargin}%
71 \item\relax}
72 {\endlist}
73 \makeatother
74 \def\ctg#1{\texttt{create-tg.#1}}
75 \def\packagesuffix{package}
76 \def\V{\string|}
77 \def\picBox#1#2#3{{\fboxsep0pt\fbox{\parbox[t][#2]{#1}{\vfill\centering#3\vfill}}}}
78 \def\picBoxi#1#2#3{{\fboxrule0pt\fboxsep0pt\fbox{\parbox[t][#2]{#1}{\vfill\centering#3\vfill}}}}
79 \begin{document}
80 \def\CMD#1{\textbackslash#1}
81 \GetFileInfo{tile-graphic.sty}
82 \title{\textsf{tile-graphic}: Break a graphic into tiles}
83 \author{D. P. Story\\
84 Email: \texttt{[email protected]}}
85 \date{processed \today}
86 \value{secnumdepth}=3
87 \value{tocdepth}=3
88 \maketitle
89 \tableofcontents
90 \let\Email\texttt
91 \DocInput{tile-graphic.dtx}
92 \IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}{\paragraph*{Index} The index goes here.\\Execute
93 \texttt{makeindex -s gind.ist -o tile-graphic.ind tile-graphic.idx} on the command line and recompile
94 \texttt{tile-graphic.dtx}.}
95 \IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here.\\Execute
96 \texttt{makeindex -s gglo.ist -o tile-graphic.gls tile-graphic.glo} on the command line and recompile
97 \texttt{tile-graphic.dtx}.}
98 \end{document}
99 %</driver>
100 % \fi
101 % \MakeShortVerb{|}
102 % \StopEventually{}
103 %
104 % \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let}
105 % \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi}
106 % \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup}
107 % \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand}
108 % \DoNotIndex{\space,\@empty,\special}
109 % \DoNotIndex{\x,\y,\z}
110 %
111 % \begin{macrocode}
112 %<*package>
113 % \end{macrocode}
114 %
115 % \section{Documentation}\label{s:docs}
116 %
117 % \def\pici{\marginpar{\raggedleft\bgroup\offinterlineskip\parindent0pt
118 % \vtop{%
119 % \picBox{20pt}{25pt}{\texttt{01}}\picBox{20pt}{25pt}{\texttt{02}}\picBox{20pt}{25pt}{\texttt{03}}\\%
120 % \picBox{20pt}{25pt}{\texttt{04}}\picBox{20pt}{25pt}{\texttt{05}}\picBox{20pt}{25pt}{\texttt{06}}\\%
121 % \picBox{20pt}{25pt}{\texttt{07}}\picBox{20pt}{25pt}{\texttt{08}}\picBox{20pt}{25pt}{\texttt{09}}\\%
122 % \picBox{20pt}{25pt}{\texttt{10}}\picBox{20pt}{25pt}{\texttt{11}}\picBox{20pt}{25pt}{\texttt{12}}\\[6pt]%
123 % {\parbox{60pt}{\small\centering Tiled graphic\\($4\times3$)}}%
124 % }%
125 % \egroup}}
126 % \def\picii{\marginpar{\raggedleft\bgroup\offinterlineskip\parindent0pt
127 % \vtop{%
128 % \picBox{20pt}{25pt}{\texttt{01}}\\\picBox{20pt}{25pt}{\texttt{02}}\\\picBox{20pt}{25pt}{\texttt{03}}\\%
129 % \picBox{20pt}{25pt}{\texttt{04}}\\\picBox{20pt}{25pt}{\texttt{05}}\\\picBox{20pt}{25pt}{\texttt{06}}\\%
130 % \picBoxi{20pt}{25pt}{$\vdots\,\vdots\,\vdots$}\\%
131 % \picBox{20pt}{25pt}{\texttt{10}}\\\picBox{20pt}{25pt}{\texttt{11}}\\\picBox{20pt}{25pt}{\texttt{12}}\\[6pt]%
132 % {\parbox{20pt}{\small\centering\strut\kern0pt\hbox to0pt{\hss{Pages}\hss}\\\strut\hbox to0pt{\hss($4\times3$)\hss}}}%
133 % }%
134 % \egroup}}
135 %
136 % \subsection{A brief description} The\pici\space document author opens the \ctg{tex} file and specifies three
137 % arguments of the \cs{setTileParams} command: a number $n$ that corresponds to the number of rows; a number
138 % $m$ that represents the number of columns; and the path to a graphic. Compiling \ctg{tex}, when the option \opt{wrttofiles} is specified, results
139 % in the specified graphic being broken down into a series of $n\times m$ \textit{tiled} graphics. The order of the creation
140 % of the tiles is top to bottom, left to right: The first row is the top most row, and the graphic is tiled across
141 % the row, from left to right, the next row, is the one just below the top row, and the graphic is tiled across that
142 % row, from left to right, and so on. Refer to the crude diagram to the left.\medskip
143 %
144 %\begin{center}
145 %\fbox{\begin{minipage}{.67\linewidth}
146 %\textbf{\textcolor{red}{Warning:}} This package uses the \pkg{shellesc} package, which requires
147 %the \texttt{--shell-escape} switch. Use this package only if you trust the author of this package.
148 %\end{minipage}}
149 %\end{center}
150 % \subsection{Applications}
151 % The \pkg{tile-graphic} package can be used to produce tiled graphics, which can be
152 % consumed by the \pkg{dps} and \pkg{acrosort} packages.
153 %
154 % \subsection{The \texttt{create-tg.tex} file}
155 % Because of the extensive use of \cs{ShellEscape}, \ctg{tex} is similar to a
156 % BAT (batch) file. When you compile \ctg{tex}, one result is \ctg{pdf}; \ctg{pdf} is
157 % a one page summary titled \textbf{Tile Graphic Report}. In addition to producing a report,
158 % there is the actual result the report refers to: the production of tiled graphic files (PDFs).
159 %
160 % Tiled graphics are obtained by compiling \ctg{tex},
161 % after setting three parameters; using this package, therefore, is very simple.
162 % Below is the verbatim listing of the \ctg{tex}, found in the \texttt{examples} folder.
163 %\begin{Verbatim}[xleftmargin=\leftmargini,codes={\catcode`\%=9},commandchars={!@^}]
164 % \documentclass{article}
165 % !makebox[0pt][r]@!rmfamily(1)!enspace^\usepackage[!ameta@options^]{tile-graphic}
166 % !makebox[0pt][r]@!rmfamily(2)!enspace^\setTileParams[!ameta@ig-opts^]{!ameta@nRows^}{!ameta@nCols^}{!ameta@path^}
167 % \begin{document}
168 % !makebox[0pt][r]@!rmfamily(3)!enspace^\tileTheGraphic
169 % \end\darg{document}
170 %\end{Verbatim}
171 % When \texttt{create-tg.tex} is compiled, the DVI (in the case of \LaTeX) or the PDF (in all other cases) produces
172 % a single page document the title of which is ``\textbf{Tile Graphic Report}.'' The file also produces, depending
173 % on the options used, various \emph{separate} PDFs consisting of tiled graphics.
174 %
175 % \paragraph*{Discussion.} We discuss each of the numbered lines slightly out of order.
176 %\begin{enumerate}
177 % \item[(2)] \cs{setTileParams[\ameta{ig-opts}]\darg{\ameta{nRows}}\darg{\ameta{nCols}}\darg{\ameta{path}}}\DescribeMacro\setTileParams\\
178 % The command and its arguments are placed in the preamble.
179 % \begin{description}
180 % \item[\normalfont\ameta{ig-opts}] This optional argument is passed to the underlying optional argument of the \cs{includegraphics} command.
181 % Normally, there is no optional options passed.
182 %
183 % \item[\normalfont\ameta{nRows}] This argument declares the number of rows you want to break the graphic into.
184 %
185 % \item[\normalfont\ameta{nCols}] This argument declares the number of columns you want to break the graphic into.
186 %
187 % \item[\normalfont\ameta{path}] The path to the graphic. The graphic is any
188 % file format supported by the PDF creator. For a
189 % \texttt{latex->dvips->\ameta{\upshape ps2pdf\string|distiller}} workflow, the graphic
190 % should be an EPS file; in all other workflows, the graphic can be a PDF
191 % (or some other supported graphical format). For example, if the graphic
192 % is in the \texttt{graphics} folder of the source file, then \ameta{path}
193 % might read \texttt{graphics/mygraphic}, where \texttt{mygraphic.pdf} (for example) is
194 % in the \texttt{graphics} folder.
195 % \end{description}
196 % With no package options, compiling \ctg{tex} produces a document a single page document
197 % with a message, seen in \hyperref[fig:noopts]{Figure~\ref*{fig:noopts}}.
198 %
199 % \begin{figure}[htb]\centering
200 % \includegraphics[width=.67\linewidth]{docs/graphics/noopts}
201 % \caption{No options}\label{fig:noopts}
202 % \end{figure}
203 % \item[(1)] \cs{usepackage[\ameta{options}]\darg{tile-graphic}}\picii\\
204 % For the package declaration, the \ameta{options} are described below.
205 % \begin{description}
206 % \item[\opt{wrttofiles}] When \ctg{tex} is compiled with the \opt{wrttofiles} option \emph{only}
207 % and with a \ameta{path} argument of \texttt{graphics/mygraphic},
208 % $\ameta{nRows}\times\ameta{nCols}$ individual tile PDF files named
209 % \begin{quote}
210 % \texttt{mygraphic\_01.pdf}, \texttt{mygraphic\_02.pdf}, \dots
211 % \end{quote} are created and placed in the \texttt{graphics} folder.
212 % If no subfolder is specified, files are placed in the source file's folder. The source file that is compiled
213 % (\texttt{create-tg.pdf}) contains the \textbf{Tile Graphic Report}.
214 %
215 % \item[\opt{!wrttofiles}] (Convenience option) This option reverts to the default, no separate tile PDFs are produced.
216 %
217 % \item[\opt{packagefiles}]
218 % When this option is specified, $\ameta{nRows}\times\ameta{nCols}$ pages are produced and ``packaged'' in a separate
219 % PDF document named \texttt{\ameta{basename}\_\packagesuffix.pdf}, where \ameta{basename} is the base name of the graphic.
220 % See the crude illustration to the left.
221 %
222 % \item[\opt{!packagefiles}] (Convenience option) Reverses the \opt{packagefiles} option,
223 % as a result, no package file is created.
224 %
225 % \item[\opt{pdfcreator=\ameta{{\upshape pdflatex\string|lualatex\string|xelatex\string|ps2pdf\string|distiller}}}]\leavevmode\\
226 % When the option \opt{wrttofiles} or \opt{packagefiles}
227 % is specified, compiling \ctg{tex} produces one or more PDF files. These PDFs are produced
228 % by \app{pdflatex}, \app{lualatex}, \app{xelatex}, \app{ps2pdf}, or \app{distiller} by executing a
229 % series of \cs{ShellEscape} commands. The PDF creator
230 % application used is determined by the value of the \opt{pdfcreator} key. The default is \texttt{pdflatex}.
231 %
232 % Using the \cs{ShellEscape} command is system dependent. The \pkg{tile-graphic} package is set up for
233 % the \app{Windows} OS; it uses \textsf{del}, \textsf{copy}, and \textsf{move}. Refer to
234 % \hyperref[s:custcmds]{Section~\ref*{s:custcmds}} for more information for modifying these
235 % system commands.
236 %
237 % \pkg{tile-graphic} also uses \cs{ShellEscape} to compile certain dynamically created TEX files. There are hooks
238 % to modify the compile commands that can be used at your discretion. Again, refer to
239 % \hyperref[s:custcmds]{Section~\ref*{s:custcmds}} for more information.
240 % \end{description}
241 % \item[(3)] \cs{tileTheGraphic}\DescribeMacro\tileTheGraphic\relax\space is placed in the body of the document. It is this command that does all the work,
242 % based on the parameters of \cs{setTileParam}.
243 %\end{enumerate}
244 %
245 %\paragraph*{Required packages.} The following package are required: \pkg{shellesc}, \pkg{web},
246 %\pkg{graphicx}, and \pkg{multido}.
247 %
248 %\paragraph*{Try it, you'll like it.} The first thing to do, once the package is installed, is to try the
249 % compiling the file \ctg{tex}. There are three graphics files, one at the top level of the \texttt{examples}
250 % folder, one in the \texttt{choo} subfilder, and one in the \texttt{postscript} subfolder. Try both graphics (only one graphic at a time, however). Try all possible combinations
251 % of the basic options \opt{wrttofiles}, \opt{!wrttofiles}, \opt{packagefiles}, and \opt{!packagefiles}; you can even try
252 % the various values of \opt{pdfcreator}.
253 %
254 %\subsection{Description of the workflow}
255 % Be aware that there are two instances, or stages, of compiling:
256 % \begin{quote}
257 % \begin{enumerate}
258 % \item[Stage 1.]\label{Item:one} Compiling \ctg{tex}, usually, this is initiated in some {\LaTeX} editor. At this stage,
259 % you can compile with \app{latex.exe}, \app{pdflatex.exe}, \app{lualatex.exe}, or \app{xelatex.exe}.
260 % When \DescribeMacro\setTileParams\cs{setTileParams} is expanded, it reads the graphic file,
261 % \ameta{path}, using \cs{includegraphics} to determine its size. Therefore, the graphic must
262 % be one that is supported by the pdf creator at this point. For example if the graphic is a PDF, yet
263 % you use \app{latex.exe} to compile \ctg{tex}, you get an error because \app{latex.exe} does not support
264 % PDF inclusion.
265 % \item[Stage 2.]\label{Item:two} Compiling of one or more files to produce tiled graphics, this step is initiated
266 % by the \cs{ShellEscape} command. The application used to compile at this stage is determined
267 % by the \key{pdfcreator} key. When the \opt{packagefiles} option is taken, the \DescribeMacro\setTileParams
268 % \cs{setTileParams} is expanded again and the graphic file, \ameta{path}, is included to determine
269 % dimension of the graphic. Again, the graphic must be a format supported by the PDF creator as selected
270 % by the \key{pdfcreator} key, which may be different from the compiler of the first case above.
271 % \end{enumerate}
272 % \end{quote}
273 % Additional thoughts on the workflow.
274 % \begin{itemize}
275 % \item \key{pdfcreator=\ameta{\upshape pdflatex\string|lualatex\string|xelatex}}\\[3pt]
276 % This is the easiest and simplest case. Usually the PDF creators for the two stages of compiling are the same
277 % (refer to Stages~\hyperref[Item:one]{1} and~\hyperref[Item:two]{2}, above). These are direct-to-PDF applications, the workflow
278 % is relatively quick, smooth, and automated. All AUX files are are deleted except for the AUX files of the
279 % main file \ctg{tex}.
280 %
281 % \item \key{pdfcreator=\ameta{\upshape ps2pdf\string|distiller}}\\[3pt]
282 % The graphic file format must be EPS for \hyperref[Item:two]{Stage~2}; however, if you are not
283 % using \app{latex.exe} in \hyperref[Item:one]{Stage~1}, the graphic must be one that is supported
284 % by the PDF creator used. Thus you may have two copies of the graphic of different formats. You're
285 % not going to do that, are you? Usually the PDF creators for the two stages of compiling are the same, that way
286 % you need not have two formats for the graphic.
287 % \begin{itemize}
288 % \item \key{pdfcreator=\ameta{\upshape ps2pdf}}\\[3pt]
289 % The workflow is \texttt{latex\,->\,dvips\,->\,ps2pdf}
290 % \item \key{pdfcreator=\ameta{\upshape distiller}}\\[3pt]
291 % The workflow is \texttt{latex\,->\,dvips\,->\,distiller}.
292 % There is a difference between using \app{distiller} and \app{ps2pdf}, in the latter case, the PS
293 % file can be a relative path; in the former case, it must be a full (or absolute) path, this is a
294 % slight complication. For this bad boy, we provide the \DescribeMacro\fullPathToSource
295 % \cs{fullPathToSource}, refer to \hyperref[s:custcmds]{Section~\ref*{s:custcmds}} for more details.
296 % \end{itemize}
297 % \end{itemize}
298 % \subsection{The Configuration File}
299 % A configuration file, named \marginpar{\raggedleft\small\texttt{tg.cfg}}\texttt{tg.cfg},
300 % is input at the end of the package. You might make any customizations there, where you
301 % customize for the pdf creator you always use, or, if you use several, you can make
302 % customizations for each by using the \cs{ifcase} structure below.
303 %\begin{Verbatim}[xleftmargin=\leftmargini,codes={\catcode`\%=9},commandchars=!()]
304 %\ifcase\tg@case\relax
305 % \def\tg@pdfcreator@app{pdflatex}
306 % !quad!ameta(customizations-for-pdflatex)
307 %\or
308 % \def\tg@pdfcreator@app{lualatex}
309 % !quad!ameta(customizations-for-lualatex)
310 %\or
311 % \def\tg@pdfcreator@app{xelatex}
312 % !quad!ameta(customizations-for-xelatex)
313 %\or
314 % \def\tg@pdfcreator@app{ps2pdf}
315 % !quad!ameta(customizations-for-ps2pdf)
316 %\or
317 % \def\tg@pdfcreator@app{acrodist}
318 % !quad!ameta(customizations-for-acrodist)
319 %\fi
320 %\end{Verbatim}
321 %See the file \marginpar{\raggedleft\small\texttt{tg.cfg.txt}}\texttt{tg.cfg.txt} for this structure.
322 %Rename it to \texttt{tg.cfg} if found to be useful.
323 % $$
324 % \rule[2pt]{.25\linewidth}{.4pt}\, \textbf{End of Documentation}\,\rule[2pt]{.25\linewidth}{.4pt}
325 % $$
326 % \section{The package code}
327 %
328 % Having finished the barest of documentation, we begin the markup of this package.
329 % \changes{v1.0}{2020/05/27}{Set version number to v1.0 to publish package}
330 % \subsection{Options}
331 % We bring in the \pkg{xkeyval} package so we can gather our options using
332 % it's commands, rather than the default \pkg{keyval} commands.
333
334 % \begin{macrocode}
335 \RequirePackage{xkeyval}
336 % \end{macrocode}
337 % \leavevmode\IndexOpt{wrttofiles}\IndexOpt[\protect\EXCL]{!wrttofiles} When \opt{wrttofiles} is specfied,
338 % $\ameta{nRows}\times\ameta{nCols}$ PDF files are created. When \opt{!wrttofiles} is used, these files
339 % just mentions are not created.
340 % \begin{macrocode}
341 \newif\if@wrttofiles\@wrttofilesfalse
342 \DeclareOptionX{wrttofiles}{\@wrttofilestrue}
343 \DeclareOptionX{!wrttofiles}{\@wrttofilesfalse}
344 % \end{macrocode}
345 % \leavevmode\IndexOpt{packagefiles} When specified, a single ``package'' PDF is created containing
346 % $\ameta{nRos}\times\ameta{nCols}$ pages of tiled graphics
347 % Likewise, the option \IndexOpt[\protect\EXCL]{!packagefiles}\opt{!packagefiles} reverses \opt{packagefiles} to return
348 % to the default state, files are not packaged.
349 % \begin{macrocode}
350 \newif\if@packagefiles \@packagefilestrue
351 \DeclareOptionX{packagefiles}{\@packagefilestrue}
352 \DeclareOptionX{!packagefiles}{\@packagefilesfalse}
353 % \end{macrocode}
354 % \leavevmode\IndexOpt{pdfcreator}\hskip-\marginparsep\texttt{=\ameta{{\upshape pdflatex\string|lualatex\string|xelatex\string|ps2pdf\string|distiller}}}
355 % \begin{macrocode}
356 \define@choicekey*+{tile-graphic.sty}{pdfcreator}[\val\nr]%
357 {pdflatex,lualatex,xelatex,ps2pdf,distiller}{%
358 \edef\tg@case{\nr}%
359 \ifcase\nr\relax
360 \def\tg@pdfcreator@app{pdflatex}\or
361 \def\tg@pdfcreator@app{lualatex}\or
362 \def\tg@pdfcreator@app{xelatex}\or
363 \def\tg@pdfcreator@app{ps2pdf}\or
364 \def\tg@pdfcreator@app{acrodist}\fi
365 }{\PackageWarning{tile-graphics}%
366 {Bad choice for pdfcreator, permissible values\MessageBreak
367 are pdflatex, lualatex, xelatex, ps2pdf, and\MessageBreak
368 distiller.\MessageBreak Using the default pdflatex}}
369 \def\tg@pdfcreator@app{pdflatex}\def\tg@case{0}
370 % \end{macrocode}
371 % Process the options
372 % \begin{macrocode}
373 \ProcessOptionsX\relax
374 \edef\tg@restoreCats{%
375 \catcode`\noexpand\"=\the\catcode`\"\relax
376 \catcode`\noexpand\,=\the\catcode`\,\relax
377 \catcode`\noexpand\_=\the\catcode`\_\relax
378 }
379 \@makeother\"\@makeother\,\@makeother\_
380 % \end{macrocode}
381 % \subsection{Required Packages}
382 % The \pkg{web} package is use to set the page dimensions, it also brings in \pkg{hyperref}.
383 % We use \pkg{graphicx} package to have access to \cs{includegraphics}. The \cs{multido} package
384 % is used to work across the face of the graphic by row, top to bottom, to clip off little bounding boxes of the graphic.
385 % \pkg{shellesc} is required for the \opt{wrttofiles} option.
386 % \begin{macrocode}
387 \RequirePackage{shellesc}
388 \RequirePackage{web}
389 \RequirePackage{graphicx}
390 \RequirePackage{multido}
391 % \end{macrocode}
392 % \subsection{Registers and other preliminaries}
393 % We declare a new if, \DescribeMacro\if@wrtorpkg\cs{if@wrtorpkg}, which is true if either \cs{if@wrttofiles}
394 % or \cs{if@packagefiles} is true. This is a convenience to the coding.
395 % \begin{macrocode}
396 \newif\if@wrtorpkg \@wrtorpkgfalse
397 \if@wrttofiles
398 \@wrtorpkgtrue
399 \else
400 \if@packagefiles
401 \@wrtorpkgtrue
402 \fi
403 \fi
404 \newif\iftg@direct \tg@directtrue
405 \newif\iftgfolder \tgfolderfalse
406 % \end{macrocode}
407 % \leavevmode\DescribeMacro\iftg@direct
408 % \cs{iftg@direct} is false if \key{pdfcreator=\ameta{ps2pdf\string|distiller}}.
409 % \begin{macrocode}
410 \ifnum\tg@case>\tw@\relax\tg@directfalse\fi
411 % \end{macrocode}
412 % A few comments on the \cs{ifpassthruTG} switch. This package performs some tricks.
413 % Initially, \cs{ifpassthruTG} is true, and certain portions of the code are executed. When \texttt{create-tg.tex}
414 % is compiled with \cs{passthruTGtrue}, it writes to the current folder the file \texttt{package-data.cut} containing the single command \cs{passthruTGfalse}.
415 % During this compile, \texttt{create-tg.tex} makes a copy of itself named \texttt{\ameta{basename}\_\packagesuffix.tex}.
416 % It is this tile that is compiled by \cs{ShellEscape}, and when compiled, reads \texttt{package-data.cut}, since it now exists,
417 % and \cs{ifpassthruTG} is set to false, at which point a different set of code lines are executed.
418 % \begin{macrocode}
419 \newif\ifpassthruTG \passthruTGtrue
420 % \end{macrocode}
421 % Some miscellaneous lengths, boxes, and utility commands.
422 % \begin{macrocode}
423 \newdimen\tg@dima
424 \newdimen\tg@dimb
425 \newbox\tg@box
426 \newcount\tg@Cnt
427 \def\tg@rmslash#1/{\def\tgInFolder{#1}}%
428 \let\tgInFolder\@empty
429 % \end{macrocode}
430 %\goodbreak
431 % \subsection{Some customization commands}\label{s:custcmds}
432 % \paragraph*{System commands.} These are \DescribeMacro\sysdel\cs{sysdel},
433 % \DescribeMacro\syscopy\cs{syscopy}, and \DescribeMacro\sysmove\cs{sysmove}. The
434 % default is to use \app{Windows} OS commands. Changes for UNIX/Linux or MacOS are easy enough
435 % by declaring these three commands in the preamble (or in \texttt{tg.cfg}), their arguments are the names of
436 % the corresponding system commands for deleting, copying, and moving files.
437 % \begin{macrocode}
438 \def\sysdel#1{\def\tg@sysdel{#1\space}}
439 \sysdel{del}
440 \def\syscopy#1{\def\tg@syscopy{#1\space}}
441 \syscopy{copy}
442 \def\sysmove#1{\def\tg@sysmove{#1\space}}
443 \sysmove{move}
444 % \end{macrocode}
445 % \paragraph*{Changing the switches in Stage 2.} Here is a link to the \hyperref[Item:two]{Stage~2} reference.
446 % There are two TEX files compiled: (1) the package file, and (2)
447 % the individual tiles graphic files. We provide a hook to modify the command line
448 % switches of the \texttt{pdfcreator}. \DescribeMacro\pkgappArgs\cs{pkgappArgs} is the hook
449 % into the creation of the package file. Use \texttt{\#1} to represent the \texttt{pdfcreator}
450 % application. For example, \verb~\pkappArgs{#1 -halt-on-error}~ produces a command line
451 % of \begin{quote}\app{pdflatex -halt-on-error --shell-escape \ameta{targeted-package-file.tex}}\end{quote}
452 % For a \texttt{pdfcreator} of \app{pdflatex}.
453 % The \texttt{--shell-escape} is automatically included.
454 % \begin{macrocode}
455 \def\pkgappArgs#1{\def\pkg@ppArgs##1{#1}}
456 \pkgappArgs{#1}
457 % \end{macrocode}
458 % We also separately compile each of the separate tile graphics. \DescribeMacro\tileappArgs
459 % \cs{tileappArgs} is similar to \cs{pkgappArgs}. If we declare \verb~\tileappArgs{#1 -halt-on-error}~, then the command line
460 % becomes,
461 % \begin{quote}\app{pdflatex -halt-on-error \ameta{targeted-tile-graphic.tex}}\end{quote}
462 % Here, \texttt{--shell-escape} is not automatically included as it is not needed for this step.
463 % \begin{macrocode}
464 \def\tileappArgs#1{\def\tile@ppArgs##1{#1}}
465 \tileappArgs{#1}
466 % \end{macrocode}
467 %
468 % \subparagraph*{Some unverified tricks.} What if your system does not recognize \app{pdflatex},
469 % \app{lualatex}, and so on; perhaps they are know by different names. You can use these hooks
470 % to fix that. For example,
471 % \begin{quote}\ttfamily
472 % \string\pkgappArgs\darg{\ameta{alt-pdflatex}.exe \ameta{other-switches}}
473 % \end{quote}
474 % Or, perhaps the path to this application is not on the system paths, hence \app{pdflatex}
475 % is not recognized, in this case, try
476 % \begin{quote}\ttfamily
477 % \string\pkgappArgs\darg{\ameta{path-to}/\ameta{alt-pdflatex}.exe \ameta{other-switches}}
478 % \end{quote}
479 % that ``should'' work.\par\medskip\noindent
480 % When \key{pdfcreator=\ameta{ps2pdf\string|distiller}}, we provide two hooks for this workflow:
481 % \DescribeMacro\latexappArgs\cs{latexappArgs} and \DescribeMacro\dvipsappArgs\cs{dvipsappArgs}. These function
482 % similar to the ones described above; for example, \verb~\dvipsappArgs{#1 -q*}~ passes the \texttt{-q*} switch
483 % (quiet mode) to \app{dvips}. No separate commands for a package compile versus a tile compile, as seen above,
484 % are defined, though that could change.
485 % \begin{macrocode}
486 \def\latexappArgs#1{\def\latex@ppArgs##1{#1}}
487 \latexappArgs{#1}
488 \def\dvipsappArgs#1{\def\dvips@ppArgs##1{#1}}
489 \dvipsappArgs{#1}
490 % \end{macrocode}
491 % \leavevmode\DescribeMacro\definePath\hskip-\marginparsep\texttt{\darg{\ameta{\cs{cmd}}}\darg{\ameta{path}}}
492 % A command taken from \pkg{eforms} that normalizes the argument before
493 % defining \cs{cmd}.
494 % \begin{macrocode}
495 \providecommand{\definePath}[1]{\def\ef@ctrlName{#1}%
496 \hyper@normalise\ef@definePath}
497 \def\ef@definePath#1{\expandafter\xdef\ef@ctrlName{#1}}
498 % \end{macrocode}
499 % \subparagraph*{Support for \key{pdfcreator=distiller}.}\leavevmode\medskip\par\noindent
500 % \leavevmode\DescribeMacro\fullPathToSource\hskip-\marginparsep\texttt{\darg{\ameta{path}}}
501 % Set the full path to the source file (\texttt{create-tg.tex}). This command is only needed
502 % when \opt{pdfcreator=distiller}.
503 % \begin{macrocode}
504 \def\fullPathToSource{\definePath{\tg@fullPathToSource}}
505 \let\tg@fullPathToSource\@empty
506 % \end{macrocode}
507 % \paragraph*{After creation hooks.} We provide additional hooks, the first is placed
508 % just after a tile file is created, and second one is placed just after the package file is created.
509 %
510 % \medskip\noindent
511 %\DescribeMacro\afterTileCreationHook\hskip-\marginparsep\texttt
512 %{\darg{\ameta{\cs{cmds}}}} The \ameta{\cs{cmds}} can be any valid {\LaTeX} commands,
513 %conceptually, the commands may contain \cs{ShellEscape} commands. The hook is placed
514 %just after a tile file is created as a PDF.\par\medskip\noindent
515 %\DescribeMacro\afterPkgCreationHook\hskip-\marginparsep\texttt
516 %{\darg{\ameta{\cs{cmds}}}} Similar to \cs{afterTileCreationHook}, but for the creation
517 %of the tile package.
518 % \begin{macrocode}
519 \def\afterTileCreationHook#1{\def\@fterTileCreationHook{#1}}
520 \let\@fterTileCreationHook\relax
521 % \end{macrocode}
522 % The definition of \cs{afterPkgCreationHook}.
523 % \begin{macrocode}
524 \def\afterPkgCreationHook#1{\def\@fterPkgCreationHook{#1}}
525 \let\@fterPkgCreationHook\relax
526 % \end{macrocode}
527 %\subparagraph*{Examples.} This example makes each \emph{tile} PDF file into a tile EPS file.
528 %We use the utility executable \app{pdftops}, which may be available on your {\TeX} system.
529 %In the preamble or above the \cs{tileTheGraphic} command, place the following commands.
530 %\begin{Verbatim}[xleftmargin=\parindent,codes={\catcode`\%=9},commandchars={*()}]
531 %\afterTileCreationHook{*%
532 % \ShellEscape{pdftops -eps tile-template.pdf
533 % tile-template.eps}*%
534 % \ShellEscape{copy tile-template.eps \tgTileBaseIndx.eps}*%
535 % \iftgfolder
536 % \ShellEscape{move \tgTileBaseIndx.eps \tgInFolder}*%
537 % \fi
538 %}
539 %\afterPkgCreationHook{*%
540 % \typeout{!! Package creation: \tgBaseName_package.pdf !!}}
541 %\end{Verbatim}
542 %\subparagraph*{Commentary.} At insertion point of the hooks in the code stream, the
543 %tile file is named \texttt{tile-template}.
544 %The declared \cs{afterTileCreationHook} converts each tile file,
545 %to an EPS file of the same name. Then, it copies \texttt{tile-temp.eps} to
546 %\DescribeMacro\tgTileBaseIndx\cs{tgTileBaseIndx.eps}. Next, we test whether
547 %this file came from a subfolder (using the switch \DescribeMacro\iftgfolder
548 %\cs{iftgfolder}). Finally, if the file belongs in the folder, \DescribeMacro\tgInFolder\cs{tgInFolder},
549 %we move it there. For the \cs{afterPkgCreationHook}, we do nothing other than to write some
550 %text to the terminal, we use the base name of the graphic \DescribeMacro\tgBaseName
551 %\cs{tgBaseName}.
552 %\medskip\par\noindent
553 % \DescribeMacro\packagesuffix\hskip-\marginparsep\texttt{\darg{\ameta{name}}}
554 % The name used as suffix to the packaged tiled files. Originally, this was \texttt{packaged},
555 % but I am changing it to \texttt{package}, to be in conformance with the \pkg{acrosort} package.
556 % \changes{v1.0.1}{2020/05/27}{Replace suffix of packaged with just package, but control the
557 % naming with \string\cs{packagesuffix}.}
558 % \begin{macrocode}
559 \newcommand{\packagesuffix}{package}
560 % \end{macrocode}
561 % \subsection{\tops{\protect\cs{setTileParams}}{\textbackslash{setTileParams}}: A preamble command}
562 % \leavevmode\DescribeMacro\setTileParams\hskip-\marginparsep
563 % \texttt{[\ameta{ig-opts}]\darg{\ameta{nRows}}\darg{\ameta{nCols}}\darg{\ameta{path}}} The parameters
564 % are described in Section~\ref{s:docs} (\textbf{Documentation}).
565 % \begin{macrocode}
566 \newcommand{\setTileParams}[4][]{%
567 % \end{macrocode}
568 % We require the entries in \texttt{\#2} and \texttt{\#3} (\ameta{nRows} and \ameta{nCols})
569 % to be nonnegative natural numbers (1, 2, 3, \dots), so we pass through a dimension register
570 % and into a count register, this should make what is entered a natural number.
571 % If not greater or equal to 1, we complain, and set to the number 2.
572 % \begin{macrocode}
573 \tg@dima #3\p@\relax
574 \ifdim\tg@dima < \p@
575 \PackageWarning{tile-graphic}
576 {Number of columns must be positive,\MessageBreak
577 setting number of columns to 2}\tg@dima\tw@\p@\fi
578 \edef\nCols{\strip@pt\tg@dima}%
579 \tg@Cnt\nCols\relax
580 \edef\n@Cols{\the\tg@Cnt}\edef\nCols{\the\tg@Cnt}%
581 \tg@dima #2\p@\relax
582 \ifdim\tg@dima < \p@
583 \PackageWarning{tile-graphic}
584 {Number of rows must be positive,\MessageBreak
585 setting number of rows to 2}\tg@dima\tw@\p@\fi
586 \edef\nRows{\strip@pt\tg@dima}%
587 \tg@Cnt\nRows\relax
588 \edef\n@Rows{\the\tg@Cnt}\edef\nRows{\the\tg@Cnt}%
589 \multiply\tg@Cnt \nCols\relax
590 \edef\nFilesCreated{\the\tg@Cnt}%
591 \def\pathToPic{#4}%
592 % \end{macrocode}
593 % Parse the path to obtain the parts of the path, area, base, and extension.
594 % \begin{macrocode}
595 \filename@parse{#4}%
596 \edef\tg@dir{\filename@area}%
597 \ifx\tg@dir\@empty\tgfolderfalse\else
598 \expandafter\tg@rmslash\tg@dir
599 \tgfoldertrue
600 \fi
601 \edef\tg@base{\filename@base}%
602 \edef\tgBaseName{\filename@base}%
603 \edef\tg@ext{\filename@ext}%
604 % \end{macrocode}
605 % Get graphic dimensions, dimensions needed for {\TeX} (pt) and PDF (bp)
606 % \begin{macrocode}
607 \setbox\tg@box\hbox{\includegraphics[draft,#1]{#4}}%
608 \setlength\tg@dima{\the\wd\tg@box}%
609 \tg@dima=.99626\tg@dima
610 \divide\tg@dima \nCols
611 \edef\bpWdtile{\strip@pt\tg@dima}%
612 \setlength\tg@dima{\the\ht\tg@box}%
613 \tg@dima=.99626\tg@dima
614 \divide\tg@dima \nRows
615 \edef\bpHttile{\strip@pt\tg@dima}%
616 \setbox\tg@box\box\voidb@x
617 \tg@dima=\bpHttile pt \relax
618 \edef\tg@HT{\the\tg@dima}
619 \tg@dima=\bpWdtile pt \relax
620 \edef\tg@WD{\the\tg@dima}
621 % \end{macrocode}
622 % Set margins and screen size using the \pkg{web} package. If \cs{ifpassthruTG} is true,
623 % we use reasonably size dimensions to display the \textbf{Tile Graphic Report}; otherwise,
624 % we use dimensions based on the size of the graphic determined by \ameta{path}.
625 % \begin{macrocode}
626 \ifpassthruTG
627 \web@MargScrDimOpts{.25in}{.25in}{24pt}{.25in}{5in}{6in}
628 \else
629 \web@MargScrDimOpts{0pt}{0pt}{0pt}{0pt}{\tg@HT}{\tg@WD}
630 \fi
631 % \end{macrocode}
632 % \paragraph*{Bounding box calculations for the tiles}\leavevmode\par\medskip\noindent
633 %^^A%
634 % The $y$-coordinate calculations: If \cs{nRows} is $3$, for example, we calculate $4$ $y$-coodinates,
635 % \cs{y1}, \cs{y2}, \cs{y3}, \cs{y4}, from bottom to top.
636 % \begin{macrocode}
637 \@tempcnta\n@Rows\relax
638 \advance\@tempcnta\@ne
639 \edef\n@Rows{\the\@tempcnta}
640 \@tempcnta\z@
641 \tg@dima0pt
642 \tg@dimb=\tg@HT\relax
643 \@whilenum \@tempcnta < \n@Rows \do {%
644 \advance\@tempcnta\@ne
645 \csarg\edef{y\the\@tempcnta}{\strip@pt\tg@dima}
646 \advance\tg@dima \tg@dimb
647 }
648 % \end{macrocode}
649 % The $x$-coordinate calculations If \cs{nCols} is $2$, for example, we calculate $3$ $x$-coodinates,
650 % \cs{x1}, \cs{x2}, \cs{x3}, from left to right.
651 % \begin{macrocode}
652 \@tempcnta\n@Cols\relax
653 \advance\@tempcnta\@ne
654 \edef\n@Cols{\the\@tempcnta}
655 \@tempcnta\z@
656 \tg@dima0pt
657 \tg@dimb=\tg@WD\relax
658 \@whilenum \@tempcnta < \n@Cols \do {%
659 \advance\@tempcnta\@ne
660 \csarg\edef{x\the\@tempcnta}{\strip@pt\tg@dima}
661 \advance\tg@dima \tg@dimb
662 }
663 % \end{macrocode}
664 % Having finished the calculations, we then execute \cs{tg@wrtthefiledoc}.
665 % \begin{macrocode}
666 \if@wrtorpkg\expandafter
667 \tg@wrtthefiledoc\fi
668 }
669 % \end{macrocode}
670 % \DescribeMacro\tg@wrtthefiledoc
671 % This command writes the \texttt{tile-template.tex} file to the source
672 % file folder. It will read,
673 %\begin{Verbatim}[xleftmargin=\leftmargini,codes={\catcode`\%=9}]
674 %\RequirePackage{tmp}
675 %\documentclass{article}
676 %\usepackage{web}
677 %\usepackage{graphicx}
678 %\let\WriteBookmarks\relax
679 %\margins{0pt}{0pt}{0pt}{0pt}
680 %\screensize{\tg@HT}{\tg@WD}
681 %\parindent0pt\parskip0pt
682 %\begin{document}
683 %\tgInputContent
684 %\end{document}
685 %\end{Verbatim}
686 %This is the file that is compiled using \cs{ShellEscape} to create the individual
687 %tile files. This document contains a trick, the use of the \pkg{tmp} package, which
688 %is written dynamically just before this file is compiled. The \pkg{tmp} package is
689 %created by \cs{tg@wrttmppkg}, defined next. The \pkg{tmp} package defines the
690 %command \DescribeMacro\tgInputContent\cs{tgInputContent} in the body of the document.
691 % \begin{macrocode}
692 \def\tg@wrtthefiledoc{\newwrite\wrttiledoc
693 \long\def\IWTD##1{\immediate\write\wrttiledoc{##1}}
694 \immediate\openout \wrttiledoc tile-template.tex
695 \IWTD{%
696 \string\RequirePackage{tmp}^^J%
697 \string\documentclass{article}^^J%
698 \string\usepackage{web}^^J%
699 \string\usepackage{graphicx}^^J%
700 \string\let\string\WriteBookmarks\string\relax^^J%
701 \string\margins{0pt}{0pt}{0pt}{0pt}^^J%
702 \string\screensize{\tg@HT}{\tg@WD}^^J%
703 \string\parindent0pt\string\parskip0pt^^J%
704 \string\begin{document}^^J%
705 \string\tgInputContent^^J%
706 \string\end{document}}%
707 \immediate\closeout \wrttiledoc
708 }
709 % \end{macrocode}
710 % \leavevmode\DescribeMacro\tg@wrttmppkg\hskip-\marginparsep\texttt{\darg{\ameta{basename}}\darg{\ameta{indx}}}
711 % Write the \pkg{tmp} package dynamically: \ameta{basename} is the base name of the graphic; \ameta{indx} is the
712 % index of the tile (\texttt{01}, \texttt{02}, \texttt{03}, \dots). The action of this package
713 % is to define \cs{tgInputContent} to input the file
714 % \begin{quote}\ttfamily
715 % \ameta{basename}\_\ameta{indx}.cut
716 % \end{quote}
717 % \begin{macrocode}
718 \def\tg@wrttmppkg#1#2{\def\CommentCutFile{tmp.sty}%
719 \immediate\openout\CommentStream \CommentCutFile
720 \immediate\write\CommentStream{\string
721 \def\string\tgInputContent{\string
722 \InputIfFileExists{#1_#2.cut}%
723 {}{\string\null}}}%
724 \immediate\closeout\CommentStream
725 }
726 % \end{macrocode}
727 % \subsection{\tops{\protect\cs{tileTheGraphic}}{\textbackslash{tileTheGraphic}}: A document body command}
728 % The file \texttt{create-tb.tex} contains the single command \cs{tileTheGraphic} in the body
729 % of the document. It has not arguments.
730 % \begin{macrocode}
731 \InputIfFileExists{package-data.cut}{}{}%
732 % \end{macrocode}
733 % \DescribeMacro\tg@msgi
734 % is the content of \texttt{create-tg} to deliver the \textbf{Tile Graphic Report}. It may be redefined.
735 % This content command is expanded in \cs{tileTheGraphic}, defined below.
736 % \begin{macrocode}
737 \def\tg@msgi{%
738 \textbf{Tile Graphic Report}\medskip\par
739 \textbf{Options:}
740 \begin{itemize}
741 \if@wrttofiles
742 \item The \texttt{wrttofiles} option taken,
743 {\nFilesCreated} files written ({\nRows}~rows, {\nCols}~cols):
744 \begin{quote}
745 \texttt{\tg@base\_01.pdf}, \texttt{\tg@base\_02.pdf}, \dots.
746 \end{quote}
747 \ifx\tg@dir\@empty Files saved to source file folder. \else
748 Files saved to the \texttt{\tgInFolder} folder.\fi
749 \else
750 \item The \texttt{!wrttofiles} option taken, no files written.
751 \fi
752 \if@packagefiles
753 \item The \texttt{packagefiles} option taken,
754 package file saved as \texttt{\tg@base\_\packagesuffix.pdf}.
755 The package contains {\nFilesCreated} pages of tiled graphics.
756 \ifx\tg@dir\@empty
757 The package file saved to source file folder.
758 \else
759 The package file saved to the \texttt{\tgInFolder} folder.
760 \fi
761 \else
762 \item The \texttt{!packagefiles} option taken,
763 no package file created.
764 \fi
765 \end{itemize}
766 \if@wrtorpkg\else
767 Try using the \texttt{wrttofiles} and/or
768 \texttt{packagefiles} option(s) to obtain a nontrivial result.
769 \fi
770 }
771 % \end{macrocode}
772 %\leavevmode\DescribeMacro\tileTheGraphic (No arguments) This is the command that tiles
773 %the graphic.
774 % \begin{macrocode}
775 \def\tileTheGraphic{\begingroup\let\@nu\@nameuse
776 % \end{macrocode}
777 % If the \opt{!packagefiles} option is in effect, we set \cs{ifpassthruTG} to false
778 % so we can execute the \cs{else} part within \texttt{create-tg.tex} (as opposed
779 % to in \texttt{\ameta{basename}\_\packagesuffix.tex}).
780 % \begin{macrocode}
781 \if@packagefiles\else\global\passthruTGfalse\expandafter
782 \tg@msgi % provide content
783 \fi
784 \ifpassthruTG
785 \tg@msgi % provide content
786 \else
787 % \end{macrocode}
788 % Okay, we are here either because we are compiling this file either from within
789 % \texttt{\ameta{basename}\_\packagesuffix.tex} or from within the source file \texttt{create-tg.tex}
790 % with the \opt{!packagefiles} option is in effect.
791 % \begin{macrocode}
792 \global\let\tg@IndxToks\@empty
793 % \end{macrocode}
794 % Nested \cs{multido} loop to create grid
795 % \begin{macrocode}
796 \if@wrtorpkg\expandafter\tg@domultido\fi
797 \fi
798 \endgroup
799 \xdef\nFilesCreated{\the\tg@Cnt}%
800 \edef\x{\if@wrtorpkg\noexpand\compileTileFiles\fi}\x
801 }
802 % \end{macrocode}
803 % \leavevmode\DescribeMacro\tg@domultido Called by \cs{tileTheGraphic}. Consists of
804 % nested \cs{multido} loops. The command both creates the package file and the individual
805 % tile graphics, depending on the options. The command \cs{tg@IndexToks} creates a token list
806 % of indices \verb~{01}{02}{03}...~ that is later used in a \cs{@tfor} loop.
807 % \begin{macrocode}
808 \def\tg@domultido{%
809 \tg@Cnt\z@
810 \multido{\iR=\nRows+-1}{\nRows}{%
811 \multido{\iC=1+1}{\nCols}{%
812 \global\advance\tg@Cnt\@ne
813 \ifnum\tg@Cnt<10\relax
814 \edef\x{0\the\tg@Cnt}\else
815 \edef\x{\the\tg@Cnt}\fi
816 \edef\y{\noexpand\g@addto@macro\noexpand
817 \tg@IndxToks{{\x}}}\y
818 \@tempcntb\iC
819 \advance\@tempcntb\@ne
820 \edef\oX{\the\@tempcntb}%
821 \@tempcntb\iR
822 \advance\@tempcntb\@ne
823 \edef\oY{\the\@tempcntb}%
824 % \end{macrocode}
825 % We write the CUT files.
826 % \begin{macrocode}
827 \wrtTileCuts
828 % \end{macrocode}
829 % Include the graphic with the appropriate viewport and clip; however,
830 % we executed the temporary command \cs{z} if the option \cs{packagefiles}
831 % is in effect.
832 % \begin{macrocode}
833 \edef\z{\noexpand\parbox{\tg@WD}{\noexpand
834 \includegraphics[width=\tg@WD,%
835 viewport=\@nu{x\iC} \@nu{y\iR} \@nu{x\oX} \@nu{y\oY},%
836 clip]{\pathToPic}}}\if@packagefiles\expandafter
837 \z\expandafter\newpage\fi
838 }% inner multido
839 }% outer multido
840 }
841 % \end{macrocode}
842 % \leavevmode\DescribeMacro\wrtTileCuts (Called by \cs{tg@domultido}) The CUT files created are the body content
843 % of the \texttt{tile-template.tex} file. The CUTs are also used by the package file routine.
844 % The content of these CUT files has the following form:
845 %\begin{Verbatim}[xleftmargin=\parindent,codes={\catcode`\%=9},commandchars=!()]
846 %\parbox{132.23935pt}{\includegraphics[width=132.23935pt,
847 % viewport=0 114.23943 132.23935 228.47885,clip]{!ameta(pathToPic)}}
848 %\end{Verbatim}
849 %where the values of \texttt{width} and \texttt{viewport} were calculated by the \cs{setTileParams}
850 %in the preamble.
851 % \begin{macrocode}
852 \def\wrtTileCuts{%
853 \def\CommentCutFile{\tg@base_\x.cut}%
854 \immediate\openout\CommentStream=\CommentCutFile
855 \immediate\write\CommentStream{\string
856 \parbox{\tg@WD}{\string
857 \includegraphics[width=\tg@WD,%
858 viewport=\@nu{x\iC} \@nu{y\iR} \@nu{x\oX} \@nu{y\oY},%
859 clip]{\pathToPic}}}\immediate\closeout\CommentStream
860 }
861 % \end{macrocode}
862 %\leavevmode\DescribeMacro\compileTileFiles (Called from \cs{tileTheGraphic}) This command performs
863 %the \cs{ShellEscape} steps. It is executed only if the \opt{wrttofiles} or \opt{packagefiles} option
864 %is taken (or both).
865 % \begin{macrocode}
866 \def\compileTileFiles{%
867 \ifpassthruTG
868 \if@packagefiles
869 % \end{macrocode}
870 % \paragraph*{Package the tile files.} This code is executed by \texttt{create-tg.tex} (because \cs{passthruTG} is true).
871 % We write the \texttt{package-data.cut} file, later input by the \pkg{tmp} package, which puts \cs{passthruTG}
872 % to false.
873 % \begin{macrocode}
874 \def\CommentCutFile{package-data.cut}%
875 \immediate\openout\CommentStream \CommentCutFile
876 \immediate\write\CommentStream{\string\passthruTGfalse}%
877 \immediate\closeout\CommentStream
878 % \end{macrocode}
879 % Then copy \cs{create-tg.tex} to \texttt{\ameta{basename}\_\packagesuffix.tex}. Keep in mind
880 % that when we compile \cs{tg@base\_\packagesuffix.tex} which uses the \pkg{tile-graphic} package,
881 % \cs{passthruTG} is false. When \texttt{\ameta{basename}\_\packagesuffix.tex} gets here,
882 % this block of code is skipped over.
883 % \begin{macrocode}
884 \ShellEscape{\tg@syscopy \jobname.tex
885 \tg@base_\packagesuffix.tex}%
886 % \end{macrocode}
887 % and compile with the \texttt{--shell-escape} switch,
888 % \begin{macrocode}
889 \iftg@direct
890 \ShellEscape{\pkg@ppArgs{\tg@pdfcreator@app} --shell-escape
891 \tg@base_\packagesuffix.tex}%
892 \else
893 \ShellEscape{\latex@ppArgs{latex} --shell-escape
894 \tg@base_\packagesuffix.tex}%
895 \ShellEscape{\dvips@ppArgs{dvips} \tg@base_\packagesuffix.dvi}%
896 \ifnum\tg@case=\thr@@
897 \ShellEscape{\pkg@ppArgs{\tg@pdfcreator@app}
898 \tg@base_\packagesuffix.ps}%
899 \else
900 \ShellEscape{\pkg@ppArgs{\tg@pdfcreator@app} /N /Q
901 "\tg@fullPathToSource/\tg@base_\packagesuffix.ps"}%
902 \fi
903 \ShellEscape{\tg@sysdel \tg@base_\packagesuffix.dvi
904 \tg@base_\packagesuffix.ps}%
905 \fi
906 % \end{macrocode}
907 % Insert the after-package-creation-hook \DescribeMacro\@fterPkgCreationHook
908 % \cs{@fterPkgCreationHook}
909 % \begin{macrocode}
910 \@fterPkgCreationHook
911 % \end{macrocode}
912 % clean up,
913 % \begin{macrocode}
914 \ShellEscape{\tg@sysdel \tg@base_\packagesuffix.tex
915 \tg@base_\packagesuffix.log \tg@base_\packagesuffix.aux}%
916 % \end{macrocode}
917 % and move into the folder from which the graphic resides, if necessary.
918 % \begin{macrocode}
919 \iftgfolder
920 \ShellEscape{\tg@sysmove
921 \tg@base_\packagesuffix.pdf \tgInFolder}\fi
922 \fi
923 \else
924 % \end{macrocode}
925 % \paragraph*{Create the tile files.} This block is compiled if \cs{passThruTG}
926 % is false and the \opt{wrttofiles} option is taken.
927 % The block gets compiled in two instances:
928 % \begin{enumerate}
929 % \item[(1)] by \texttt{\ameta{basename}\_\packagesuffix.tex} if the \opt{packagefiles} and
930 % \opt{wrttofiles} options are taken;
931 % \item[(2)] by \texttt{create-tg.tex} if \opt{!packagefiles} and
932 % \opt{wrttofiles} options are taken. (Recall that if \opt{!packagefiles}
933 % is taken, then \cs{ifpassThruTG} is set to false earlier in the code stream.)
934 % \end{enumerate}
935 % \begin{macrocode}
936 \if@wrttofiles
937 \edef\@tforexp{\noexpand
938 \@tfor\noexpand\Indx:=\tg@IndxToks}%
939 % \end{macrocode}
940 % For each token in \cs{tg@IndexToks} (\verb!{01}{02}{03}...)!, we compile
941 % the dynamic file \texttt{tile-template.tex}.
942 % \begin{macrocode}
943 \@tforexp \do {%
944 \edef\tgTileBaseIndx{\tg@base_\Indx}%
945 % \end{macrocode}
946 % Create the \pkg{tmp} package with parameters \ameta{basename} and \ameta{indx}.
947 % \begin{macrocode}
948 \edef\x{\noexpand\tg@wrttmppkg{\tg@base}{\Indx}}\x
949 % \end{macrocode}
950 % Compile this turkey,
951 % \begin{macrocode}
952 \iftg@direct
953 \ShellEscape{\tile@ppArgs{\tg@pdfcreator@app}
954 tile-template.tex}%
955 \else
956 \ShellEscape{\latex@ppArgs{latex} --shell-escape
957 tile-template.tex}%
958 \ShellEscape{\dvips@ppArgs{dvips} tile-template.dvi}%
959 \ifnum\tg@case=\thr@@
960 \ShellEscape{\pkg@ppArgs{\tg@pdfcreator@app}
961 tile-template.ps}%
962 \else
963 \ShellEscape{\pkg@ppArgs{\tg@pdfcreator@app} /N /Q
964 "\tg@fullPathToSource/tile-template.ps"}%
965 \fi
966 \ShellEscape{\tg@sysdel tile-template.dvi
967 tile-template.ps}%
968 \fi
969 % \end{macrocode}
970 % Insert the after-tile-creation-hook \DescribeMacro\@fterTileCreationHook
971 % \cs{@fterTileCreationHook}
972 % \begin{macrocode}
973 \@fterTileCreationHook
974 \ShellEscape{\tg@syscopy tile-template.pdf
975 \tgTileBaseIndx.pdf}%
976 % \end{macrocode}
977 % clean up,
978 % \begin{macrocode}
979 \ShellEscape{\tg@syscopy tile-template.pdf
980 \tgTileBaseIndx.pdf}%
981 }% do
982 % \end{macrocode}
983 % and move to another folder if necessary
984 % \begin{macrocode}
985 \iftgfolder
986 \ShellEscape{\tg@sysmove \tg@base_*.pdf \tgInFolder}\fi
987 \fi
988 \fi
989 % \end{macrocode}
990 % finished! Just clean up all aux files.
991 % \begin{macrocode}
992 \ShellEscape{\tg@sysdel \tg@base_*.cut package-data.cut}%
993 \ShellEscape{\tg@sysdel tmp.sty tile-template.*}%
994 }
995 % \end{macrocode}
996 % Letting \cs{WriteBookmarks} to \cs{relax} prevents \pkg{hyperref} from
997 % complaining about the OUT file is not up to date. No bookmarks are created.
998 % Also load the configuration file \marginpar{\raggedleft\small\texttt{tg.cfg}}\texttt{tg.cfg},
999 % if it exists.
1000 % \begin{macrocode}
1001 \let\WriteBookmarks\relax
1002 \InputIfFileExists{tg.cfg}{}{}
1003 \tg@restoreCats
1004 \parindent0pt
1005 % \end{macrocode}
1006 % \begin{macrocode}
1007 %</package>
1008 % \end{macrocode}
1009 %\Finale
1010 \endinput