Debian Codegraph @

texmf-dist/doc/latex/incgraph/incgraph.tex

raw
1 % \LaTeX-Main\
2 % !TeX encoding=UTF-8
3 %% The LaTeX package incgraph - version 1.4.0 (2026/03/04)
4 %% incgraph.tex: package documentation
5 %%
6 %% -------------------------------------------------------------------------------------------
7 %% Copyright (c) 2012-2026 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
8 %% -------------------------------------------------------------------------------------------
9 %%
10 %% This work may be distributed and/or modified under the
11 %% conditions of the LaTeX Project Public License, either version 1.3
12 %% of this license or (at your option) any later version.
13 %% The latest version of this license is in
14 %% http://www.latex-project.org/lppl.txt
15 %% and version 1.3c or later is part of all distributions of LaTeX
16 %% version 2008 or later.
17 %%
18 %% This work has the LPPL maintenance status `author-maintained'.
19 %%
20 %% This work consists of all files listed in README.md
21 %%
22 \documentclass[a4paper,11pt]{ltxdoc}
23
24 \usepackage{incgraph.doc}
25
26
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 \begin{document}
29 \begin{center}
30 \vspace*{5mm}
31 \begin{tcolorbox}[enhanced,
32 center upper,width=10cm,boxrule=0.4pt,
33 colback=white,colframe=black!50!yellow,drop fuzzy midday shadow=black!50!yellow]
34 {\bfseries\LARGE The \texttt{incgraph} package\par}\medskip
35 {\large Manual for version \version\ (\datum)\par}
36 \end{tcolorbox}\bigskip
37 {\large Thomas F.~Sturm%
38 \footnote{Prof.~Dr.~Dr.~Thomas F.~Sturm, Institut f\"{u}r Mathematik und Informatik,
39 University of the Bundeswehr Munich, D-85577 Neubiberg, Germany;
40 email: \href{mailto:[email protected]}{[email protected]}}\par\medskip
41 \normalsize\url{https://www.ctan.org/pkg/incgraph}\par
42 \url{https://github.com/T-F-S/incgraph}
43 }
44 \end{center}
45 \bigskip
46 \begin{absquote}
47 \begin{center}\bfseries Abstract\end{center}
48 |incgraph| provides tools for including graphics on full paper size.
49 The graphics can be centered for a given paper format or the paper may be
50 resized to the graphics dimensions.
51 The main use case for the package |incgraph| is to transform one or many scans
52 or taken pictures to a PDF document. It can also be applied for full paper size
53 \LaTeX\ created graphics.
54 The package |incgraph| provides a tool box with basic macros and a
55 convenience user interface which wraps the well-known |includegraphics|.
56 Also, bookmarking is especially supported.
57 \end{absquote}
58
59 \enlargethispage*{1cm}
60 \tableofcontents
61
62 \begin{inctext}[paper=graphics]
63 \begin{tcolorbox}[title={Caveat\hfill --- Page \thepage\ ---},
64 colframe=red!65!black,colback=red!10!white,fonttitle=\Large\bfseries,
65 fontupper=\large,arc=0mm,outer arc=0mm]
66 This documentation contains a lot of effects which can only be seen
67 when viewed on a computer screen. If you read this text on paper, you
68 will not notice the paper resizing and the bookmarks. Also, pages in landscape may probably
69 be rotated by your printer.
70 \end{tcolorbox}
71 \end{inctext}
72
73
74 %--------------------------------------
75 \section{Introduction}
76 \subsection{Motivation}
77 The main purpose of this package is to include one or more graphics on full
78 paper size. This means that a graphic is either centered on a blank page
79 presumable of the given document paper size or the page is resized
80 to the dimensions of the graphic.
81 For the graphics, JPG files or PDF files or other supported formats may be
82 used by inclusion. Alternatively, the graphics (or whatever) can be produced
83 by \LaTeX\ code.
84 An important use case for the package |incgraph| is to transform one or many scans
85 or taken pictures to a PDF document. Optionally, the included graphics can
86 be commented with bookmarks for the resulting PDF document.
87
88 The well-known |graphicx| package \cite{package:graphicx} allows the inclusion
89 of several types of external graphics files. The convenience user interface
90 of |incgraph| described in Section~\ref{sec:interface} relies on this package and adds
91 assistance for the described purpose. Note that the package is designed for and
92 tested with |pdflatex| to produce PDF directly. Also, the package is
93 intended to harmonize with |lualatex|.
94 Some features like the paper
95 resizing may not be applicable for other work-flows.
96
97 Many of the features of the convenience user interface can be used directly
98 with various basic macros. These are collected and described
99 as a \enquote{basic tool box} in Section~\ref{sec:basictoolbox}.
100
101 If this package does not aid your intended purpose, you may take a look
102 at the |pdfpages| package \cite{package:pdfpages} which also supports the insertion of
103 external multi-page PDF documents.
104
105
106 \subsection{Loading the Package}
107 |incgraph| is loaded in the usual manner in the preamble:
108 \begin{dispListing}
109 \usepackage{incgraph}
110 \end{dispListing}
111
112 The package |incgraph| loads the package
113 |pgfkeys| \cite{package:tikz}. If no options are given, it also
114 loads the packages |pgf|, |pgffor| \cite{package:tikz},
115 the package |graphicx| \cite{package:graphicx}, and the
116 package |bookmark| \cite{package:bookmark}.
117
118 The following package options are available:
119
120 %-------------------------------------------------------------------------------
121 \begin{docPackageOptions}
122 {
123 {
124 doc name = pgf,
125 doc description = {no value, initially set},
126 },
127 {
128 doc name = nopgf,
129 doc description = {no value, initially unset},
130 },
131 }
132 The option |nopgf| prevents the loading of |pgf| and |pgffor|.\\
133 The opposite option |pgf| resets to loading the packages.
134 \end{docPackageOptions}
135 %-------------------------------------------------------------------------------
136
137 %-------------------------------------------------------------------------------
138 \begin{docPackageOptions}
139 {
140 {
141 doc name = graphicx,
142 doc description = {no value, initially set},
143 },
144 {
145 doc name = nographicx,
146 doc description = {no value, initially unset},
147 },
148 }
149 The option |nographicx| prevents the loading of |graphicx|.\\
150 The opposite option |graphicx| resets to loading the package.
151 \end{docPackageOptions}
152 %-------------------------------------------------------------------------------
153
154 %-------------------------------------------------------------------------------
155 \begin{docPackageOptions}
156 {
157 {
158 doc name = bookmark,
159 doc description = {no value, initially set},
160 },
161 {
162 doc name = nobookmark,
163 doc description = {no value, initially unset},
164 },
165 }
166 The option |nobookmark| prevents the loading of |bookmark|.\\
167 The opposite option |bookmark| resets to loading the package.
168 \end{docPackageOptions}
169 %-------------------------------------------------------------------------------
170
171 So, the minimal package loading is done with the following:
172 \begin{dispListing}
173 \usepackage[nopgf,nographicx,nobookmark]{incgraph}
174 \end{dispListing}
175
176 Note that you can always load the mentioned packages yourself. This is
177 intended to avoid possible option clashes the easy way.
178
179
180 \clearpage
181 %--------------------------------------
182 \section{User Interface}\label{sec:interface}
183
184 \subsection{Inclusion Macros for External Graphics}
185 The macros of this section rely on the |\includegraphics| command from
186 the package |graphicx|~\cite{package:graphicx}.
187 %Section \ref{sec:basictoolbox} describes more basic commands.
188
189 \begin{docCommand}{incgraph}{\oarg{options}\oarg{graphics options}\marg{file name}}
190 The picture file with the given \meta{file name} is included in the center
191 of a separate page. Depending on the \meta{options}, this page keeps the
192 document size or is resized to the graphics dimensions.
193 The applicable \meta{options} are listed in Section \ref{sec:keys}.
194 If \meta{graphics options} are given, these are added to the options for
195 the underlying |\includegraphics| command. See the documentation of
196 |graphicx| \cite{package:graphicx} for a list of applicable \meta{graphics options}.
197
198
199 \begin{texexptitled}%
200 {The hand-drawn example (centered); see page~\pageref{exacenter}}{exacenter.listing}
201 \incgraph[paper=current,label={exacenter},overlay page number at bottom,
202 bookmark={The hand-drawn example (centered)}]{example.jpg}
203 \end{texexptitled}
204
205 \begin{texexptitled}%
206 {The hand-drawn example (resized page); see page~\pageref{exaresized}}{exaresized.listing}
207 \incgraph[paper=graphics,label={exaresized},
208 bookmark={The hand-drawn example (resized page)}]{example.jpg}
209 \end{texexptitled}
210
211 \begin{texexptitled}%
212 {The hand-drawn example (rotated and oversized); see page~\pageref{exarotated}}{exarotated.listing}
213 \incgraph[paper=current,label={exarotated},target=oversized,
214 bookmark={The hand-drawn example (rotated and oversized)}]%
215 [angle=30,scale=3]{example.jpg}
216 \end{texexptitled}
217 \end{docCommand}
218
219 \enlargethispage*{1cm}
220 \begin{docCommand}{incmultigraph}{\oarg{options}\oarg{graphics options}\marg{file name pattern}\marg{list}}
221 All picture files matching the given \meta{file name pattern} where some
222 parts are substituted by elements of the \meta{list}
223 are included in the center of separate pages. Depending on the \meta{options}, the pages keep the
224 document size or are resized to the graphics dimensions.
225 The applicable \meta{options} are listed in Section \ref{sec:keys}.
226 If \meta{graphics options} are given, these are added to the options for
227 the underlying |\includegraphics| command. See the documentation of
228 |graphicx| \cite{package:graphicx} for a list of applicable \meta{graphics options}.\\
229 The \meta{list} may contain any construction allowed for the |\foreach| statement \cite{package:tikz},
230 especially a list of numbers.
231 The elements of the list can be used inside the \meta{file name pattern}
232 with the following macros:
233 \begin{itemize}
234 \item\docAuxCommand{n}: The current element of the list (may be a number).
235 \item\docAuxCommand{ni}: The position of the current element inside the list, i.\,e.\ |\ni|
236 counts from 1 to the size of the list.
237 \item\docAuxCommand{nn}: The zero-filled |\n|, if |\n| is a number. The digit
238 number of |\nn| is determined by \refKey{/igr/zerofill}.
239 \end{itemize}
240 The resolved \meta{file name pattern} is stored inside the macro:
241 \begin{itemize}
242 \item\docAuxCommand{nt}: This file name may be used for bookmarking.
243 \end{itemize}
244 In the default behavior, non existing files are ignored.
245
246 \begin{texexptitled}%
247 {A series of pictures; see from page~\pageref{exaseries.1}. The image files
248 exaimage-0001.png to exaimage-0150.png are included but only three
249 of them exist.}{exaseries.listing}
250 \incmultigraph[zerofill=4,bookmark={A series of pictures: \nt},
251 paper=current,label={exaseries.\n}]{exaimage-\nn.png}{1,...,150}
252 \end{texexptitled}
253 \end{docCommand}
254
255 \pagebreak
256
257 \begin{docCommand}[doc new=2026-02-25]{incmultipages}{\oarg{options}\oarg{graphics options}\marg{file name}\marg{page list}}
258 This is mainly a specialized version of \refCom{incmultigraph} for inclusion
259 of one or several pages from a singular PDF file with given \meta{file name}.
260 All pages corresonding to the given \meta{page list}
261 are included in the center of separate pages.
262 \begin{itemize}
263 \item
264 Depending on the \meta{options}, the pages keep the
265 document size or are resized to the graphics dimensions.
266 The applicable \meta{options} are listed in Section \ref{sec:keys}.\
267 \item
268 If \meta{graphics options} are given, these are added to the options for
269 the underlying |\includegraphics| command. See the documentation of
270 |graphicx| \cite{package:graphicx} for a list of applicable \meta{graphics options}.
271 Note that the graphics option |page=\n| is set automatically.
272 \item The \meta{page list} may contain any construction allowed for the |\foreach| statement \cite{package:tikz},
273 basically a list of numbers. The page count of the PDF file is available as
274 \docAuxCommand{last} or alternatively \docAuxCommand{igrLastPage}. For example:\\
275 \begin{tabular}{@{}ll@{}}
276 \verb#{1,...,\last}# & All pages.\\
277 \verb#{\last,...,1}# & All pages in reverse order.\\
278 \verb#{2,4,...,\last}# & All even pages.\\
279 \verb#{2,...,\inteval{\last-1}}# & All pages without the first and the last page.\\
280 \verb#{\inteval{\last-4},...,\last}# & Last 5 pages.\\
281 \verb#{1,...,5,17,40,41,...,\last}# & Pages 1,2,3,4,5,17,40,41,42,43 until last page.
282 \end{tabular}
283 \end{itemize}
284 The elements of the list can be used for bookmarking
285 with the following macros:
286 \begin{itemize}
287 \item\docAuxCommand{n}: The current page of the list.
288 \item\docAuxCommand{ni}: The position of the current page inside the list, i.\,e.\ |\ni|
289 counts from 1 to the size of the list.
290 \item\docAuxCommand{nn}: The zero-filled |\n|. The digit
291 number of |\nn| is determined by \refKey{/igr/zerofill}.
292 \end{itemize}
293 The \meta{file name} is stored inside the macro:
294 \begin{itemize}
295 \item\docAuxCommand{nt}: This file name may be used for bookmarking.
296 \end{itemize}
297 In the default behavior, non existing files are ignored. Also, non
298 existing pages are ignored.
299 \begin{dispListing}
300 \incmultipages[
301 paper = a4,
302 bookmark = {Imported page \n\ of \nt}
303 ]
304 {incgraph-example-a.pdf}
305 {1,...,\last}
306 \end{dispListing}
307 This example is continued in Section~\ref{sec:reformatting}.\par
308 The same output can be generated with \refCom{incmultigraph}. Here, the page
309 count has to be computed separately and the behavior in case of missing files
310 or pages is different:
311 \begin{dispListing}
312 \igrGetLastPage{incgraph-example-a.pdf}
313 \incmultigraph[
314 paper = a4,
315 bookmark = {Imported page \n\ of \nt}
316 ]
317 [page=\n]
318 {incgraph-example-a.pdf}
319 {1,...,\igrLastPage}
320 \end{dispListing}
321
322
323 \end{docCommand}
324
325
326 \clearpage
327 \subsection{Inclusion Macro for Internal Graphics}
328
329 \begin{docEnvironment}{inctext}{\oarg{options}}
330 The environment content is included in the center
331 of a separate page. Depending on the \meta{options}, this page keeps the
332 document size or is resized to the content dimensions.
333 The applicable \meta{options} are listed in Section \ref{sec:keys}.
334
335
336 \begin{texexptitled}%
337 {Some text on a shrunk paper; see page~\pageref{inctext1}}{inctext1.listing}
338 \begin{inctext}[paper=graphics,label={inctext1},bookmark={A huge ABC}]
339 \fontsize{20mm}{20mm}\selectfont\bfseries ABC
340 \end{inctext}
341 \end{texexptitled}
342
343
344 \begin{texexptitled}%
345 {A tikzpicture as text content; see page~\pageref{inctext2}}{inctext2.listing}
346 \begin{inctext}[paper=a6,landscape,label={inctext2},bookmark={Graph},
347 overlay page number at bottom=8mm]
348 \begin{tikzpicture}[zustand/.style={circle,fill=Gold,draw},scale=2]
349 \draw node[zustand] (s0) {$s_0$}
350 +(30:3cm) node[zustand] (s1) {$s_1$}
351 ++(-30:3cm) node[zustand] (s2) {$s_2$}
352 +(30:3cm) node[zustand] (s3) {$s_3$};
353 \path[very thick,-latex]
354 (s0) edge node[above left] {a} (s1)
355 edge node[below left] {b} (s2)
356 (s1) edge[out=-120,in=120] node[left] {b} (s2)
357 edge node[above right] {a} (s3)
358 (s2) edge[out=60,in=-60] node[right] {a} (s1)
359 edge node[below right] {b} (s3);
360 \end{tikzpicture}
361 \end{inctext}
362 \end{texexptitled}
363 \end{docEnvironment}
364
365
366 \subsection{(Global) Option Setting}
367
368 \begin{docCommand}{igrset}{\marg{options}}
369 Sets options for \refCom{incgraph}, \refCom{incmultigraph}, and
370 \refEnv{inctext} inside the current \TeX\ group.
371 For example, the options \refKey{/igr/paper} and
372 \refKey{/igr/zerofill} may be defined for the whole document by this:
373 \begin{dispListing}
374 \igrset{paper=current,zerofill=3}
375 \end{dispListing}
376 \end{docCommand}
377
378
379 \clearpage
380 %--------------------------------------
381 \section{Option Keys}\label{sec:keys}
382 The package |incgraph| uses the key-value interface of
383 the |pgfkeys| \cite{package:tikz}.
384
385 \subsection{Paper (Media) Size}\label{sec:papersize}
386
387 \begin{docIgrKey}{currentpaper}{}{no value}
388 The paper size keeps unchanged at the current size
389 except if \refKey{/igr/landscape} is used.
390 The current paper size has not to
391 be the document paper size.
392 See page \pageref{exacenter} for the output
393 of Example \ref{exacenter.listing} on page \pageref{exacenter.listing}.
394 \end{docIgrKey}
395
396 \begin{docIgrKey}{documentpaper}{}{no value}
397 The paper size is set to the initial document paper size.
398 \end{docIgrKey}
399
400 \begin{docIgrKey}{graphicspaper}{}{no value, initially set}
401 The paper is resized to the dimensions of the included image.
402 The \refKey{/igr/landscape} option is ignored for this paper.
403 See page \pageref{exaresized} for the output
404 of Example \ref{exaresized.listing} on page \pageref{exaresized.listing}.
405 \end{docIgrKey}
406
407
408 \begin{docIgrKey}{paper size}{=\meta{width}:\meta{height}}{no default}
409 The paper is resized to the given \meta{width} and \meta{height}.
410 \end{docIgrKey}
411
412 \begin{docIgrKey}{paper}{=\meta{name}}{no default}
413 The paper size is chosen according to the given \meta{name}.
414 Feasible values for the \meta{name} are
415 |current|, |document|, |graphics|,
416 |a0|, |a1|, |a2|, |a3|, |a4|, |a5|, |a6|, |a7|, |a8|, |a9|, |a10|,
417 |b0|, |b1|, |b2|, |b3|, |b4|, |b5|, |b6|, |b7|, |b8|, |b9|, |b10|,
418 |c0|, |c1|, |c2|, |c3|, |c4|, |c5|, |c6|, |c7|, |c8|, |c9|, |c10|,
419 |d0|, |d1|, |d2|, |d3|, |d4|, |d5|, |d6|, |d7|,
420 |executive|, |letter|, |legal|, |ledger|.
421 \end{docIgrKey}
422
423 \begin{docIgrKey}{landscape}{}{no value}
424 If set the width and height of the chosen paper are switched. Note that
425 this turns the paper by 90 degrees but the contents of the paper is not
426 turned.
427 \end{docIgrKey}
428
429 \begin{docIgrKey}{portrait}{}{no value, initially set}
430 Disables the \refKey{/igr/landscape} mode.
431 \end{docIgrKey}
432
433
434 \ExplSyntaxOn
435 \foreach \x in {a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,
436 b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,
437 c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,
438 d0,d1,d2,d3,d4,d5,d6,d7,
439 executive,letter,legal,ledger}
440 {\begin{docIgrKey}{\x paper}{}{no~value}
441 \igrset{\x paper}%
442 The~paper~size~is~set~to~
443 \texttt{\l__incgra_target_width_tl}~$\times$~\texttt{\l__incgra_target_heigth_tl}.
444 \end{docIgrKey}}
445 \ExplSyntaxOff
446
447 \begin{docIgrKey}{center}{}{no value, deprecated}
448 An alias for \refKey{/igr/currentpaper}.
449 \end{docIgrKey}
450
451 \begin{docIgrKey}{page}{}{no value, deprecated}
452 An alias for \refKey{/igr/graphicspaper}.
453 \end{docIgrKey}
454
455
456 \clearpage
457 \subsection{Graphics Inclusion}
458
459 \begin{docIgrKey}{options}{=\marg{graphics options}}{no default, initially empty}
460 The \meta{graphics options} are applied to the underlying \docAuxCommand*{includegraphics} command.
461 See the documentation of
462 |graphicx| \cite{package:graphicx} for a list of applicable \meta{graphics options}.
463 \begin{texexptitled}%
464 {A resized image; see page~\pageref{exagraphresize}}{exagraphresize.listing}
465 \igrset{options={width=10cm,height=10cm}, paper=graphics,
466 overlay page number at top=5mm
467 }
468
469 \incgraph[bookmark={A resized image}, label={exagraphresize}]%
470 {exaimage-0037.png}
471 \end{texexptitled}
472 \end{docIgrKey}
473
474 \begin{docIgrKey}{options add}{=\marg{graphics options}}{no default, initially empty}
475 The \meta{graphics options} are added to the current list of options
476 for the underlying \docAuxCommand*{includegraphics} command.
477 \end{docIgrKey}
478
479
480 \begin{docIgrKey}{include command}{\colOpt{=\meta{macro}}}{default and initially \cs{includegraphics}}
481 Replaces the internally used \docAuxCommand*{includegraphics} command by the given \meta{macro}.
482 Note that \meta{macro} has to have the same signature as \docAuxCommand*{includegraphics},
483 i.\,e.\ it has to take two arguments where the first argument is optional.
484 \end{docIgrKey}
485
486 \begin{docIgrKey}{existence check}{=\meta{macro}}{no default}
487 Replaces the internally used \docAuxCommand*{IfFileExists}
488 (in truth \docAuxCommand*{file_if_exist:nTF})
489 command by the given \meta{macro}.
490 Note that \meta{macro} has to have the same signature as \docAuxCommand*{IfFileExists},
491 i.\,e.\ it has to take three arguments.
492 \end{docIgrKey}
493
494 \begin{docIgrKeys}[
495 doc parameter = {},
496 doc description = {no value}
497 ]
498 {
499 {
500 doc name = no existence check,
501 doc new = 2021-10-16,
502 },
503 {
504 doc name = fail on not found,
505 },
506 }
507 Omits any existence checks by the package, i.e. the underlying
508 \docAuxCommand*{includegraphics} is called directly and may
509 stop the compilation with an error if the included file does not exist.
510 Both options are equal, but the newer \refKey{/igr/no existence check}
511 is considered to be more comprehensible.
512 \end{docIgrKeys}
513
514 \begin{docIgrKey}{ignore on not found}{}{no value, initially set}
515 Not existing included files are ignored without warning. This is the default
516 setting and is intended to be used with fragmentary file lists.
517 \end{docIgrKey}
518
519 \clearpage
520
521 \begin{docIgrKeys}[
522 doc parameter = \colOpt{=\marg{extension list}},
523 doc description = {initially unset},
524 doc new = 2021-10-16,
525 ]
526 {
527 {
528 doc name = ignore on not found with extensions,
529 },
530 {
531 doc name = ignore on not found with extensions*,
532 },
533 }
534 Tests, if the included file with an added \emph{extension} exists and
535 performs the inclusion on existence. Otherwise, included files are ignored without warning.
536 Tested \emph{extensions} are taken from the optional comma separated \meta{extension list}
537 or (exclusively) from the configured list from \refKey{/igr/extensions} and friends
538 (only, if \meta{extension list} is not given).\par
539 \refKey{/igr/ignore on not found with extensions*} also tests, if the included
540 file without added \emph{extension} exists and takes it on existence.\par
541 Note that if a file is included with a given extension, this extension is not
542 replaced by the listed extension, but prolonged with it.\par
543 These options are intended for mixed file lists, e.g. |.jpg| and |.png|, or
544 unkown type file lists.
545 Note that if you \emph{know} the (singular) extension of your files, you are
546 encouraged to use \refKey{/igr/ignore on not found} instead for performance reasons.
547 \begin{dispListing}
548 \incmultigraph[ignore on not found with extensions={.jpg,.png}]{myfile\n}{1,...,100}
549 % includes e.g. `myfile1.jpg`, `myfile2.png`, `myfile42.jpg`, ...
550 \incmultigraph[ignore on not found with extensions={.jpg,.png}]{myfile\n.xy}{1,...,100}
551 % includes e.g. `myfile1.xy.jpg`, `myfile2.xy.png`, `myfile42.xy.jpg`, ...
552 \incgraph[ignore on not found with extensions={.jpg,.png}]{myfile}
553 % tests `myfile.jpg` and `myfile.png` for existence (and inclusion)
554 \incgraph[ignore on not found with extensions*={.jpg,.png}]{myfile}
555 % tests `myfile`, `myfile.jpg`, and `myfile.png` for existence (and inclusion)
556 \incmultigraph[ignore on not found with extensions]{myfile\n}{1,...,100}
557 % includes files with extensions given by /igr/extensions
558 \end{dispListing}
559 \end{docIgrKeys}
560
561
562 \begin{docIgrKey}[][doc new=2021-10-16]{extensions}{=\marg{extension list}}{initially |.jpg,.png|}
563 Specifies a comma separated \meta{extension list} to be used in combination with
564 \refKey{/igr/ignore on not found with extensions}.
565 \end{docIgrKey}
566
567
568 \begin{docIgrKey}[][doc new=2021-10-16]{extensions add}{=\marg{extension list}}{initially unset}
569 Adds a comma separated \meta{extension list} to an already defined list from
570 \refKey{/igr/extensions}.
571 \end{docIgrKey}
572
573
574 \begin{docIgrKey}[][doc new=2021-10-16]{extensions from graphics}{}{initially unset}
575 Takes the list of extensions from \docAuxCommand*{DeclareGraphicsExtensions}
576 of the |graphics| \cite{package:graphicx} package as setup for \refKey{/igr/extensions}.
577 While this looks like the most comfortable options, this can significantely
578 increase compilation time when used for fragmentary file lists, because
579 every non-existing file from the file list will induce a lot of existence checks.
580 Also note that this options uses internals from |graphics| and is not
581 guaranteed to work with future versions of |graphics|.
582 \end{docIgrKey}
583
584
585 \clearpage
586 \subsection{Hypertargets, Labels, and Bookmarks}
587
588 \begin{docIgrKey}{hyper}{}{no value, initially set}
589 An automated hyper target is set to the current image. The hyper target is placed
590 at the top left corner of the page. It is used internally, when a bookmark is added.
591 \end{docIgrKey}
592
593 \begin{docIgrKey}{no hyper}{}{no value}
594 No automated hyper target is set to the current image. Use this option, if
595 the package |bookmark| is not included.
596 \end{docIgrKey}
597
598 \begin{docIgrKey}{target}{=\meta{anchor}}{no default}
599 The next hypertarget destination value is set to \meta{anchor} instead of
600 an automatically created value. This may be used for hyperlinks.
601 \begin{dispExample}
602 \hyperlink{oversized}{This is linked to the oversized example (click me)}.
603 The target value '|oversized|' was defined in Example~\ref{exarotated.listing},
604 see page~\pageref{exarotated.listing}.
605 \end{dispExample}
606 \end{docIgrKey}
607
608
609 \clearpage
610
611 \begin{docIgrKey}{label}{=\meta{text}}{no default, initially empty}
612 Adds a \LaTeX\ label to the included image.
613 \end{docIgrKey}
614
615
616 \begin{docIgrKey}{bookmark}{=\meta{text}}{no default, initially empty}
617 Adds a PDF bookmark with the given \meta{text} to the current image.
618 \end{docIgrKey}
619
620 \begin{docIgrKey}{bookmark options}{=\marg{bookmark options}}{no default, initially empty}
621 Sets the options for a bookmark.
622 See the documentation of
623 |bookmark| \cite{package:bookmark} for a list of applicable \meta{bookmark options}.
624 \begin{texexptitled}%
625 {Bookmark options; see page~\pageref{exabookmark}}{exabookmark.listing}
626 % not every PDF reader will show the effect!
627 \igrset{bookmark options={bold,color={red}},currentpaper}
628 \incgraph[bookmark={This ugly image again!},label={exabookmark}]%
629 {example.jpg}
630 \end{texexptitled}
631 \end{docIgrKey}
632
633 \begin{docIgrKey}{bookmark heading}{=\meta{text}}{no default, initially empty}
634 For \refCom{incmultigraph} and \refCom{incmultipages}, an additional bookmark with the given \meta{text}
635 is set as a heading before the images are included.
636 \begin{texexptitled}%
637 {A series of pictures; see from page~\pageref{exaheading.1}}{exaheading.listing}
638 \incmultigraph[zerofill=4,currentpaper,
639 bookmark heading={A series of pictures},
640 bookmark heading options={level=subsection},
641 bookmark={\nt},bookmark options={level=subsubsection},
642 overlay page number at bottom,
643 label={exaheading.\n}]{exaimage-\nn.png}{1,...,150}
644 \end{texexptitled}
645 \end{docIgrKey}
646
647 \begin{docIgrKey}{bookmark heading options}{=\marg{bookmark options}}{no default, initially empty}
648 Sets the options for a \refKey{/igr/bookmark heading}.
649 See the documentation of
650 |bookmark| \cite{package:bookmark} for a list of applicable \meta{bookmark options}.
651 \end{docIgrKey}
652
653
654
655 \clearpage
656 \subsection{Autosize}
657
658 \begin{docIgrKeys}
659 {
660 {
661 doc name = autosize,
662 doc parameter = \colOpt{=true\textbar false},
663 doc description = {default |true|, initially |false|},
664 doc new = {2024-03-09}
665 }
666 }
667 If set to |true|, the picture box is resized to fit into the paper while
668 keeping the aspect ratio. This
669 setting has no effect for \refKey{/igr/graphicspaper}.
670 Note that this autosize is applied after possible size and scaling options
671 for |\includegraphics| are conducted, see \refCom{incgraph} and \refCom{incmultigraph}.
672
673 \begin{texexptitled}%
674 {Autosized pictures; see from page~\pageref{autosize.1}}{autosize.listing}
675 \incmultigraph[zerofill=4, currentpaper, autosize,
676 bookmark heading={Autosized pictures},
677 bookmark heading options={level=subsection},
678 bookmark={\nt},bookmark options={level=subsubsection},
679 overlay page number at bottom,
680 label={autosize.\n}]{exaimage-\nn.png}{1,...,150}
681 \end{texexptitled}
682
683 The following tuning
684 options influence how the resizing is done.
685 \end{docIgrKeys}
686
687
688 \begin{docIgrKeys}
689 [
690 doc parameter = {=\meta{length}},
691 doc description = {no default, initially |0mm|},
692 doc new = {2024-03-09}
693 ]
694 {
695 { doc name = autosize width gap },
696 { doc name = autosize height gap },
697 { doc name = autosize gap }
698 }
699 \meta{length} is subtracted from the width or height of the current paper size
700 to compute the target size for the automatic picture box scaling.
701 \refKey{/igr/autosize gap} sets both values at the same time.
702 For example, |autosize gap=20mm| gives (at least) |10mm| space around
703 the rescaled picture box.\par
704 Negative \meta{length} values allow the picture box to extrude over the borders of
705 the current paper.
706 \end{docIgrKeys}
707
708
709 \begin{docIgrKeys}
710 [
711 doc parameter = {=\meta{floating-point expression}},
712 doc new = {2024-03-09}
713 ]
714 {
715 { doc name = autosize min scale, doc description = {no default, initially |0.001|} },
716 { doc name = autosize max scale, doc description = {no default, initially |1000|} }
717 }
718 The scale number of the automatic scaling will
719 always be between \refKey{/igr/autosize min scale} and \refKey{/igr/autosize max scale}
720 even if other settings are violated.\par
721 |autosize min scale=1| means that the picture box is never to be shrunk.\par
722 |autosize max scale=1| means that the picture box is never to be enlarged.\par
723 \end{docIgrKeys}
724
725
726
727 \clearpage
728 \subsection{Borders and Shifts}
729
730 The following settings enlarge or shrink the picture box, if
731 \refKey{/igr/graphicspaper} is used. For other paper settings, the result
732 will be a certain shift of the picture box since the enlarged box
733 will be centered on the paper.
734
735 \begin{docIgrKey}[][doc new and updated={2015-03-12}{2024-03-08}]{left border}{=\meta{length}}{no default, initially |0pt|}
736 Adds a space of \meta{length} at the left hand side.
737 \end{docIgrKey}
738
739 \begin{docIgrKey}[][doc new and updated={2015-03-12}{2024-03-08}]{bottom border}{=\meta{length}}{no default, initially |0pt|}
740 Adds a space of \meta{length} at the bottom.
741 \end{docIgrKey}
742
743 \begin{docIgrKey}[][doc new and updated={2015-03-12}{2024-03-08}]{right border}{=\meta{length}}{no default, initially |0pt|}
744 Adds a space of \meta{length} at the right hand side.
745 \end{docIgrKey}
746
747 \begin{docIgrKey}[][doc new and updated={2015-03-12}{2024-03-08}]{top border}{=\meta{length}}{no default, initially |0pt|}
748 Adds a space of \meta{length} at the top.
749 \end{docIgrKey}
750
751 \begin{docIgrKey}[][doc new and updated={2015-03-12}{2024-03-08}]{horizontal border}{=\meta{length}}{no default, initially |0pt|}
752 Adds a space of \meta{length} at the left hand side and the right hand side.
753 \end{docIgrKey}
754
755 \begin{docIgrKey}[][doc new and updated={2015-03-12}{2024-03-08}]{vertical border}{=\meta{length}}{no default, initially |0pt|}
756 Adds a space of \meta{length} at the top and bottom.
757 \end{docIgrKey}
758
759 \begin{docIgrKey}[][doc new and updated={2015-03-12}{2024-03-08}]{border}{=\meta{length}}{no default, initially |0pt|}
760 Adds a space of \meta{length} at all four sides.
761 \end{docIgrKey}
762
763 \begin{docIgrKey}[][doc new={2024-03-08}]{xshift}{=\meta{length}}{no default, initially |0pt|}
764 Shifts the picture box in horizontal direction without changing the paper size.
765 This adapts the current values of \refKey{/igr/left border} and \refKey{/igr/right border}.
766 Therefore, use this option \emph{after} the border values are set.
767 \end{docIgrKey}
768
769 \begin{docIgrKey}[][doc new={2024-03-08}]{yshift}{=\meta{length}}{no default, initially |0pt|}
770 Shifts the picture box in vertical direction without changing the paper size.
771 This adapts the current values of \refKey{/igr/top border} and \refKey{/igr/bottom border}.
772 Therefore, use this option \emph{after} the border values are set.
773 \end{docIgrKey}
774
775
776
777 \clearpage
778 \subsection{Map and Match}
779
780 \begin{docIgrKey}{set matches}{=\marg{list}}{no default, initially empty}
781 The \meta{list} is a comma separated list of \meta{key}=\meta{value} pairs.
782 For every pair, the given \meta{key} is mapped to the given \meta{value}.
783 Later, this \meta{value} can be retrieved by
784 \refKey{/igr/if match code},
785 \refKey{/igr/if match set}, and
786 \refKey{/igr/if match set bookmark}.
787
788 \begin{dispListing}
789 \igrset{set matches={
790 foo = bar,
791 1 = A very red image,
792 37 = A not so centered number,
793 123 = A greenish example}}
794 \end{dispListing}
795 \end{docIgrKey}
796 \tcbusetemp
797
798 \begin{docIgrKey}{if match code}{=\marg{key}\marg{then}\marg{else}}{no default}
799 If the \meta{key} was defined by \refKey{/igr/set matches},
800 \refCom{igrsetmatchvalue}, or \refCom{igrsetmatches},
801 the corresponding value is put in the
802 macro |\igrmatchvalue| and the \meta{then} code is
803 executed. If the \meta{key} is unknown, the \meta{else} code is
804 executed.
805 \end{docIgrKey}
806
807 \begin{docIgrKey}{if match set}{=\marg{key}\marg{then}\marg{else}}{no default}
808 If the \meta{key} was defined by \refKey{/igr/set matches},
809 \refCom{igrsetmatchvalue}, or \refCom{igrsetmatches},
810 the corresponding value is put in the
811 macro |\igrmatchvalue| and |\igrset{|\meta{then}|}| is executed.
812 If the \meta{key} is unknown, |\igrset{|\meta{else}|}| is executed.
813 \end{docIgrKey}
814
815 \begin{docIgrKey}{if match set bookmark}{=\marg{key}\marg{then}\marg{else}}{no default}
816 If the \meta{key} was defined by \refKey{/igr/set matches},
817 \refCom{igrsetmatchvalue}, or \refCom{igrsetmatches},
818 the corresponding value is put in the
819 macro |\igrmatchvalue| and the current PDF bookmark is set to \meta{then}.
820 If the \meta{key} is unknown, the current PDF bookmark is set to \meta{else}.
821 \begin{texexptitled}%
822 {Map and match example; see from page~\pageref{examatch.1}}{examatch.listing}
823 \incmultigraph[zerofill=4,paper=graphics,
824 bookmark heading={Map and match example},
825 bookmark heading options={level=subsection},
826 bookmark options={level=subsubsection},
827 if match set bookmark={\n}{\igrmatchvalue\ (\n)}{\nt},
828 overlay page number at bottom,
829 label={examatch.\n}]{exaimage-\nn.png}{1,...,150}
830 \end{texexptitled}
831 \end{docIgrKey}
832
833 \begin{docIgrKey}{disable match}{}{no value, initially set}
834 Disables the statements by
835 \refKey{/igr/if match code},
836 \refKey{/igr/if match set}, and
837 \refKey{/igr/if match set bookmark}.
838 \end{docIgrKey}
839
840 \clearpage
841
842 \subsection{Overlays}
843
844 \begin{docIgrKey}{overlay}{=\marg{tikz code}}{no default, initially unset}
845 Introduces arbitrary \meta{tikz code} to be drawn over the included image.
846 Note that the \tikzname\ package \cite{package:tikz} has to be loaded separately.
847 To support positioning inside the picture, two |tikz| nodes named
848 |box| and |page| are defined. |box| takes the dimensions of the included image
849 and |page| takes the dimensions of the image or of the page depending on the usage of
850 \refKey{/igr/paper}.
851 \begin{texexptitled}%
852 {Overlay; see page~\pageref{overlay}}{overlay.listing}
853 \igrset{bookmark options={level=subsection}, paper=current}
854 \incgraph[bookmark={Picture with overlay},label={overlay},
855 overlay={
856 \node[draw=red,line width=3pt,fill=red,fill opacity=0.1,
857 minimum width=14cm,circle] (circ) at (page.center) {};
858 \node[fill=blue!5!white,below right,text width=4cm] (A)
859 at ([xshift=1cm,yshift=-1cm]page.north west)
860 {This included image is overlayed with |tikz| code.};
861 \node[fill=green!10!white,above,text width=7cm] (B)
862 at ([yshift=2cm]page.south)
863 {Image Name: \nt\\Page number: \thepage\\
864 Example~\ref{overlay.listing} on page~\pageref{overlay.listing}};
865 \draw[line width=2pt,->] (A)--(circ);
866 \draw[line width=2pt,green!50!black,dashed]
867 (box.south west)--(box.south east);
868 \draw[line width=2pt,->,green!50!black] (B)--(box.south);
869 }]{example.jpg}
870 \end{texexptitled}
871 \end{docIgrKey}
872
873 \begin{docIgrKey}{overlay page number at}{=\meta{position}}{no default, initially unset}
874 Overlays the page number at the given |tikz| \meta{position}.
875 \end{docIgrKey}
876
877 \begin{docIgrKey}{overlay page number at bottom}{\colOpt{=\meta{length}}}{default |1.5cm|}
878 Overlays the page number at \meta{length} above the bottom edge of the paper.
879 See Example~\ref{exacenter.listing} on page~\pageref{exacenter.listing}
880 and the result on page~\pageref{exacenter}.
881 \end{docIgrKey}
882
883 \begin{docIgrKey}{overlay page number at top}{\colOpt{=\meta{length}}}{default |1.5cm|}
884 Overlays the page number at \meta{length} below the top edge of the paper.
885 See Example~\ref{exagraphresize.listing} on page~\pageref{exagraphresize.listing}
886 and the result on page~\pageref{exagraphresize}.
887 \end{docIgrKey}
888
889
890 \begin{docIgrKey}[][doc new=2021-10-11]{overlay page number options}{=\marg{tikz options}}{no default, initially\\
891 \texttt{fill opacity=0.35,draw opacity=0.5,text opacity=1,inner xsep=1em,\\
892 rounded corners,fill=white,draw=black}}
893 Defines the \tikzname\ node style for drawing the page number with one
894 of the options above, e.g. \refKey{/igr/overlay page number at}
895 \end{docIgrKey}
896
897
898 \begin{docIgrKey}[][doc new=2021-10-21]{overlay page number options app}{=\marg{tikz options}}{no default, initially unset}
899 Appends the given \meta{tikz options} to \refKey{/igr/overlay page number options}.
900 \end{docIgrKey}
901
902
903 \begin{docIgrKey}{no overlay}{}{no value, initially set}
904 Removes the overlay setting.
905 \end{docIgrKey}
906
907
908 \clearpage
909 \subsection{Miscellaneous}
910
911
912 \begin{docIgrKey}{pagestyle}{=\meta{page style}}{no default, initially |empty|}
913 Sets the \meta{page style} for the included graphics.
914 \end{docIgrKey}
915
916
917 \begin{docIgrKey}{zerofill}{=\meta{digits}}{no default, initially |0|}
918 For \refCom{incmultigraph}, the current number element
919 is filled up with leading zeros until the \meta{digits} count is reached.
920 If \meta{digits} is 0 or 1, nothing is added. A \meta{digits} value
921 greater than 10 is treated as 10 which is the maximum number of
922 possible digits. The result is accessible as |\nn|, see \refCom{incmultigraph}.
923 Note that |zerofill| should be set to |0| if the list elements
924 in \refCom{incmultigraph} are not numbers.
925 \end{docIgrKey}
926
927 \clearpage
928 \hypertarget{optkeyexamples}{}%
929 \bookmark[level=section,dest=optkeyexamples]{User Interface and Option Examples}
930 \igrset{bookmark options={level=subsubsection}}
931 \foreach \n in {1,...,12} {\inputlisting{\n}}
932
933 \clearpage
934 %--------------------------------------
935
936 \section{Examples}
937
938 \subsection{Including some Scans to Standard Paper}
939 In this scenario, we have some scans (or images from whatever source) which
940 should be combined to a PDF document for our paperless office.
941 The paper size of the PDF document is set to a standard paper (here: letter size)
942 to allow the document to be printed.
943
944 The following Example \ref{somescans} is a complete template for such a document.
945 Here, the images |example.jpg|,
946 |exaimage-0001.png|,
947 |exaimage-0037.png|, and
948 |exaimage-0123.png| are used for the resulting document.
949 All included images are automatically bookmarked with the page number and
950 the file name of the source image.
951
952
953 \inputexamplelisting{\jobname-example-a.tex}{somescans}
954
955 %\def\thecurrentexample{\jobname-example-a.tex}
956 %\tcbinputlisting{listing file=\thecurrentexample,listing only,
957 % example={\texttt{\thecurrentexample}}{somescans}}
958
959 The compiled result of this stand-alone source code is not found in this document but as
960 a separate file in the documentation directory of the package.
961
962
963
964 \clearpage
965 \subsection{Creating a Picture Book}
966 For this example, we assume again that a bunch of image files is to be
967 combined to a PDF document. This time, the target document should be read or
968 displayed mainly on computer screens and may never be printed. Therefore,
969 the paper size is set flexible for the current image.
970
971 The following Example \ref{picturebook} is a complete template for such a document.
972 All included images are resized to a common width, but this is not necessary.
973 The resulting document is considered as an e-book where the bookmarks are the
974 most important navigation accessory.
975 Single page inclusions with \refCom{incgraph} are bookmarked directly, but
976 multi-page inclusions with \refCom{incmultigraph} can be bookmarked using the
977 map-and-match feature of the package.
978 The example shows a mixed usage of the macros.
979 Note that the bookmarks of the multi-page part are matched with the numbers
980 contained in the file names of |exaimage-0001.png| to |exaimage-0150.png|.
981
982
983 \inputexamplelisting{\jobname-example-b.tex}{picturebook}
984
985 %\def\thecurrentexample{\jobname-example-b.tex}
986 %\tcbinputlisting{listing file=\thecurrentexample,listing only,
987 % example={\texttt{\thecurrentexample}}{picturebook}}
988
989 The compiled result of this stand-alone source code is not found in this document but as
990 a separate file in the documentation directory of the package.
991
992
993 \clearpage
994 \subsection{Reformatting from Letter to DIN A4 (and vice versa)}\label{sec:reformatting}
995 In this scenario, we assume to have a PDF document with the 'wrong' paper size.
996 Here, |incgraph-example-a.pdf| has the letter format, but A4 paper
997 is needed. |incgraph| is used to reformat to the desired paper size.
998 Of course, it also works the other way around.
999
1000 The following Example \ref{reformatting} is a complete template for such a document.
1001 The document gets the desired paper size with the \refKey{/igr/paper} option.
1002 Then, all four pages of the original document are imported to the new paper
1003 size. Note that the actual document content itself is not resized because
1004 letter and DIN A4 are not so very different. If needed, the content could be
1005 shrunk or enlarged easily by adding a |scale| option for the underlying
1006 |\includegraphics| macro or by using \refKey{/igr/autosize}.
1007
1008
1009 \inputexamplelisting{\jobname-example-c.tex}{reformatting}
1010
1011 %\def\thecurrentexample{\jobname-example-c.tex}
1012 %\tcbinputlisting{listing file=\thecurrentexample,listing only,
1013 % example={\texttt{\thecurrentexample}}{reformatting}}
1014
1015
1016 The compiled result of this stand-alone source code is not found in this document but as
1017 a separate file in the documentation directory of the package.
1018
1019
1020
1021
1022 \clearpage
1023 \subsection{Drawing on Full Paper Size}
1024
1025
1026
1027 In the following examples, no external image is included to the document.
1028 Instead, the image (or whatever) is created inside the document and put
1029 on a separate page which could be resized or take the original document
1030 paper size.
1031
1032 In Example \ref{fullpaperdrawing1}, a |tikzpicture| is drawn. The whole
1033 picture is put inside an \refEnv{inctext} environment which puts the drawing
1034 on a separate page which gets the dimensions of the drawing.
1035
1036 \begin{texexptitled}{Creation of a special text page (resized)}{fullpaperdrawing1}
1037 \begin{inctext}[paper=graphics, bookmark=My special text page (resized)]
1038 \begin{tikzpicture}%
1039 \coordinate (A) at (0,0); \coordinate (B) at (16,16);
1040 \path[use as bounding box,top color=Goldenrod!25,bottom color=Navy!25]
1041 (A) rectangle (B);
1042 \coordinate (C) at ([xshift=1cm,yshift=1cm]A);
1043 \coordinate (D) at ([xshift=-1cm,yshift=-1cm]B);
1044 \path (C) -- coordinate (E) (D);
1045 \draw[rounded corners=5mm,very thick,Navy] (C) rectangle (D);
1046 \path (C) |-
1047 node [pos=0.75,fill=white,draw=Navy,very thick,inner sep=3mm]
1048 {My Special Page \thepage} (D);
1049 \node[text width=10cm,align=flush center,font=\Large] at (E) {
1050 This is my special page. It takes the dimensions of the underlying
1051 |tikzpicture| as seen in the source code of Example~\ref{fullpaperdrawing1}
1052 on page~\pageref{fullpaperdrawing1}.};
1053 \end{tikzpicture}
1054 \end{inctext}
1055 \end{texexptitled}
1056 See the result on the following page.
1057 \clearpage\inputlastlisting
1058
1059
1060 In Example \ref{fullpaperdrawing2}, nearly the same |tikzpicture| is drawn.
1061 This time, the current paper size is used which puts the drawing
1062 on a separate page but without resizing the paper.
1063 To draw seamlessly, the document paper size of 21cm to 29.7cm is used
1064 directly inside the |tikzpicture|.
1065
1066
1067 \begin{texexptitled}{Creation of a special text page (fitted)}{fullpaperdrawing2}
1068 \begin{inctext}[paper=current, target=mytarget,
1069 bookmark=My special text page (fitted)]
1070 \begin{tikzpicture}%
1071 \coordinate (A) at (0,0); \coordinate (B) at (21,29.7);
1072 \path[use as bounding box,top color=Goldenrod!25,bottom color=Navy!25]
1073 (A) rectangle (B);
1074 \coordinate (C) at ([xshift=1cm,yshift=1cm]A);
1075 \coordinate (D) at ([xshift=-1cm,yshift=-1cm]B);
1076 \path (C) -- coordinate (E) (D);
1077 \draw[rounded corners=5mm,very thick,Navy] (C) rectangle (D);
1078 \path (C) |-
1079 node [pos=0.75,fill=white,draw=Navy,very thick,inner sep=3mm]
1080 {My Special Page \thepage} (D);
1081 \node[text width=10cm,align=flush center,font=\Large] at (E) {
1082 This is my special page. It consumes the whole document paper size with
1083 an underlying |tikzpicture| as seen in the source code of
1084 Example~\ref{fullpaperdrawing2} on page~\pageref{fullpaperdrawing2}.};
1085 \end{tikzpicture}
1086 \end{inctext}
1087 \end{texexptitled}
1088
1089
1090 See the result on the following \hyperlink{mytarget}{page}.
1091 \clearpage\inputlastlisting
1092
1093
1094
1095
1096
1097 %--------------------------------------
1098 \section{Basic Tool Box}\label{sec:basictoolbox}
1099 In this section, some basic macros of the package are documented.
1100 It is assumed that most users will only need the macros from the
1101 user interface described in Section \ref{sec:interface} and Section \ref{sec:keys}.
1102
1103
1104 \subsection{Page Size Commands}
1105
1106 The following macros are auxiliary tools which wrap corresponding length registers
1107 from |pdflatex| and |lualatex|.
1108
1109 \begin{docCommand}[doc new=2021-10-12]{igrGetPageSize}{}
1110 Reads the current page dimensions and stores them into the macros
1111 \refCom{igrPageWidth} and \refCom{igrPageHeight}.
1112 \end{docCommand}
1113
1114 \begin{docCommand}[doc new=2021-10-12]{igrPageWidth}{}
1115 After using \refCom{igrGetPageSize}, \refCom{igrPageWidth} contains
1116 the current page width. This is |\pdfpagewidth| for |pdflatex|,
1117 |\pagewidth| for |lualatex| and a choice of |\pdfpagewidth| or |\paperwidth|
1118 for other engines.
1119 \end{docCommand}
1120
1121 \begin{docCommand}[doc new=2021-10-12]{igrPageHeight}{}
1122 After using \refCom{igrGetPageSize}, \refCom{igrPageHeight} contains
1123 the current page height. This is |\pdfpageheight| for |pdflatex|,
1124 |\pageheight| for |lualatex| and a choice of |\pdfpageheight| or |\paperheight|
1125 for other engines.
1126 \end{docCommand}
1127
1128
1129 \begin{docCommand}[doc new=2021-10-12]{igrSetPageSize}{\marg{width}\marg{height}}
1130 Sets the current page dimensions to \meta{width} and \meta{height}.
1131 In depends on the used engine, if a call to this command has success or
1132 not. This should work for |pdflatex| and |lualatex|.
1133 \end{docCommand}
1134
1135
1136 \subsection{Last Page Commands (Number of Pages)}
1137
1138 The following macros are auxiliary tools which used to wrap corresponding functions
1139 from |pdflatex| and |lualatex|. Now, they rely on the L3 programming layer.
1140
1141 \begin{docCommand}[doc new and updated={2021-10-18}{2026-02-25}]{igrGetLastPage}{\marg{file}}
1142 Reads the page count from the specified (PDF-)\meta{file} and stores it in
1143 the macro \refCom{igrLastPage}.\par
1144 Since 2026, this command has been implemented as a wrapper around
1145 \docAuxCommand*{graphics_get_pagecount:nN} from the L3 programming layer.
1146 \end{docCommand}
1147
1148
1149 \begin{docCommand}[doc new and updated={2021-10-18}{2026-02-25}]{igrLastPage}{}
1150 After calling \refCom{igrGetLastPage}, the macro \refCom{igrLastPage} contains
1151 the page count of the currently processed file.\par
1152 Note that since 2026 the value of \refCom{igrLastPage} is assigned locally;
1153 previously, it was assigned globally.\par
1154 Also note that the page count is available alternatively inside
1155 \refCom{incmultipages} as \docAuxCommand{last}.
1156 \end{docCommand}
1157
1158
1159 \clearpage
1160 \subsection{Full Page Commands}
1161
1162 \begin{docCommand}{igrpage}{\marg{text}}
1163 The \meta{text} is put on a separate page which is resized to fit the
1164 dimensions of the \meta{text}. \meta{text} may be single letter, an
1165 included picture, or any \LaTeX\ code.
1166 The page number is stored into \docAuxCommand{theigrpage} and
1167 \docAuxCommand{igrAutoTarget} holds a hyper target value for bookmarking.
1168 The style of the separate page is set to
1169 the content of the macro
1170 \docAuxCommand{igrpagestyle} which defaults to 'empty' but can be
1171 redefined.
1172 \end{docCommand}
1173
1174 \begin{docCommand}{igrcenter}{\marg{text}}
1175 The \meta{text} is put in the center of a separate page which has the
1176 current document dimensions. \meta{text} may be single letter, an
1177 included picture or any \LaTeX\ code.
1178 The page number is stored into \docAuxCommand{theigrpage} and
1179 \docAuxCommand{igrAutoTarget} holds a hyper target value for bookmarking.
1180 The style of the separate page is set to
1181 the content of the macro
1182 \docAuxCommand{igrpagestyle} which defaults to 'empty' but can be
1183 redefined.
1184 \end{docCommand}
1185
1186 \begin{docCommand}{igrcenterfit}{\marg{width}\marg{height}\marg{text}}
1187 The \meta{text} is put in the center of a separate page which
1188 is resized to the given \meta{width} and \meta{height}.
1189 \meta{text} may be single letter, an
1190 included picture or any \LaTeX\ code.
1191 The page number is stored into \docAuxCommand{theigrpage} and
1192 \docAuxCommand{igrAutoTarget} holds a hyper target value for bookmarking.
1193 The style of the separate page is set to
1194 the content of the macro
1195 \docAuxCommand{igrpagestyle} which defaults to 'empty' but can be
1196 redefined.
1197 \end{docCommand}
1198
1199
1200 \begin{docCommand}{igrtargetset}{\marg{anchor}}
1201 The next value for \docAuxCommand{igrAutoTarget} is set to \meta{anchor}.
1202 This can be used for hand-made hyperlinks or bookmarks.
1203 An application for |igrtargetset| is found in Example~\ref{fullpaperdrawing2}
1204 on page~\pageref{fullpaperdrawing2}.
1205 \end{docCommand}
1206
1207 \clearpage
1208 \subsection{Box Commands}
1209
1210 \begin{docCommand}{igrboxset}{\marg{text}}
1211 The \meta{text} is put into a \TeX\ box named \docAuxCommand{igrbox}.
1212 Additionally, some auxiliary macros are defined:
1213 \begin{itemize}
1214 \item\docAuxCommand{igrAutoTarget}: unique value for a hyper target.
1215 \item\docAuxCommand{igrBoxWidth}: width of the |\igrbox|.
1216 \item\docAuxCommand{igrBoxHeight}: total height of the |\igrbox|.
1217 \item\docAuxCommand{igrBoxht}: height of the |\igrbox|.
1218 \item\docAuxCommand{igrBoxdp}: depth of the |\igrbox|.
1219 \end{itemize}
1220 \begin{dispExample}
1221 \igrboxset{This is an example}
1222 |\igrAutoTarget| = \igrAutoTarget, |\igrBoxWidth| = \igrBoxWidth,
1223 |\igrBoxHeight| = \igrBoxHeight,\\
1224 |\igrBoxht| = \igrBoxht, |\igrBoxdp| = \igrBoxdp;
1225 \end{dispExample}
1226 \end{docCommand}
1227
1228 \begin{docCommand}{igrboxcenter}{}
1229 The current content of the |\igrbox|
1230 is put in the center of a separate page which has the
1231 current |pdfpage| dimensions.\\
1232 The style of the separate page is set to
1233 the content of the macro
1234 \docAuxCommand{igrpagestyle} which defaults to 'empty' but can be
1235 redefined.
1236 Note that a |\clearpage| or similar has to be inserted before this command.
1237 \end{docCommand}
1238
1239 \clearpage
1240 \begin{docCommand}{igrboxtikz}{}
1241 The current content of the |\igrbox| is embedded into a |\node| command
1242 from the |tikz| package \cite{package:tikz} which has to be loaded separately.
1243 Also, the bounding box is adjusted to the |\igrbox|.\\
1244 To support positioning inside the picture, two |tikz| nodes named
1245 |box| and |page| are defined which both take the dimensions of the |\igrbox|.
1246 \begin{dispExample}
1247 \igrboxset{\includegraphics{example.jpg}}%
1248 \begin{tikzpicture}%
1249 \igrboxtikz%
1250 \draw[blue,very thick] (0,0) rectangle (\igrBoxWidth,\igrBoxHeight);
1251 \draw[red] (0,0) grid (\igrBoxWidth,\igrBoxHeight);
1252 \draw[black] ([xshift=-1cm,yshift=-1cm]page.north east) circle (1cm);
1253 \end{tikzpicture}
1254 \end{dispExample}
1255
1256 The boxing macros can also be used nested (see the result on the following page):
1257 \begin{dispListing}
1258 \igrpage{\igrboxset{\includegraphics{example.jpg}}%
1259 \begin{tikzpicture}%
1260 \igrboxtikz%
1261 \draw[blue,very thick] (0,0) rectangle (\igrBoxWidth,\igrBoxHeight);
1262 \draw[red] (0,0) grid (\igrBoxWidth,\igrBoxHeight);
1263 \draw[black] ([xshift=1cm,yshift=-1cm]page.north west) circle (1cm);
1264 \end{tikzpicture}}
1265 \end{dispListing}
1266 \tcbusetemp
1267 \end{docCommand}
1268
1269
1270 \begin{docCommand}{igrboxtikzpage}{}
1271 This is an alias for \refCom{igrboxtikz}.
1272 \end{docCommand}
1273
1274
1275 \begin{docCommand}{igrboxtikzcenter}{}
1276 The current content of the |\igrbox| is embedded into a |\node| command
1277 from the |tikz| package \cite{package:tikz} which has to be loaded separately.
1278 This node is placed in the center of a bounding box which takes the current
1279 page dimensions. Afterwards, |\igrBoxWidth| and |\igrBoxHeight| are
1280 redefined to the dimensions of the total page.\\
1281 To support positioning inside the picture, two |tikz| nodes named
1282 |box| and |page| are defined. |box| takes the dimensions of the |\igrbox|
1283 and |page| takes the dimensions of the |tikzpicture|.
1284 \begin{dispListing}
1285 \igrcenter{\igrboxset{\includegraphics{example.jpg}}%
1286 \begin{tikzpicture}%
1287 \igrboxtikzcenter%
1288 \draw[help lines] (0,0) grid (\igrBoxWidth,\igrBoxHeight);
1289 \draw[dashed] (box.south west) rectangle (box.north east);
1290
1291 \draw[very thick,<->] (page.north west)--(box.north west);
1292 \draw[very thick,<->] (page.north east)--(box.north east);
1293 \draw[very thick,<->] (page.south west)--(box.south west);
1294 \draw[very thick,<->] (page.south east)--(box.south east);
1295 \end{tikzpicture}}
1296 \end{dispListing}
1297 See the result on the following page.
1298 \tcbusetemp
1299 \end{docCommand}
1300
1301
1302 \subsection{Map and Match Commands}
1303
1304
1305 \begin{docCommand}{igrsetmatchvalue}{\marg{key}\marg{value}}
1306 The given \meta{key} is mapped to the given \meta{value}. Later, this
1307 \meta{value} can be retrieved by \refCom{igrifmatch}.
1308 \begin{dispExample}
1309 \igrsetmatchvalue{my key A}{my value A}
1310 \def\keytester#1{\igrifmatch{#1}{Hurray: '\igrmatchvalue'}{'#1' unknown}}
1311
1312 \keytester{something}\\
1313 \keytester{my key A}
1314 \end{dispExample}
1315 \end{docCommand}
1316
1317
1318 \begin{docCommand}{igrsetmatches}{\marg{list}}
1319 The \meta{list} is a comma separated list of \meta{key}=\meta{value} pairs.
1320 On every pair, the \refCom{igrsetmatchvalue} macro is applied.
1321 \begin{dispExample}
1322 \igrsetmatches{my key A = my value A, bar = Shakespeare}
1323 \def\keytester#1{\igrifmatch{#1}{Hurray: '\igrmatchvalue'}{'#1' unknown}}
1324
1325 \keytester{something}\\
1326 \keytester{bar}\\
1327 \keytester{my key A}
1328 \end{dispExample}
1329 \end{docCommand}
1330
1331
1332 \begin{docCommand}{igrifmatch}{\marg{key}\marg{then}\marg{else}}
1333 If a \meta{key} was defined by \refCom{igrsetmatchvalue} or
1334 \refCom{igrsetmatches}, the corresponding value is put in the
1335 macro \docAuxCommand{igrmatchvalue} and the \meta{then} code is
1336 executed. If the \meta{key} is unknown, the \meta{else} code is
1337 executed.
1338 \begin{dispExample}
1339 \igrsetmatches{1 = January, 2 = February, 3 = March, apr = April}
1340 \def\monthname#1{\igrifmatch{#1}{The name of month #1\ is \igrmatchvalue.}{%
1341 You are kidding.}}
1342
1343 \monthname{1} \monthname{foo} \monthname{2}\\
1344 \monthname{3} \monthname{apr} \monthname{35}
1345 \end{dispExample}
1346 \end{docCommand}
1347
1348
1349 \clearpage
1350 \subsection{Zero Filling Commands}
1351
1352 \begin{docCommand}{igrmakezerofill}{\marg{macro}\marg{digits}}
1353 With this command, a new \meta{macro} can be defined which takes a
1354 non negative number as parameter.
1355 This number is filled up with leading zeros until the
1356 \meta{digits} count is reached.
1357 If \meta{digits} is 0 or 1, nothing is added. A \meta{digits} value
1358 greater than 10 is treated as 10 which is the maximum number of
1359 possible digits.
1360 \begin{dispExample}
1361 \igrmakezerofill{\myfill}{0}
1362 \myfill{7}, \myfill{12}, \myfill{934}, \myfill{665234}.\\
1363 \igrmakezerofill{\myfill}{3}
1364 \myfill{7}, \myfill{12}, \myfill{934}, \myfill{665234}.\\
1365 \igrmakezerofill{\myfill}{5}
1366 \myfill{7}, \myfill{12}, \myfill{934}, \myfill{665234}.\\
1367 \igrmakezerofill{\myfill}{9}
1368 \myfill{7}, \myfill{12}, \myfill{934}, \myfill{665234}.\\
1369 \igrmakezerofill{\myfill}{30}
1370 \myfill{7}, \myfill{12}, \myfill{934}, \myfill{665234}.
1371 \end{dispExample}
1372 \begin{dispExample}
1373 \igrmakezerofill{\threedigits}{3}
1374 \threedigits{1}%
1375 \foreach \n in {2,...,100} {, \threedigits{\n}}.
1376 \end{dispExample}
1377 \end{docCommand}
1378
1379 \clearpage
1380 %--------------------------------------
1381 \printbibliography[heading=bibintoc]
1382
1383 \printindex
1384
1385 \end{document}