Debian Codegraph @

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

raw
1 %
2 % \iffalse
3 %
4 %<*(package,pppdftexdef,ppluatexdef,ppvtexdef,ppxetexdef,ppdvipsdef,ppdvipdfmxdef,ppnulldef)>
5 %% Copyright (C) 2001-2026 Andreas MATTHIAS
6 %%
7 %% This work may be distributed and/or modified under the conditions
8 %% of the LaTeX Project Public License, either version 1.3c
9 %% of this license or (at your option) any later version.
10 %% The latest version of this license is in
11 %% <http://www.latex-project.org/lppl.txt>.
12 %%
13 %% This work has the LPPL maintenance status `maintained'.
14 %%
15 %% The Current Maintainer of this work is
16 %% Andreas Matthias <[email protected]>.
17 %
18 %</(package,pppdftexdef,ppluatexdef,ppvtexdef,ppxetexdef,ppdvipsdef,ppdvipdfmxdef,ppnulldef)>
19 %<*!installer>
20 %%
21 %% Please send error reports and suggestions for improvements to
22 %% Andreas MATTHIAS <[email protected]>.
23 %</!installer>
24 %%
25 %
26 %<*!(example1,example2,example3,installer)>
27 %<*dtx>
28 \makeatletter
29 %</dtx>
30 \def\AM@git@tag{v0.6h}
31 \def\AM@git@date{2026/03/30}
32 \def\AM@git@hash{8329ae0af7}
33 %</!(example1,example2,example3,installer)>
34 %
35 %
36 %<*dtx>
37 \ProvidesFile{pdfpages.dtx}
38 %</dtx>
39 %<package>\NeedsTeXFormat{LaTeX2e}
40 %<package>\ProvidesPackage{pdfpages}
41 %<pppdftexdef>\ProvidesFile{pppdftex.def}
42 %<ppluatexdef>\ProvidesFile{ppluatex.def}
43 %<ppvtexdef>\ProvidesFile{ppvtex.def}
44 %<ppxetexdef>\ProvidesFile{ppxetex.def}
45 %<ppdvipsdef>\ProvidesFile{ppdvips.def}
46 %<ppdvipdfmxdef>\ProvidesFile{ppdvipdfmx.def}
47 %<ppnulldef>\ProvidesFile{ppnull.def}
48 %<driver>\ProvidesFile{pdfpages.drv}
49 %<*!(example1,example2,example3,installer)>
50 % \fi
51 %
52 % \makeatletter
53 % \ProvidesFile{pdfpages.dtx}
54 [\AM@git@date\space\AM@git@tag\space
55 %
56 % \iffalse
57 %</!(example1,example2,example3,installer)>
58 %<*none>
59 % \fi
60 ]
61 % \makeatother
62 % \iffalse
63 %</none>
64 %<*!(example1,example2,example3,installer)>
65 %<*dtx>
66 \makeatother
67 %</dtx>
68 %</!(example1,example2,example3,installer)>
69 %
70 %<package> Insert pages of external PDF documents (AM)]
71 %<pppdftexdef> Pdfpages driver for pdfTeX (AM)]
72 %<ppluatexdef> Pdfpages driver for LuaTeX (AM)]
73 %<ppvtexdef> Pdfpages driver for VTeX (AM)]
74 %<ppxetexdef> Pdfpages driver for XeTeX (AM)]
75 %<ppdvipsdef> Pdfpages driver for dvips (AM)]
76 %<ppdvipdfmxdef> Pdfpages driver for dvipdfmx (AM)]
77 %<ppnulldef> Pdfpages dummy driver (AM)]
78 %
79 %
80 % \fi
81 %
82 % \GetFileInfo{pdfpages.dtx}
83 %
84 % \CheckSum{5475}
85 %
86 % \CharacterTable
87 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
88 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
89 % Digits \0\1\2\3\4\5\6\7\8\9
90 % Exclamation \! Double quote \" Hash (number) \#
91 % Dollar \$ Percent \% Ampersand \&
92 % Acute accent \' Left paren \( Right paren \)
93 % Asterisk \* Plus \+ Comma \,
94 % Minus \- Point \. Solidus \/
95 % Colon \: Semicolon \; Less than \<
96 % Equals \= Greater than \> Question mark \?
97 % Commercial at \@ Left bracket \[ Backslash \\
98 % Right bracket \] Circumflex \^ Underscore \_
99 % Grave accent \` Left brace \{ Vertical bar \|
100 % Right brace \} Tilde \~}
101 %
102 %
103 % \iffalse
104 %<*driver>
105 \documentclass{ltxdoc}
106 \usepackage{array}
107 \usepackage{graphicx}
108 \usepackage{booktabs, tabularx}
109 \usepackage{tikz}
110 \usetikzlibrary{decorations, decorations.pathmorphing}
111 \usepackage{adjustbox}
112 \usepackage{cmap}
113 \usepackage{hypdoc}
114 \hypersetup{colorlinks, linkcolor=blue, pdfstartview={Fit},
115 bookmarksopenlevel=1, bookmarksnumbered=false}
116 \OnlyDescription
117 \begin{document}
118 \DocInput{pdfpages.dtx}
119 \end{document}
120 %</driver>
121 % \fi
122 %
123 % \newcommand*{\versionlist}{%
124 % \setlength{\topsep}{0pt}%
125 % \setlength{\itemsep}{0pt}%
126 % \setlength{\leftmargin}{20pt}%
127 % \setlength{\parsep}{0pt}}
128 % \newcommand{\marginstyle}
129 % {\raggedleft\itshape\small}
130 %
131 % \def\pdfTeX{pdfTeX}
132 % \def\pdfLaTeX{pdfLaTeX}
133 % \def\luaTeX{LuaTeX}
134 % \def\VTeX{VTeX}
135 % \def\XeTeX{XeTeX}
136 % \def\dvips{dvips}
137 % \def\dvipdfmx{dvipdfmx}
138 % \def\pTeX{pTeX}
139 % \def\PDF{{\small PDF}}
140 % \def\PS{{\small PS}}
141 % \def\DVI{{\small DVI}}
142 %
143 % \pdfstringdefDisableCommands{%
144 % \def\pdfTeX{pdfTeX}%
145 % \def\luaTeX{LuaTeX}%
146 % \def\VTeX{VTeX}%
147 % \def\XeTeX{XeTeX}%
148 % }
149 %
150 % \makeatletter
151 % \title{The \textsf{pdfpages} Package\thanks{This file has version
152 % number \AM@git@tag, last revised \AM@git@date.\\The official
153 % repository is \url{https://github.com/AndreasMatthias/pdfpages}.}}
154 % \author{Andreas \textsc{Matthias}\\
155 % \href{mailto:[email protected]}{[email protected]}}
156 % \date{\AM@git@date}
157 % \makeatother
158 %
159 % \maketitle
160 %
161 % \begin{abstract}
162 % \noindent
163 % This package simplifies the insertion of external multi-page \PDF\
164 % or \PS\ documents. It supports \pdfTeX, \VTeX, \XeTeX, \luaTeX, and
165 % \pTeX.
166 % \end{abstract}
167 %
168 % \tableofcontents
169 %
170 %
171 % \section{Introduction}
172 % When creating \PDF\ documents, it is sometimes useful to insert pages
173 % of external \PDF\ documents. This can be done with the
174 % |\includegraphics| command from the \texttt{graphics} package. But a
175 % simple |\includegraphics{doc.pdf}| normally produces `|Overfull \hbox|'
176 % and `|Overfull \vbox|' warnings, because the size of the inserted pages
177 % does not match the print space.
178 %
179 % The |pdfpages| package makes it easy to insert pages of external \PDF\
180 % documents without worrying about the print space. Here are some
181 % features of the |pdfpages| package: Several logical pages can be
182 % arranged onto each sheet of paper and the layout can be changed
183 % individually. A lot of hypertext operations are supported, like links
184 % to the inserted pages, links to the original \PDF\ document, threads,
185 % etc. When working with \VTeX\ the same is possible with PostScript
186 % documents, too. Note that PostScript documents are only supported by
187 % \VTeX\ and \emph{not} by \pdfLaTeX.
188 %
189 % When producing \DVI\ output |pdfpages| cannot insert pages of a \PDF\
190 % documents. But instead of interrupting execution |pdfpages| will insert
191 % empty pages. This feature is important when using packages like
192 % |pst-pdf|, which need to produce \DVI\ output at the first run.
193 %
194 % \paragraph{Links and other interactive features of PDF documents}
195 % When including pages of a PDF only the so called content stream of
196 % these pages is copied but no links. Up to now there are no TeX-engines
197 % (\pdfTeX, \XeTeX, \ldots) available that can copy links or other
198 % interactive features of a PDF document, too. Thus, all kinds of
199 % links\footnote{Actually not only links but all kinds of \emph{PDF
200 % annotations} will get lost.} will get lost during
201 % inclusion. (Using |\includepdf|, |\includegraphics|, or other low-level
202 % commands.)
203 %
204 % However, there's a glimmer of hope. Some links may be extracted and later
205 % reinserted by a package called \emph{pax} which can be downloaded from
206 % CTAN \cite{pax}. Have a look at it!
207 %
208 %
209 % \section{Usage}
210 % \subsection{Package Options}
211 %
212 % \begin{minipage}{\linewidth}
213 % |\usepackage[|\meta{options}|]{pdfpages}|
214 %
215 % \begin{quote}
216 % \meta{option} --
217 % \begin{minipage}[t]{.8\linewidth}
218 % \setlength\leftmargini{3.5em}
219 % \begin{description}
220 % \setlength\itemsep{0pt}
221 % \item[|final|:] Inserts pages. This is the default.
222 % \item[|draft|:] Does not insert pages, but prints a box
223 % and the filename instead.
224 % \item[|demo|:] Inserts empty pages instead of the actual PDFs.
225 % \item[|nodemo|:] Disables `demo'.
226 % \item[|enable-survey|:] Activates survey functionalities.
227 % (\emph{experimental, subject to change})
228 % \end{description}
229 % \end{minipage}
230 % \end{quote}
231 % \end{minipage}
232 %
233 %
234 % \subsection{Commands}
235 %
236 % \DescribeMacro{\includepdf}
237 % Inserts pages of an external \PDF\ document.
238 %
239 % \medskip\noindent
240 % \begin{minipage}{\linewidth}
241 % |\includepdf[|\meta{key=val}|]{|\meta{filename}|}|
242 %
243 % \begin{quote}
244 % \begin{tabular}{@{}l@{\,--~}>{\raggedright}p{.8\linewidth}}
245 % \meta{key=val} & A comma separated list of options
246 % using the \meta{key}=\meta{value} syntax.
247 % \tabularnewline[.25\baselineskip]
248 % \meta{filename} & Filename of the \PDF\ document. (The
249 % filename \emph{must not} contain any blanks!)
250 % \end{tabular}
251 % \end{quote}
252 % \end{minipage}\bigskip
253 %
254 %
255 % \noindent
256 % The following list describes all possible options of
257 % |\includepdf|. All options are using the \meta{key=value} syntax.
258 %
259 % \newcommand*{\df}[1]{(Default: \mbox{|#1|})}
260 %
261 % \setlength{\leftmargini}{\parindent}
262 % \begin{itemize}
263 %
264 %
265 % \item Main options:
266 %
267 % \begin{description}
268 % \makeatletter\@beginparpenalty=10000\makeatother
269 % \item[pages] Selects pages to insert. The argument is a comma
270 % separated list, containing page numbers
271 % (|pages={3,5,6,8}|), ranges of page numbers
272 % (|pages={4-9}|) or any combination.
273 % To insert empty pages use |{}|.
274 % \par
275 % E.g.: |pages={3,{},8-11,15}| will insert
276 % page 3, an empty page, and pages 8, 9, 10, 11,
277 % and 15.
278 % \par
279 % Page ranges are specified by the following syntax:
280 % \meta{m}|-|\meta{n}. This selects all pages from
281 % \meta{m} to \meta{n}. Omitting \meta{m} defaults
282 % to the first page; omitting \meta{n} defaults to
283 % the last page of the document. Another way to
284 % select the last page of the document, is to use the
285 % keyword |last|. (This is only permitted in a
286 % page range.)
287 % \par
288 % E.g.: |pages=-| will insert \emph{all} pages
289 % of the document, and |pages=last-1| will insert
290 % all pages in reverse order.
291 % \par\df{pages=1}
292 % \item[nup] Puts multiple logical pages onto each sheet
293 % of paper. The syntax of this option is:
294 % |nup=|\meta{xnup}|x|\meta{ynup}. Where
295 % \meta{xnup} and \meta{ynup} specify the number of
296 % logical pages in horizontal and vertical direction,
297 % which are arranged on each sheet of paper.
298 % \df{nup=1x1}
299 % \item[landscape] Specifies the format of the sheet of paper,
300 % which is rotated by 90~degrees. This does
301 % \emph{not} affect the logical pages, which
302 % will \emph{not} be rotated by the `landscape'
303 % option. To rotate the logical pages use the
304 % `angle' option (e.g.~`angle=90').
305 % Either `true' or `false' (or no value, which
306 % is equivalent to `true'). \df{landscape=false}
307 % \end{description}
308 %
309 %
310 % \item Layout options:
311 %
312 % \begin{description}
313 % \makeatletter\@beginparpenalty=10000\makeatother
314 % \item[delta] Puts some horizontal and vertical space between the
315 % logical pages. The argument should be two dimensions,
316 % separated by space. See Chapter~\ref{sec:layout} and
317 % Figure~\ref{fig:layout}. \df{delta=0 0}.
318 % \item[offset] Displaces the origin of the inserted pages.
319 % The argument should be two dimensions, separated
320 % by space. In `oneside' documents positive values
321 % shift the pages to the \emph{right} and to the
322 % \emph{top} margin, respectively, whereas in `twoside'
323 % documents positive values shift the pages to the
324 % \emph{outer} and to the \emph{top} margin,
325 % respectively. See Chapter~\ref{sec:layout} and
326 % Figure~\ref{fig:layout}. \df{offset=0 0}
327 % \item[frame] Puts a frame around each logical page. The frame is
328 % made of lines of thickness |\fboxrule|. Either `true'
329 % or `false' (or no value, which is equivalent to `true').
330 % \df{frame=false}
331 % \item[column] Pdfpages normally uses `row-major' layout, where
332 % successive pages are placed in rows along the paper.
333 % The |column| option changes the output into a
334 % `column-major' layout, where successive pages are
335 % arranged in columns down the paper.
336 % Either `true' or `false' (or no value, which
337 % is equivalent to `true'). \df{column=false}
338 % \item[columnstrict] By default the last page is not set in a
339 % strict `column-major' layout, if the logical
340 % pages do not fill up the whole page. The
341 % |columnstrict| option forces a strict
342 % `column-major' layout for the last page.
343 % Either `true' or `false' (or no value, which
344 % is equivalent to `true'). \df{columnstrict=false}
345 % \par\hskip15pt
346 % \begin{minipage}[b]{110pt}
347 % \centering
348 % \begin{tabular}{|c|c|c|}\hline
349 % 1 & 4 & \phantom{6}\\\hline
350 % 2 & 5 &\\\hline
351 % 3 &&\\\hline
352 % \end{tabular}\smallskip\par
353 % |columnstrict=true|
354 % \end{minipage}
355 % \hskip15pt
356 % \begin{minipage}[b]{110pt}
357 % \centering
358 % \begin{tabular}{|c|c|c|}\hline
359 % 1 & 3 & 5\\\hline
360 % 2 & 4 & \\\hline
361 % &&\\\hline
362 % \end{tabular}\smallskip\par
363 % |columnstrict=false|
364 % \end{minipage}
365 % \item[openright] This option puts an empty page before the
366 % first logical page. In combination with |nup=2x1|,
367 % |nup=2x2|, etc., this means that the first page
368 % is on the right side. The same effect can be
369 % achieved with the |pages| option, if an empty page
370 % is inserted in front of the first page.
371 % Either `true' or `false' (or no value, which
372 % is equivalent to `true'). \df{openright=false}
373 % \item[openrighteach] Similar to |openright| but affects
374 % \emph{each} file processed by |\includepdfmerge|.
375 % \item[pagecommand] Declares \LaTeX\ commands, which are executed
376 % on each sheet of paper.
377 % \df{pagecommand=\{\bslash thispagestyle\{empty\}\}}
378 % \item[pagecommand*] Declares \LaTeX\ commands that are executed
379 % on the very first page only.
380 % \df{pagecommand*=\{\}}
381 % \item[turn] By default pages in landscape format are displayed
382 % in landscape orientation (if the \PDF\ viewer supports
383 % this). With \texttt{turn=false} this can be prohibited.
384 % Either `true' or `false' (or no value, which
385 % is equivalent to `true'). \df{turn=true}
386 % \item[noautoscale] By default pages are scaled automatically.
387 % This can be suppressed with the
388 % \texttt{noautoscale} option.
389 % In combination with the \texttt{scale} option
390 % (from graphicx) the user has full control over
391 % the scaling process.
392 % Either `true' or `false' (or no value, which
393 % is equivalent to `true'). \df{noautoscale=false}
394 % \item[fitpaper] Adjusts the paper size to the one of the
395 % inserted document.
396 % Either `true' or `false' (or no value, which
397 % is equivalent to `true'). \df{fitpaper=false}
398 % \item[reflect] Reflects included pages.
399 % Either `true' or `false' (or no value, which
400 % is equivalent to `true'). \df{reflect=false}
401 % \item[signature] Creates booklets by rearranging
402 % pages into signatures and setting
403 % |nup=1x2| or |nup=2x1|, respectively. This option
404 % takes one argument specifying the size of the
405 % signature, which should be a multiple of 4.\par
406 % An example for documents in portrait orientation:\par
407 % |\includepdf[pages=-, signature=8,|\\
408 % \hspace*{6em} |landscape]{portrait-doc.pdf}|\par
409 % An example for documents in landscape orientation:\par
410 % |\includepdf[pages=-, signature=8]{landscape-doc.pdf}|
411 % \item[signature*] Similar to |signature|, but for right-edge binding.
412 % \item[booklet] This option is just a shortcut of the `signature'
413 % option, if you choose a signature value
414 % so large that all pages fit into one signature.
415 % Either `true' or `false' (or no value, which
416 % is equivalent to `true'). \df{booklet=false}
417 % \item[booklet*] Similar to |booklet|, but for right-edge binding.
418 % \item[flip-other-edge] Flip paper for duplex printing on the other edge.
419 % Only relevant in combination with |booklet|, |booklet*|,
420 % |signature|, or |signature*|. See section \ref{sec:booklets}.
421 % \df{flip-other-edge=false}
422 % \item[picturecommand] Declares picture commands which are executed
423 % on every page within a picture environment with the
424 % base point at the lower left corner of the page.
425 % (The base point does not change if the page is
426 % rotated, e.g.~by the |landscape| option.)
427 % \df{picturecommand=\{\}}
428 % \item[picturecommand*] Like |picturecommand|, but with the restriction
429 % that |picturecommand*| executes its picture commands
430 % only on the very first page.
431 % \df{picturecommand*=\{\}}
432 % \item[pagetemplate] By default the first inserted page will be
433 % used as a template. This means that all further
434 % pages are scaled such that they match within the
435 % contour of this
436 % first page. This option allows to declare another
437 % page to be used as a template; which is only useful
438 % if a \PDF\ document contains different page sizes
439 % or page orientations. The argument should
440 % be a page number.
441 % \df{pagetemplate=\meta{first inserted page}}
442 % \item[templatesize] This option is similar to the |pagetemplate|
443 % option, but its arguments specify the size of
444 % the template directly. Its syntax is:
445 % |templatesize={|\meta{width}|}{|\meta{height}|}|
446 % Note: The two lengths should be a bit larger than
447 % desired, to keep away from rounding errors.\par
448 % \df{templatesize=\meta{size of the first inserted page}}
449 % \item[rotateoversize] This option allows to rotate oversized
450 % pages. E.g.\ pages in landscape orientation are
451 % oversized relatively to their portrait counterpart,
452 % because they do not match within the contour of
453 % a portrait page without rotating them. By default
454 % oversized pages are scale and are \emph{not} rotated.
455 % Either `true' or `false' (or no value, which
456 % is equivalent to `true'). \df{rotateoversize=false}
457 % \item[doublepages] Inserts every page twice. This is useful for
458 % 2-up printing, if one wants to cut the stack of paper
459 % afterwards to get two copies.
460 % Either `true' or `false' (or no value, which
461 % is equivalent to `true'). \df{doublepages=false}
462 % \item[doublepagestwist] Whereas with |doublepages| the cutting
463 % edge is once on the inner side and ones on the outer
464 % side, |doublepagestwist| turns the pages such, that
465 % the cutting edge is always on the inner side.
466 % Either `true' or `false' (or no value, which is
467 % equivalent to `true'). \df{doublepagestwist=false}
468 % \item[doublepagestwistodd] Turns the pages such, that the
469 % cutting edge is always on the outer side.
470 % Either `true' or `false' (or no value, which is
471 % equivalent to `true'). \df{doublepagestwistodd=false}
472 % \item[doublepagestwist*] Like |doublepagestwist| but for
473 % double side printing.
474 % Either `true' or `false' (or no value, which is
475 % equivalent to `true'). \df{doublepagestwist*=false}
476 % \item[doublepagestwistodd*] Like |doublepagestwistodd| but for
477 % double side printing
478 % Either `true' or `false' (or no value, which is
479 % equivalent to `true'). \df{doublepagestwistodd*=false}
480 % \item[duplicatepages] Duplicates each page $n$ times,
481 % with $n$ being the argument to this option.
482 % \df{duplicatepages=2}
483 % \end{description}
484 %
485 % \item Miscellaneous options:
486 % \makeatletter\@beginparpenalty=10000\makeatother
487 % \begin{description}
488 % \item[lastpage] In \DVI\ mode pdfpages cannot determine the number of
489 % pages of the included document. So this option is suitable to
490 % specify the number of pages. This option is only used in \DVI\ mode
491 % and has no meaning in any other mode. The argument should be a page
492 % number. \df{lastpage=1}
493 % \end{description}
494 %
495 % \item Hypertext options:
496 %
497 % \begin{description}
498 % \makeatletter\@beginparpenalty=10000\makeatother
499 % \item[link] Inserted pages become a target
500 % of a hyperlink. The name of the link is
501 % `\texttt{\meta{filename}.\meta{page number}}'.
502 % The filename extension of \meta{filename}
503 % \emph{must not} be stripped.
504 % Either `true' or `false' (or no value, which
505 % is equivalent to `true').
506 % \df{link=false}
507 % \item[linkname] Changes the default linkname created by the option
508 % \texttt{link}. Instead of \meta{filename} the
509 % value of this option is used. E.g.~\texttt{
510 % linkname=mylink} produces the linknames
511 % `\texttt{mylink.\meta{page number}}'.
512 % \item[thread] Combines inserted pages to an article thread.
513 % Either `true' or `false' (or no value, which
514 % is equivalent to `true'). \df{thread=false}
515 % \item[threadname] Several threads are distinguished by their
516 % threadnames. By default the threadname is equal
517 % to the filename (plus filename extension), but it
518 % can be changed with this option. This is useful if
519 % the same file is inserted twice or more times and
520 % should not be combined to one single thread.
521 % Or the other way round if pages from different
522 % documents should be combined to one single thread.
523 % \df{threadname=\meta{filename.ext}}
524 % \item[linktodoc] Lets the inserted pages be hyperlinks to the
525 % document from which they were extracted.
526 % Note that the \PDF-Viewer will not find the
527 % file, if filename extension (.pdf) is missing
528 % in \meta{filename}.
529 % Either `true' or `false' (or no value, which
530 % is equivalent to `true'). \df{linktodoc=false}
531 % \end{description}
532 %
533 %
534 % \item Additional hypertext options:
535 %
536 % \begin{description}
537 % \makeatletter\@beginparpenalty=10000\makeatother
538 % \item[linkfit] Specifies, how the viewer displays a linked page.
539 % This option changes the default behavior of the
540 % option \texttt{link}.
541 % Possible values are:
542 % \texttt{Fit},
543 % \texttt{FitH \meta{top}},
544 % \texttt{FitV \meta{left}},
545 % \texttt{FitB},
546 % \texttt{FitBH \meta{top}},
547 % \texttt{FitBV \meta{left}},
548 %^^A \texttt{fitr \meta{left} \meta{bottom}
549 %^^A \meta{right} \meta{top}},
550 %^^A \texttt{xyz \meta{left} \meta{top} \meta{zoom}},
551 % and \texttt{Region}.
552 %
553 % See \cite{PDFRef} for a details description of these
554 % \PDF\ destinations. The |region| destination was
555 % added by pdfpages and is not a real \PDF\
556 % destinations. It scales a page such that the
557 % included page fits exactly into the window of the
558 % \PDF\ viewer.\par
559 % Note that not all of these options are supported by
560 % all \TeX-engines or drivers, respectively.
561 % \df{linkfit=fit}
562 % \item[linktodocfit] By default the option \texttt{linktodoc} opens
563 % the page in `Fit in Window' view.
564 % Another view can be specified with this option.
565 % Possible values are the legal \PDF\ tokens:
566 % \texttt{/FitH} \meta{top}, \texttt{/FitV}
567 % \meta{left}, etc.
568 % (See \cite{PDFRef} for more details.)
569 % \df{linktodocfit=/Fit}
570 % \item[newwindow] By default option |linktodoc| opens a new
571 % window. This can be changed with option |newwindow|.
572 % Either `true' or `false' (or no value, which
573 % is equivalent to `true'). \df{newwindow=true}
574 % \item[linkfilename] Sets the name (with path) of the file to be
575 % linked to by the option \texttt{linktodoc}.
576 % You will hardly ever need this option.
577 % \df{linkfilename=\meta{filename.ext}}
578 % \end{description}
579 %
580 %
581 % \item Experimental options: (Syntax may change in future versions!)
582 %
583 % \begin{description}
584 % \makeatletter\@beginparpenalty=10000\makeatother
585 %
586 % \item[addtotoc] Adds an entry to the table of contents. This
587 % option requires five arguments, separated by commas:
588 %
589 % \texttt{addtotoc=\{\meta{page number},^^A
590 % \meta{section},\meta{level},\meta{heading},^^A
591 % \meta{label}\}}
592 %
593 % \begingroup
594 % \renewcommand*\descriptionlabel[1]{\hspace\labelsep
595 % \normalfont #1}
596 % \begin{description}
597 % \item[\meta{page number}:] Page number of the
598 % inserted page.
599 % \item[\meta{section}:] \LaTeX\ sectioning name
600 % -- e.g., section, subsection, \ldots
601 % \item[\meta{level}:] Number, denoting depth of
602 % section -- e.g., 1 for section level, 2 for
603 % subsection level, \ldots
604 % \item[\meta{heading}:] Title inserted in the
605 % table of contents.
606 % \item[\meta{label}:] Name of the label. This label
607 % can be referred to with |\ref| and |\pageref|.
608 % \end{description}
609 % \endgroup
610 %
611 % Note: The order of the five arguments must not
612 % be mixed. Otherwise you will get very strange
613 % error messages.
614 %
615 % The |addtotoc| option
616 % accepts multiple sets of the above mentioned five
617 % arguments, all separated by commas. The sets must
618 % be sorted such that the \meta{page number}s are in
619 % ascending order. (Strictly speaking they must have
620 % the same order as the page numbers specified by
621 % the |pages| option.)
622 %
623 % The proper recursive definition of the |addtotoc|
624 % option is:
625 %
626 % \texttt{addtotoc=}\{\meta{toc-list}\}
627 %
628 % \meta{toc-list} $\rightarrow$ \meta{page number},^^A
629 % \meta{section},\meta{level},\meta{heading},^^A
630 % \meta{label}[,\meta{toc-list}]
631 %
632 %
633 % \item[addtolist] Adds an entry to the list of figures, the
634 % list of tables, or any other list
635 % (e.g.~from \emph{float.sty}). This option
636 % requires four arguments, separated by commas:
637 %
638 % \texttt{addtolist=\{\meta{page number},^^A
639 % \meta{type},\meta{heading},\meta{label}\}}
640 %
641 % \begingroup
642 % \renewcommand*\descriptionlabel[1]{\hspace\labelsep
643 % \normalfont #1}
644 % \begin{description}
645 % \item[\meta{page number}:] Page number of the
646 % inserted page.
647 % \item[\meta{type}:] Name of a floating
648 % environment. (\texttt{figure},
649 % \texttt{table}, etc.)
650 % \item[\meta{heading}:] Title inserted into LoF,
651 % LoT, etc.
652 % \item[\meta{label}:] Name of the label. This label
653 % can be referred to with |\ref| and |\pageref|.
654 % \end{description}
655 % \endgroup
656 %
657 % Like \texttt{addtotoc}, \texttt{addtolist} accepts
658 % multiple sets of the above mentioned four arguments,
659 % all separated by commas. The proper recursive
660 % definition is:
661 %
662 % \texttt{addtolist=}\{\meta{lof-list}\}
663 %
664 % \meta{lof-list} $\rightarrow$ \meta{page number},^^A
665 % \meta{type},\meta{heading},\meta{label}^^A
666 % [,\meta{lof-list}]
667 %
668 %
669 % \item[alt] This options adds an alternative text for accessibility
670 % if package |tagpdf|\footnote{Package |tagpdf| is loaded by
671 % default in recent \LaTeX\ kernels, if you enable |tagging| in
672 % the meta data: |\bslash DocumentMetadata\{tagging=on\}|.}
673 % is loaded.
674 % (Default: |alt={File \FileName}|)
675 % \par
676 % \emph{Note}: Even if the included pdf is a structured (tagged)
677 % pdf, it is not possible to copy this structure. The included pdf
678 % will always be marked as a figure with an alternative text
679 % without any further structure.
680 %
681 %
682 % \item[alt*] This option expects a list in which you can specify an
683 % alternative text for some or all pages.
684 % For instance |alt*={1,lorem,2,ipsum}| sets
685 % \emph{lorem} and \emph{ipsum} as alternative text for page
686 % 1 and 2, respectively.\par
687 % This is the syntax of the list:\par
688 % \quad\texttt{alt*=}\{\meta{tag-list}\}\par
689 % \quad\meta{tag-list} $\rightarrow$ \meta{page number},^^A
690 % \meta{alternative text} [,\meta{tag-list}]
691 %
692 %
693 % \item[artifact] This option marks all pages as artifacts
694 %
695 %
696 % \item[survey] Creates a survey of those pages of the document, which
697 % are marked with |\AddToSurvey|. (|\AddToSurvey| is
698 % a simple command with no arguments. It just writes out
699 % labels to the |.aux| file.)
700 % This option may be used when preparing slides to
701 % create a survey of only `finished' pages -- if
702 % pages are build up incrementally.
703 %
704 % To use this option a special sequence of production
705 % steps must be obeyed. Here is a small example:
706 %
707 %\begin{verbatim}
708 % --- slides.tex ---
709 % \documentclass{article}
710 % \usepackage[draft,enable-survey]{pdfpages}
711 % \begin{document}
712 % ... some text ...
713 % \AddToSurvey
714 % ... some text ...
715 % \includepdf[survey,nup=2x2]{slides-tmp.pdf}
716 % \end{document}
717 %\end{verbatim}
718 %
719 % This is the outline of a document, called |slides.tex|.
720 % Run it through \pdfLaTeX\ several times until all
721 % cross-references are solved. (\LaTeX\ will produce a
722 % warning, if cross-references are not solved, yet.)
723 % Now copy the file |slides.pdf| to |slides-tmp.pdf|
724 % and rename |draft| (package option of pdfpages) to
725 % |final|. The next and final run through \pdfLaTeX\
726 % will actually insert the desired pages, whereas the
727 % former runs with |draft| did just insert blank pages.
728 % The inserted pages are hyperlink to the orignial
729 % pages.
730 %
731 % Experienced users would certainly call
732 %\begingroup
733 %\setlength\topsep{0pt}
734 %\begin{verbatim}
735 % pdflatex '\PassOptionsToPackage{final}{pdfpages} \input{slides}'
736 %\end{verbatim}
737 %\endgroup
738 % instead of exchanging |draft| for |final|.
739 %
740 % Either `true' or `false' (or no value, which
741 % is equivalent to `true'). \df{survey=false}
742 %
743 %
744 % \item[survey-nolink] Same as option |survey| except that the
745 % inserted pages do not become hyperlinks.
746 % This option may be used to create an external survey.
747 % To continue the example above (|slides.tex|), it
748 % is now possible to create handouts of the `finished'
749 % slides as an external document.
750 %
751 %\begin{verbatim}
752 % \documentclass{article}
753 % \usepackage{xr}
754 % \externaldocument{slides}
755 % \usepackage[enable-survey]{pdfpages}
756 % \begin{document}
757 % \includepdf[survey-nolink, nup=1x2]{slides.pdf}
758 % \end{document}
759 %\end{verbatim}
760 %
761 % Either `true' or `false' (or no value, which
762 % is equivalent to `true'). \df{survey-nolink=false}
763 %
764 %
765 % \item[xr-prefix] Adjusts a prefix to the labels |\includepdf| is
766 % looking for. The name of the prefix must be the
767 % same as the name of the optional argument of
768 % |\externaldocument|.
769 % \df{xr-prefix=\{\}}
770 %
771 %
772 % \end{description}
773 %
774 % \end{itemize}
775 %
776 %
777 % \begin{figure}
778 % \centering
779 % \setlength{\unitlength}{.7mm}
780 % \def\thick{.7pt}
781 % \def\thin{.2pt}
782 % ^^A\fbox{
783 % \begin{picture}(145,238)
784 % \small
785 % \put(0,33){
786 % \linethickness{\thick}
787 % \put(0,0){\framebox(145,205){}}
788 % \linethickness{\thin}
789 % \put(10,15){\dashbox(35,49){}}
790 % \put(55,15){\dashbox(35,49){}}
791 % \put(100,15){\dashbox(35,49){}}
792 % \put(10,78){\dashbox(35,49){}}
793 % \put(55,78){\dashbox(35,49){}}
794 % \put(100,78){\dashbox(35,49){}}
795 % \put(10,141){\dashbox(35,49){}}
796 % \put(55,141){\dashbox(35,49){}}
797 % \put(100,141){\dashbox(35,49){}}
798 % \put(5,7){
799 % \put(10,15){\framebox(35,49){}}
800 % \put(55,15){\framebox(35,49){}}
801 % \put(100,15){\framebox(35,49){}}
802 % \put(10,78){\framebox(35,49){}}
803 % \put(55,78){\framebox(35,49){}}
804 % \put(100,78){\framebox(35,49){}}
805 % \put(10,141){\framebox(35,49){}}
806 % \put(55,141){\framebox(35,49){}}
807 % \put(100,141){\framebox(35,49){}}
808 % \put(45,36){\vector(1,0){10}}
809 % \put(55,36){\vector(-1,0){10}}
810 % \put(44.5,38){\textit{delx}}
811 % \put(90,36){\vector(1,0){10}}
812 % \put(100,36){\vector(-1,0){10}}
813 % \put(89.5,38){\textit{delx}}
814 % \put(27,64){\vector(0,1){14}}
815 % \put(27,78){\vector(0,-1){14}}
816 % \put(15,70){\textit{dely}}
817 % \put(27,127){\vector(0,1){14}}
818 % \put(27,141){\vector(0,-1){14}}
819 % \put(15,133){\textit{dely}}
820 % }
821 % \put(10,15){\vector(1,0){5}}
822 % \put(15,15){\vector(0,1){7}}
823 % \put(8,8){\textit{offx}}
824 % \put(17,17){\textit{offy}}
825 % }
826 %
827 % ^^A legend
828 %
829 % \setlength{\fboxsep}{4pt}
830 % \put(72.5,10){
831 % \makebox(0,0){
832 % \fbox{
833 % \begin{tabular}{l@{\hskip20pt}l}
834 % \linethickness{\thick}^^A
835 % \raisebox{.8ex}{\line(1,0){5}} physical sheet of paper
836 % &
837 % |delta=|\meta{delx} \meta{dely}
838 % \\
839 % \linethickness{\thin}^^A
840 % \raisebox{.8ex}{\line(1,0){5}} logical pages
841 % &
842 % |offset=|\meta{offx} \meta{offy}
843 % \\
844 % \raisebox{.8ex}{\line(1,0){1}\hskip.55mm\line(1,0){1}
845 % \hskip.55mm\line(1,0){1}} centered position
846 % &
847 % \\
848 % \end{tabular}
849 % }}
850 % }
851 % \end{picture}
852 % ^^A}% fbox
853 % \caption{Layout}
854 % \label{fig:layout}
855 % \end{figure}
856 %
857 %
858 % \noindent
859 % Internally the command |\includepdf|
860 % makes use of the |\includegraphics| command from the |graphicx|
861 % (actually |graphics|) package. Hence it is possible to use
862 % all the options of |\includegraphics|, too.
863 % Options which are not interpreted by |\includepdf|
864 % are passed directly to |\includegraphics|.
865 %
866 % Especially the `trim' and `clip' options of |\includegraphics|
867 % are quite useful, if only parts of a page should be inserted.
868 % (Maybe to cut off the header and footer of the inserted pages.)
869 % Just use the `trim' and `clip' options as if they were options
870 % of |\includepdf|. They will be passed to |\includegraphics|
871 % internally.
872 %
873 %
874 % \begin{samepage}
875 % \bigskip\noindent
876 % \DescribeMacro{\includepdfmerge}
877 % Inserts pages of several external \PDF\ documents.
878 %
879 % \medskip\noindent
880 % |\includepdfmerge[|\meta{key=val}|]{|\meta{file-page-list}|}|
881 %
882 % \begin{quote}
883 % \begin{tabular}{@{}l@{\,--~}>{\raggedright}p{.73\linewidth}}
884 % \meta{key=val} & A comma separated list of options
885 % using the \meta{key}=\meta{value} syntax.
886 % \tabularnewline
887 % \meta{file-page-list} & \meta{filename}[\textbf{,}^^A
888 % \meta{page spec}]^^A
889 % [\textbf{,}\meta{file-page-list}]\\
890 % A comma separated list of filenames and
891 % optional \meta{page spec} specifiers.
892 % A \meta{page spec} can be everything the
893 % option |pages| accepts.
894 %
895 % \end{tabular}
896 % \end{quote}
897 % \end{samepage}
898 %
899 % The |\includepdfmerge| command uses the same options as
900 % |\includepdf| with
901 % one exception. The option |pages| has no meaning for
902 % |\includepdfmerge|. Instead the \meta{page spec} specifier
903 % is used to specify which pages should be inserted.
904 % The \meta{page spec} specifier accepts the same values as
905 % the |pages| option. If no \meta{page spec} specifier is given,
906 % only the first page will be inserted.
907 %
908 % \paragraph{Examples:}
909 % To create a kind of summary of three \PDF\ documents, it might
910 % be nice to insert just the first page of each document and
911 % to provide links to the original documents:
912 %
913 % \begin{quote}
914 % |\includepdfmerge[nup=1x3, landscape, linktodoc]|\\
915 % | {doc1.pdf, doc2.pdf, doc3.pdf}|
916 % \end{quote}
917 %
918 % \noindent
919 % But sometimes the title page of a document is not the first page.
920 % So it would be more pleasant to insert the title page of
921 % each document than the first page. This can be done with
922 % the \meta{page spec} specifier. The following example inserts
923 % the second page of \textit{doc1.pdf} and the third page of
924 % \textit{doc2.pdf} and \textit{doc3.pdf}:
925 %
926 % \begin{quote}
927 % |\includepdfmerge[nup=1x3, landscape, linktodoc]|\\
928 % | {doc1.pdf, 2, doc2.pdf, 3, doc3.pdf, 3}|
929 % \end{quote}
930 %
931 % \noindent
932 % Here is an example of more complex \meta{page spec}
933 % specifiers:
934 %
935 % \begin{quote}
936 % |\includepdfmerge[nup=1x3, landscape, linktodoc]|\\
937 % | {doc1.pdf, 1-3,|\\
938 % | doc2.pdf, 3, 5, 9,|\\
939 % | doc3.pdf, 3-5, 7}|
940 % \end{quote}
941 %
942 %
943 %
944 % \bigskip\noindent
945 % \DescribeMacro{\includepdfset}
946 % If you need the same options for |\includepdf| all the time, it is
947 % possible to define global options with |\includepdfset|. The
948 % argument of |\includepdfset| is a comma separated list of options,
949 % using the \meta{key}=\meta{value} syntax.
950 % These options are processed each time |\includepdf| is called.
951 % Local options (passed as an optional argument directly to |\includepdf|)
952 % are overwriting global options:
953 % \begin{quote}
954 % |\includepdfset{|\meta{global options}|}|\\
955 % |\includepdf[|\meta{local options}|]{pdf-file}|
956 % \end{quote}
957 % Only options specific to this package can be made global by
958 % |\includepdfset|. Options of the graphicx package are not
959 % concerned.
960 %
961 % \bigskip\noindent
962 % \DescribeMacro{\threadinfodict}
963 % When using the option |thread| to create an article thread, it
964 % may be useful to create a thread information dictionary, too,
965 % which contains informations about the thread, such as its title,
966 % author, and creation date. The macro |\threadinfodict| is used
967 % to set these informations. It can be redefined and may contain
968 % entries of a thread information dictionary in low-level \PDF\
969 % commands.
970 % (See \cite{PDFRef} for more information.)
971 %
972 % \smallskip
973 % |\renewcommand*{\threadinfodict}|\\\hspace*{\parindent}
974 % | {/Title (My first thread) /Author (That's me!)}|
975 %
976 %
977 %
978 % \subsection{Layout}
979 % \label{sec:layout}
980 %
981 % The default layout can be changed by the options |delta|
982 % and |offset|. Figure~\ref{fig:layout} shows the
983 % meaning of these options.
984 %
985 % The inserted logical pages are being centered on the
986 % sheet of paper by default. To displace them use the |offset|
987 % option, which argument should be two dimensions. E.g.~
988 % |offset=10mm 14mm| means that the logical pages are displaced
989 % by 10\,mm in horizontal direction and by 14\,mm in vertical
990 % direction.
991 % In `oneside' documents positive values shift the pages to
992 % the \emph{right} and to the \emph{top} margin, respectively,
993 % whereas in `twoside' documents positive values shift the pages
994 % to the \emph{outer} and to the \emph{top} margin, respectively.
995 %
996 % By default logical pages are being arranged side by side.
997 % To put some space between them, use the |delta| option,
998 % whose argument should be two dimensions.
999 % Figure~\ref{fig:layout} shows the meaning of |delta|.
1000 %
1001 % The layout options |delta| and |offset|
1002 % \textit{always} refer to a sheet of paper in portrait
1003 % orientation. No matter whether you have set the
1004 % |landscape| option to |true|, or not.
1005 %
1006 % If you are confused about horizontal\,(|x|)
1007 % and vertical\,(|y|) directions, just set the option
1008 % |turn=false|. Now your \PDF\ viewer shows the pages in
1009 % the \textit{same} orientation as in Figure~\ref{fig:layout}.
1010 % And the options |delta| and |offset| have
1011 % the \textit{same} meaning as in Figure~\ref{fig:layout}.
1012 % Regardless of any other options.
1013 %
1014 %
1015 % \subsection{Booklets}
1016 % \label{sec:booklets}
1017 %
1018 % There are some important points that have a significant impact on the
1019 % layout of a booklet:
1020 %
1021 % \begin{itemize}
1022 % \item Option |landscape| of the document class.
1023 % \item Option |landscape| of the |\includepdf| command.
1024 % \item Paper format of the included PDF.
1025 % \item Option |nup|\footnote{Up to version 0.6c the |booklet| option was
1026 % overriding any |nup| setting of the user. But this is no longer the
1027 % case. Now the user has to choose a correct |nup| setting.} of the
1028 % |\includepdf| command.
1029 % \item Option |flip-other-edge| of the |\includepdf| command.
1030 % \end{itemize}
1031 %
1032 % Changing the paper orientation to landscape can be done either by
1033 % using |landscape| as an option of the document class,
1034 % i.e. |\documentclass[landscape,...]{...}|, or as an option of the
1035 % |\includepdf| command, i.e |\includepdf[landscape,...]{...}|.
1036 % But it should not be used for both at the same time.
1037 %
1038 % For duplex printing there are two ways of flipping a sheet of
1039 % paper. Either on the long edge or on the short edge. But note that
1040 % the layouts are different depending on the flip edge.
1041 %
1042 % Thus, you have to tell you printer in the printer settings which
1043 % flip edge you prefer. And you have to generate the corresponding
1044 % layout with |\includepdf|, which provides the option |flip-other-edge|
1045 % to swap the flip edge.
1046 %
1047 % Here are some examples in which the flip edge is marked by a red
1048 % zigzag line.
1049 %
1050 % \newif\ifpflip
1051 % \newif\ifplandscape
1052 % \tikzset{
1053 % wd/.initial = 20mm, wd/.get = \pw, wd/.store in = \pw,
1054 % ht/.initial = 14mm, ht/.get = \ph, ht/.store in = \ph,
1055 % flip/.is if = pflip,
1056 % lscape/.is if = plandscape,
1057 % pics/page/.code = {%
1058 % \def\hh{\dimexpr \ph/2 \relax}
1059 % \def\hw{\dimexpr \pw/2 \relax}
1060 % \coordinate (TL) at (-\hw, \hh);^^A top left
1061 % \coordinate (CL) at (-\hw, 0); ^^A center left
1062 % \coordinate (BL) at (-\hw, -\hh); ^^A bottom left
1063 % \coordinate (BC) at (0, -\hh); ^^A bottom center
1064 % \def\lskip{2pt}
1065 % \def\flipedge{\draw [color=red, decorate, decoration=saw, double]}
1066 % \draw (BL) rectangle ++(\pw, \ph);
1067 % \ifplandscape
1068 % ^^A landscape page
1069 % \draw (CL) -- ++(\pw, 0);
1070 % \foreach \i in {0,...,20}{%
1071 % \def\ycur{\dimexpr \hh*3/18 + \lskip*\i \relax}
1072 % \def\ymax{\dimexpr \hh*7/9 \relax}
1073 % \draw [color=gray] (CL)++(1/9*\pw, \ycur) -- ++(7/9*\pw, 0);
1074 % \draw [color=gray] (CL)++(1/9*\pw, -\ycur) -- ++(7/9*\pw, 0);
1075 % \ifdim \ycur > \dimexpr \ymax - \lskip \relax
1076 % \breakforeach
1077 % \fi
1078 % }%
1079 % \ifpflip
1080 % \flipedge (BL)++(-3pt, 0) -- ++(0, \ph);
1081 % \else
1082 % \flipedge (TL)++(0, 3pt) -- ++(\pw, 0);
1083 % \fi
1084 % \else
1085 % ^^A portrait page
1086 % \draw (BC) -- ++(0, \ph);
1087 % \foreach \i in {0,...,20}{%
1088 % \def\ycur{\dimexpr \hh - \ph*1/9 - \lskip*\i \relax}
1089 % \def\ymin{\dimexpr -\hh + \ph*3/18 \relax}
1090 % \draw [color=gray] (-7/9*\hw, \ycur) -- ++(6/9*\hw, 0);
1091 % \draw [color=gray] (1/9*\hw, \ycur) -- ++(6/9*\hw, 0);
1092 % \ifdim \ycur < \dimexpr \ymin + \lskip \relax
1093 % \breakforeach
1094 % \fi
1095 % }%
1096 % \ifpflip
1097 % \flipedge (TL) ++(0, 3pt) -- ++(\pw, 0);
1098 % \else
1099 % \flipedge (BL)++(-3pt, 0) -- ++(0, \ph);
1100 % \fi
1101 % \fi
1102 % }}
1103 %
1104 % \def\lpage#1{\tikz\pic[wd=20mm, ht=14mm, #1]{page};}
1105 % \def\ppage#1{\tikz\pic[wd=14mm, ht=20mm, #1]{page};}
1106 % \def\cvert#1{\multicolumn{1}{c}{\adjustbox{valign=c}{#1}}}
1107 %
1108 % \medskip
1109 % • Flip edge paralell to binding edge:
1110 %
1111 % \begin{small}
1112 % \begin{tabularx}{\linewidth}{X@{\qquad\qquad}X}
1113 % \cvert{\lpage{}} & \cvert{\ppage{lscape}} \\
1114 % |\documentclass[landscape]{article}| & |\documentclass{article}| \\
1115 % |...| & |...| \\
1116 % |\includepdf[| & |\includepdf[| \\
1117 % | pages=-,| & | pages=-,| \\
1118 % | booklet, nup=2x1,| & | booklet, nup=1x2| \\
1119 % |]{...}| & |]{...}| \\
1120 % \end{tabularx}
1121 % \end{small}\medskip
1122 %
1123 % \medskip
1124 % • Flip edge perpendicular to binding edge:
1125 %
1126 % \begin{small}
1127 % \begin{tabularx}{\linewidth}{X@{\qquad\qquad}X}
1128 % \cvert{\lpage{flip}} & \cvert{\ppage{lscape, flip}} \\
1129 % |\documentclass[landscape]{article}| & |\documentclass{article}| \\
1130 % |...| & |...| \\
1131 % |\includepdf[| & |\includepdf[| \\
1132 % | pages=-,| & | pages=-,| \\
1133 % | booklet, nup=2x1,| & | booklet, nup=1x2| \\
1134 % | flip-other-edge| & | flip-other-edge| \\
1135 % |]{...}| & |]{...}| \\
1136 % \end{tabularx}
1137 % \end{small}
1138 %
1139 % \medskip Very slim paper formats require a slightly different layout
1140 % like in the following example. Note the difference in using |landscape|
1141 % compared to the examples above.
1142 %
1143 % \begin{small}
1144 % \begin{tabularx}{\linewidth}{X@{\qquad\qquad}X}
1145 % \cvert{\ppage{}} & \cvert{\lpage{lscape}} \\
1146 % |\documentclass{article}| & |\documentclass[landscape]{article}| \\
1147 % |...| & |...| \\
1148 % |\includepdf[| & |\includepdf[| \\
1149 % | pages=-,| & | pages=-,| \\
1150 % | booklet, nup=2x1,| & | booklet, nup=1x2| \\
1151 % |]{...}| & |]{...}| \\
1152 % \end{tabularx}
1153 % \end{small}
1154 %
1155 %
1156 % \subsection{Hints for Users of platex}
1157 % \begin{itemize}
1158 % \item
1159 % The recommended way to tell |pdfpages| that you are using |platex| is to
1160 % add |dvipdfmx| as a class option, e.g.:
1161 %
1162 % \begin{quote}
1163 % |\documentclass[dvipdfmx]{article}| \\
1164 % |\usepackage{pdfpages}|
1165 % \end{quote}
1166 %
1167 % \item Pdfpages calls program |extractbb| to get the total number of
1168 % pages of a PDF. But if an |xbb| file (output of |extractbb|) exists,
1169 % pdfpages will not call |extractbb| but use this file. However, be
1170 % very cautious with |xbb| files: \emph{Do not use |xbb| files for PDFs
1171 % with varying page sizes.} Because an |xbb| file contains only the page
1172 % size of a single page.
1173 % \end{itemize}
1174 %
1175 %
1176 % \subsection{Pitfalls}
1177 %
1178 % \begin{description}
1179 % \item[pagecolor]
1180 % When setting the background color with |\pagecolor|
1181 % (a command from \textit{color.sty}), the first
1182 % |\pagecolor| \emph{must} precede |\usepackage{pdfpages}|.
1183 % \begin{quote}
1184 % |\usepackage{color}|\\
1185 % |\pagecolor{white}|\\
1186 % |\usepackage{pdfpages}|
1187 % \end{quote}
1188 % The color is nonrelevant, it can be changed afterwards
1189 % by using |\pagecolor| again. Just the order (first
1190 % |\pagecolor| before |\usepackage{pdfpages}|) is
1191 % important. -- This is not needed when using \VTeX.
1192 % \end{description}
1193 %
1194 %
1195 % \section{Required Packages}
1196 %
1197 % The |pdfpages| package requires the following packages:
1198 %
1199 % \begin{description}
1200 % \item[eso-pic]
1201 % \texttt{CTAN:macros/latex/contrib/eso-pic/}
1202 % \item[atbegshi]
1203 % \texttt{CTAN:macros/latex/contrib/oberdiek/}
1204 % \item[pdflscape]
1205 % \texttt{CTAN:macros/latex/contrib/oberdiek/}
1206 % \item[graphicx, ifthen, calc]
1207 % These packages belong to the standard \LaTeX\
1208 % distribution.
1209 % \end{description}
1210 %
1211 % \noindent
1212 % Furthermore it requires a recent version of:
1213 % \begin{description}
1214 % \item[pdftex.def]
1215 % \texttt{ http://www.tug.org/applications/pdftex/}
1216 % \end{description}
1217 %
1218 % \noindent
1219 % Since pdf\TeX, Version 3.14159-1.00a-pretest-20010806,
1220 % \PDF\ import has improved a lot. This
1221 % results in much smaller file sizes, faster processing and the
1222 % intuitively correct treatment of landscape pages.
1223 % The latest version of pdf\TeX\ can be found at:
1224 % \texttt{ftp://ftp.muni.cz/pub/tex/local/cstug/thanh/pdftex}.
1225 %
1226 %
1227 %
1228 % \section{Acknowledgment}
1229 % I would like to thank \textsc{Rolf Niepraschk} and
1230 % \textsc{Heiko Oberdiek} for their useful
1231 % hints and suggestions. As well as \textsc{Ross Moore},
1232 % who encouraged me to implement the hypertext features.
1233 %
1234 %
1235 % \StopEventually{
1236 % \begin{thebibliography}{9}
1237 %
1238 % \bibitem{pdftex}
1239 % H\`an Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh,
1240 % Sebastian Rahtz, Hans Hagen,
1241 % \textit{The \pdfTeX\ user manual},
1242 % \url{http://www.tug.org/applications/pdftex}
1243 %
1244 % \bibitem{PDFRef}
1245 % \textit{PDF Reference}, Adobe Systems Incorporated,\\
1246 % \url{http://www.adobe.com/devnet/pdf/pdf_reference.html}
1247 %
1248 % \bibitem{pax}
1249 % Heiko Oberdiek,
1250 % \textit{pax: Extract and reinsert PDF annotations with pdfTeX}
1251 % \url{http://www.ctan.org/pkg/pax}
1252 %
1253 % \end{thebibliography}
1254 % }
1255 %
1256 %
1257 % \iffalse
1258 %<*package>
1259 % \fi
1260 % \section{Implementation}
1261 %
1262 % \subsection{Package Options}
1263 % \begin{macrocode}
1264 \newif\ifAM@pkg@draft \AM@pkg@draftfalse
1265 \DeclareOption{draft}{\AM@pkg@drafttrue}
1266 \DeclareOption{final}{\AM@pkg@draftfalse}
1267 \newif\ifAM@pkg@survey \AM@pkg@surveyfalse
1268 \DeclareOption{enable-survey}{\AM@pkg@surveytrue}
1269 \DeclareOption{disable-survey}{\AM@pkg@surveyfalse}
1270 \newif\ifAM@pkg@demo \AM@pkg@demofalse
1271 \DeclareOption{demo}{\AM@pkg@demotrue}
1272 \DeclareOption{nodemo}{\AM@pkg@demofalse}
1273 % \end{macrocode}
1274 % |\AM@ifdriverlater| checks that the driver loaded is more recent
1275 % than the given date. See |\@ifpackagelater| from the standard
1276 % \LaTeX\ kernel.
1277 % \begin{macrocode}
1278 \def\AM@ifdriverlater{\@ifl@ter{def}}
1279 % \end{macrocode}
1280 % The configuration file |pdfpages.cfg| can be used to make
1281 % new driver files known to the package.
1282 % \begin{macrocode}
1283 \InputIfFileExists{pdfpages.cfg}{%
1284 \PackageInfo{pdfpages}{Loading configuration file `pdfpages.cfg'}}{}
1285 % \end{macrocode}
1286 % These options overrule the automatic detection of the \TeX-engine.
1287 % \begin{macrocode}
1288 \DeclareOption{pdftex}{\def\AM@driver{pdftex}}
1289 \DeclareOption{luatex}{\def\AM@driver{luatex}}
1290 \DeclareOption{vtex}{\def\AM@driver{vtex}}
1291 \DeclareOption{xetex}{\def\AM@driver{xetex}}
1292 \DeclareOption{dvips}{\def\AM@driver{dvips}}
1293 \DeclareOption{dvipdfmx}{\def\AM@driver{dvipdfmx}}
1294 \DeclareOption{null}{\def\AM@driver{null}}
1295 % \end{macrocode}
1296 % \begin{macrocode}
1297 \ProcessOptions
1298 % \end{macrocode}
1299 % \subsection{Detection of TeX-Engine}
1300 %
1301 % Automatic detection of \TeX-engine: \pdfTeX, \VTeX\ or \XeTeX.
1302 % This detection is omitted if |\AM@driver| is already defined. This
1303 % happens if the driver was given as a package option or if
1304 % the driver was identified in the configuration files |pdfpages.cfg|
1305 %
1306 % \begin{macrocode}
1307 \ifAM@pkg@demo
1308 \def\AM@driver{null}
1309 \fi
1310 \@ifundefined{AM@driver}{
1311 \begingroup
1312 \@ifundefined{luatexversion}{%
1313 \@ifundefined{pdftexversion}{%
1314 \@ifundefined{XeTeXversion}{%
1315 \@ifundefined{OpMode}{%
1316 \gdef\AM@driver{null}
1317 }{\gedf\AM@driver{vtex}}%
1318 }{\gdef\AM@driver{xetex}}%
1319 }{\gdef\AM@driver{pdftex}}%
1320 }{\gdef\AM@driver{luatex}}%
1321 \endgroup
1322 }{}
1323 % \end{macrocode}
1324 % \subsection{Required Packages and Version Checking}
1325 %
1326 % \begin{macrocode}
1327 \RequirePackage{ifthen, calc, eso-pic, etoolbox}
1328 %\@ifundefined{kansuji}{%
1329 \RequirePackage{graphicx}%
1330 %}{%
1331 % \RequirePackage[dvipdfmx]{graphicx}%
1332 %}
1333 \newif\ifAM@DVIoutput\AM@DVIoutputfalse
1334 \newdimen\AM@pagewidth
1335 \newdimen\AM@pageheight
1336 \newdimen\AM@fboxrule
1337 \input{pp\[email protected]}
1338 \ifx\AM@endinput\relax\expandafter\endinput\fi
1339 \ifAM@pkg@survey
1340 \let\AM@setanchor\AM@anchor@special
1341 \RequirePackage{count1to}%
1342 \AddToShipoutPicture{\AM@setanchor}%
1343 \fi
1344 % \end{macrocode}
1345 % We use |\PLS@Rotate| from |pdflscape| to ratate pages. But simply
1346 % loading |pdflscape| modifies the |landscape| environment such that
1347 % \emph{all} landscape pages are rotated by default which is undesired.
1348 % To prevent this we postpone the loading of the package.
1349 %
1350 % If the user loads |pdflscape| explicitely she gets the rotated
1351 % landscape environment and the packages will not be reloaded by the next
1352 % commands. However, if |pdflscape| is not loaded by the user, then we
1353 % load it and reset the |landscape| environment afterwards.
1354 % \begin{macrocode}
1355 \AtBeginDocument{%
1356 \let\AM@orig@landscape\landscape
1357 \let\AM@orig@endlandscape\endlandscape
1358 \RequirePackage{pdflscape}%
1359 \let\landscape\AM@orig@landscape
1360 \let\endlandscape\AM@orig@endlandscape
1361 }
1362 % \end{macrocode}
1363 % Let's save the original meaning of |\includegraphics|, because
1364 % graphicx.sty in demo mode (`demo' option) will overwrite the definition of
1365 % |\includegraphics| \emph{after} |\begin{document}|.
1366 % \begin{macrocode}
1367 \let\AM@Ginclude@graphics\Ginclude@graphics
1368 % \end{macrocode}
1369 % Checking for new versions of \texttt{eso-pic.sty}.
1370 % \begin{macrocode}
1371 \@ifpackagelater{eso-pic}{2001/07/20}
1372 {\def\AM@AddToShipoutPicture{\AddToShipoutPicture*}%
1373 \def\AM@ClearShipoutPicture{\relax}}
1374 {\def\AM@AddToShipoutPicture{\AddToShipoutPicture}%
1375 \def\AM@ClearShipoutPicture{\ClearShipoutPicture}}
1376 \let\Orig@AM@AddToShipoutPicture\AM@AddToShipoutPicture
1377 % \end{macrocode}
1378 % \subsection{Booleans}
1379 % \begin{macrocode}
1380 \newif\ifAM@openright\AM@openrightfalse
1381 \newif\ifAM@openrighteach\AM@openrighteachfalse
1382 \newif\ifAM@frame\AM@framefalse
1383 \newif\ifAM@landscape\AM@landscapefalse
1384 \newif\ifAM@turn\AM@turntrue
1385 \newif\ifAM@thread\AM@threadfalse
1386 \newif\ifAM@link\AM@linkfalse
1387 \newif\ifAM@linktodoc\AM@linktodocfalse
1388 \newif\ifAM@survey\AM@surveyfalse
1389 \newif\ifAM@surveynolink\AM@surveynolinkfalse
1390 \newif\ifAM@output\AM@outputtrue
1391 \newif\ifAM@column\AM@columnfalse
1392 \newif\ifAM@columnstrict\AM@columnstrictfalse
1393 \newif\ifAM@noautoscale\AM@noautoscalefalse
1394 \newif\ifAM@fitpaper\AM@fitpaperfalse
1395 \newif\ifAM@doublepages\AM@doublepagesfalse
1396 \newif\ifAM@doublepagestwist\AM@doublepagestwistfalse
1397 \newif\ifAM@doublepagestwistx\AM@doublepagestwistxfalse
1398 \newif\ifAM@doublepagestmp\AM@doublepagestmpfalse
1399 \newif\ifAM@doublepagestmpi\AM@doublepagestmpifalse
1400 \newif\ifAM@duplicatepages\AM@duplicatepagesfalse
1401 \newif\ifAM@linkfilename\AM@linkfilenamefalse
1402 \newif\ifAM@signature\AM@signaturefalse
1403 \newif\ifAM@signaturestar\AM@signaturestarfalse
1404 \newif\ifAM@booklet\AM@bookletfalse
1405 \newif\ifAM@swap@flip@edge\AM@swap@flip@edgefalse
1406 \newif\ifAM@upsidedown\AM@upsidedownfalse
1407 \newif\ifAM@newwindow\AM@newwindowtrue
1408 \newif\ifAM@rescale\AM@rescalefalse
1409 \newif\ifAM@rotateoversize\AM@rotateoversizefalse
1410 \newif\ifAM@firstpage\AM@firstpagefalse
1411 \newif\ifAM@reflect\AM@reflectfalse
1412 \newif\ifAM@reflectall\AM@reflectallfalse
1413 \newif\ifAM@scale\AM@scaletrue
1414 \newif\ifAM@newpage\AM@newpagefalse
1415 \newif\ifAM@pagecount@updated
1416 \newif\ifAM@artifact
1417 % \end{macrocode}
1418 % Check, if memoir is loaded.
1419 % \begin{macrocode}
1420 \newif\ifAM@memoir\AM@memoirfalse
1421 \@ifclassloaded{memoir}{\AM@memoirtrue}{}
1422 % \end{macrocode}
1423 % Pdfpages calls |\includegraphics| several times to retrieve necessary
1424 % information like width, height, or number of pages without actually
1425 % typesetting the image. Just the final call to |\includegraphics| will
1426 % eventually typeset the image. Packages which hook into
1427 % |\includegraphics| and whish to check whether or not this is the final
1428 % call to |\includegraphics| can do so by using the counter
1429 % |\pdfpages@includegraphics@status|:
1430 % \begin{quotation}
1431 % \begin{tabular}{@{}cl@{}}
1432 % \toprule
1433 % Status & Use of |\includegraphics| ...\\
1434 % \midrule
1435 % 0 & outside of pdfpages\\
1436 % 1 & inside of pdfpages: final call\\
1437 % 2 & inside of pdfpages: non-final call, for internal use\\
1438 % \bottomrule
1439 % \end{tabular}
1440 % \end{quotation}
1441 % \begin{macrocode}
1442 \newcount\pdfpages@includegraphics@status
1443 \pdfpages@includegraphics@status\z@
1444 % \end{macrocode}
1445 % \subsection{Commands}
1446 % Declare macro names and define default values.
1447 % \begin{macrocode}
1448 \newcommand*{\AM@pagestemp}{1}
1449 \newcommand*{\AM@pagecommand}{\thispagestyle{empty}}
1450 \newcommand*{\AM@pagecommandstar}{}
1451 \newcommand*{\AM@lscape@rot}{0}
1452 \newcommand*{\AM@threadname}{}\newcommand*{\AM@linkname}{}
1453 \newcommand*{\AM@linkname@option}{}
1454 \newcommand*{\AM@linktodocfit}{/Fit}
1455 \newcommand*{\threadinfodict}{}
1456 \newcommand*{\AM@toclist}{}\newcommand*{\AM@loflist}{}
1457 \newcommand*{\AM@altlist}{}
1458 \newcommand*{\AM@signature}{}
1459 \newcommand*{\AM@ARBug@hook}{}
1460 \newcommand*{\AM@xrprefix}{}
1461 \newcommand*{\AM@picturecommand}{}
1462 \newcommand*{\AM@picturecommandstar}{}
1463 \newsavebox{\AM@pagebox}
1464 % \end{macrocode}
1465 % \macro{\AM@checkinteger}
1466 % Check, if |#1| is a positive integer.
1467 % (Note: |\AM@checkinteger| was not reliable in older versions (<0.5n) of
1468 % this package. Let's use the definition from \emph{biblatex.sty} which seems
1469 % to be much better.)
1470 % \begin{macrocode}
1471 \newif\ifAM@integer
1472 \def\AM@checkinteger#1{%
1473 \expandafter\AM@checkinteger@\expandafter{#1}}
1474 % \end{macrocode}
1475 % \begin{macrocode}
1476 \def\AM@checkinteger@#1{%
1477 \begingroup
1478 \def\do##1{\uccode`##1=`\%}%
1479 \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
1480 \makeatletter
1481 \catcode`\%=9
1482 \endlinechar\m@ne
1483 \uppercase{\scantokens{\def\AM@temp{#1}}}%
1484 \ifx\AM@temp\@empty
1485 \global\AM@integertrue
1486 \else
1487 \global\AM@integerfalse
1488 \fi
1489 \endgroup}
1490 % \end{macrocode}
1491 % \macro{\AM@findfile}
1492 % Find file and set |\AM@currentdocname|.
1493 % \begin{macrocode}
1494 \newcommand*{\AM@findfile@i}[2]{%
1495 \ifAM@pkg@demo
1496 \else
1497 \let\Ginclude@graphics\AM@Ginclude@graphics
1498 \fi
1499 \let\AM@currentdocname\relax
1500 \AM@IfFileExists{#1.#2}{\edef\AM@currentdocname{#1.#2}}{%
1501 \AM@IfFileExists{#1}{\edef\AM@currentdocname{#1}}{%
1502 \ifx\Ginput@path\@undefined\else
1503 \expandafter\@tfor\expandafter\AM@dir\expandafter
1504 :\expandafter=\Ginput@path\do{%
1505 \AM@IfFileExists{\AM@dir#1.#2}{%
1506 \ifx\AM@currentdocname\relax
1507 \edef\AM@currentdocname{\AM@dir#1.#2}%
1508 \fi
1509 }{%
1510 \AM@IfFileExists{\AM@dir#1}{%
1511 \ifx\AM@currentdocname\relax
1512 \edef\AM@currentdocname{\AM@dir#1}%
1513 \fi
1514 }{}%
1515 }%
1516 }% \@tfor
1517 \fi
1518 }%
1519 }%
1520 }
1521 \newcommand*{\AM@findfile@ii}[1]{%
1522 \ifx\AM@currentdocname\relax
1523 \PackageError{pdfpages}{Cannot find file `#1'}{}%
1524 \let\AM@filenotfound\relax
1525 \fi
1526 }
1527 % \end{macrocode}
1528 % The options |width| and |height| (of graphics.sty) have no reasonable
1529 % meaning for |\includepdf|. Quit the contrary they spoil the calculation
1530 % of the scaling factors and therefore should not be used with pdfpages.
1531 %
1532 % Nevertheless these options are very usefull for |\includegraphics| and
1533 % some users even set these options globally:
1534 %
1535 % \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
1536 %
1537 % In this way these options have an undesirable impact on pdfpages as
1538 % well since pdfpages forwards these options to graphics. Therefore we
1539 % kind of disable these settings by inserting |width=!,height=!| into
1540 % |\AM@global@opts| which itself gets finally inserted into the option
1541 % list of each |\includegraphics| call.
1542 %
1543 % \begin{macrocode}
1544 \newtoks\AM@global@opts
1545 \newcommand*{\AM@disable@width@height}{width=!,height=!}
1546 \AM@global@opts\expandafter{\AM@disable@width@height}
1547 % \end{macrocode}
1548 % \macro{\includepdfset}
1549 % This command sets global options for |\includepdf|
1550 % and |\includepdfmerge|.
1551 % \begin{macrocode}
1552 \newcommand*{\includepdfset}[1]{%
1553 \AM@global@opts\expandafter{\AM@disable@width@height,#1}%
1554 }
1555 % \end{macrocode}
1556 % \macro{\includepdf}
1557 % This command inserts any pages of an external
1558 % \PDF\ document.
1559 % \begin{macrocode}
1560 \newcommand*{\includepdf}[2][]{%
1561 \begingroup
1562 \global\pdfpages@includegraphics@status\tw@
1563 \@ifundefined{@setmarks}{\let\@setmarks\relax}{}
1564 \AM@pagecnt\@ne
1565 \AM@reset@view
1566 \let\AM@threadname\relax
1567 \def\AM@tmp{pdfpages}
1568 \let\PageNum\relax
1569 \let\FileName\relax
1570 \let\Artifact\relax
1571 \expandafter\AM@split@options
1572 \expandafter\AM@tmp
1573 \expandafter{\the\AM@global@opts,#1}%
1574 \edef\AM@temp{{pdfpages}{\the\@temptokena}}%
1575 \expandafter\setkeys\AM@temp
1576 % \end{macrocode}
1577 % \begin{macrocode}
1578 \ifthenelse{\boolean{AM@pkg@draft} \and \boolean{AM@survey}}{%
1579 \let\AM@currentdocname\relax
1580 \renewcommand\includegraphics[2][]{Survey in draft-mode}%
1581 \def\AM@pagecount{0}%
1582 }{%
1583 \AM@findfile{#2}%
1584 \ifx\AM@threadname\relax
1585 \def\AM@threadname{\AM@currentdocname}%
1586 \fi
1587 }%
1588 % \end{macrocode}
1589 % Gather all pdfpages' labels form the |aux| file and store
1590 % the page numbers in |\AM@pagestemp|. If there are no labels
1591 % reset |\AM@pagestemp|.
1592 % \begin{macrocode}
1593 \ifAM@survey
1594 \def\AM@pagestemp{}%
1595 \@tempcnta=0
1596 \def\foo{%
1597 \@ifundefined{r@\AM@xrprefix pdfpages@page\the\@tempcnta}%
1598 {\let\foo\relax}
1599 {\expandafter\ifx\expandafter\\\AM@pagestemp\\
1600 \edef\AM@pagestemp{%
1601 \AM@pageref{\AM@xrprefix pdfpages@page\the\@tempcnta}}%
1602 \else
1603 \edef\AM@pagestemp{\AM@pagestemp,%
1604 \AM@pageref{\AM@xrprefix pdfpages@page\the\@tempcnta}}%
1605 \fi
1606 \advance\@tempcnta 1\relax
1607 }%
1608 \foo
1609 }%
1610 \foo
1611 \expandafter\ifx\expandafter\\\AM@pagestemp\\
1612 \def\AM@pagestemp{1}%
1613 \fi
1614 \fi
1615 % \end{macrocode}
1616 % \begin{macrocode}
1617 \ifAM@output
1618 \AM@SuspendTagging
1619 \expandafter\AM@readlist\expandafter{\AM@pagestemp}%
1620 \expandafter\AM@output\expandafter{\the\AM@global@opts,#1}%
1621 \AM@ResumeTagging
1622 \fi
1623 % \end{macrocode}
1624 % \begin{macrocode}
1625 \AM@CheckAtEnd
1626 \endgroup
1627 \AM@ClearShipoutPicture
1628 \global\pdfpages@includegraphics@status\z@
1629 }
1630 % \end{macrocode}
1631 % \macro{\includepdfmerge}
1632 % This command merges pages of several \PDF\ documents.
1633 % \begin{macrocode}
1634 \newcommand*{\includepdfmerge}[2][]{%
1635 \begingroup
1636 \global\pdfpages@includegraphics@status\tw@
1637 \AM@pagecnt\@ne
1638 \AM@reset@view
1639 \let\AM@threadname\relax
1640 \let\AM@currentdocname\relax
1641 \def\AM@tmp{pdfpages}
1642 \let\PageNum\relax
1643 \let\FileName\relax
1644 \let\Artifact\relax
1645 \expandafter\AM@split@options
1646 \expandafter\AM@tmp
1647 \expandafter{\the\AM@global@opts,#1}%
1648 \edef\AM@temp{{pdfpages}{\the\@temptokena}}%
1649 \expandafter\setkeys\AM@temp
1650 \AM@SuspendTagging
1651 \AM@readlist{#2}%
1652 \expandafter\AM@output\expandafter{\the\AM@global@opts,#1}%
1653 \AM@ResumeTagging
1654 \AM@CheckAtEnd
1655 \endgroup
1656 \AM@ClearShipoutPicture
1657 \global\pdfpages@includegraphics@status\z@
1658 }
1659 % \end{macrocode}
1660 % \macro{\AM@CheckAtEnd}
1661 % Some simple checks.
1662 % \begin{macrocode}
1663 \newcommand{\AM@CheckAtEnd}{%
1664 \ifx\@empty\AM@toclist\else
1665 \PackageWarning{pdfpages}{%
1666 There's something wrong with the entries\MessageBreak
1667 of `addtotoc'. Not all entries were\MessageBreak
1668 processed. Check `addtotoc'}%
1669 \fi
1670 \ifx\@empty\AM@loflist\else
1671 \PackageWarning{pdfpages}{%
1672 There's something wrong with the entries\MessageBreak
1673 of `addtolist'. Not all entries were\MessageBreak
1674 processed. Check `addtolist'}%
1675 \fi
1676 \ifx\@empty\AM@altlist\else
1677 \PackageWarning{pdfpages}{%
1678 There's something wrong with the entries\MessageBreak
1679 of option `alt*'. Not all entries were\MessageBreak
1680 processed. Check `alt*'}%
1681 \fi
1682 }
1683 % \end{macrocode}
1684 % Use some macros from |tagpdf.sty| if is is loaded.
1685 % \begin{macrocode}
1686 \def\AM@SuspendTagging{%
1687 \ifdefined\SuspendTagging
1688 \par
1689 \SuspendTagging{pdfpages}%
1690 \fi}
1691 \def\AM@ResumeTagging{%
1692 \ifdefined\ResumeTagging
1693 \ResumeTagging{pdfpages}%
1694 \fi}
1695 % \end{macrocode}
1696 % \macro{\AM@output}
1697 % This is the main output routine used by |\includepdf|
1698 % and |\includepdfmerge|.
1699 % Let's stop here if the PDF file doesn't exist and the user did not quit
1700 % \LaTeX\ yet (which may result from `--interaction=scrollmode`).
1701 % If we do not quit here, we might run into an infinite loop.
1702 % \begin{macrocode}
1703 \newcommand\AM@output{%
1704 \ifdefined\AM@filenotfound
1705 \else
1706 \expandafter\AM@output@i
1707 \fi
1708 }
1709 \newcommand{\AM@output@i}[1]{%
1710 % \end{macrocode}
1711 % For the following calculations we need to know the page size.
1712 % But since we are still before |\newpage| we must not set |\paper{width,height}|
1713 % and must not call |\AM@setpagedimen| now. This shall be done after |\newpage|.
1714 % However, to get the calculation right we set and use |\AM@page{width,height}|,
1715 % which will eventually (after the next |\newpage|) become the real page size.
1716 % \begin{macrocode}
1717 \AM@getpagedimen
1718 \ifdim\AM@pagewidth=\z@
1719 \AM@pagewidth=210mm
1720 \PackageWarningNoLine{pdfpages}{%
1721 Erroneous page width of 0.0pt is corrected}%
1722 \fi
1723 \ifdim\AM@pageheight=\z@
1724 \AM@pageheight=297mm
1725 \PackageWarningNoLine{pdfpages}{%
1726 Erroneous page height of 0.0pt is corrected}%
1727 \fi
1728 % \end{macrocode}
1729 % Floats are unwanted here. Thus defer all floats until after |\includepdf|.
1730 % \par
1731 % 1) Floats which are already in \LaTeX's output routine shall be removed from
1732 % there and pushed onto |\@deferlist| or |\@dbldeferlist|.
1733 % \begin{macrocode}
1734 \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
1735 \gdef\@toplist{}%
1736 \gdef\@botlist{}%
1737 \xdef\@dbldeferlist{\@dbltoplist\@dbldeferlist}%
1738 \gdef\@dbltoplist{}%
1739 % \end{macrocode}
1740 % 2) Clear |\@deferlist| and |\@dbldeferlist|. But save them first
1741 % so they can be restored later.
1742 % \begin{macrocode}
1743 \global\let\AM@deferlist\@deferlist
1744 \gdef\@deferlist{}%
1745 \global\let\AM@dbldeferlist\@dbldeferlist
1746 \gdef\@dbldeferlist{}%
1747 % \end{macrocode}
1748 % Some drivers, like |ppnull|, need a hook to disable
1749 % |\includegraphics|.
1750 % \begin{macrocode}
1751 \AM@disable@includegraphics
1752 % \end{macrocode}
1753 % Some macros may already be initialized by |\includepdfset|.
1754 % So do not reset them here.
1755 % \begin{macrocode}
1756 \@ifundefined{AM@xnup}
1757 {\def\AM@xnup{\@ne}\def\AM@ynup{\@ne}%
1758 \def\AM@xnupminusi{\z@}\def\AM@ynupminusi{\z@}}{}%
1759 \@ifundefined{AM@deltax}
1760 {\def\AM@deltax{-\AM@fboxrule}\def\AM@deltay{-\AM@fboxrule}}{}%
1761 \@ifundefined{AM@xoffset}
1762 {\def\AM@xoffset{\z@}\def\AM@yoffset{\z@}}{}%
1763 \def\AM@xpos{\z@}\def\AM@ypos{\z@}%
1764 % \end{macrocode}
1765 % Read in optional parameters.
1766 % \begin{macrocode}
1767 \ifAM@pkg@draft \setkeys{Gin}{draft=true}%
1768 \else \setkeys{Gin}{draft=false}%
1769 \fi
1770 % \end{macrocode}
1771 % \begin{macrocode}
1772 \ifAM@landscape
1773 \def\AM@lscape@rot{90}%
1774 \let\AM@temp\AM@xnup
1775 \let\AM@xnup\AM@ynup
1776 \let\AM@ynup\AM@temp
1777 \fi
1778 \AM@setphantom
1779 \ifthenelse{\boolean{AM@openright}\and\not\boolean{AM@openrighteach}}
1780 {\AM@openright}{}%
1781 \ifx\AM@signature\@empty\AM@filluppagelist
1782 \else\AM@prepare@signature\AM@signaturetrue\fi
1783 % \end{macrocode}
1784 % \begin{macrocode}
1785 \@tempcnta=\AM@xnup\relax \advance\@tempcnta\m@ne
1786 \edef\AM@xnupminusi{\the\@tempcnta}%
1787 \@tempcnta=\AM@ynup\relax \advance\@tempcnta\m@ne
1788 \edef\AM@ynupminusi{\the\@tempcnta}%
1789 % \end{macrocode}
1790 % \begin{macrocode}
1791 \ifthenelse{\boolean{AM@column}%
1792 \and\not\boolean{AM@columnstrict}}
1793 {\AM@getlastn{\AM@doclist}{\AM@nup}%
1794 \edef\AM@lastndocs{\AM@lastnitems}%
1795 \AM@getlastn{\AM@pagelist}{\AM@nup}%
1796 \edef\AM@lastnpages{\AM@lastnitems}%
1797 \AM@resort
1798 \AM@count{\AM@pagelist}%
1799 \expandafter\ifx\expandafter\\\AM@pagelist\\%
1800 \edef\AM@pagelist{\AM@resortedpagelist}%
1801 \edef\AM@doclist{\AM@resorteddoclist}%
1802 \else
1803 \edef\AM@pagelist{\AM@pagelist,\AM@resortedpagelist}%
1804 \edef\AM@doclist{\AM@doclist,\AM@resorteddoclist}%
1805 \fi}{}%
1806 % \end{macrocode}
1807 % \begin{macrocode}
1808 \ifthenelse{\boolean{AM@frame}}%
1809 {\global\let\AM@fbox\fbox
1810 \setlength\AM@fboxrule{\fboxrule}}%
1811 {\global\let\AM@fbox\relax
1812 \setlength\AM@fboxrule{\z@}}%
1813 \ifthenelse{\boolean{AM@reflect}}%
1814 {\global\let\AM@reflectbox\reflectbox}%
1815 {\global\let\AM@reflectbox\relax}%
1816 \setbox\AM@pagebox\null
1817 % \end{macrocode}
1818 % \begin{macrocode}
1819 \ifthenelse{\boolean{AM@column}}
1820 {\def\AM@xnupi{\@ne}%
1821 \def\AM@ynupi{\z@}}
1822 {\def\AM@xnupi{\z@}%
1823 \def\AM@ynupi{\@ne}}%
1824 % \end{macrocode}
1825 % \begin{macrocode}
1826 \AM@firstpagetrue
1827 % \end{macrocode}
1828 % Determine scaling factor:
1829 % The logical pages are scaled such, that they match on
1830 % one sheet of paper.
1831 % \begin{macrocode}
1832 \@ifundefined{AM@pagetemplate}
1833 {\AM@readfirst{\AM@pagelist}%
1834 \edef\AM@nextpage{\the\toks@}}
1835 {\edef\AM@nextpage{\AM@pagetemplate}}%
1836 \AM@readfirst{\AM@doclist}%
1837 \edef\AM@docname{\the\toks@}%
1838 \AM@isphantom
1839 \edef\AM@page{\AM@nextpage}%
1840 \let\PageNum\AM@page
1841 \let\FileName\AM@currentdocname
1842 \ifAM@noautoscale
1843 \def\AM@globalscale{1}%
1844 \else
1845 \AM@split@options{Gin@noscale}{#1}%
1846 \let\AM@filelist@save\@filelist
1847 \ifAM@DVIoutput
1848 \setbox\@tempboxa=\hbox{\rule{597pt}{845pt}}%
1849 \else
1850 \ifAM@templatesize
1851 \setbox\@tempboxa=\hbox{%
1852 \rotatebox{\AM@lscape@rot}{\copy\AM@templatesizebox}}%
1853 \else
1854 \edef\AM@opts{[\AM@disable@width@height,\the\@temptokena,
1855 page=\AM@page, angle=\AM@lscape@rot]}%
1856 \setbox\@tempboxa=\hbox{%
1857 \expandafter\includegraphics\AM@opts{\AM@docname}}%
1858 \fi
1859 \fi
1860 % \end{macrocode}
1861 % Fit papersize.
1862 % \begin{macrocode}
1863 \ifthenelse{\boolean{AM@fitpaper}}{
1864 \setlength{\AM@pagewidth}{\wd\@tempboxa}%
1865 \setlength{\AM@pageheight}{\ht\@tempboxa + \dp\@tempboxa}%
1866 }{}%
1867 % \end{macrocode}
1868 % Calculate required scaling in horizontal direction.
1869 % \begin{macrocode}
1870 \def\AM@xscale{%
1871 (\AM@pagewidth - \tw@\AM@fboxrule*\AM@xnup
1872 - \AM@deltax * \AM@xnupminusi) /
1873 (\AM@xnup * \real{\strip@pt\wd\@tempboxa})
1874 }%
1875 \setlength{\@tempdima}{\AM@xscale}%
1876 \edef\AM@xscale{\strip@pt\@tempdima}%
1877 % \end{macrocode}
1878 % Calculate required scaling in vertical direction.
1879 % \begin{macrocode}
1880 \setlength{\@tempdimb}{\ht\@tempboxa + \dp\@tempboxa}%
1881 \def\AM@yscale{
1882 (\AM@pageheight - \tw@\AM@fboxrule*\AM@ynup
1883 - \AM@deltay *\AM@ynupminusi) /
1884 (\AM@ynup * \real{\strip@pt\@tempdimb})
1885 }%
1886 \setlength{\@tempdima}{\AM@yscale}%
1887 \edef\AM@yscale{\strip@pt\@tempdima}%
1888 % \end{macrocode}
1889 % The lower value of |\AM@xscale| and |\AM@yscale| is used
1890 % as the overall scaling factor |\AM@globalscale|.
1891 % \begin{macrocode}
1892 \@tempdima=\AM@xscale\p@
1893 \@tempdimb=\AM@yscale\p@
1894 \ifdim\@tempdima<\@tempdimb
1895 \let\AM@globalscale\AM@xscale
1896 \else
1897 \let\AM@globalscale\AM@yscale
1898 \fi
1899 \fi
1900 % \end{macrocode}
1901 % Determine horizontal and vertical margins.
1902 % |\AM@xoffset| and |\AM@yoffset| are \textit{not}
1903 % taken into account for this calculation.
1904 % \begin{macrocode}
1905 \let\AM@filelist@save\@filelist
1906 \AM@split@options{Gin}{#1}%
1907 \ifAM@templatesize
1908 \setbox\@tempboxa=\hbox{%
1909 \scalebox{\AM@scale@factor}{\copy\AM@templatesizebox}}%
1910 \setbox\@tempboxa=\hbox{%
1911 \scalebox{\AM@globalscale}{\copy\@tempboxa}}%
1912 \setbox\@tempboxa=\hbox{%
1913 \rotatebox{\AM@lscape@rot}{\copy\@tempboxa}}%
1914 \else
1915 \edef\AM@opts{[\AM@disable@width@height,\the\@temptokena,
1916 page=\AM@page, scale=\AM@globalscale,
1917 angle=\AM@lscape@rot]}%
1918 \setbox\@tempboxa=\hbox{%
1919 \expandafter\includegraphics\AM@opts{\AM@docname}}%
1920 \fi
1921 \let\@filelist\AM@filelist@save
1922 \edef\AM@templatewidth{\the\wd\@tempboxa}%
1923 \setlength{\@tempdima}{\ht\@tempboxa + \dp\@tempboxa}%
1924 \edef\AM@templateheight{\the\@tempdima}%
1925 \setlength{\@tempdimb}{\ht\@tempboxa + \dp\@tempboxa}%
1926 \def\AM@xmargin{%
1927 (\AM@pagewidth - (\wd\@tempboxa+\tw@\AM@fboxrule)*\AM@xnup
1928 - \AM@deltax * \AM@xnupminusi) * \real{.5}%
1929 }%
1930 \def\AM@ymargin{%
1931 (\AM@pageheight - (\@tempdimb+\tw@\AM@fboxrule)*\AM@ynup
1932 - \AM@deltay * \AM@ynupminusi) * \real{.5}%
1933 }%
1934 \setlength{\@tempdima}{\AM@xmargin}%
1935 \edef\AM@xmargin{\the\@tempdima}%
1936 \setlength{\@tempdima}{\AM@ymargin}%
1937 \edef\AM@ymargin{\the\@tempdima}%
1938 % \end{macrocode}
1939 % \begin{macrocode}
1940 \ifthenelse{\boolean{AM@landscape}}{%
1941 \edef\AM@temp{\AM@xnup}%
1942 \edef\AM@xnup{\AM@ynup}%
1943 \edef\AM@ynup{\AM@temp}%
1944 }{}%
1945 % \end{macrocode}
1946 % This loop arranges one or more \PDF\ pages onto each sheet
1947 % of paper.
1948 % \begin{macrocode}
1949 \setboolean{AM@endoflist}{false}%
1950 \clearpage
1951 \whiledo{\not\boolean{AM@endoflist}}{%
1952 \AM@getfirst{\AM@pagelist}%
1953 \edef\AM@nextpage{\the\toks@}%
1954 \AM@isphantom
1955 \@tempcnta=\AM@nextpage\relax
1956 \edef\AM@linktodoc@page{\the\@tempcnta}%
1957 \advance\@tempcnta\m@ne
1958 \edef\AM@linktodoc@page@m@ne{\the\@tempcnta}%
1959 \AM@getfirst{\AM@doclist}%
1960 \edef\AM@docname{\the\toks@}%
1961 \ifAM@linkfilename
1962 \else
1963 \let\AM@linkfilename\AM@docname
1964 \fi
1965 \ifx\@empty\AM@linkname@option \edef\AM@linkname{\the\toks@}%
1966 \else \edef\AM@linkname{\AM@linkname@option} \fi
1967 % \end{macrocode}
1968 % Each logical page has an element number of
1969 % |(\AM@xnupi,\AM@ynupi)|, where |(1,1)| indicates the upper
1970 % left position.
1971 % \begin{macrocode}
1972 \ifthenelse{\boolean{AM@column}}
1973 {\@tempcnta=\AM@ynupi\relax
1974 \@tempcntb=\AM@ynup\relax
1975 \advance\@tempcnta\@ne
1976 \ifnum\@tempcnta>\@tempcntb
1977 \@tempcnta=\@ne
1978 \@tempcntb=\AM@xnupi\relax
1979 \advance\@tempcntb\@ne
1980 \edef\AM@xnupi{\the\@tempcntb}%
1981 \fi
1982 \edef\AM@ynupi{\the\@tempcnta}%
1983 \@tempcnta=\AM@xnupi\relax
1984 \@tempcntb=\AM@xnup\relax
1985 \ifnum\@tempcnta>\@tempcntb
1986 \def\AM@xnupi{\@ne}%
1987 \AM@newpagetrue
1988 \fi
1989 }
1990 {\@tempcnta=\AM@xnupi\relax
1991 \@tempcntb=\AM@xnup\relax
1992 \advance\@tempcnta\@ne
1993 \ifnum\@tempcnta>\@tempcntb
1994 \@tempcnta=\@ne
1995 \@tempcntb=\AM@ynupi\relax
1996 \advance\@tempcntb\@ne
1997 \edef\AM@ynupi{\the\@tempcntb}%
1998 \fi
1999 \edef\AM@xnupi{\the\@tempcnta}%
2000 \@tempcnta=\AM@ynupi\relax
2001 \@tempcntb=\AM@ynup\relax
2002 \ifnum\@tempcnta>\@tempcntb
2003 \def\AM@ynupi{\@ne}%
2004 \AM@newpagetrue
2005 \fi
2006 }%
2007 % \end{macrocode}
2008 % \begin{macrocode}
2009 \ifAM@newpage
2010 \clearpage
2011 \AM@newpagefalse
2012 \fi
2013 \edef\AM@page{\AM@nextpage}%
2014 \let\PageNum\AM@page
2015 \let\FileName\AM@currentdocname
2016 % \end{macrocode}
2017 % Load next page and verify if it has the same page size as the
2018 % page template. If not, adjust the scale |\AM@localscale| and
2019 % the local offset |\AM@localxoff| and |\AM@localyoff|.
2020 % \begin{macrocode}
2021 \edef\AM@opts{[\AM@disable@width@height,\the\@temptokena,
2022 page=\AM@page, scale=\AM@globalscale,
2023 angle=\AM@lscape@rot]}%
2024 \setbox\@tempboxa=\hbox{%
2025 \expandafter\includegraphics\AM@opts{\AM@docname}}%
2026 \edef\AM@localwd{\the\wd\@tempboxa}%
2027 \setlength{\@tempdima}{\ht\@tempboxa + \dp\@tempboxa}%
2028 \edef\AM@localht{\the\@tempdima}%
2029 \AM@rescalefalse
2030 \ifdim\AM@localwd=\AM@templatewidth \else \AM@rescaletrue \fi
2031 \ifdim\AM@localht=\AM@templateheight \else \AM@rescaletrue \fi
2032 \def\AM@localxoff{\z@}%
2033 \def\AM@localyoff{\z@}%
2034 \def\AM@rotateoversize{0}%
2035 \def\AM@localscale{\p@}%
2036 \ifAM@rescale
2037 \ifthenelse{\lengthtest{\AM@localwd<\AM@templatewidth} \and
2038 \lengthtest{\AM@localht<\AM@templateheight}}{%
2039 % \end{macrocode}
2040 % Smaller pages are \emph{not} scaled up, just their local offset
2041 % is adjusted.
2042 % \begin{macrocode}
2043 \setlength{\@tempdima}{(\AM@templatewidth - \AM@localwd)
2044 * \real{.5}}%
2045 \edef\AM@localxoff{\the\@tempdima}%
2046 \setlength{\@tempdima}{(\AM@templateheight - \AM@localht)
2047 * \real{.5}}%
2048 \edef\AM@localyoff{\the\@tempdima}%
2049 }{%
2050 % \end{macrocode}
2051 % Larger pages are scaled down and their local offset is adjusted.
2052 % \begin{macrocode}
2053 \ifAM@rotateoversize
2054 \def\AM@rotateoversize{90}%
2055 \let\AM@filelist@save\@filelist
2056 \edef\AM@opts{[\AM@disable@width@height,\the\@temptokena,
2057 page=\AM@page, scale=\AM@globalscale,
2058 angle=\AM@lscape@rot, angle=90]}%
2059 \setbox\@tempboxa=\hbox{%
2060 \expandafter\includegraphics\AM@opts{\AM@docname}}%
2061 \let\@filelist\AM@filelist@save
2062 \edef\AM@localwd{\the\wd\@tempboxa}%
2063 \setlength{\@tempdima}{\ht\@tempboxa + \dp\@tempboxa}%
2064 \edef\AM@localht{\the\@tempdima}%
2065 \fi
2066 \setlength{\@tempdima}
2067 {\p@ * \ratio{\AM@templatewidth}{\AM@localwd}}%
2068 \edef\AM@localxscale{\the\@tempdima}%
2069 \setlength{\@tempdima}
2070 {\p@ * \ratio{\AM@templateheight}{\AM@localht}}%
2071 \edef\AM@localyscale{\the\@tempdima}%
2072 \ifdim\AM@localxscale<\AM@localyscale
2073 \let\AM@localscale\AM@localxscale
2074 \setlength{\@tempdima}{\AM@localxscale}%
2075 \setlength{\@tempdima}{(\AM@templateheight -
2076 \AM@localht * \real{\strip@pt\@tempdima}) * \real{.5}}%
2077 \edef\AM@localyoff{\the\@tempdima}%
2078 \else
2079 \let\AM@localscale\AM@localyscale
2080 \setlength{\@tempdima}{\AM@localyscale}%
2081 \setlength{\@tempdima}{(\AM@templatewidth -
2082 \AM@localwd * \real{\strip@pt\@tempdima}) * \real{.5}}%
2083 \edef\AM@localxoff{\the\@tempdima}%
2084 \fi
2085 }%
2086 \fi
2087 \setlength{\@tempdima}{\AM@localscale}%
2088 \edef\AM@localscale{\strip@pt\@tempdima}%
2089 % \end{macrocode}
2090 % The above calculation are wrong if |noautoscale| is used.
2091 % Thus reset values here.
2092 % \begin{macrocode}
2093 \ifAM@noautoscale
2094 \def\AM@localxoff{\z@}%
2095 \def\AM@localyoff{\z@}%
2096 \def\AM@localscale{1}%
2097 \fi
2098 % \end{macrocode}
2099 % \begin{macrocode}
2100 \let\AM@filelist@save\@filelist
2101 \AM@split@options{Gin}{#1}%
2102 \edef\AM@opts{[\AM@disable@width@height,\the\@temptokena,
2103 page=\AM@page, scale=\AM@globalscale,
2104 angle=\AM@lscape@rot]}%
2105 \setbox\@tempboxa=\hbox{%
2106 \expandafter\includegraphics\AM@opts{\AM@docname}}%
2107 \let\@filelist\AM@filelist@save
2108 \setlength{\@tempdimc}{\ht\@tempboxa + \dp\@tempboxa}%
2109 % \end{macrocode}
2110 % Eso-pic set the origin of the coordinate system by default to the
2111 % lower left corner which is what pdfpages assumes. However, with the
2112 % option |texcoord| eso-pic sets the origin to the upper left corner.
2113 % Let's take care of this.
2114 % \begin{macrocode}
2115 \edef\AM@texcoord{%
2116 \ifESO@texcoord
2117 -\AM@pageheight
2118 \else
2119 \z@
2120 \fi
2121 }%
2122 % \end{macrocode}
2123 % Determine the position (coordinates) of the logical pages.
2124 % These are |\AM@xpos| and |\AM@ypos|.
2125 % \begin{macrocode}
2126 \def\AM@add{+}%
2127 \if@twoside\ifodd\c@page\else\def\AM@add{-}\fi\fi
2128 \setlength{\@tempdimb}{\ht\@tempboxa + \dp\@tempboxa}%
2129 \ifthenelse{\boolean{AM@landscape}}
2130 {\def\AM@xpos{%
2131 \AM@xmargin \AM@add\AM@xoffset + \AM@localxoff +
2132 (\AM@templatewidth + \AM@deltax + \tw@\AM@fboxrule) *
2133 (\AM@ynupi - 1)
2134 }%
2135 \def\AM@ypos{%
2136 \AM@texcoord +
2137 \AM@ymargin + \AM@yoffset + \AM@localyoff +
2138 (\AM@templateheight + \AM@deltay + \tw@\AM@fboxrule) *
2139 (\AM@xnupi - 1)
2140 }%
2141 }
2142 {\def\AM@xpos{%
2143 \AM@xmargin \AM@add\AM@xoffset + \AM@localxoff +
2144 (\AM@templatewidth + \AM@deltax + \tw@\AM@fboxrule) *
2145 (\AM@xnupi - 1)
2146 }%
2147 \def\AM@ypos{%
2148 \AM@texcoord +
2149 \AM@ymargin + \AM@yoffset + \AM@localyoff +
2150 (\AM@templateheight + \AM@deltay + \tw@\AM@fboxrule) *
2151 (\AM@ynup-\AM@ynupi)
2152 }%
2153 }%
2154 \setlength{\@tempdima}{\AM@xpos}%
2155 \edef\AM@xpos{\strip@pt\@tempdima}%
2156 \setlength{\@tempdima}{\AM@ypos}%
2157 \edef\AM@ypos{\strip@pt\@tempdima}%
2158 % \end{macrocode}
2159 % Ship out page.
2160 % \begin{macrocode}
2161 \ifnum\AM@xnupi=1
2162 \ifnum\AM@ynupi=1
2163 \ifAM@reflectall
2164 \setbox\AM@pagebox\null
2165 \fi
2166 \ifAM@swap@flip@edge
2167 \ifAM@signature
2168 \ifAM@upsidedown\AM@upsidedownfalse\else\AM@upsidedowntrue\fi
2169 \@tempdima=\AM@xoffset\relax
2170 \multiply\@tempdima\m@ne
2171 \edef\AM@xoffset{\the\@tempdima}%
2172 \fi
2173 \fi
2174 \fi
2175 \fi
2176 \ifAM@phantompage
2177 \def\AM@shippage{}%
2178 \else
2179 \AM@set@alt
2180 \AM@set@artifact
2181 \AM@split@options{Gin}{#1}%
2182 \edef\AM@opts{[
2183 \AM@disable@width@height,\the\@temptokena,
2184 page=\AM@page, scale=\AM@globalscale,
2185 scale=\AM@localscale,
2186 \ifAM@artifact
2187 artifact,
2188 \else
2189 alt={\AM@alt@text},
2190 \fi
2191 \ifAM@upsidedown angle=180,\fi
2192 \ifAM@doublepagestwist\ifAM@doublepagestmp
2193 angle=180,\fi\fi
2194 angle=\AM@rotateoversize, angle=\AM@lscape@rot]}%
2195 \edef\AM@shippage{%
2196 \noexpand\put(\AM@xpos,\AM@ypos){%
2197 \noexpand\raisebox{\dp\@tempboxa}{%
2198 % \end{macrocode}
2199 % Raise the target of a link to the top of the included page.
2200 % \begin{macrocode}
2201 \noexpand\raise \ifx\\\AM@view@ypos\\\ht\@tempbox\else\AM@view@ypos\p@\fi
2202 \hbox to 0pt {\hskip\AM@view@xpos bp\AM@hyper@begin@i}%
2203 % \end{macrocode}
2204 % \begin{macrocode}
2205 \global\pdfpages@includegraphics@status\@ne
2206 \fboxsep=\z@
2207 \AM@hyper@begin@ii\noexpand\AM@fbox{%
2208 \noexpand\AM@ARBug@hook
2209 \noexpand\AM@reflectbox{%
2210 \expandafter\noexpand\expandafter
2211 \includegraphics\AM@opts{\AM@docname}}}%
2212 \global\pdfpages@includegraphics@status\tw@
2213 \AM@hyper@end}}%
2214 }%
2215 \fi
2216 \ifAM@doublepagestwist
2217 \ifAM@doublepagestmpi
2218 \ifAM@doublepagestwistx\AM@doublepagestmpifalse\fi
2219 \ifAM@doublepagestmp\AM@doublepagestmpfalse
2220 \else\AM@doublepagestmptrue\fi
2221 \else\AM@doublepagestmpitrue\fi
2222 \fi
2223 \AM@AddToShipoutPicture{\setlength{\unitlength}{\p@}%
2224 \global\let\AM@filelist@save\@filelist}%
2225 % \end{macrocode}
2226 % Adjust paper size:
2227 % After |\newpage| we may finally set |\paper{width,height}| and call
2228 % |\AM@setpagedimen|.
2229 % \begin{macrocode}
2230 \ifthenelse{\boolean{AM@fitpaper}}{
2231 \setlength{\paperwidth}{\AM@pagewidth}%
2232 \setlength{\paperheight}{\AM@pageheight}%
2233 \AM@fitpaper@special
2234 \AM@setpagedimen
2235 \ifAM@memoir
2236 \setlength{\stockwidth}{\AM@pagewidth}%
2237 \setlength{\stockheight}{\AM@pageheight}%
2238 \setlength{\trimtop}{0pt}%
2239 \setlength{\trimedge}{0pt}%
2240 \fi
2241 }{}
2242 % \end{macrocode}
2243 % |eso-pic| needs |\paperwidth| and |\paperheight|, which may
2244 % not be defined, e.g. with |minimal.cls|.
2245 % \begin{macrocode}
2246 \ifdim\paperwidth=\z@
2247 \let\paperwidth\AM@pagewidth
2248 \fi
2249 \ifdim\paperheight=\z@
2250 \let\paperheight\AM@pageheight
2251 \fi
2252 % \end{macrocode}
2253 % \begin{macrocode}
2254 \if@twocolumn
2255 \@twocolumnfalse
2256 \let\AM@twocolumn\relax
2257 \fi
2258 % \end{macrocode}
2259 % |\AM@pagebox| is only used for option |reflect|, which was added
2260 % lately. Probabley it would be better to use |\AM@pagebox| in
2261 % all cases?
2262 % \begin{macrocode}
2263 \ifAM@reflectall
2264 \begin{lrbox}{\AM@pagebox}
2265 \global\let\AM@filelist@save\@filelist
2266 \usebox{\AM@pagebox}\AM@shippage
2267 \global\let\@filelist\AM@filelist@save
2268 \end{lrbox}
2269 \else
2270 \expandafter\AM@AddToShipoutPicture\expandafter{%
2271 \expandafter\AM@ResumeTagging
2272 \AM@shippage
2273 \global\let\@filelist\AM@filelist@save
2274 }%
2275 \fi
2276 \AM@toclof{\AM@page}%
2277 \ifnum\AM@xnupi=\AM@xnup\relax
2278 \ifnum\AM@ynupi=\AM@ynup\relax
2279 \begingroup
2280 \ifAM@firstpage\AM@pagecommandstar\fi
2281 \AM@pagecommand
2282 \endgroup
2283 \hskip\z@
2284 \ifthenelse{\boolean{AM@turn}\AND\boolean{AM@landscape}}{%
2285 \AM@setRotate
2286 }{}%
2287 \AM@AddToShipoutPicture{%
2288 \begingroup\AM@picturecommand\endgroup}%
2289 \ifAM@firstpage
2290 \AM@AddToShipoutPicture{%
2291 \begingroup\AM@picturecommandstar\endgroup}%
2292 \AM@firstpagefalse
2293 \fi
2294 \ifAM@reflectall
2295 \AM@AddToShipoutPicture{%
2296 \hskip\AM@pagewidth
2297 \reflectbox{\usebox\AM@pagebox}%
2298 \global\let\@filelist\AM@filelist@save
2299 }%
2300 \AM@ClearShipoutPicture
2301 \fi
2302 \fi
2303 \fi
2304 % \end{macrocode}
2305 % \begin{macrocode}
2306 }% whiledo
2307 \global\let\@deferlist\AM@deferlist
2308 \global\let\@dbldeferlist\AM@dbldeferlist
2309 \ifx\AM@twocolumn\relax
2310 \@twocolumntrue
2311 \@firstcolumnfalse
2312 \fi
2313 \newpage
2314 \ifthenelse{\boolean{AM@turn}\AND\boolean{AM@landscape}}{%
2315 \AM@resetRotate
2316 }{}
2317 }% AM@output
2318 % \end{macrocode}
2319 % \macro{\AM@readlist}
2320 % \macro{\AM@readlisti}
2321 % \macro{\AM@range@or@docname}
2322 % \macro{\AM@checkrange}
2323 % \macro{\AM@expand@range}
2324 % \macro{\AM@check@valid@pagenumber}
2325 % \macro{\AM@strip@slash}
2326 % \macro{\AM@checkpagenumber}
2327 % \macro{\AM@setnewdocname}
2328 % \macro{\AM@append}
2329 % These macros parse a comma separated list, which contains
2330 % page numbers, page ranges, and/or document names. The
2331 % results are stored in two macros: |\AM@pagelist| which
2332 % contains only page numbers (page ranges are split into
2333 % separate page numbers) and |\AM@doclist| which contains
2334 % the document names; one name for each page number in
2335 % |\AM@pagelist|.
2336 % \begin{macrocode}
2337 \newif\ifAM@default@range@added
2338 \newcommand*{\AM@readlist}[1]{%
2339 \AM@pagecount@updatedfalse
2340 \AM@default@range@addedtrue
2341 \def\AM@pagelist{}%
2342 \def\AM@doclist{}%
2343 \AM@readlisti#1,\END,
2344 \AM@add@default@range
2345 \edef\AM@doclist{\expandafter\@gobble\AM@doclist\@empty}%
2346 \edef\AM@pagelist{\expandafter\@gobble\AM@pagelist\@empty}%
2347 }
2348 % \end{macrocode}
2349 % \begin{macrocode}
2350 \def\AM@add@default@range{%
2351 \ifAM@default@range@added
2352 \else
2353 \expandafter\AM@read@defaultpages\AM@pagestemp,\END,
2354 \fi
2355 \AM@default@range@addedtrue
2356 }
2357 % \end{macrocode}
2358 % \begin{macrocode}
2359 \def\AM@read@defaultpages#1,{%
2360 \ifx\END#1
2361 \else
2362 \edef\AM@x{\AM@trim@space{#1}}%
2363 \ifx\AM@x\@empty
2364 \AM@append{}%
2365 \AM@ReturnAfterElseFiFi\AM@read@defaultpages
2366 \else
2367 \expandafter\AM@checkrange\AM@x-\END
2368 \AM@expand@range\AM@i\AM@ii
2369 \AM@ReturnAfterFiFi\AM@read@defaultpages
2370 \fi
2371 \fi
2372 }
2373 % \end{macrocode}
2374 % \begin{macrocode}
2375 \newcommand{\AM@readlisti}{}
2376 \def\AM@readlisti#1,{%
2377 \ifx\AM@currentdocname\relax
2378 \else
2379 \ifAM@pagecount@updated
2380 \else
2381 \AM@getpagecount
2382 \AM@pagecount@updatedtrue
2383 \fi
2384 \fi
2385 \def\AM@temp{#1}%
2386 \ifx\END#1
2387 \else
2388 \AM@range@or@docname{#1}%
2389 \expandafter\AM@readlisti
2390 \fi
2391 }
2392 % \end{macrocode}
2393 % \begin{macrocode}
2394 \def\AM@range@or@docname#1{%
2395 \edef\AM@arg{\AM@trim@space{#1}}%
2396 \ifx\AM@arg\@empty
2397 \AM@append{}%
2398 \else
2399 \expandafter\AM@checkrange\AM@arg-\END
2400 \ifAM@isrange
2401 \ifx\AM@currentdocname\relax
2402 \AM@setnewdocname{\AM@arg}%
2403 \else
2404 \AM@expand@range\AM@i\AM@ii
2405 \AM@default@range@addedtrue
2406 \fi
2407 \else
2408 \AM@add@default@range
2409 \AM@setnewdocname{\AM@arg}%
2410 \AM@pagecount@updatedfalse
2411 \fi
2412 \fi
2413 }
2414 % \end{macrocode}
2415 % \begin{macrocode}
2416 \def\AM@last{last}
2417 \def\AM@empty{}
2418 \newif\ifAM@isrange
2419 % \end{macrocode}
2420 % \begin{macrocode}
2421 \def\AM@checkrange#1-#2\END{%
2422 \AM@israngefalse
2423 \AM@check@valid@pagenumber{#1}%
2424 \ifx\\#1\\%
2425 \def\AM@i{1}%
2426 \else
2427 \edef\AM@i{#1}%
2428 \fi
2429 \def\AM@ii{}%
2430 \ifAM@isrange
2431 \ifx\\#2\\%
2432 \else
2433 \edef\AM@ii{\AM@strip@slash#2\END}%
2434 \AM@check@valid@pagenumber{\AM@ii}%
2435 \ifx\AM@ii\AM@empty
2436 \let\AM@ii\AM@last
2437 \fi
2438 \fi
2439 \fi
2440 }
2441 % \end{macrocode}
2442 % \begin{macrocode}
2443 \def\AM@expand@range#1#2{%
2444 \edef\AM@i{#1}%
2445 \edef\AM@ii{#2}%
2446 \ifx\AM@i\AM@last
2447 \let\AM@i\AM@lastpage
2448 \let\AM@i\AM@pagecount
2449 \fi
2450 \ifx\AM@ii\AM@last
2451 \let\AM@ii\AM@lastpage
2452 \let\AM@ii\AM@pagecount
2453 \fi
2454 \ifx\AM@ii\AM@empty
2455 \let\AM@ii\AM@i
2456 \fi
2457 \@tempcnta=\AM@i\relax
2458 \@tempcntb=\AM@ii\relax
2459 \ifnum\@tempcnta<\@tempcntb
2460 \def\AM@rel{<}%
2461 \let\AM@inc\@ne
2462 \else
2463 \def\AM@rel{>}%
2464 \let\AM@inc\m@ne
2465 \fi
2466 \advance\@tempcntb\AM@inc
2467 \whiledo{\@tempcnta\AM@rel\@tempcntb}{%
2468 \AM@checkpagenumber{\the\@tempcnta}%
2469 \AM@append{\the\@tempcnta}%
2470 \advance\@tempcnta\AM@inc
2471 }%
2472 }
2473 % \end{macrocode}
2474 % \begin{macrocode}
2475 \def\AM@check@valid@pagenumber#1{%
2476 \AM@checkinteger{#1}%
2477 \ifAM@integer
2478 \AM@israngetrue
2479 \else
2480 \AM@israngefalse
2481 \fi
2482 \edef\AM@tmp{#1}%
2483 \ifx\AM@tmp\AM@last
2484 \AM@israngetrue
2485 \fi
2486 }
2487 % \end{macrocode}
2488 % \begin{macrocode}
2489 \def\AM@strip@slash#1-#2\END{%
2490 \ifx\\#2\\%
2491 #1%
2492 \else
2493 #1-#2%
2494 \fi
2495 }
2496 % \end{macrocode}
2497 % \begin{macrocode}
2498 \providecommand*{\AM@checkpagenumber}[1]{%
2499 \ifnum#1>\AM@pagecount\relax
2500 \ifthenelse{\boolean{AM@pkg@draft} \and \boolean{AM@survey}}{%
2501 }{%
2502 \PackageError{pdfpages}
2503 {Page #1 of `\AM@currentdocname' does not exist}
2504 {You have set a wrong page number in the `pages' option.
2505 Document \MessageBreak `\AM@currentdocname' does not
2506 have #1 pages.}%
2507 }%
2508 \fi
2509 }
2510 % \end{macrocode}
2511 % \begin{macrocode}
2512 \newcommand*{\AM@setnewdocname}[1]{%
2513 \ifAM@openrighteach
2514 \ifodd\AM@pagecnt
2515 \AM@append{}
2516 \fi
2517 \fi
2518 \AM@add@default@range
2519 \edef\AM@temp{\AM@trim@space{#1}}%
2520 \AM@findfile{\AM@temp}%
2521 \AM@default@range@addedfalse
2522 }
2523 % \end{macrocode}
2524 % \begin{macrocode}
2525 \newcount\AM@pagecnt
2526 \newcommand*{\AM@append}[1]{%
2527 \advance\AM@pagecnt\@ne
2528 \edef\AM@doclist{\AM@doclist,\AM@currentdocname}%
2529 \edef\AM@pagelist{\AM@pagelist,#1}%
2530 \ifAM@doublepages
2531 \edef\AM@doclist{\AM@doclist,\AM@currentdocname}%
2532 \edef\AM@pagelist{\AM@pagelist,#1}%
2533 \fi
2534 \ifAM@duplicatepages
2535 \count@=0
2536 \loop
2537 \advance\count@ 1
2538 \ifnum\count@<\AM@nduplicatepages
2539 \edef\AM@doclist{\AM@doclist,\AM@currentdocname}%
2540 \edef\AM@pagelist{\AM@pagelist,#1}%
2541 \repeat
2542 \fi
2543 }
2544 % \end{macrocode}
2545 % \macro{\AM@getfirst}
2546 % \macro{\AM@getfirsti}
2547 % \macro{\AM@getfirstii}
2548 % Parameter |#1| must be a macro containing a csv-list.
2549 % |\AM@getfirst| removes the first item of this list
2550 % \textit{and} stores it in |\toks@|.
2551 % \begin{macrocode}
2552 \newif\ifAM@endoflist\AM@endoflistfalse
2553 \newcommand{\AM@getfirst}{}
2554 \def\AM@getfirst#1{\expandafter\AM@getfirsti#1,\END#1\END}
2555 % \end{macrocode}
2556 % \begin{macrocode}
2557 \newcommand{\AM@getfirsti}{}
2558 \def\AM@getfirsti#1,#2\END#3\END{%
2559 \edef#3{#2}%
2560 \ifx\\#2\\%
2561 \setboolean{AM@endoflist}{true}%
2562 \def#3{}%
2563 \else
2564 \edef#3{\AM@getfirstii#2\END}%
2565 \fi
2566 \toks@{#1}%
2567 }
2568 % \end{macrocode}
2569 % \begin{macrocode}
2570 \newcommand{\AM@getfirstii}{}
2571 \def\AM@getfirstii#1,\END{#1}
2572 % \end{macrocode}
2573 % \macro{\AM@readfirst}
2574 % Read first item of a list and store it in |\toks@|.
2575 % (Do not remove it.)
2576 % \begin{macrocode}
2577 \newcommand{\AM@readfirst}{}
2578 \newcommand{\AM@readfirsti}{}
2579 \def\AM@readfirst#1{\expandafter\AM@readfirsti#1,\END}
2580 \def\AM@readfirsti#1,#2\END{\toks@{#1}}
2581 % \end{macrocode}
2582 % \macro{\AM@getlast}
2583 % \macro{\AM@getlasti}
2584 % \macro{\AM@getlastn}
2585 % These macros are similar to |\AM@getfirst|. |\AM@getlast|
2586 % stores the last item in |\AM@lastitem| and removes it
2587 % from the list. |\AM@getlastn| does the same with the
2588 % last |n| items which are stored in |\AM@lastnitems|.
2589 % \begin{macrocode}
2590 \newcommand{\AM@getlast}{}
2591 \def\AM@getlast#1{%
2592 \let\AM@temp\relax
2593 \expandafter\AM@getlasti#1,\END
2594 \@ifundefined{AM@temp}{\def#1{}}{\edef#1{\AM@temp}}%
2595 }
2596 % \end{macrocode}
2597 % \begin{macrocode}
2598 \def\AM@ReturnAfterFi#1\fi{\fi#1}
2599 \def\AM@ReturnAfterFiFi#1\fi\fi{\fi\fi#1}
2600 \def\AM@ReturnAfterElseFiFi#1\else#2\fi#3\fi{\fi\fi#1}
2601 % \end{macrocode}
2602 % \begin{macrocode}
2603 \newcommand{\AM@getlasti}{}
2604 \def\AM@getlasti#1,#2\END{%
2605 \ifx\\#2\\%
2606 \def\AM@lastitem{#1}%
2607 \else
2608 \@ifundefined{AM@temp}
2609 {\edef\AM@temp{#1}}
2610 {\edef\AM@temp{\AM@temp,#1}}%
2611 \AM@ReturnAfterFi{\AM@getlasti#2\END}%
2612 \fi
2613 }
2614 % \end{macrocode}
2615 % \begin{macrocode}
2616 \newcommand{\AM@getlastn}{}
2617 \def\AM@getlastn#1#2{%
2618 \let\AM@templist\relax
2619 \@tempcnta=\z@
2620 \loop
2621 \ifnum\@tempcnta<#2
2622 \AM@getlast{#1}%
2623 \@ifundefined{AM@templist}
2624 {\edef\AM@templist{\AM@lastitem}}
2625 {\edef\AM@templist{\AM@lastitem,\AM@templist}}%
2626 \advance\@tempcnta\@ne
2627 \repeat
2628 \edef\AM@lastnitems{\AM@templist}%
2629 }
2630 % \end{macrocode}
2631 % \macro{\AM@split@firstn}
2632 % Removes the first |n=#2| items from the cvs=list, which
2633 % is specified by the name of a macro in |#1|. These |n|
2634 % items are split into two lists with the names |#1@firstn|
2635 % and |#1@lastn|. The latter one is sorted backwards. This
2636 % is needed for a faster processing of the |signature| option.
2637 % \begin{macrocode}
2638 \newcommand{\AM@split@firstn}{}
2639 \def\AM@split@firstn#1#2{%
2640 \edef\AM@tmp{\expandafter\@gobble\string#1@firstn}%
2641 \AM@getfirst{#1}%
2642 \expandafter\edef\csname\AM@tmp\endcsname{\the\toks@}%
2643 \@tempcnta=\@ne
2644 \@tempcntb=#2 \divide\@tempcntb\tw@
2645 \loop\ifnum\@tempcnta<\@tempcntb
2646 \AM@getfirst{#1}%
2647 \expandafter\edef\csname\AM@tmp\endcsname
2648 {\@nameuse{\AM@tmp},\the\toks@}%
2649 \advance\@tempcnta\@ne
2650 \repeat
2651 \edef\AM@tmp{\expandafter\@gobble\string#1@lastn}%
2652 \AM@getfirst{#1}%
2653 \expandafter\edef\csname\AM@tmp\endcsname{\the\toks@}%
2654 \@tempcnta=\@ne
2655 \loop\ifnum\@tempcnta<\@tempcntb
2656 \AM@getfirst{#1}%
2657 \expandafter\edef\csname\AM@tmp\endcsname
2658 {\the\toks@,\@nameuse{\AM@tmp}}%
2659 \advance\@tempcnta\@ne
2660 \repeat
2661 }
2662 % \end{macrocode}
2663 % \macro{\AM@count}
2664 % \macro{\AM@counti}
2665 % Parameter |#1| must be a macro containing a csv-list.
2666 % |\AM@count| counts the items of this list, but it does
2667 % not count the last \textit{empty} items of this list.
2668 % The number of items is stored in |\@tempcnta|.
2669 % \begin{macrocode}
2670 \newif\ifAM@again\AM@againtrue
2671 \newcommand{\AM@count}{}
2672 \def\AM@count#1{%
2673 \edef\AM@templist{#1}%
2674 \loop
2675 \AM@getlast{\AM@templist}%
2676 \expandafter\ifx\expandafter\\\AM@lastitem\\%
2677 \else
2678 \AM@againfalse
2679 \expandafter\ifx\expandafter\\\AM@templist\\%
2680 \edef\AM@templist{\AM@lastitem}%
2681 \else
2682 \edef\AM@templist{\AM@templist,\AM@lastitem}%
2683 \fi
2684 \@tempcnta=\z@
2685 \expandafter\AM@counti\AM@templist,\END,
2686 \fi
2687 \ifAM@again
2688 \repeat
2689 }
2690 % \end{macrocode}
2691 % \begin{macrocode}
2692 \newcommand{\AM@counti}{}
2693 \def\AM@counti#1,{%
2694 \ifx\END#1
2695 \else
2696 \advance\@tempcnta\@ne
2697 \expandafter\AM@counti
2698 \fi
2699 }
2700 % \end{macrocode}
2701 % \macro{\AM@resort}
2702 % To allow a more pleasant output in |column| mode, the
2703 % logical pages get resorted if they do not fill the
2704 % whole sheet of paper.
2705 % |\AM@lastnpages| must contain the pages and
2706 % |\AM@lastndocs| the corresponding documents which
2707 % should get resorted.
2708 %
2709 % E.g.: After resorting a page that contains only 5 of 9
2710 % logical pages, it looks like (b) instead of (a).
2711 %
2712 % \smallskip\par
2713 % \begin{minipage}{110pt}
2714 % \centering
2715 % \begin{tabular}{|c|c|c|}\hline
2716 % 1 & 4 & \phantom{6}\\\hline
2717 % 2 & 5 &\\\hline
2718 % 3 &&\\\hline
2719 % \end{tabular}\smallskip\par
2720 % (a)~|columnstrict=false|
2721 % \end{minipage}
2722 % \hskip15pt
2723 % \begin{minipage}{110pt}
2724 % \centering
2725 % \begin{tabular}{|c|c|c|}\hline
2726 % 1 & 3 & 5\\\hline
2727 % 2 & 4 & \\\hline
2728 % &&\\\hline
2729 % \end{tabular}\smallskip\par
2730 % (b)~|columnstrict=true|
2731 % \end{minipage}
2732 % \smallskip
2733 % \begin{macrocode}
2734 \newif\ifAM@resort@end\AM@resort@endfalse
2735 \newcommand{\AM@resort}{}
2736 \def\AM@resort{%
2737 \def\AM@resortedpagelist{}%
2738 \def\AM@resorteddoclist{}%
2739 \def\AM@xnupi{\@ne}%
2740 \def\AM@ynupi{\@ne}%
2741 % \end{macrocode}
2742 % For the following algorithm a `last page' is
2743 % defined, which has the position (|xnuplast| , |ynuplast|).
2744 % It is marked with $\times$ in the figure below.
2745 % \smallskip\par
2746 % \begin{minipage}{110pt}
2747 % \centering
2748 % \begin{tabular}{|c|c|c|}\hline
2749 % 1 & 3 & 5\\\hline
2750 % 2 & 4 & $\times$\\\hline
2751 % &&\\\hline
2752 % \end{tabular}\smallskip\par
2753 % \end{minipage}
2754 % \begin{macrocode}
2755 \AM@count{\AM@lastnpages}%
2756 \def\AM@xnuplast{%
2757 \the\@tempcnta - (\the\@tempcnta / \AM@xnup * \AM@xnup) + 1}%
2758 \def\AM@ynuplast{1 + (\the\@tempcnta / \AM@xnup)}%
2759 \setlength{\@tempdima}{\p@*(\AM@xnuplast)}%
2760 \edef\AM@xnuplast{\strip@pt\@tempdima}%
2761 \setlength{\@tempdima}{\p@*(\AM@ynuplast)}%
2762 \edef\AM@ynuplast{\strip@pt\@tempdima}%
2763 % \end{macrocode}
2764 % \begin{macrocode}
2765 \whiledo{\not\boolean{AM@resort@end}}{%
2766 \@tempcnta=\AM@ynupi\relax
2767 \@tempcntb=\AM@ynuplast\relax
2768 \ifnum\@tempcnta=\@tempcntb
2769 \@tempcnta=\AM@xnupi\relax
2770 \@tempcntb=\AM@xnuplast\relax
2771 \ifnum\@tempcnta<\@tempcntb
2772 \AM@getfirst{\AM@lastndocs}%
2773 \edef\AM@firstdocitem{\the\toks@}%
2774 \AM@getfirst{\AM@lastnpages}%
2775 \edef\AM@resortedpagelist{\AM@resortedpagelist,\the\toks@}%
2776 \edef\AM@resorteddoclist{%
2777 \AM@resorteddoclist,\AM@firstdocitem}%
2778 \else
2779 \edef\AM@resortedpagelist{\AM@resortedpagelist,}%
2780 \edef\AM@resorteddoclist{\AM@resorteddoclist,\AM@phantomdoc}%
2781 \fi
2782 \else
2783 \ifnum\@tempcnta<\@tempcntb
2784 \AM@getfirst{\AM@lastndocs}%
2785 \edef\AM@firstdocitem{\the\toks@}%
2786 \AM@getfirst{\AM@lastnpages}%
2787 \edef\AM@resortedpagelist{\AM@resortedpagelist,\the\toks@}%
2788 \edef\AM@resorteddoclist{\AM@resorteddoclist,\AM@firstdocitem}%
2789 \else
2790 \edef\AM@resortedpagelist{\AM@resortedpagelist,}%
2791 \edef\AM@resorteddoclist{\AM@resorteddoclist,\AM@phantomdoc}%
2792 \fi
2793 \fi
2794 \@tempcnta=\AM@ynupi\relax
2795 \advance\@tempcnta\@ne
2796 \edef\AM@ynupi{\the\@tempcnta}%
2797 \@tempcntb=\AM@ynup\relax
2798 \ifnum\@tempcnta>\@tempcntb
2799 \@tempcntb=\AM@xnupi\relax
2800 \advance\@tempcntb\@ne
2801 \edef\AM@xnupi{\the\@tempcntb}%
2802 \def\AM@ynupi{\@ne}%
2803 \@tempcnta=\AM@xnup\relax
2804 \ifnum\@tempcntb>\@tempcnta
2805 \setboolean{AM@resort@end}{true}%
2806 \fi
2807 \fi
2808 }%
2809 \edef\AM@resortedpagelist{\expandafter\@gobble\AM@resortedpagelist}%
2810 \edef\AM@resorteddoclist{\expandafter\@gobble\AM@resorteddoclist}%
2811 }
2812 % \end{macrocode}
2813 % \macro{\AM@split@options}
2814 % \macro{\AM@split@optionsi}
2815 % \macro{\AM@split@oprionsii}
2816 % Extracts options from the options list (|#2|) depending
2817 % on the namespace (|#1|). Possible values for |#1| are:
2818 % |pdfpages| (options concerning pdfpages), |Gin| (options
2819 % concerning graphicx) and |Gin@noscale| (options concerning
2820 % graphicx, omitting the |scale| options). The extracted options
2821 % are stored in |@temptokena|.
2822 % \begin{macrocode}
2823 \newif\ifAM@pdfpages@options
2824 \newcommand{\AM@split@options}{}
2825 \def\AM@split@options#1#2{%
2826 \def\AM@param{#1}%
2827 \def\AM@scale@factor{1}%
2828 \@temptokena{}%
2829 \AM@split@optionsi#2,\END,
2830 }
2831 % \end{macrocode}
2832 % \begin{macrocode}
2833 \def\AM@split@optionsi#1,{%
2834 \ifx\END#1
2835 \else
2836 \AM@pdfpages@optionsfalse \AM@scalefalse
2837 \AM@split@optionsii#1=\END
2838 \ifthenelse{\equal{\AM@param}{pdfpages}}
2839 {\ifAM@pdfpages@options
2840 \@temptokena\expandafter{\the\@temptokena,#1}%
2841 \fi}{}%
2842 \ifthenelse{\equal{\AM@param}{Gin}}
2843 {\ifAM@pdfpages@options\else
2844 \@temptokena\expandafter{\the\@temptokena,#1}%
2845 \fi}{}%
2846 \ifthenelse{\equal{\AM@param}{Gin@noscale}}
2847 {\ifAM@pdfpages@options\else
2848 \ifAM@scale\else
2849 \@temptokena\expandafter{\the\@temptokena,#1}%
2850 \fi
2851 \fi}{}%
2852 \expandafter\AM@split@optionsi
2853 \fi
2854 }
2855 % \end{macrocode}
2856 % \begin{macrocode}
2857 \newcommand{\AM@split@optionsii}{}
2858 \def\AM@split@optionsii#1=#2\END{%
2859 \edef\AM@temp{\AM@trim@space{#1}}%
2860 \ifthenelse{\equal{page}{\AM@temp}\or
2861 \equal{pages}{\AM@temp}\or
2862 \equal{nup}{\AM@temp}\or
2863 \equal{deltax}{\AM@temp}\or
2864 \equal{deltay}{\AM@temp}\or
2865 \equal{delta}{\AM@temp}\or
2866 \equal{offset}{\AM@temp}\or
2867 \equal{frame}{\AM@temp}\or
2868 \equal{openright}{\AM@temp}\or
2869 \equal{openrighteach}{\AM@temp}\or
2870 \equal{pagecommand}{\AM@temp}\or
2871 \equal{pagecommand*}{\AM@temp}\or
2872 \equal{landscape}{\AM@temp}\or
2873 \equal{turn}{\AM@temp}\or
2874 \equal{column}{\AM@temp}\or
2875 \equal{columnstrict}{\AM@temp}\or
2876 \equal{noautoscale}{\AM@temp}\or
2877 \equal{thread}{\AM@temp}\or
2878 \equal{threadname}{\AM@temp}\or
2879 \equal{link}{\AM@temp}\or
2880 \equal{linkfit}{\AM@temp}\or
2881 \equal{linkname}{\AM@temp}\or
2882 \equal{linktodoc}{\AM@temp}\or
2883 \equal{linktodocfit}{\AM@temp}\or
2884 \equal{linkfilename}{\AM@temp}\or
2885 \equal{survey}{\AM@temp}\or
2886 \equal{survey-nolink}{\AM@temp}\or
2887 \equal{output}{\AM@temp}\or
2888 \equal{xr-prefix}{\AM@temp}\or
2889 \equal{fitpaper}{\AM@temp}\or
2890 \equal{addtotoc}{\AM@temp}\or
2891 \equal{addtolist}{\AM@temp}\or
2892 \equal{alt*}{\AM@temp}\or
2893 \equal{alt}{\AM@temp}\or
2894 \equal{artifact}{\AM@temp}\or
2895 \equal{doublepages}{\AM@temp}\or
2896 \equal{doublepagestwist}{\AM@temp}\or
2897 \equal{doublepagestwistodd}{\AM@temp}\or
2898 \equal{doublepagestwist*}{\AM@temp}\or
2899 \equal{doublepagestwistodd*}{\AM@temp}\or
2900 \equal{duplicatepages}{\AM@temp}\or
2901 \equal{signature}{\AM@temp}\or
2902 \equal{signature*}{\AM@temp}\or
2903 \equal{booklet}{\AM@temp}\or
2904 \equal{booklet*}{\AM@temp}\or
2905 \equal{flip-other-edge}{\AM@temp}\or
2906 \equal{pagetemplate}{\AM@temp}\or
2907 \equal{templatesize}{\AM@temp}\or
2908 \equal{rotateoversize}{\AM@temp}\or
2909 \equal{picturecommand}{\AM@temp}\or
2910 \equal{picturecommand*}{\AM@temp}\or
2911 \equal{newwindow}{\AM@temp}\or
2912 \equal{reflect}{\AM@temp}\or
2913 \equal{reflect*}{\AM@temp}\or
2914 \equal{lastpage}{\AM@temp}}
2915 {\AM@pdfpages@optionstrue}{}%
2916 \ifthenelse{\equal{scale}{\AM@temp}}{%
2917 \AM@scaletrue
2918 \def\AM@ooo##1={##1}%
2919 \setlength{\@tempdima}{\p@ * \AM@scale@factor * \real{\AM@ooo#2}}%
2920 \edef\AM@scale@factor{\strip@pt\@tempdima}%
2921 }{}%
2922 }
2923 % \end{macrocode}
2924 % \macro{\AM@trim@space}
2925 % \macro{\AM@trim@spacei}
2926 % \macro{\AM@trim@spaceii}
2927 % Removes leading and trailing spaces.
2928 % \begin{macrocode}
2929 \newcommand{\AM@trim@space}{}\newcommand{\AM@trim@spacei}{}
2930 \newcommand{\AM@trim@spaceii}{}
2931 \def\AM@trim@space#1{%
2932 \expandafter\AM@trim@spacei\expandafter{\ifdim\z@=0pt#1}\fi}
2933 \def\AM@trim@spacei#1{\AM@trim@spaceii#1 \END}
2934 \def\AM@trim@spaceii#1 #2\END{#1}
2935 % \end{macrocode}
2936 % \macro{\AM@trim@leadingspace}
2937 % Removes leading space.
2938 % \begin{macrocode}
2939 \DeclareRobustCommand{\AM@trim@leadingspace}[1]{\ifdim\z@=0pt#1\fi}
2940 % \end{macrocode}
2941 % \macro{\AM@isphantom}
2942 % Checks, if current page is an empty (phantom) page.
2943 % \begin{macrocode}
2944 \newif\ifAM@phantompage
2945 \newcommand*{\AM@isphantom}{%
2946 \expandafter\ifx\expandafter\\\AM@nextpage\\%
2947 \let\AM@nextpage\AM@phantompage
2948 \let\AM@ph\phantom
2949 \AM@phantompagetrue
2950 \else
2951 \let\AM@ph\relax
2952 \AM@phantompagefalse
2953 \fi
2954 }
2955 % \end{macrocode}
2956 % \macro{\AM@hyper@begin@i}
2957 % \macro{\AM@hyper@begin@ii}
2958 % \macro{\AM@hyper@end}
2959 % Add hypertext operations (targets, links and threads) to
2960 % the inserted pages.
2961 % \begin{macrocode}
2962 \newcommand{\AM@hyper@begin@i}{%
2963 % \end{macrocode}
2964 % Page is a target for a link.
2965 % \begin{macrocode}
2966 \ifAM@link \AM@dest@special\fi
2967 }
2968 % \end{macrocode}
2969 % \begin{macrocode}
2970 \newcommand{\AM@hyper@begin@ii}{%
2971 % \end{macrocode}
2972 % Survey linking to pages.\par
2973 % \begin{macrocode}
2974 \ifAM@survey \ifAM@surveynolink\else
2975 \AM@survey@special@begin
2976 \fi\fi
2977 % \end{macrocode}
2978 % Page is linked to the original document.\par
2979 % \begin{macrocode}
2980 \ifAM@linktodoc\AM@linktodoc@special@begin\fi
2981 % \end{macrocode}
2982 % Page is a bead in a thread.
2983 % \begin{macrocode}
2984 \ifAM@thread\AM@thread@special@begin\fi
2985 }
2986 % \end{macrocode}
2987 % \begin{macrocode}
2988 \newcommand{\AM@hyper@end}{%
2989 \ifAM@survey \ifAM@surveynolink\else
2990 \AM@survey@special@end
2991 \fi \fi
2992 \ifAM@linktodoc\AM@linktodoc@special@end\fi
2993 \ifAM@thread\AM@thread@special@end\fi
2994 }
2995 % \end{macrocode}
2996 % \macro{\AM@openright}
2997 % Insert an empty item at the beginning of |\AM@pagelist|.
2998 % \begin{macrocode}
2999 \newcommand{\AM@openright}{}
3000 \def\AM@openright{%
3001 \edef\AM@pagelist{,\AM@pagelist}%
3002 \edef\AM@doclist{\AM@phantomdoc,\AM@doclist}%
3003 }
3004 % \end{macrocode}
3005 % \macro{\AM@countpagelist}
3006 % \macro{\AM@countpagelisti}
3007 % Count items in |\AM@pagelist|. The number
3008 % of items is stored in |\@tempcnta|.
3009 % \begin{macrocode}
3010 \newcommand{\AM@countpagelist}{}
3011 \def\AM@countpagelist{%
3012 \@tempcnta=\z@
3013 \expandafter\AM@countpagelisti\AM@pagelist,\END,
3014 }
3015 % \end{macrocode}
3016 % \begin{macrocode}
3017 \newcommand{\AM@countpagelisti}{}
3018 \def\AM@countpagelisti#1,{%
3019 \ifx\END#1
3020 \else
3021 \advance\@tempcnta\@ne
3022 \expandafter\AM@countpagelisti
3023 \fi
3024 }
3025 % \end{macrocode}
3026 % \macro{\AM@filluppagelist}
3027 % The number of items in |\AM@pagelist| and
3028 % |\AM@doclist| should be a multiple of
3029 % $|\AM@xnup|\nobreak\times\nobreak|\AM@ynup|$.
3030 % If not, fill up the lists with empty items.
3031 % \begin{macrocode}
3032 \newcommand{\AM@filluppagelist}{}
3033 \def\AM@filluppagelist{%
3034 \@tempcnta=\AM@xnup\relax
3035 \@tempcntb=\AM@ynup\relax
3036 \multiply\@tempcnta\@tempcntb
3037 \edef\AM@nup{\the\@tempcnta}%
3038 \AM@countpagelist
3039 \@tempcntb=\@tempcnta
3040 \divide\@tempcntb\AM@nup
3041 \multiply\@tempcntb\AM@nup
3042 \advance\@tempcnta-\@tempcntb
3043 \ifnum\@tempcnta=\z@
3044 \else
3045 \advance\@tempcnta-\AM@nup
3046 \multiply\@tempcnta\m@ne
3047 \fi
3048 \whiledo{\@tempcnta > \z@}{%
3049 \let\saveAM@pagelist\AM@pagelist
3050 \edef\AM@pagelist{\saveAM@pagelist,}%
3051 \advance\@tempcnta\m@ne
3052 \let\saveAM@doclist\AM@doclist
3053 \edef\AM@doclist{\saveAM@doclist,\AM@phantomdoc}%
3054 }%
3055 }
3056 % \end{macrocode}
3057 % \macro{\AM@prepare@signature}
3058 % Sort the pages in order to create signatures.
3059 % \begin{macrocode}
3060 \newcommand{\AM@prepare@signature}{}
3061 \def\AM@prepare@signature{%
3062 \def\AM@newpagelist{}%
3063 \def\AM@newdoclist{}%
3064 % \end{macrocode}
3065 % Calculate value of |\AM@signature| for option |booklet|.
3066 % \begin{macrocode}
3067 \ifAM@booklet
3068 \AM@countpagelist
3069 \@tempcntb=\@tempcnta
3070 \divide\@tempcnta by 4
3071 \multiply\@tempcnta by 4
3072 \advance\@tempcntb-\@tempcnta
3073 \ifnum\@tempcntb=0\else \advance\@tempcnta by 4\fi
3074 \edef\AM@signature{\the\@tempcnta}%
3075 \fi
3076 % \end{macrocode}
3077 % Make |\AM@signature| a multiply of 4.
3078 % \begin{macrocode}
3079 \@tempcnta=\AM@signature\relax
3080 \divide\@tempcnta by 4
3081 \multiply\@tempcnta by 4
3082 \ifnum\@tempcnta=0\@tempcnta=4\fi
3083 \edef\AM@signature{\the\@tempcnta}%
3084 % \end{macrocode}
3085 % Make |\AM@pagelist| and |\AM@doclist| contain a multiply
3086 % of |\AM@signature| items. (Similar to |\AM@filluppagelist|.)
3087 % \begin{macrocode}
3088 \AM@countpagelist
3089 \count@=\@tempcnta
3090 \@tempcntb=\AM@signature\relax
3091 \divide\count@\@tempcntb
3092 \multiply\count@\@tempcntb
3093 \advance\@tempcnta-\count@
3094 \ifnum\@tempcnta=0 \@tempcntb=0
3095 \else\advance\@tempcntb-\@tempcnta
3096 \fi
3097 \whiledo{\@tempcntb>\z@}{%
3098 \edef\AM@pagelist{\AM@pagelist,}%
3099 \edef\AM@doclist{\AM@doclist,\AM@phantomdoc}%
3100 \advance\@tempcntb\m@ne
3101 }%
3102 % \end{macrocode}
3103 % Now sort the pages.
3104 % \begin{macrocode}
3105 \def\AM@sort{%
3106 \def\AM@sigpagelist{}%
3107 \def\AM@sigdoclist{}%
3108 \AM@split@firstn{\AM@pagelist}{\AM@signature}%
3109 \AM@split@firstn{\AM@doclist}{\AM@signature}%
3110 \def\AM@first{%
3111 \AM@getfirst{\AM@pagelist@firstn}%
3112 \edef\AM@sigpagelist{\AM@sigpagelist,\the\toks@}%
3113 \AM@getfirst{\AM@doclist@firstn}%
3114 \edef\AM@sigdoclist{\AM@sigdoclist,\the\toks@}%
3115 }%
3116 \def\AM@last{%
3117 \AM@getfirst{\AM@pagelist@lastn}%
3118 \edef\AM@sigpagelist{\AM@sigpagelist,\the\toks@}%
3119 \AM@getfirst{\AM@doclist@lastn}%
3120 \edef\AM@sigdoclist{\AM@sigdoclist,\the\toks@}%
3121 }%
3122 \@tempcnta=\z@
3123 \@tempcntb=\AM@signature\relax
3124 \whiledo{\@tempcnta<\@tempcntb}{%
3125 \ifAM@landscape
3126 \ifAM@signaturestar
3127 \ifAM@swap@flip@edge
3128 \AM@last\AM@first\AM@last\AM@first
3129 \else
3130 \AM@first\AM@last\AM@last\AM@first
3131 \fi
3132 \else
3133 \ifAM@swap@flip@edge
3134 \AM@first\AM@last\AM@first\AM@last
3135 \else
3136 \AM@last\AM@first\AM@first\AM@last
3137 \fi
3138 \fi
3139 \else
3140 \ifAM@signaturestar
3141 \ifAM@swap@flip@edge
3142 \AM@last\AM@first\AM@last\AM@first
3143 \else
3144 \AM@first\AM@last\AM@last\AM@first
3145 \fi
3146 \else
3147 \ifAM@swap@flip@edge
3148 \AM@first\AM@last\AM@first\AM@last
3149 \else
3150 \AM@last\AM@first\AM@first\AM@last
3151 \fi
3152 \fi
3153 \fi
3154 \advance\@tempcnta by 4
3155 }%
3156 \edef\AM@newpagelist{\AM@newpagelist\AM@sigpagelist}%
3157 \edef\AM@newdoclist{\AM@newdoclist\AM@sigdoclist}%
3158 \ifx\AM@pagelist\@empty
3159 \else\expandafter\AM@sort
3160 \fi
3161 }%
3162 \AM@sort
3163 \edef\AM@pagelist{\expandafter\@gobble\AM@newpagelist}%
3164 \edef\AM@doclist{\expandafter\@gobble\AM@newdoclist}%
3165 % \end{macrocode}
3166 % \begin{macrocode}
3167 \AM@pagesize@boogie
3168 \ifnum\AM@xnup=1\relax
3169 \ifnum\AM@ynup=1\relax
3170 \ifdim\AM@pagewidth<\AM@pageheight
3171 \def\AM@xnup{1}\def\AM@ynup{2}%
3172 \else
3173 \def\AM@xnup{2}\def\AM@ynup{1}%
3174 \fi
3175 \PackageWarningNoLine{pdfpages}{%
3176 Option `nup' not set correctly. \MessageBreak
3177 I will continue with `nup=\AM@xnup x\AM@ynup'. Please remember\MessageBreak
3178 to set `nup' correctly when using `\ifAM@booklet booklet\else signature\fi'}
3179 \fi
3180 \fi
3181 }
3182 % \end{macrocode}
3183 % \macro{\AM@setphantom}
3184 % \macro{\AM@setphantompage}
3185 % \macro{\AM@setphantomdoc}
3186 % The box measures of the phantom page are used to create
3187 % empty pages. |\AM@phantomdoc| is the name and
3188 % |\AM@phantompage| is the page number of the phantom page.
3189 % \begin{macrocode}
3190 \newcommand*{\AM@setphantom}{%
3191 \@ifundefined{AM@pagetemplate}
3192 {\expandafter\AM@setphantompage\AM@pagelist,\END,}
3193 {\edef\AM@phantompage{\AM@pagetemplate}}%
3194 \expandafter\AM@setphantomdoc\AM@doclist,\END
3195 }
3196 % \end{macrocode}
3197 % \begin{macrocode}
3198 \newcommand{\AM@setphantompage}{}
3199 \def\AM@setphantompage#1,{%
3200 \def\AM@gobble##1\END,{}%
3201 \ifx\\#1\\%
3202 \expandafter\AM@setphantompage
3203 \else
3204 \def\AM@phantompage{#1}%
3205 \expandafter\AM@gobble
3206 \fi
3207 }
3208 % \end{macrocode}
3209 % \begin{macrocode}
3210 \newcommand{\AM@setphantomdoc}{}
3211 \def\AM@setphantomdoc#1,#2\END{\edef\AM@phantomdoc{#1}}
3212 % \end{macrocode}
3213 % \macro{\AM@addtotoc}
3214 % \macro{\AM@parse@toclist}
3215 % \macro{\AM@parse@toclisti}
3216 % \macro{\AM@rm@from@toclist}
3217 % \macro{\AM@rm@from@toclisti}
3218 % These macros add entries to the table of contents (toc).
3219 %
3220 % |\AM@parse@addtotoc| reads the next entries from the list
3221 % |\AM@toclist| and prepares some macros (|\AM@toc@page|,
3222 % |\AM@toc@section|, etc.), which are used by |\AM@addtotoc|.
3223 %
3224 % The list |\AM@toclist| is a comma separated list and must
3225 % contain a multiple of five entries, which there are:
3226 % \meta{page number}, \meta{section}, \meta{level},
3227 % \meta{heading} and \meta{label}.
3228 % \meta{section} is e.g., `chapter', `section', `subsection', etc.
3229 % and \meta{level} is a number, denoting depth of section e.g.,
3230 % chapter=0, section=1, etc.
3231 % \begin{macrocode}
3232 \newcommand{\AM@addtotoc@hook}{\relax}
3233 \newcommand{\AM@addtotoc}{}
3234 \def\AM@addtotoc{%
3235 \begingroup
3236 \def\@seccntformat##1{}\def\@makechapterhead##1{}%
3237 \def\@endpart{}\def\partname{}%
3238 \def\autodot{}% KOMA classes
3239 \edef\ch@pt@c{\the\AM@toc@title}% memoir classes
3240 \let\AM@addcontentsline\addcontentsline
3241 \def\addcontentsline##1##2##3{%
3242 \AM@addcontentsline{##1}{##2}{##3}%
3243 \def\thepart{}}%
3244 \AM@addtotoc@hook
3245 \edef\AM@temp{{\AM@toc@section}{\AM@toc@level}%
3246 {\z@}{\z@}{\z@}{}[\the\AM@toc@title]{}}%
3247 \edef\AM@tempi{\leavevmode\noexpand\csname @\AM@toc@section\noexpand\endcsname%
3248 [\the\AM@toc@title]{}}%
3249 \@ifundefined{@\AM@toc@section}
3250 {\expandafter\@sect\AM@temp
3251 \hskip\z@\par\vskip-\parskip\vskip-\baselineskip\hskip\z@}
3252 {\AM@tempi}%
3253 \xdef\@currentlabel{\@currentlabel}%
3254 \label{\AM@toc@label}%
3255 \endgroup
3256 }
3257 % \end{macrocode}
3258 % \begin{macrocode}
3259 \newcommand{\AM@parse@toclist}{}
3260 \def\AM@parse@toclist{%
3261 \ifx\AM@toclist\empty \def\AM@toc@page{0}%
3262 \else \expandafter\AM@parse@toclisti\AM@toclist\END
3263 \fi
3264 }
3265 % \end{macrocode}
3266 % \begin{macrocode}
3267 \newtoks\AM@toc@title
3268 \newcommand{\AM@parse@toclisti}{}
3269 \def\AM@parse@toclisti#1,#2,#3,#4,#5,#6\END{%
3270 \edef\AM@toc@page{\AM@trim@space{#1}}%
3271 \edef\AM@toc@section{\AM@trim@space{#2}}%
3272 \edef\AM@toc@level{\AM@trim@space{#3}}%
3273 \AM@toc@title{\ignorespaces #4}%
3274 \edef\AM@toc@label{\AM@trim@space{#5}}%
3275 \AM@checkinteger{\AM@toc@page}%
3276 \ifAM@integer\else
3277 \PackageError{pdfpages}
3278 {Missing number.\MessageBreak
3279 Page number in option `addtotoc' is not a number}
3280 {See the pdfpages manual for explanation.}%
3281 \fi
3282 }
3283 % \end{macrocode}
3284 % \begin{macrocode}
3285 \newcommand{\AM@rm@from@toclist}{}
3286 \def\AM@rm@from@toclist{%
3287 \expandafter\AM@rm@from@toclisti\AM@toclist\END
3288 }
3289 % \end{macrocode}
3290 % \begin{macrocode}
3291 \newcommand{\AM@rm@from@toclisti}{}
3292 \def\AM@rm@from@toclisti#1,#2,#3,#4,#5,#6\END{%
3293 \def\AM@toclist{#6}%
3294 }
3295 % \end{macrocode}
3296 % \macro{\AM@addtolist}
3297 % \macro{\AM@parse@loflist}
3298 % \macro{\AM@parse@loflisti}
3299 % \macro{\AM@rm@from@loflist}
3300 % \macro{\AM@rm@from@loflisti}
3301 % These macros add entries to the list of figures (lof),
3302 % the list of tables (lot) or any other list.
3303 %
3304 % |\AM@loflist| is a comma separated list similar to
3305 % |\AM@toclist|, which must contain the entries:
3306 % \meta{page number}, \meta{figure}, \meta{heading} and
3307 % \meta{label}.
3308 % \begin{macrocode}
3309 \newcommand{\AM@addtolist@hook}{\relax}
3310 \newcommand{\AM@addtolist}{}
3311 \def\AM@addtolist{%
3312 \def\@captype{\AM@lof@list}%
3313 \long\def\@makecaption##1##2{}%
3314 \def\@fs@capt##1##2{}% float.sty
3315 \edef\@currentlabelname{\the\AM@lof@heading}% float.sty
3316 \AM@addtolist@hook
3317 \@ifundefined{hyper@@anchor}{%
3318 \expandafter\caption\expandafter{\the\AM@lof@heading}%
3319 }{%
3320 \hyper@makecurrent{\@captype}%
3321 \expandafter\caption\expandafter{\the\AM@lof@heading}%
3322 \hyper@@anchor{\@currentHref}{\relax}%
3323 \let\Hy@float@currentHref\@undefined
3324 }%
3325 \label{\AM@lof@label}%
3326 \vskip-\baselineskip
3327 }
3328 % \end{macrocode}
3329 % \begin{macrocode}
3330 \newcommand{\AM@parse@loflist}{}
3331 \def\AM@parse@loflist{%
3332 \ifx\AM@loflist\empty \def\AM@lof@page{0}%
3333 \else \expandafter\AM@parse@loflisti\AM@loflist\END
3334 \fi
3335 }
3336 % \end{macrocode}
3337 % \begin{macrocode}
3338 \newtoks\AM@lof@heading
3339 \newcommand{\AM@parse@loflisti}{}
3340 \def\AM@parse@loflisti#1,#2,#3,#4,#5\END{%
3341 \edef\AM@lof@page{\AM@trim@space{#1}}%
3342 \edef\AM@lof@list{\AM@trim@space{#2}}%
3343 \AM@lof@heading{#3}%
3344 \edef\AM@lof@label{\AM@trim@space{#4}}%
3345 \AM@checkinteger{\AM@lof@page}%
3346 \ifAM@integer\else
3347 \PackageError{pdfpages}
3348 {Missing number.\MessageBreak
3349 Page number in option `addtolist' is not a number}
3350 {See the pdfpages manual for explanation.}%
3351 \fi
3352 }
3353 % \end{macrocode}
3354 % \begin{macrocode}
3355 \newcommand{\AM@rm@fromloflist}{}
3356 \def\AM@rm@from@loflist{%
3357 \expandafter\AM@rm@from@loflisti\AM@loflist\END
3358 }
3359 % \end{macrocode}
3360 % \begin{macrocode}
3361 \newcommand{\AM@rm@from@loflisti}{}
3362 \def\AM@rm@from@loflisti#1,#2,#3,#4,#5\END{%
3363 \def\AM@loflist{#5}%
3364 }
3365 % \end{macrocode}
3366 % \macro{\AM@toclof}
3367 % \begin{macrocode}
3368 \newcommand{\AM@toclof}{}
3369 \def\AM@toclof#1{%
3370 \ifAM@phantompage
3371 \else
3372 \AM@parse@toclist
3373 \whiledo{#1=\AM@toc@page}{%
3374 \ifx\AM@toclist\empty
3375 \else
3376 \AM@addtotoc
3377 \AM@rm@from@toclist
3378 \def\AM@toc@page{0}%
3379 \AM@parse@toclist
3380 \fi
3381 }%
3382 \AM@parse@loflist
3383 \whiledo{#1=\AM@lof@page}{%
3384 \ifx\AM@loflist\empty
3385 \else
3386 \AM@addtolist
3387 \AM@rm@from@loflist
3388 \def\AM@lof@page{0}%
3389 \AM@parse@loflist
3390 \fi
3391 }%
3392 \fi
3393 }
3394 % \end{macrocode}
3395 % \macro{\AM@set@alt}
3396 % Set alternative text from |alt|, |alt*|, or default text.
3397 % \begin{macrocode}
3398 \newcommand\AM@set@alt{}
3399 \def\AM@set@alt{%
3400 \def\AM@alt@text{}%
3401 \AM@parse@altlist
3402 \ifnum\AM@page=\AM@alt@next@page
3403 \def\AM@alt@star{true}
3404 \let\AM@alt@text\AM@alt@next@text
3405 \AM@rm@from@altlist
3406 \else
3407 \def\AM@alt@star{false}
3408 \ifdefined\AM@alt@single
3409 \let\AM@alt@text\AM@alt@single
3410 \else
3411 \def\AM@alt@text{File \FileName}%
3412 \fi
3413 \fi
3414 }
3415 % \end{macrocode}
3416 % \begin{macrocode}
3417 \newcommand\AM@parse@altlist{}
3418 \def\AM@parse@altlist{%
3419 \ifx\AM@altlist\empty
3420 \def\AM@alt@next@page{0}%
3421 \else
3422 \expandafter\AM@parse@altlist@i\AM@altlist\END
3423 \fi
3424 }
3425 % \end{macrocode}
3426 % Read the next 2 entries from |\AM@altlist| and store them in
3427 % |\AM@alt@next@page| and |\AM@alt@next@text|.
3428 % \begin{macrocode}
3429 \newcommand\AM@parse@altlist@i{}
3430 \def\AM@parse@altlist@i#1,#2,#3\END{%
3431 \edef\AM@alt@next@page{\AM@trim@space{#1}}%
3432 \edef\AM@alt@next@text{\ifdim\z@=0pt#2\fi}%
3433 \AM@checkinteger{\AM@alt@next@page}
3434 \ifAM@integer\else
3435 \PackageError{pdfpages}{%
3436 Missing number.\MessageBreak
3437 Page number in option `alt*` is not a number}{%
3438 See the pdfpages manual for more information.}%
3439 \fi
3440 }
3441 \newcommand\AM@rm@from@altlist{}
3442 \def\AM@rm@from@altlist{%
3443 \expandafter\AM@rm@from@altlist@i\AM@altlist\END
3444 }
3445 \newcommand\AM@rm@from@altlist@i{}
3446 \def\AM@rm@from@altlist@i#1,#2,#3\END{%
3447 \def\AM@altlist{#3}%
3448 }
3449 % \end{macrocode}
3450 % \macro{\AM@set@artifact}
3451 % Set |\ifAM@artifact|.
3452 % \begin{macrocode}
3453 \def\AM@set@artifact{%
3454 \def\AM@true{true}
3455 \ifdefined\AM@key@artifact
3456 \ifx\AM@key@artifact\AM@true
3457 \AM@artifacttrue
3458 \else
3459 \AM@artifactfalse
3460 \fi
3461 \else
3462 \ifx\AM@alt@star\AM@true
3463 \AM@artifactfalse
3464 \else
3465 \ifAM@firstpage
3466 \AM@artifactfalse
3467 \else
3468 \AM@artifacttrue
3469 \fi
3470 \fi
3471 \fi
3472 \def\AM@tmp{\Artifact}%
3473 \ifx\AM@alt@text\AM@tmp
3474 \AM@artifacttrue
3475 \fi
3476 }
3477 % \end{macrocode}
3478 % \macro{\AM@AddToSurvey}
3479 % Add page to survey.
3480 % \begin{macrocode}
3481 \ifAM@pkg@survey
3482 \newcommand{\AddToSurvey}{%
3483 \protected@write\@auxout{\let\AM@abs@page\relax}
3484 {\string\newlabel{\AM@xrprefix pdfpages@page\the\c@AM@survey}%
3485 {{}{\AM@abs@page}}}%
3486 \stepcounter{AM@survey}%
3487 }%
3488 \let\r@TotalPages\undefined
3489 \else
3490 \newcommand{\AddToSurvey}{}
3491 \fi
3492 % \end{macrocode}
3493 % \begin{macrocode}
3494 \newcounter{AM@survey}
3495 % \end{macrocode}
3496 % |count1to.sty| saves the absolute page number in |\count1|.
3497 % \begin{macrocode}
3498 \def\AM@abs@page{\the\count1}
3499 % \end{macrocode}
3500 % \macro{\AM@pageref}
3501 % |\AM@pageref| expands to a page number (and nothing more).
3502 % \begin{macrocode}
3503 \newcommand{\AM@pageref}{}
3504 \newcommand{\AM@@pageref}{}
3505 \newcommand{\AM@secondarg}{}
3506 \def\AM@pageref#1{\expandafter\AM@@pageref\csname r@#1\endcsname}
3507 \def\AM@@pageref#1{\expandafter\AM@secondarg#1\@nil}
3508 \def\AM@secondarg#1#2#3\@nil{#2}
3509 % \end{macrocode}
3510 % Make |\AddToSurvey| work within TeXpower's |\stepwise|.
3511 % \begin{macrocode}
3512 \def\AM@TeXpower@hook{%
3513 \ifAM@pkg@survey
3514 \@ifpackageloaded{texpower}{%
3515 \releasecounter{AM@survey}%
3516 \let\AM@SetLabel\relax
3517 \g@addto@macro\do@insert@firstanchor@TP{%
3518 \AM@SetLabel\AM@SetTarget}%
3519 \g@addto@macro\dont@insert@firstanchor@TP{%
3520 \AM@SetLabel\AM@SetTarget}%
3521 \let\AM@setanchor\relax
3522 \def\AM@SetTarget{%
3523 \begingroup
3524 \advance\count1\m@ne
3525 \AM@anchor@special
3526 \endgroup
3527 }%
3528 \let\OrigAddToSurvey\AddToSurvey
3529 \def\AddToSurvey{%
3530 \ifthenelse{\boolean{instepwise@TP}}
3531 {\ifthenelse{\boolean{firstactivation}}{\AM@AddLabel}{}}
3532 {\AM@AddLabel}%
3533 }%
3534 \def\AM@AddLabel{\global\let\AM@SetLabel\OrigAddToSurvey
3535 \AtShipout{\AM@KillLabel}}%
3536 \def\AM@KillLabel{\global\let\AM@SetLabel\relax}%
3537 }{}%
3538 \fi
3539 }
3540 \AtBeginDocument{\AM@TeXpower@hook}
3541 % \end{macrocode}
3542 % \begin{macrocode}
3543 \def\AM@CheckValue#1#2{%
3544 \ifx\\#2\\\PackageError{pdfpages}
3545 {Option `#1' must have a non-empty value}{}%
3546 \fi
3547 }
3548 % \end{macrocode}
3549 % \subsection{Options of \texttt{\protect\bslash includepdf}}
3550 % \begin{macrocode}
3551 \define@key{pdfpages}{page}{\PackageWarningNoLine{pdfpages}{%
3552 Option `page' is unknow to \string\includepdf.\MessageBreak
3553 Did you mean `pages'? (Note the `s'!)\MessageBreak
3554 OK, I'll proceed as if it were `pages'}%
3555 \AM@CheckValue{pages}{#1}%
3556 \def\AM@pagestemp{#1}}
3557 \define@key{pdfpages}{pages}{\AM@CheckValue{pages}{#1}%
3558 \edef\AM@pagestemp{#1}}
3559 \define@key{pdfpages}{nup}{\expandafter\AM@parse@nup\expanded{#1}x\END}
3560 \define@key{pdfpages}{deltax}{\expandafter\AM@parse@deltax\expanded{#1} \\}
3561 \define@key{pdfpages}{deltay}{\expandafter\AM@parse@deltay\expanded{#1} \\}
3562 \define@key{pdfpages}{delta}{\expandafter\AM@parse@delta\expanded{#1} \\}
3563 \define@key{pdfpages}{offset}{\expandafter\AM@parse@offset\expanded{#1} \\}
3564 \define@key{pdfpages}{frame}[true]{\setboolean{AM@frame}{#1}}
3565 \define@key{pdfpages}{openright}[true]{\setboolean{AM@openright}{#1}}
3566 \define@key{pdfpages}{openrighteach}[true]{\setboolean{AM@openrighteach}{#1}}
3567 \define@key{pdfpages}{pagecommand}{\def\AM@pagecommand{#1}}
3568 \define@key{pdfpages}{pagecommand*}{\def\AM@pagecommandstar{#1}}
3569 \define@key{pdfpages}{landscape}[true]{\setboolean{AM@landscape}{#1}}
3570 \define@key{pdfpages}{turn}[true]{\setboolean{AM@turn}{#1}}
3571 \define@key{pdfpages}{column}[true]{\setboolean{AM@column}{#1}}
3572 \define@key{pdfpages}{columnstrict}[true]%
3573 {\setboolean{AM@columnstrict}{#1}}
3574 \define@key{pdfpages}{noautoscale}[true]%
3575 {\setboolean{AM@noautoscale}{#1}}
3576 \define@key{pdfpages}{thread}[true]{\setboolean{AM@thread}{#1}}
3577 \define@key{pdfpages}{threadname}{\edef\AM@threadname{#1}}
3578 \define@key{pdfpages}{link}[true]{\setboolean{AM@link}{#1}}
3579 \define@key{pdfpages}{linkfit}{\expandafter\AM@convert@dest\expanded{{#1}}}
3580 \define@key{pdfpages}{linkname}{\edef\AM@linkname@option{#1}}
3581 \define@key{pdfpages}{linktodoc}[true]{\setboolean{AM@linktodoc}{#1}}
3582 \define@key{pdfpages}{linktodocfit}{\edef\AM@linktodocfit{#1}}
3583 \define@key{pdfpages}{linkfilename}{\pdfstringdef\AM@linkfilename{#1}%
3584 \AM@linkfilenametrue}
3585 \define@key{pdfpages}{survey}[true]{%
3586 \ifAM@pkg@survey\setboolean{AM@survey}{#1}%
3587 \else\AM@outputfalse\fi}
3588 \define@key{pdfpages}{survey-nolink}[true]{%
3589 \ifAM@pkg@survey\setboolean{AM@surveynolink}{#1}%
3590 \setboolean{AM@survey}{#1}
3591 \else\AM@outputfalse\fi}
3592 \define@key{pdfpages}{xr-prefix}{\edef\AM@xrprefix{#1}}
3593 \define@key{pdfpages}{fitpaper}[true]{\setboolean{AM@fitpaper}{#1}}
3594 \define@key{pdfpages}{addtotoc}{\protected@edef\AM@toclist{#1,}}
3595 \define@key{pdfpages}{addtolist}{\protected@edef\AM@loflist{#1,}}
3596 \define@key{pdfpages}{alt}{\protected@edef\AM@alt@single{#1}}
3597 \define@key{pdfpages}{alt*}{\protected@edef\AM@altlist{#1,}}
3598 \define@key{pdfpages}{artifact}[true]{\protected@edef\AM@key@artifact{#1}}
3599 \define@key{pdfpages}{doublepages}[true]%
3600 {\setboolean{AM@doublepages}{#1}}
3601 \define@key{pdfpages}{doublepagestwist}[true]%
3602 {\setboolean{AM@doublepages}{#1}%
3603 \setboolean{AM@doublepagestwist}{#1}%
3604 \AM@doublepagestmptrue\AM@doublepagestmpitrue}
3605 \define@key{pdfpages}{doublepagestwistodd}[true]%
3606 {\setboolean{AM@doublepages}{#1}%
3607 \setboolean{AM@doublepagestwist}{#1}%
3608 \AM@doublepagestmpfalse\AM@doublepagestmpitrue}
3609 \define@key{pdfpages}{doublepagestwist*}[true]%
3610 {\setboolean{AM@doublepages}{#1}%
3611 \setboolean{AM@doublepagestwist}{#1}%
3612 \AM@doublepagestmptrue\AM@doublepagestmpitrue
3613 \AM@doublepagestwistxtrue}
3614 \define@key{pdfpages}{doublepagestwistodd*}[true]%
3615 {\setboolean{AM@doublepages}{#1}%
3616 \setboolean{AM@doublepagestwist}{#1}%
3617 \AM@doublepagestmpfalse\AM@doublepagestmpitrue
3618 \AM@doublepagestwistxtrue}
3619 \define@key{pdfpages}{duplicatepages}[2]%
3620 {\edef\AM@nduplicatepages{#1}%
3621 \AM@duplicatepagestrue}
3622 \define@key{pdfpages}{signature}{\edef\AM@signature{#1}}
3623 \define@key{pdfpages}{signature*}{\edef\AM@signature{#1}%
3624 \AM@signaturestartrue}
3625 \define@key{pdfpages}{booklet}[true]{
3626 \setboolean{AM@booklet}{#1}%
3627 \ifAM@booklet
3628 \def\AM@signature{non-empty}
3629 \fi}
3630 \define@key{pdfpages}{booklet*}[true]{
3631 \ifstrequal{#1}{true}{%
3632 \setboolean{AM@booklet}{#1}
3633 \ifAM@booklet
3634 \def\AM@signature{non-empty}
3635 \AM@signaturestartrue
3636 \fi}}
3637 \define@key{pdfpages}{flip-other-edge}[true]{\setboolean{AM@swap@flip@edge}{#1}}
3638 \define@key{pdfpages}{pagetemplate}{\AM@CheckValue{pagetemplate}{#1}%
3639 \def\AM@pagetemplate{#1}}
3640 \define@key{pdfpages}{templatesize}{\expandafter\AM@parse@templatesize\expanded{#1}\END}
3641 \define@key{pdfpages}{rotateoversize}[true]%
3642 {\setboolean{AM@rotateoversize}{#1}}
3643 \define@key{pdfpages}{picturecommand}{\def\AM@picturecommand{#1}}
3644 \define@key{pdfpages}{picturecommand*}{\def\AM@picturecommandstar{#1}}
3645 \define@key{pdfpages}{newwindow}[true]{\setboolean{AM@newwindow}{#1}}
3646 \define@key{pdfpages}{reflect*}[true]{\setboolean{AM@reflect}{#1}}
3647 \define@key{pdfpages}{reflect}[true]{\setboolean{AM@reflectall}{#1}}
3648 \define@key{pdfpages}{lastpage}{\edef\AM@pagecount{#1}}
3649 % \end{macrocode}
3650 % \macro{\AM@parse@nup}
3651 % Parsing \texttt{nup} item.
3652 % \begin{macrocode}
3653 \newcommand{\AM@parse@nup}{}
3654 \def\AM@parse@nup#1x#2\END{%
3655 \ifx\\#2\\%
3656 \def\AM@shortnupsyntax{}%
3657 \def\AM@xnup{\@ne}%
3658 \def\AM@ynup{\@ne}%
3659 \ifnum#1=\tw@
3660 \def\AM@xnup{\tw@}%
3661 \def\AM@ynup{\@ne}%
3662 \fi
3663 \ifnum#1=4
3664 \def\AM@xnup{\tw@}%
3665 \def\AM@ynup{\tw@}%
3666 \fi
3667 \else
3668 \def\AM@xnup{#1}%
3669 \AM@parse@nupi#2%
3670 \fi
3671 }
3672 \def\AM@parse@nupi#1x{\def\AM@ynup{#1}}
3673 % \end{macrocode}
3674 % \macro{\AM@parse@templatesize}
3675 % Parsing \texttt{templatesize} item.
3676 % \begin{macrocode}
3677 \newcommand{\AM@parse@templatesize}{}
3678 \def\AM@parse@templatesize#1#2\END{%
3679 \setbox\AM@templatesizebox=\hbox{\rule{#1}{#2}}%
3680 \AM@templatesizetrue
3681 }
3682 \newbox\AM@templatesizebox
3683 \newif\ifAM@templatesize\AM@templatesizefalse
3684 % \end{macrocode}
3685 % \macro{\AM@parse@deltax}
3686 % \macro{\AM@parse@deltay}
3687 % \macro{\AM@parse@offset}
3688 % Parsing arguments. These lines are derived
3689 % from \texttt{graphicx.sty}.
3690 % \begin{macrocode}
3691 \def\AM@parse@deltax#1 #2\\{\AMGin@defaultbp\AM@deltax{#1}}
3692 % \end{macrocode}
3693 % \begin{macrocode}
3694 \def\AM@parse@deltay#1 #2\\{\AMGin@defaultbp\AM@deltay{#1}}
3695 % \end{macrocode}
3696 % \begin{macrocode}
3697 \def\AM@parse@delta#1 #2 #3\\{%
3698 \AMGin@defaultbp\AM@deltax{#1}%
3699 \AMGin@defaultbp\AM@deltay{#2}}
3700 % \end{macrocode}
3701 % \begin{macrocode}
3702 \def\AM@parse@offset#1 #2 #3\\{%
3703 \AMGin@defaultbp\AM@xoffset{#1}%
3704 \AMGin@defaultbp\AM@yoffset{#2}}
3705 % \end{macrocode}
3706 % \begin{macrocode}
3707 \def\AMGin@defaultbp#1#2{%
3708 \afterassignment\AMGin@def@bp\dimen@#2bp\relax{#1}{#2}}
3709 % \end{macrocode}
3710 % \begin{macrocode}
3711 \def\AMGin@def@bp#1\relax#2#3{%
3712 \if!#1!%
3713 \def#2{#3bp}%
3714 \else
3715 \[email protected]\dimen@
3716 \edef#2{\strip@pt\dimen@ bp}%
3717 \fi
3718 }
3719 % \end{macrocode}
3720 % Multiplication of \#1 by 1000.
3721 % Used to calculate the zoom factor (destination XYZ) for pdftex and luatex.
3722 % \begin{macrocode}
3723 \def\AM@thousand#1{\AM@thousand@i#1.0000.\END}
3724 \def\AM@thousand@i#1.#2.#3\END{\AM@thousand@ii#1.#2#3\END}
3725 \def\AM@thousand@ii#1.#2#3#4#5#6\END{#1#2#3#4}
3726 % \end{macrocode}
3727 % Load patch file, if one exists.
3728 % \begin{macrocode}
3729 \InputIfFileExists{pdfpages.fix}{%
3730 \PackageInfo{pdfpages}{Loading patch file `pdfpages.fix'}}{}
3731 % \end{macrocode}
3732 %
3733 %
3734 % \iffalse
3735 %</package>
3736 % \fi
3737 %
3738 % \subsection{Driver files}
3739 %
3740 % \subsubsection{\pdfTeX\ and \luaTeX\ drivers}
3741 %
3742 % The driver file for \pdfTeX\ and \luaTeX\ are mostly the same.
3743 % So far they only differ in checking of the version numbers of
3744 % the \TeX-engines and graphicx driver files.
3745 %
3746 % Check \pdfTeX\ version.
3747 % \begin{macrocode}
3748 %<*pppdftexdef>
3749 \ifnum\pdftexversion<100
3750 \PackageError{pdfpages}
3751 {Package pdfpages requires at least\MessageBreak
3752 pdfTeX version 1.00}
3753 {Update your TeX distribution.}%
3754 \let\AM@endinput\relax
3755 \expandafter\endinput
3756 \fi
3757 %</pppdftexdef>
3758 % \end{macrocode}
3759 % Starting with LuaTeX 0.85 quite a few primitives have been renamed
3760 % and/or removed. To cope with these changes we have to provide both
3761 % primitive names depending on which version we are running.
3762 % \begin{macrocode}
3763 %<*(pppdftexdef,ppluatexdef)>
3764 %<*ppluatexdef>
3765 \ifnum\luatexversion<85
3766 %</ppluatexdef>
3767 \let\AM@outputmode\pdfoutput
3768 \let\AM@saveimageresource\pdfximage
3769 \let\AM@lastsavedimageresourcepages\pdflastximagepages
3770 \let\AM@luatexpagewidth\pdfpagewidth
3771 \let\AM@luatexpageheight\pdfpageheight
3772 \let\AM@annotation\pdfannot
3773 \let\AM@thread\pdfthread
3774 \let\AM@destination\pdfdest
3775 %<*ppluatexdef>
3776 \else
3777 \let\AM@outputmode\outputmode
3778 \let\AM@saveimageresource\saveimageresource
3779 \let\AM@lastsavedimageresourcepages\lastsavedimageresourcepages
3780 \let\AM@luatexpagewidth\pagewidth
3781 \let\AM@luatexpageheight\pageheight
3782 \protected\def\AM@annotation {\pdfextension annot }%
3783 \protected\def\AM@thread {\pdfextension thread }%
3784 \protected\def\AM@destination {\pdfextension dest }%
3785 \fi
3786 %</ppluatexdef>
3787 %</(pppdftexdef,ppluatexdef)>
3788 % \end{macrocode}
3789 % Insert dummy driver |ppnull.def| if we are not running in PDF mode.
3790 % \begin{macrocode}
3791 %<*pppdftexdef>
3792 \ifcase\pdfoutput
3793 \input{ppnull.def}
3794 \expandafter\endinput
3795 \fi
3796 %</pppdftexdef>
3797 %<*ppluatexdef>
3798 \ifcase\AM@outputmode
3799 \input{ppnull.def}
3800 \expandafter\endinput
3801 \fi
3802
3803 %</ppluatexdef>
3804 % \end{macrocode}
3805 % Check if the graphics package was loaded with an
3806 % incompatible driver option (e.g. dvips).
3807 % \begin{macrocode}
3808 %<*pppdftexdef>
3809 \begingroup
3810 \@ifundefined{[email protected]}{%
3811 \PackageError{pdfpages}
3812 {The graphics package was loaded with driver\MessageBreak
3813 `\Gin@driver', which cannot be used with pdfTeX}
3814 {Check the driver option of the graphics package.}
3815 \global\let\AM@endinput\relax
3816 \aftergroup\endinput}{}
3817 \endgroup
3818 % \end{macrocode}
3819 % Check for \texttt{pdftex.def} version \texttt{2000/05/12 v0.02u}
3820 % or higher:
3821 % \begin{list}{$\ast$}{\versionlist}
3822 % \makeatletter\@beginparpenalty=10000\makeatother
3823 % \item support for multipage \PDF\ files, option `page' added (HO).
3824 % \end{list}
3825 % \begin{macrocode}
3826 \AM@ifdriverlater{pdftex}{2000/05/12}{}{%
3827 \PackageError{pdfpages}
3828 {Your version of `pdftex.def' is too old.\MessageBreak
3829 There is no multipage support\MessageBreak
3830 in `pdftex.def' < 0.02u}
3831 {Please, update your `pdftex.def'!}}
3832 % \end{macrocode}
3833 % Check for \texttt{pdftex.def} version \texttt{2000/09/14 v0.03d}
3834 % or higher:
3835 % \begin{list}{$\ast$}{\versionlist}
3836 % \makeatletter\@beginparpenalty=10000\makeatother
3837 % \item Fixes for `viewport' and `trim' (HO).
3838 % \item Clip support added for viewport and trim (HO).
3839 % \end{list}
3840 % \begin{macrocode}
3841 \AM@ifdriverlater{pdftex}{2000/09/14}{}{%
3842 \PackageWarningNoLine{pdfpages}{%
3843 Your version of `pdftex.def' is too old.\MessageBreak
3844 There might be problems with\MessageBreak
3845 the `trim' and `clip' options.\MessageBreak
3846 Please, update your `pdftex.def'}}
3847 %</pppdftexdef>
3848 % \end{macrocode}
3849 %
3850 % Get last page number.
3851 %
3852 % \noindent
3853 % Note: Do not use |\pdfximage| directly. This compromises packages which
3854 % manipulate the input path of graphicx.sty.
3855 %
3856 % Unfortunately, |\pdflastximagepages| is not updated if |\includegraphics|
3857 % is used repeatedly on the same file. Heiko is aware of this and will provide
3858 % a solution in pdftex.def. Until then we will use the original graphicx's filename
3859 % from |\Gread@@pdftex|.
3860 %
3861 % \def\AM@getpagecount{%
3862 % \setbox\@tempboxa=\hbox{\includegraphics{\AM@currentdocname}}%
3863 % \edef\AM@pagecount{\the\AM@lastsavedimageresourcepages}%
3864 % }
3865 %
3866 % \begin{macrocode}
3867 %<*(pppdftexdef,ppluatexdef)>
3868 \let\AM@Gread@@pdftex\Gread@@pdftex
3869 \renewcommand*{\Gread@@pdftex}[1]{%
3870 \xdef\AM@currentdocname@fix{#1}%
3871 \AM@Gread@@pdftex{#1}%
3872 }
3873 \def\AM@getpagecount{%
3874 \setbox\@tempboxa=\hbox{\includegraphics{\AM@currentdocname}}%
3875 \AM@saveimageresource{\AM@currentdocname@fix}%
3876 \edef\AM@pagecount{\the\AM@lastsavedimageresourcepages}%
3877 }
3878 % \end{macrocode}
3879 % Page dimensions.
3880 % \begin{macrocode}
3881 \def\AM@getpagedimen{%
3882 \AM@pagewidth=\paperwidth
3883 \AM@pageheight=\paperheight
3884 }
3885 \def\AM@setpagedimen{%
3886 \AM@luatexpagewidth\AM@pagewidth
3887 \AM@luatexpageheight\AM@pageheight
3888 }
3889 \let\AM@pagesize@boogie\relax
3890 % \end{macrocode}
3891 % Change paper size.
3892 % \begin{macrocode}
3893 \let\AM@fitpaper@special\relax
3894 % \end{macrocode}
3895 % Find file.
3896 %
3897 % Package grffile.sty is a dummy package nowadays, and |\grffile@IfFileExists|
3898 % doesn't exists anymore. (21.11.2019)
3899 % \begin{macrocode}
3900 \def\AM@findfile#1{%
3901 \AM@findfile@i{#1}{pdf}%
3902 \AM@findfile@ii{#1}%
3903 }
3904 \AtBeginDocument{%
3905 \let\AM@IfFileExists\IfFileExists
3906 \@ifpackageloaded{grffile}{%
3907 \@ifundefined{grffile@IfFileExists}{}{%
3908 \let\AM@IfFileExists\grffile@IfFileExists}%
3909 }{}%
3910 }
3911 % \end{macrocode}
3912 % Rotate page.
3913 % Use new pdfmanagement macros if available, and fallback to pdflscape
3914 % if they are not available.
3915 % \begin{macrocode}
3916 \ExplSyntaxOn
3917 \@ifundefined{pdfmanagement_add:nnn}{%
3918 \def\AM@setRotate{\PLS@Rotate{90}}%
3919 \def\AM@resetRotate{\PLS@Rotate{0}}%
3920 }{%
3921 \def\AM@setRotate{\pdfmanagement_add:nnn{ThisPage}{Rotate}{90}}%
3922 \def\AM@resetRotate{}%
3923 }%
3924 \ExplSyntaxOff
3925 % \end{macrocode}
3926 % Link to original document.
3927 % \begin{macrocode}
3928 \def\AM@linktodoc@special@begin{%
3929 \AM@annotation width \wd\@tempboxa
3930 height \ht\@tempboxa
3931 depth \dp\@tempboxa
3932 {/Subtype /Link /Border [0 0 0]
3933 /A << /S /GoToR
3934 /F (\AM@linkfilename)
3935 /D [\AM@linktodoc@page@m@ne \AM@linktodocfit]
3936 \ifAM@newwindow/NewWindow true\fi >>}%
3937 }
3938 \let\AM@linktodoc@special@end\relax
3939 % \end{macrocode}
3940 % Survey.
3941 % \begin{macrocode}
3942 \def\AM@survey@special@begin{%
3943 \AM@annotation width \wd\@tempboxa
3944 height \ht\@tempboxa
3945 depth \dp\@tempboxa
3946 {/Subtype /Link /Border [0 0 0]
3947 /A << /S /GoTo
3948 /D (pdfpages.\AM@linktodoc@page@m@ne) >>}%
3949 }
3950 \let\AM@survey@special@end\relax
3951 % \end{macrocode}
3952 % Thread.
3953 % \begin{macrocode}
3954 \def\AM@thread@special@begin{%
3955 \AM@thread width \wd\@tempboxa
3956 height \ht\@tempboxa
3957 depth \dp\@tempboxa
3958 attr {/I <<\threadinfodict>>}%
3959 name {\AM@threadname}%
3960 }
3961 \let\AM@thread@special@end\relax
3962 % \end{macrocode}
3963 % Destination of links.
3964 % \begin{macrocode}
3965 \def\AM@reset@view{%
3966 \def\AM@view{fit}%
3967 \def\AM@view@xpos{0}%
3968 \def\AM@view@ypos{}}
3969 \def\AM@dest@special{\AM@destination name {\AM@linkname.\AM@page} \AM@view}
3970 \def\AM@anchor@special{\AM@destination name {pdfpages.\the\count1} fit}
3971 % \end{macrocode}
3972 % Convert synatx of \PDF\ destinations.
3973 % \pdfTeX\ does not support positional parameters to |fith| etc.
3974 % \begin{macrocode}
3975 \def\AM@convert@dest#1{%
3976 \AM@convert@dest@i #1 0 0 0\END}
3977 \def\AM@convert@dest@i#1 #2 #3 #4\END{%
3978 \def\tag{#1}%
3979 \def\x{FitH}%
3980 \ifx\x\tag
3981 \def\AM@view{fith}%
3982 \def\AM@view@ypos{#2}%
3983 \else
3984 \def\x{FitBH}%
3985 \ifx\x\tag
3986 \def\AM@view{fitbh}%
3987 \def\AM@view@ypos{#2}%
3988 \else
3989 \def\x{FitV}%
3990 \ifx\x\tag
3991 \def\AM@view{fitv}%
3992 \def\AM@view@xpos{#2}%
3993 \else
3994 \def\x{FitBV}%
3995 \ifx\x\tag
3996 \def\AM@view{fitbv}%
3997 \def\AM@view@xpos{#2}%
3998 \else
3999 \def\x{FitR}%
4000 \ifx\x\tag
4001 \def\AM@view{fitr}%
4002 \PackageWarningNoLine{pdfpages}{%
4003 `linkfit=FitR' is not supported,
4004 I will try `linkfit=Region'.}%
4005 \def\tag{region}%
4006 \else
4007 \def\x{FitB}%
4008 \ifx\x\tag
4009 \def\AM@view{fitb}%
4010 \else
4011 \def\x{XYZ}%
4012 \ifx\x\tag
4013 \def\AM@view{xyz zoom \AM@thousand{#4}}%
4014 \def\AM@view@xpos{#2}
4015 \def\AM@view@ypos{#3}
4016 \else
4017 \def\x{Region}%
4018 \ifx\x\tag
4019 \def\AM@view{fitr
4020 width \the\wd\@tempboxa
4021 height \the\ht\@tempboxa
4022 depth \the\dp\@tempboxa}%
4023 \else
4024 \def\AM@view{fit}%
4025 \fi
4026 \fi
4027 \fi
4028 \fi
4029 \fi
4030 \fi
4031 \fi
4032 \fi
4033 }
4034 % \end{macrocode}
4035 % Do not disable |\includegraphics|.
4036 % \begin{macrocode}
4037 \let\AM@disable@includegraphics\relax
4038 % \end{macrocode}
4039 %
4040 % \iffalse
4041 %</(pppdftexdef,ppluatexdef)>
4042 %
4043 %<*ppvtexdef>
4044 % \fi
4045 %
4046 % \subsubsection{\VTeX\ driver}
4047 %
4048 % Check if the graphics package was loaded with an
4049 % incompatible driver option (e.g. dvips).
4050 % \begin{macrocode}
4051 \begingroup
4052 \@ifundefined{[email protected]}{%
4053 \PackageError{pdfpages}
4054 {The graphics package was loaded with driver\MessageBreak
4055 `\Gin@driver', which cannot be used with VTeX}
4056 {Check the driver option of the graphics package.}%
4057 \global\let\AM@endinput\relax
4058 \aftergroup\endinput}{}
4059 \endgroup
4060 % \end{macrocode}
4061 % Check \VTeX\ version.
4062 % \begin{macrocode}
4063 \ifnum\VTeXversion<822
4064 \PackageError{pdfpages}
4065 {Package pdfpages requires at least\MessageBreak
4066 VTeX version 8.22}
4067 {Update your VTeX distribution.}%
4068 \let\AM@endinput\relax
4069 \fi
4070 % \end{macrocode}
4071 % Check |vtex.def| version.
4072 % \begin{macrocode}
4073 \AM@ifdriverlater{vtex}{2003/06/16}{}{%
4074 \PackageError{pdfpages}{%
4075 Your version of `vtex.def' is too old}
4076 {Please, update your `vtex.def'!}%
4077 \let\AM@endinput\relax
4078 \expandafter\endinput
4079 }
4080 % \end{macrocode}
4081 % Get last page number.
4082 % \begin{macrocode}
4083 \def\AM@getpagecount{%
4084 \getpagecount\count@ \AM@currentdocname\relax
4085 \edef\AM@pagecount{\the\count@}%
4086 }
4087 % \end{macrocode}
4088 % Page dimensions.
4089 % \begin{macrocode}
4090 \def\AM@getpagedimen{%
4091 \AM@pagewidth=\mediawidth
4092 \AM@pageheight=\mediaheight
4093 }
4094 \def\AM@setpagedimen{%
4095 \mediawidth\AM@pagewidth
4096 \mediaheight\AM@pageheight
4097 }
4098 \let\AM@pagesize@boogie\relax
4099 % \end{macrocode}
4100 % Rotate page.
4101 % Use new pdfmanagement macros if available, and fallback to pdflscape
4102 % if they are not available.
4103 % \begin{macrocode}
4104 \def\AM@setRotate{\special{pS:
4105 [{ThisPage}\string<\string</Rotate 90\string>\string>%]
4106 /PUT pdfmark}%
4107 }
4108 \def\AM@resetRotate{}
4109 % \end{macrocode}
4110 % Change paper size.
4111 % \begin{macrocode}
4112 \def\AM@fitpaper@special{%
4113 \immediate\xspecial{option updatemediasizes="on"}}
4114 % \end{macrocode}
4115 % Find file.
4116 % \begin{macrocode}
4117 \def\AM@findfile#1{%
4118 \AM@findfile@i{#1}{pdf}%
4119 \ifx\AM@currentdocname\relax
4120 \AM@findfile@i{#1}{ps}%
4121 \fi
4122 \AM@findfile@ii{#1}%
4123 }
4124 \let\AM@IfFileExists\IfFileExists
4125 % \end{macrocode}
4126 % Link to original document.
4127 % \begin{macrocode}
4128 \def\AM@linktodoc@special@begin{%
4129 \special{!aref <\ifAM@newwindow n\fi
4130 f=\AM@linkfilename>!\AM@linktodoc@page;
4131 a=</Border [0 0 0]>}%
4132 }
4133 \def\AM@linktodoc@special@end{%
4134 \special{!endaref}%
4135 }
4136 % \end{macrocode}
4137 % Survey.
4138 % \begin{macrocode}
4139 \def\AM@survey@special@begin{%
4140 \special{!aref pdfpages.\AM@linktodoc@page@m@ne;
4141 a=</Border [0 0 0]>}%
4142 }
4143 \def\AM@survey@special@end{%
4144 \special{!endaref}%
4145 }
4146 % \end{macrocode}
4147 % Thread.
4148 % \begin{macrocode}
4149 \def\AM@thread@special@begin{%
4150 \special{!thread <\threadinfodict> \AM@threadname}%
4151 }
4152 \def\AM@thread@special@end{\special{!endthread}}
4153 % \end{macrocode}
4154 % Destination of links.
4155 % \begin{macrocode}
4156 \def\AM@reset@view{%
4157 \def\AM@view{}%
4158 \def\AM@view@xpos{0}%
4159 \def\AM@view@ypos{}}
4160 \def\AM@dest@special{\special{!aname \AM@linkname.\AM@page}}
4161 \def\AM@anchor@special{\special{!aname pdfpages.\the\count1}}
4162 % \end{macrocode}
4163 % Convert synatx of \PDF\ destinations.
4164 % \begin{macrocode}
4165 \def\AM@convert@dest#1{}
4166 % \end{macrocode}
4167 % Do not disable |\includegraphics|.
4168 % \begin{macrocode}
4169 \let\AM@disable@includegraphics\relax
4170 % \end{macrocode}
4171 %
4172 % \iffalse
4173 %</ppvtexdef>
4174 %
4175 %<*ppxetexdef>
4176 % \fi
4177 %
4178 % \subsubsection{\XeTeX\ driver}
4179 %
4180 % Check if the graphics package was loaded with an
4181 % incompatible driver option (e.g. dvips).
4182 % \begin{macrocode}
4183 \begingroup
4184 \@ifundefined{[email protected]}{%
4185 \PackageError{pdfpages}
4186 {The graphics package was loaded with driver\MessageBreak
4187 `\Gin@driver', which cannot be used with XeTeX}
4188 {Check the driver option of the graphics package.}
4189 \global\let\AM@endinput\relax
4190 \aftergroup\endinput}{}
4191 \endgroup
4192 % \end{macrocode}
4193 % Packages like ngerman.sty make " with catcode 11 active. So let's
4194 % use " with catcode 12 to delimit arguments.
4195 % \begin{macrocode}
4196 {\catcode`\"=12
4197 \gdef\AM@XeTeXquote{"}%
4198 }
4199 % \end{macrocode}
4200 % Get last page number. |\XeTeXpdfpagecount| is only defined
4201 % for |pdf| files. For all other file types |\AM@pagecount|
4202 % must be set to |1| explicitely.
4203 %
4204 % \noindent
4205 % Note: |import.sty| imports tex-files from sub-directories, allowing
4206 % these tex-files to use e.g. |\includegraphics|. However, this does not
4207 % work out of the box for pdfpages with XeTeX-driver (as it does with
4208 % pdftex-driver). We have to use |\import@path| of |import.sty|.
4209 %
4210 % Oups: |Subfiles.sty| uses |\import@path| as well. But we shall \emph{not}
4211 % use |\import@path| in combination with |subfiles.sty|. Let's use macro |\subfix|
4212 % to check for |subfiles.sty|.
4213 % \begin{macrocode}
4214 \def\AM@getpagecount{%
4215 \expandafter\filename@parse\expandafter{\AM@currentdocname}%
4216 \begingroup\edef\x{%
4217 \lowercase{\endgroup
4218 \def\noexpand\type@ext{\expandafter\scantokens\expandafter{\filename@ext\noexpand}}}}%
4219 \x
4220 \ifx\type@ext\AM@pdf@ext
4221 \ifdefined\subfix
4222 \let\AM@import@path\@empty
4223 \else
4224 \ifdefined\import@path
4225 \let\AM@import@path\import@path
4226 \else
4227 \let\AM@import@path\@empty
4228 \fi
4229 \fi
4230 \setbox\@tempboxa=\hbox{\includegraphics{\AM@currentdocname}}%
4231 \edef\AM@pagecount{\the\XeTeXpdfpagecount\AM@XeTeXquote
4232 \AM@import@path\AM@currentdocname\AM@XeTeXquote\relax}%
4233 \else
4234 \def\AM@pagecount{1}%
4235 \fi
4236 }
4237 \def\AM@pdf@ext{pdf}
4238 % \end{macrocode}
4239 % |\XeTeXversion| has changed from time to time: 0.997, 0.997-dev,
4240 % 0.998.1
4241 % \begin{macrocode}
4242 \begingroup
4243 \def\gobble@nil#1\@nil{}
4244 \ifnum\XeTeXversion=0
4245 \afterassignment\gobble@nil
4246 \count@\expandafter\@gobble\XeTeXrevision.\@nil
4247 \ifnum\count@<997
4248 \PackageError{pdfpages}
4249 {Package pdfpages requires at least XeTeX-0.997}
4250 {Update your TeX distribution!}
4251 \global\let\AM@endinput\relax
4252 \aftergroup\endinput
4253 \fi
4254 \fi
4255 \endgroup
4256 % \end{macrocode}
4257 % Page dimensions.
4258 % \begin{macrocode}
4259 \def\AM@getpagedimen{%
4260 \AM@pagewidth=\paperwidth
4261 \AM@pageheight=\paperheight
4262 }
4263 \def\AM@setpagedimen{%
4264 \pdfpagewidth\AM@pagewidth
4265 \pdfpageheight\AM@pageheight
4266 }
4267 \def\AM@pagesize@boogie{%
4268 \ifdim\AM@pagewidth=\z@
4269 \ifdim\AM@pageheight=\z@
4270 \let\AM@pagewidth\paperwidth
4271 \let\AM@pageheight\paperheight
4272 \fi
4273 \fi
4274 }
4275 % \end{macrocode}
4276 % Change paper size.
4277 % \begin{macrocode}
4278 \let\AM@fitpaper@special\relax
4279 % \end{macrocode}
4280 % Find file.
4281 % \begin{macrocode}
4282 \def\AM@findfile#1{%
4283 \AM@findfile@i{#1}{pdf}%
4284 \AM@findfile@ii{#1}%
4285 }
4286 \long\def\AM@IfFileExists#1#2#3{%
4287 \openin\@inputcheck=\AM@XeTeXquote#1\AM@XeTeXquote\relax
4288 \ifeof\@inputcheck
4289 \ifx\input@path\@undefined
4290 \def\reserved@a{#3}%
4291 \else
4292 \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
4293 \fi
4294 \else
4295 \closein\@inputcheck
4296 \edef\@filef@und{#1 }%
4297 \def\reserved@a{#2}%
4298 \fi
4299 \reserved@a}
4300 % \end{macrocode}
4301 % Rotate page.
4302 % \begin{macrocode}
4303 \ExplSyntaxOn
4304 \@ifundefined{pdfmanagement_add:nnn}{%
4305 \def\AM@setRotate{\PLS@Rotate{90}}%
4306 \def\AM@resetRotate{\PLS@Rotate{0}}%
4307 }{%
4308 \def\AM@setRotate{\pdfmanagement_add:nnn{ThisPage}{Rotate}{90}}%
4309 \def\AM@resetRotate{}%
4310 }%
4311 \ExplSyntaxOff
4312 % \end{macrocode}
4313 % Link to original document.
4314 % \begin{macrocode}
4315 \def\AM@linktodoc@special@begin{%
4316 \special{pdf: annot
4317 width \the\wd\@tempboxa\space
4318 height \the\ht\@tempboxa\space
4319 depth \the\dp\@tempboxa\space
4320 << /Type /Annot
4321 /Subtype /Link /Border [0 0 0]
4322 /A << /S /GoToR
4323 /F (\AM@linkfilename)
4324 /D [\AM@linktodoc@page@m@ne \AM@linktodocfit]
4325 \ifAM@newwindow/NewWindow true\fi >>
4326 >>}%
4327 }
4328 \let\AM@linktodoc@special@end\relax
4329 % \end{macrocode}
4330 % Survey.
4331 % \begin{macrocode}
4332 \def\AM@survey@special@begin{%
4333 \special{pdf: annot
4334 width \the\wd\@tempboxa\space
4335 height \the\ht\@tempboxa\space
4336 depth \the\dp\@tempboxa\space
4337 << /Type /Annot
4338 /Subtype /Link /Border [0 0 0]
4339 /A << /S /GoTo
4340 /D (pdfpages.\AM@linktodoc@page@m@ne) >>
4341 >>}%
4342 }
4343 \let\AM@survey@special@end\relax
4344 % \end{macrocode}
4345 % Thread.
4346 % \begin{macrocode}
4347 \def\AM@thread@special@begin{%
4348 \special{pdf: thread @\AM@threadname\space
4349 width \the\wd\@tempboxa\space
4350 height \the\ht\@tempboxa\space
4351 depth \the\dp\@tempboxa\space
4352 <<\threadinfodict>>
4353 }%
4354 }
4355 \let\AM@thread@special@end\relax
4356 % \end{macrocode}
4357 % Destination of links.
4358 % \begin{macrocode}
4359 \def\AM@reset@view{%
4360 \def\AM@view{/Fit}%
4361 \def\AM@view@xpos{0}%
4362 \def\AM@view@ypos{}}
4363 \def\AM@dest@special{%
4364 \special{pdf: dest (\AM@linkname.\AM@page) [ @thispage \AM@view ]}}
4365 \def\AM@anchor@special{%
4366 \special{pdf: dest (pdfpages.\the\count1) [ @thispage /Fit ]}}
4367 % \end{macrocode}
4368 % Convert synatx of \PDF\ destinations.
4369 % \begin{macrocode}
4370 \def\AM@convert@dest#1{%
4371 \AM@convert@dest@i #1 0 0 0\END}
4372 \def\AM@convert@dest@i#1 #2 #3 #4\END{%
4373 \def\tag{#1}%
4374 \def\x{FitH}%
4375 \ifx\x\tag
4376 \def\AM@view{/FitH @ypos}%
4377 \def\AM@view@ypos{#2}%
4378 \else
4379 \def\x{FitBH}%
4380 \ifx\x\tag
4381 \def\AM@view{/FitBH @ypos}%
4382 \def\AM@view@ypos{#2}%
4383 \else
4384 \def\x{FitV}%
4385 \ifx\x\tag
4386 \def\AM@view{/FitV @xpos}%
4387 \def\AM@view@xpos{#2}%
4388 \else
4389 \def\x{FitBV}%
4390 \ifx\x\tag
4391 \def\AM@view{/FitBV @xpos}%
4392 \def\AM@view@xpos{#2}%
4393 \else
4394 \def\x{fitr}%
4395 \ifx\x\tag
4396 \def\AM@view{/XYZ @xpos @ypos null}%
4397 \PackageWarningNoLine{pdfpages}{%
4398 `linkfit=FitR' is not supported.}%
4399 \else
4400 \def\x{FitB}%
4401 \ifx\x\tag
4402 \def\AM@view{/FitB}%
4403 \else
4404 \def\x{XYZ}%
4405 \ifx\x\tag
4406 \def\AM@view{/XYZ @xpos @ypos #4}%
4407 \def\AM@view@xpos{#2}%
4408 \def\AM@view@ypos{#3}%
4409 \else
4410 \def\x{Region}%
4411 \ifx\x\tag
4412 \def\AM@view{/XYZ @xpos @ypos null}%
4413 \PackageWarningNoLine{pdfpages}{%
4414 `linkfit=Region' is not supported by XeTeX.}%
4415 \else
4416 \def\AM@view{/Fit}%
4417 \fi
4418 \fi
4419 \fi
4420 \fi
4421 \fi
4422 \fi
4423 \fi
4424 \fi
4425 }
4426 % \end{macrocode}
4427 % Do not disable |\includegraphics|.
4428 % \begin{macrocode}
4429 \let\AM@disable@includegraphics\relax
4430 % \end{macrocode}
4431 %
4432 % \iffalse
4433 %</ppxetexdef>
4434 %
4435 %<*ppdvipsdef>
4436 % \fi
4437 %
4438 % \subsubsection{Dvips driver}
4439 %
4440 % \begin{macrocode}
4441 \def\AM@notsupported#1{%
4442 \PackageWarning{pdfpages}{#1 not supported by driver dvips}}
4443 % \end{macrocode}
4444 % Get last page number.
4445 % \begin{macrocode}
4446 \def\AM@getpagecount{%
4447 \ifx\AM@pagecount\AM@undefined
4448 \AM@notsupported{Page selections}
4449 \def\AM@pagecount{1}%
4450 \gdef\AM@getpagecount{%
4451 \def\AM@pagecount{1}%
4452 }%
4453 \fi
4454 }
4455 % \end{macrocode}
4456 % Page dimensions.
4457 % \begin{macrocode}
4458 \def\AM@getpagedimen{%
4459 \AM@pagewidth=\paperwidth
4460 \AM@pageheight=\paperheight
4461 }
4462 \def\AM@setpagedimen{%
4463 \paperwidth\AM@pagewidth
4464 \paperheight\AM@pageheight
4465 }
4466 \let\AM@pagesize@boogie\relax
4467 % \end{macrocode}
4468 % Rotate page.
4469 % \begin{macrocode}
4470 \def\AM@setRotate{\AM@notsupported{Page rotations}}
4471 \def\AM@resetRotate{}
4472 % \end{macrocode}
4473 % Change paper size.
4474 % \begin{macrocode}
4475 \def\AM@fitpaper@special{\AM@notsupported{Option fitpaper}}
4476 % \end{macrocode}
4477 % Find file.
4478 % \begin{macrocode}
4479 \def\AM@findfile#1{%
4480 \AM@findfile@i{#1}{eps}%
4481 \ifx\AM@currentdocname\relax
4482 \AM@findfile@i{#1}{ps}%
4483 \fi
4484 \AM@findfile@ii{#1}%
4485 }
4486 \let\AM@IfFileExists\IfFileExists
4487 % \end{macrocode}
4488 % Link to original document.
4489 % \begin{macrocode}
4490 \def\AM@linktodoc@special@begin{Links}
4491 \let\AM@linktodoc@special@end\relax
4492 % \end{macrocode}
4493 % Survey.
4494 % \begin{macrocode}
4495 \def\AM@survey@special@begin{\AM@notsupported{Option survey}}
4496 \let\AM@survey@special@end\relax
4497 % \end{macrocode}
4498 % Thread.
4499 % \begin{macrocode}
4500 \def\AM@thread@special@begin{\AM@notsupported{Option thread}}
4501 \let\AM@thread@special@end\relax
4502 % \end{macrocode}
4503 % Destination of links.
4504 % \begin{macrocode}
4505 \def\AM@reset@view{%
4506 \def\AM@view{}%
4507 \def\AM@view@xpos{0}%
4508 \def\AM@view@ypos{}}
4509 \def\AM@dest@special{\AM@notsupported{Links}}
4510 \def\AM@anchor@special{\AM@notsupported{Links}}
4511 % \end{macrocode}
4512 % Convert synatx of \PDF\ destinations.
4513 % \begin{macrocode}
4514 \def\AM@convert@dest#1{}
4515 % \end{macrocode}
4516 % Do not disable |\includegraphics|.
4517 % \begin{macrocode}
4518 \let\AM@disable@includegraphics\relax
4519 % \end{macrocode}
4520 % Add option page to |\includegraphics|.
4521 % \begin{macrocode}
4522 \@ifundefined{KV@Gin@page}{%
4523 \define@key{Gin}{page}{%
4524 \ifnum#1=1 %
4525 \else
4526 \PackageError{pdfpages}{%
4527 Multipage images are not supported by driver dvips%
4528 }\@ehc
4529 \fi
4530 }}{}
4531 % \end{macrocode}
4532 %
4533 % \iffalse
4534 %</ppdvipsdef>
4535 %
4536 %<*ppdvipdfmxdef>
4537 % \fi
4538 %
4539 % \subsubsection{Dvipdfmx driver}
4540 %
4541 % Driver |dvipdfmx| must be invoked explicitely by the user. There are
4542 % several ways to do this. Though only the first of the following ways is
4543 % recommended.
4544 %
4545 % \begin{itemize}
4546 % \item
4547 % This is the recommended way. PDF output as expected.
4548 % \begin{quote}
4549 % |\documentclass[a4paper,dvipdfmx]{article}|\\
4550 % |\usepackage{pdfpages}|
4551 % \end{quote}
4552 %
4553 % \item
4554 % Warning. Forcing dvipdfmx.def. PDF output as expected.
4555 % \begin{quote}
4556 % |\documentclass[a4paper]{article}|\\
4557 % |\usepackage[dvipdfmx]{pdfpages}|
4558 % \end{quote}
4559 %
4560 % \item
4561 % Assuming user wants to use dvips. Therefor pdfpages will just insert
4562 % empty pages.
4563 % \begin{quote}
4564 % |\documentclass[a4paper]{article}|\\
4565 % |\usepackage{pdfpages}|
4566 % \end{quote}
4567 % \end{itemize}
4568 %
4569 %
4570 % \noindent
4571 % Package |graphicx| should be loaded with the |dvipdfmx| driver.
4572 % However, \break |\RequirePackage[dvipdfmx]{graphicx}| is not recommended
4573 % because it will cause an `option clash' if a user loaded |graphicx|
4574 % with additional options previously. Thus, we expect the user to load
4575 % |graphicx| with |dvipdfmx| driver before loading pdfpages.
4576 % \begin{macrocode}
4577 \def\AM@tmp{dvipdfmx.def}
4578 \ifx\Gin@driver\AM@tmp\else
4579 \PackageWarningNoLine{pdfpages}{%
4580 Graphicx.sty not loaded with driver `dvipdfmx'.\MessageBreak
4581 Please, specify the driver as a class option\MessageBreak
4582 \@spaces \string\documentclass[dvipdfmx]{...}\MessageBreak
4583 or load graphicx explicitely before pdfpages,\MessageBreak
4584 e.g.:\MessageBreak
4585 \@spaces \string\usepackage[dvipdfmx]{graphicx}\MessageBreak
4586 \@spaces \string\usepackage[dvipdfmx]{pdfpages}\MessageBreak
4587 This time I will try to load `dvipdfmx.def' which \MessageBreak
4588 will overwrite `\string\Gin@driver'.\MessageBreak
4589 Let's hope for the best}%
4590 \input{dvipdfmx.def}%
4591 \fi
4592 % \end{macrocode}
4593 % Packages like ngerman.sty make " with catcode 11 active. So let's
4594 % use " with catcode 12 to delimit arguments.
4595 % \begin{macrocode}
4596 {\catcode`\"=12
4597 \gdef\AM@quote{"}%
4598 }%
4599 % \end{macrocode}
4600 % Get last page number.
4601 % This driver uses the external program |extractbb| to retrieve the total number
4602 % of pages. Many thanks to Noriyuki Abe who provided this code.
4603 % \begin{macrocode}
4604 \def\AM@getpagecount{%
4605 % \end{macrocode}
4606 % Try reading |.xbb| file if available.
4607 % \begin{macrocode}
4608 \ifAM@pagecount@updated
4609 \else
4610 \expandafter\expandafter\expandafter\AM@get@xbb@filename
4611 \csname Gin@[email protected]\endcsname\AM@currentdocname
4612 \immediate\openin\@inputcheck=\AM@xbb@filename
4613 \AM@read@xbb\@inputcheck
4614 \immediate\closein\@inputcheck
4615 \ifAM@pagecount@updated
4616 \PackageInfo{pdfpages}{Reading file `\AM@xbb@filename'}%
4617 \fi
4618 % \end{macrocode}
4619 % Try reading output of program |extractbb|.
4620 % \begin{macrocode}
4621 \ifAM@pagecount@updated
4622 \else
4623 \immediate\openin\@inputcheck=
4624 \AM@quote|extractbb -O \AM@currentdocname\AM@quote
4625 \AM@read@xbb\@inputcheck
4626 \immediate\closein\@inputcheck
4627 \PackageInfo{pdfpages}{Running extractbb on file `\AM@currentdocname'}%
4628 \fi
4629 \fi
4630 % \end{macrocode}
4631 % If all fails set number of pages to 1. Maybe it is a graphics file
4632 % like |jpg|, |png|, etc.
4633 % \begin{macrocode}
4634 \ifx\AM@pagecount\AM@undefined
4635 \def\AM@pagecount{1}
4636 \fi
4637 }
4638 % \end{macrocode}
4639 % Construct filename of |xbb| file.
4640 % |#1:{pdf}, #2:{.xbb}, #3:{file.pdf}|
4641 % \begin{macrocode}
4642 \def\AM@get@xbb@filename#1#2#3{%
4643 \filename@parse{#3}%
4644 \edef\AM@xbb@filename{\filename@area\filename@base#2}%
4645 }
4646 % \end{macrocode}
4647 % Read ouput of program |extractbb|.
4648 % \begin{macrocode}
4649 \def\AM@read@xbb#1{%
4650 \@tempswatrue
4651 \loop
4652 \ifeof#1
4653 \@tempswafalse
4654 \else
4655 \begingroup
4656 \catcode`\%=12\relax
4657 \immediate\global\read#1 to \@tempa
4658 \endgroup
4659 \expandafter\AM@find@pages\@tempa:\relax
4660 \fi
4661 \if@tempswa\repeat
4662 }
4663 % \end{macrocode}
4664 % Find string |%%Pages:|
4665 % \begin{macrocode}
4666 \long\def\AM@find@pages#1:#2\relax{%
4667 \def\@tempb{#1}%
4668 \edef\@tempc{\@percentchar\@percentchar Pages}%
4669 \ifx\@tempb\@tempc
4670 \AM@set@pagecount#2%
4671 \AM@pagecount@updatedtrue
4672 \fi
4673 }
4674 \def\AM@set@pagecount#1:{\def\AM@pagecount{#1}}
4675 % \end{macrocode}
4676 % Page dimensions.
4677 % \begin{macrocode}
4678 \def\AM@getpagedimen{%
4679 \AM@pagewidth=\paperwidth
4680 \AM@pageheight=\paperheight
4681 }
4682 \def\AM@setpagedimen{%
4683 \special{pdf:pagesize width \the\AM@pagewidth\space
4684 height \the\AM@pageheight\space}%
4685 }
4686 \def\AM@pagesize@boogie{%
4687 \ifdim\AM@pagewidth=\z@
4688 \ifdim\AM@pageheight=\z@
4689 \let\AM@pagewidth\paperwidth
4690 \let\AM@pageheight\paperheight
4691 \fi
4692 \fi
4693 }
4694 % \end{macrocode}
4695 % Rotate page.
4696 % \begin{macrocode}
4697 \def\AM@setRotate{\special{pdf: put @thispage <</Rotate 90>>}}%
4698 \def\AM@resetRotate{}
4699 % \end{macrocode}
4700 % Change paper size.
4701 % \begin{macrocode}
4702 \let\AM@fitpaper@special\relax
4703 % \end{macrocode}
4704 % Find file.
4705 % \begin{macrocode}
4706 \def\AM@findfile#1{%
4707 \AM@findfile@i{#1}{pdf}%
4708 \AM@findfile@ii{#1}%
4709 }
4710 \let\AM@IfFileExists\IfFileExists
4711 % \end{macrocode}
4712 % Link to original document.
4713 % \begin{macrocode}
4714 \def\AM@linktodoc@special@begin{%
4715 \special{pdf: ann
4716 width \the\wd\@tempboxa\space
4717 height \the\ht\@tempboxa\space
4718 depth \the\dp\@tempboxa\space
4719 << /Type /Annot
4720 /Subtype /Link /Border [0 0 0]
4721 /A << /S /GoToR
4722 /F (\AM@linkfilename)
4723 /D [\AM@linktodoc@page@m@ne \AM@linktodocfit]
4724 \ifAM@newwindow/NewWindow true\fi >>
4725 >>}%
4726 }
4727 \let\AM@linktodoc@special@end\relax
4728 % \end{macrocode}
4729 % Survey.
4730 % \begin{macrocode}
4731 \let\AM@survey@special@begin\relax
4732 \let\AM@survey@special@end\relax
4733 % \end{macrocode}
4734 % Thread.
4735 % \begin{macrocode}
4736 \def\AM@thread@special@begin{%
4737 \special{pdf: thread @\AM@threadname\space
4738 width \the\wd\@tempboxa\space
4739 height \the\ht\@tempboxa\space
4740 depth \the\dp\@tempboxa\space
4741 <<\threadinfodict>>}%
4742 }
4743 \let\AM@thread@special@end\relax
4744 % \end{macrocode}
4745 % Destination of links.
4746 % \begin{macrocode}
4747 \def\AM@reset@view{%
4748 \def\AM@view{/Fit}%
4749 \def\AM@view@xpos{0}%
4750 \def\AM@view@ypos{}}
4751 \def\AM@dest@special{%
4752 \special{pdf: dest (\AM@linkname.\AM@page) [ @thispage \AM@view ]}}
4753 \def\AM@anchor@special{%
4754 \special{pdf: dest (pdfpages.\the\count1) [ @thispage /Fit ]}}
4755 % \end{macrocode}
4756 % Convert synatx of \PDF\ destinations.
4757 % \begin{macrocode}
4758 \def\AM@convert@dest#1{%
4759 \expandafter\AM@convert@dest@i\ifdim\z@=0pt#1 \END\fi}
4760 \def\AM@convert@dest@i#1 #2\END{%
4761 \begingroup
4762 \def\tag{#1}%
4763 \def\x{FitH}%
4764 \ifx\x\tag
4765 \gdef\AM@view{/FitH @ypos}%
4766 \else
4767 \def\x{FitBH}%
4768 \ifx\x\tag
4769 \gdef\AM@view{/FitBH @ypos}%
4770 \else
4771 \def\x{FitV}%
4772 \ifx\x\tag
4773 \gdef\AM@view{/FitV @xpos}%
4774 \else
4775 \def\x{FitBV}%
4776 \ifx\x\tag
4777 \gdef\AM@view{/FitBV @xpos}%
4778 \else
4779 \def\x{fitr}%
4780 \ifx\x\tag
4781 \gdef\AM@view{/XYZ @xpos @ypos null}%
4782 \PackageWarningNoLine{pdfpages}{%
4783 `linkfit=FitR' is not supported.}%
4784 \else
4785 \def\x{FitB}%
4786 \ifx\x\tag
4787 \gdef\AM@view{/FitB}%
4788 \else
4789 \def\x{XYZ}%
4790 \ifx\x\tag
4791 \gdef\AM@view{/XYZ @xpos @ypos null}%
4792 \else
4793 \def\x{Region}%
4794 \ifx\x\tag
4795 \gdef\AM@view{/XYZ @xpos @ypos null}%
4796 \PackageWarningNoLine{pdfpages}{%
4797 `linkfit=Region' is not supported by dvipdfmx.}%
4798 \else
4799 \gdef\AM@view{/Fit}%
4800 \fi
4801 \fi
4802 \fi
4803 \fi
4804 \fi
4805 \fi
4806 \fi
4807 \fi
4808 \endgroup
4809 }
4810 % \end{macrocode}
4811 % Do not disable |\includegraphics|.
4812 % \begin{macrocode}
4813 \let\AM@disable@includegraphics\relax
4814 % \end{macrocode}
4815 %
4816 % \iffalse
4817 %</ppdvipdfmxdef>
4818 %
4819 %<*ppnulldef>
4820 % \fi
4821 %
4822 % \subsubsection{Null driver}
4823 % This is a dummy driver used when producing {\small DVI} output.
4824 %
4825 % \begin{macrocode}
4826 \AM@DVIoutputtrue
4827 \PackageWarningNoLine{pdfpages}{%
4828 I will use a dummy \string\includepdf\space command\MessageBreak
4829 which will insert empty pages instead of the actual\MessageBreak
4830 PDF file because we are running in \ifAM@pkg@demo `demo' mode%
4831 \else DVI mode or with\MessageBreak dvips driver%
4832 \fi}
4833 % \end{macrocode}
4834 % Find file: the file must not exist for this dummy driver. Let's just
4835 % set \cmd{\AM@currentdocname}.
4836 % \begin{macrocode}
4837 \def\AM@findfile#1{%
4838 \def\AM@currentdocname{#1}%
4839 }
4840 \let\AM@IfFileExists\IfFileExists
4841 % \end{macrocode}
4842 % Get last page number.
4843 % \begin{macrocode}
4844 \def\AM@getpagecount{%
4845 \ifx\AM@pagecount\AM@undefined
4846 \PackageWarningNoLine{pdfpages}{%
4847 I cannot determine the number of pages of the\MessageBreak
4848 included document, because we are running in\MessageBreak
4849 \ifAM@pkg@demo `demo' mode.
4850 \else DVI mode.
4851 \fi
4852 \MessageBreak
4853 You can use the option `lastpage' to give me a hint}%
4854 \edef\AM@pagecount{1}%
4855 \fi
4856 }
4857 % \end{macrocode}
4858 % Page dimensions.
4859 % \begin{macrocode}
4860 \def\AM@getpagedimen{%
4861 \AM@pagewidth=\paperwidth
4862 \AM@pageheight=\paperheight
4863 }
4864 \def\AM@setpagedimen{%
4865 \paperwidth\AM@pagewidth
4866 \paperheight\AM@pageheight
4867 }
4868 \let\AM@pagesize@boogie\relax
4869 % \end{macrocode}
4870 % Change paper size.
4871 % \begin{macrocode}
4872 \let\AM@fitpaper@special\relax
4873 % \end{macrocode}
4874 % Find file.
4875 % \begin{macrocode}
4876 \def\AM@findfile#1{%
4877 \def\AM@currentdocname{}%
4878 }
4879 % \end{macrocode}
4880 % Rotate page.
4881 % \begin{macrocode}
4882 \let\AM@setlscape\relax
4883 % \end{macrocode}
4884 % Link to original document.
4885 % \begin{macrocode}
4886 \let\AM@linktodoc@special@begin\relax
4887 \let\AM@linktodoc@special@end\relax
4888 % \end{macrocode}
4889 % Survey.
4890 % \begin{macrocode}
4891 \let\AM@survey@special@begin\relax
4892 \let\AM@survey@special@end\relax
4893 % \end{macrocode}
4894 % Thread.
4895 % \begin{macrocode}
4896 \let\AM@thread@special@begin\relax
4897 \let\AM@thread@special@end\relax
4898 % \end{macrocode}
4899 % Destination of links.
4900 % \begin{macrocode}
4901 \def\AM@reset@view{%
4902 \def\AM@view{}%
4903 \def\AM@view@xpos{0}%
4904 \def\AM@view@ypos{}}
4905 \let\AM@dest@special\relax
4906 \let\AM@anchor@special\relax
4907 % \end{macrocode}
4908 % Convert synatx of \PDF\ destinations.
4909 % \begin{macrocode}
4910 \def\AM@convert@dest#1{}
4911 % \end{macrocode}
4912 % Disable |\includegraphics|.
4913 % \begin{macrocode}
4914 \def\AM@disable@includegraphics{%
4915 \renewcommand\includegraphics[2][]{}%
4916 }
4917 % \end{macrocode}
4918 % Don't check page numbers.
4919 % \begin{macrocode}
4920 \newcommand*{\AM@checkpagenumber}[1]{}
4921 % \end{macrocode}
4922 %
4923 % \iffalse
4924 %</ppnulldef>
4925 % \fi
4926 %
4927 % \section{History}
4928 %
4929 % \subsection*{2001/01/17 v0.1b}
4930 % \begin{itemize}
4931 % \item The first released version.
4932 % \end{itemize}
4933 %
4934 % \subsection*{2001/02/03 v0.1c}
4935 % \begin{itemize}
4936 % \item Pages are being centered automatically.
4937 % \end{itemize}
4938 %
4939 % \subsection*{2001/03/16 v0.1f}
4940 % \begin{itemize}
4941 % \item Option |pages| added.
4942 % \end{itemize}
4943 %
4944 % \subsection*{2001/04/07 v0.1h}
4945 % \begin{itemize}
4946 % \item Hypertext operations added. (Hyperlinks, threads)
4947 % \end{itemize}
4948 %
4949 % \subsection*{2001/11/12 v0.2}
4950 % \begin{itemize}
4951 % \item Support of |m|$\times$|n| logical pages on each sheet of paper.
4952 % \item Options |column| and |columnstrict| added.
4953 % \item New command |\inlcudepdfmerge|.
4954 % \end{itemize}
4955 %
4956 % \subsection*{2001/12/26 v0.2c}
4957 % \begin{itemize}
4958 % \item Option |fitpaper| added.
4959 % \end{itemize}
4960 %
4961 % \subsection*{2001/03/31 v0.2g}
4962 % \begin{itemize}
4963 % \item Option |signature| added.
4964 % \item Options |addtotoc| and |addtolist| added.
4965 % \item Option |doublepages| added.
4966 % \item Options now have their own namespace |pdfpages| and do not extent
4967 % the |Gin| (graphicx) namespace any longer.
4968 % \end{itemize}
4969 %
4970 % \subsection*{2002/12/14 v0.2l}
4971 % \begin{itemize}
4972 % \item Survey functionality added.
4973 % \end{itemize}
4974 %
4975 % \subsection*{2003/06/02 v0.2m}
4976 % \begin{itemize}
4977 % \item Support of \PDF s with mixed portrait/landscape pages. Options
4978 % |pagetemplate| and |rotateoversize| added.
4979 % \item Support of |\graphicspath|.
4980 % \item Options |picturecommand| and |picturecommand*| added.
4981 % \item Reverse page order: |pages=7-3|, |pages=last-5|
4982 % \end{itemize}
4983 %
4984 % \subsection*{2003/06/21 v0.3a}
4985 % \begin{itemize}
4986 % \item Support of \VTeX.
4987 % \item Driver layer added. All driver specific macros are defined in
4988 % |.def| driver files.
4989 % \end{itemize}
4990 %
4991 % \subsection*{2003/07/16 v0.3b}
4992 % \begin{itemize}
4993 % \item Option |\doublepagestwist| added.
4994 % \end{itemize}
4995 %
4996 % \subsection*{2003/12/08 v0.3e}
4997 % \begin{itemize}
4998 % \item Option |reflect| added.
4999 % \item Made |\AddToSurvey| work within TeXpower's |\stepwise|.
5000 % \end{itemize}
5001 %
5002 % \subsection*{2004/02/21 v0.3f}
5003 % \begin{itemize}
5004 % \item Option |signature*| (right-edge binding) added.
5005 % \item Optimizations for a faster processing of signatures.
5006 % \end{itemize}
5007 %
5008 % \subsection*{2006/08/05 v0.4a}
5009 % \begin{itemize}
5010 % \item Support of \DVI\ mode: Insertion of empty pages instead of
5011 % interrupting execution.
5012 % \item Option |lastpage| added.
5013 % \end{itemize}
5014 %
5015 % \subsection*{2007/04/21 v0.4b}
5016 % \begin{itemize}
5017 % \item Support of \XeTeX.
5018 % \end{itemize}
5019 %
5020 % \subsection*{2008/04/27 v0.4d}
5021 % \begin{itemize}
5022 % \item A more robust check of |\XeTeXversion|.
5023 % \end{itemize}
5024 %
5025 % \subsection*{2008/05/11 v0.4e}
5026 % \begin{itemize}
5027 % \item Make |\AM@trim@leadingspace| robust to allow macros
5028 % in the caption argument of |addtolist|.
5029 % \end{itemize}
5030 %
5031 % \subsection*{2008/06/05 v0.4f}
5032 % \begin{itemize}
5033 % \item If |fitpaper| is used together with |angle| the resulting
5034 % |\@tempboxa| might have a depth unequal to zero. Taking this
5035 % into consideration when calculation page dimensions.
5036 % \end{itemize}
5037 %
5038 % \subsection*{2008/10/17 v0.4g}
5039 % \begin{itemize}
5040 % \item Macro |\AM@region@calc| was missing in the VTeX driver.
5041 % \end{itemize}
5042 %
5043 % \subsection*{2009/06/07 v0.4h}
5044 % \begin{itemize}
5045 % \item Added dvips driver provided by Heiko Oberdiek.
5046 % \end{itemize}
5047 %
5048 % \subsection*{2009/10/11 v0.4i}
5049 % \begin{itemize}
5050 % \item Added dvipdfm driver.
5051 % \item |\AM@toc@title| uses |\ignorespaces|, |\AM@lof@heading|
5052 % doesn't need that
5053 % \end{itemize}
5054 %
5055 % \subsection*{2010/01/12 v0.4j}
5056 % \begin{itemize}
5057 % \item Make |\AM@reflectbox| and |\AM@fbox| global definitions which is
5058 % necessary for package textpos.sty.
5059 % \item Refrain from setting |\AM@localxoff|, |\AM@localyoff|,
5060 % and |\AM@localscale| if option |noautoscale| is used.
5061 % \end{itemize}
5062 %
5063 % \subsection*{2010/08/08 v0.4k}
5064 % \begin{itemize}
5065 % \item Bugfix for memoir chapter classes.
5066 % \end{itemize}
5067 %
5068 % \subsection*{2010/11/26 v0.4l}
5069 % \begin{itemize}
5070 % \item Bugfix: In `signatures' the sign of |xoffset| must
5071 % change on every second page.
5072 % \end{itemize}
5073 %
5074 % \subsection*{2010/12/18 v0.4m}
5075 % \begin{itemize}
5076 % \item Bugfix: Wrong offset of signature.
5077 % \end{itemize}
5078 %
5079 % \subsection*{2011/03/10 v0.4n}
5080 % \begin{itemize}
5081 % \item Bugfix: In |\includepdfmerge|, |\AM@readlist| has to be
5082 % after |\setkeys|.
5083 % \end{itemize}
5084 %
5085 %
5086 % \subsection*{2011/07/02 v0.4p}
5087 % \begin{itemize}
5088 % \item Bugfix: |templatesize| ignored |scale| option.
5089 % \end{itemize}
5090 %
5091 %
5092 % \subsection*{2012/03/08 v0.4q}
5093 % \begin{itemize}
5094 % \item Macro |\AM@checkinteger| rewritten.
5095 % \item Loading |graphicx.sty| without explicit driver information.
5096 % \end{itemize}
5097 %
5098 % \subsection*{2012/04/03 v0.4s}
5099 % \begin{itemize}
5100 % \item Revert to the older |\AM@checkinteger| but now with changed
5101 % catcode for |_| (underscore).
5102 % \end{itemize}
5103 %
5104 % \subsection*{2012/08/28 v0.4t}
5105 % \begin{itemize}
5106 % \item Add option |duplicatepages|. Requested by Allan Pickett.
5107 % \end{itemize}
5108 %
5109 % \subsection*{2013/05/30 v0.4u}
5110 % \begin{itemize}
5111 % \item Compatibility with |import.sty|.
5112 % \end{itemize}
5113 %
5114 % \subsection*{2013/08/25 v0.4v}
5115 % \begin{itemize}
5116 % \item |\pdflastximagepages| is not updated if using |\includegraphics|
5117 % on the same file repeatedly. The provided fix is temporarily until
5118 % there's a better solution implemented in |pdftex.def|.
5119 % \end{itemize}
5120 %
5121 % \subsection*{2015/04/14 v0.4w}
5122 % \begin{itemize}
5123 % \item Driver file for \luaTeX:
5124 % So far \luaTeX\ used the driver file of \pdfTeX, which does not work
5125 % any more. As of luaTeX-0.80 the deprecated primitive |\pdftexversion| is
5126 % removed. Thus \luaTeX\ chokes on the code for checking the version number
5127 % of \pdfTeX. Therefore \luaTeX\ gets its on driver file |ppluatex.def|.
5128 % \end{itemize}
5129 %
5130 % \subsection*{2015/05/04 v0.4x}
5131 % \begin{itemize}
5132 % \item Issue with uppercase filename extentions in ppxetex.def fixed.
5133 % \item Issue with suspending of floats, and bang floats, during output fixed.
5134 % \end{itemize}
5135 %
5136 % \subsection*{2015/07/06 v0.4z}
5137 % \begin{itemize}
5138 % \item Package option `demo' added.
5139 % \end{itemize}
5140 %
5141 % \subsection*{2015/07/18 v0.5a}
5142 % \begin{itemize}
5143 % \item Driver dvipdfm removed.
5144 % \item Driver dvipdfmx added.
5145 % \end{itemize}
5146 %
5147 % \subsection*{2015/08/13 v0.5b}
5148 % \begin{itemize}
5149 % \item Driver dvipdfmx uses |extractbb| to get the total number of
5150 % pages of a PDF.
5151 % \end{itemize}
5152 %
5153 % \subsection*{2015/09/18 v0.5d}
5154 % \begin{itemize}
5155 % \item \emph{Iff} pdflscape is \emph{not} loaded by the user explicitly,
5156 % reset modification of the landscape environment after loading
5157 % pdflscape.
5158 % \end{itemize}
5159 %
5160 % \subsection*{2016/04/10 v0.5e}
5161 % \begin{itemize}
5162 % \item Cope with new primitive names introduced in LuaTeX 0.85.
5163 % \item Respect eso-pic's option |texcoord|.
5164 % \end{itemize}
5165 %
5166 % \subsection*{2016/04/19 v0.5f}
5167 % \begin{itemize}
5168 % \item Use |\includegraphics[width=!,height=!,...]{...}| to (kind of)
5169 % disable |width| and |height| options.
5170 % \item All (really all) options can be made global with
5171 % |\includepdfset|. (It's no more restricted to options of pdfpages.)
5172 % \end{itemize}
5173 %
5174 % \subsection*{2016/12/11 v0.5g}
5175 % \begin{itemize}
5176 % \item Conflict between |nup| and |addtotoc| fixed. A |\newpage| was triggered
5177 % on each page where |addtotoc| inserted a label.
5178 % \end{itemize}
5179 %
5180 % \subsection*{2017/01/12 v0.5h}
5181 % \begin{itemize}
5182 % \item Do not use |\stockwidth| to check for memoir, |\stockwidth| is used
5183 % by other packages as well.
5184 % \end{itemize}
5185 %
5186 % \subsection*{2017/06/13 v0.5i}
5187 % \begin{itemize}
5188 % \item Since 2017/06/01 (v5.0a) xetex.def does not define
5189 % |\def\G@pdf@ext{.pdf}| any more. In consequence of removing
5190 % |\G@pdf@ext| pdfpages could no longer determine the number of pages
5191 % of a PDF correctly.
5192 % \end{itemize}
5193 %
5194 % \subsection*{2017/07/14 v0.5j}
5195 % \begin{itemize}
5196 % \item Fixed |addtolist| which was broken when used with |float.sty|.
5197 % \end{itemize}
5198 %
5199 % \subsection*{2017/08/14 v0.5k}
5200 % \begin{itemize}
5201 % \item Documentation.
5202 % \end{itemize}
5203 %
5204 %
5205 % \subsection*{2017/10/31 v0.5l}
5206 % \begin{itemize}
5207 % \item Signatures for right edge binding were wrong when using
5208 % |signature*| and |landscape| together.
5209 % \end{itemize}
5210 %
5211 % \subsection*{2019/09/19 v0.5m}
5212 % \begin{itemize}
5213 % \item Expanding argument for |pages| option: \par
5214 % |\def\foo{1-4}\includepdf[pages=\foo]{dummy.pdf}|
5215 % \end{itemize}
5216 %
5217 % \subsection*{2019/09/21 v0.5n}
5218 % \begin{itemize}
5219 % \item |\AM@checkinteger| rewritten.
5220 % \item File names like `1.pdf' or `1-2.pdf' are now handled correctly by |\includepdfmerge|.
5221 % Rewritten |\AM@range@or@docname|, |\AM@checkrange|, |\AM@expand@range|, ...
5222 % \end{itemize}
5223 %
5224 % \subsection*{2019/11/21 v0.5o}
5225 % \begin{itemize}
5226 % \item This update fixes a bug with grffile.sty. Pdfpages tried to use
5227 % an internal command of grffile.sty, which no longer exists, since
5228 % grffile.sty is an empty dummy package nowadays.
5229 % \end{itemize}
5230 %
5231 % \subsection*{2019/12/17 v0.5p}
5232 % \begin{itemize}
5233 % \item Bug fix: Make empty pages empty. Empty pages like [pages={3,,5}]
5234 % weren't empty, but set as page 1, which was due to a bug in
5235 % |\AM@range@or@docname|.
5236 % \end{itemize}
5237 %
5238 % \subsection*{2020/01/27 v0.5q}
5239 % \begin{itemize}
5240 % \item Now |\includepdfmerge| supports option |pages|,
5241 % too. E.g. |\includepdfmerge[pages={2-}]{a.pdf, b.pdf}| inserts all pages
5242 % but the first of each pdf.
5243 % \item Option |openrighteach| added.
5244 % \end{itemize}
5245 %
5246 % \subsection*{2021/01/09 v0.5r}
5247 % \begin{itemize}
5248 % \item |\pdfpages@includegraphics@status| added.
5249 % \end{itemize}
5250 %
5251 % \subsection*{2021/02/05 v0.5s}
5252 % \begin{itemize}
5253 % \item Pdfpages redefined |\fboxsep| and |\fboxrule| inside
5254 % |\includepdf|. Thereby causing unexpected results if |\fbox| was used
5255 % inside option |picturecommand|. This bug is fixed. Now |\fboxsep| and
5256 % |\fboxrule| equal the values which were active just before
5257 % calling |\includepdf|.
5258 % \end{itemize}
5259 %
5260 % \subsection*{2021/03/06 v0.5t}
5261 % \begin{itemize}
5262 % \item Page rotation: Use new pdfmanagement macros if they are
5263 % available, and fallback to pdflscape if they are not available.
5264 % \end{itemize}
5265 %
5266 % \subsection*{2022/01/29 v0.5u}
5267 % \begin{itemize}
5268 % \item Adding |\leavevmode| before |\@chapter|,... in |addtotoc|.
5269 % Bug fix for \url{https://tex.stackexchange.com/questions/631514/}.
5270 % \end{itemize}
5271 %
5272 % \subsection*{2022/05/21 v0.5v}
5273 % \begin{itemize}
5274 % \item Do not enter an infinite loop if the PDF file doesn't exist.
5275 % Bug fix for \url{https://tex.stackexchange.com/questions/644971/}.
5276 % \end{itemize}
5277 %
5278 % \subsection*{2022/10/09 v0.5w}
5279 % \begin{itemize}
5280 % \item Keyval arguments get fully expanded.
5281 % \end{itemize}
5282 %
5283 % \subsection*{2022/12/19 v0.5x}
5284 % \begin{itemize}
5285 % \item Expand args of addtotoc and addtolist more graciously.
5286 % \end{itemize}
5287 %
5288 % \subsection*{2024/01/21 v0.5y}
5289 % \begin{itemize}
5290 % \item Fix issues with twocolumn documents
5291 % \begin{itemize}
5292 % \item |\newpage| -> |\clearpage|
5293 % \item Define |\@setmarks| if undefined.
5294 % \end{itemize}
5295 % \end{itemize}
5296 %
5297 % \subsection*{2024/04/29 v0.6a}
5298 % \begin{itemize}
5299 % \item Bugfix for ppxetex driver: Don't use |\import@path| in combination
5300 % with |subfiles.sty|.
5301 % \end{itemize}
5302 %
5303 % \subsection*{2024/08/20 v0.6b}
5304 % \begin{itemize}
5305 % \item Make |\includepdf[pages=-]{\detokenize{file.pdf}}| work in xelatex.
5306 % \end{itemize}
5307 %
5308 % \subsection*{2024/10/28 v0.6c}
5309 % \begin{itemize}
5310 % \item Add option |pagecommand*|.
5311 % \end{itemize}
5312 %
5313 % \subsection*{2025/01/20}
5314 % \begin{itemize}
5315 % \item From now on changes will be documented in the official repository only.
5316 % \end{itemize}
5317 %
5318 % \Finale
5319 %
5320 % \iffalse
5321 %<*example1>
5322 \documentclass[a4paper,12pt]{article}
5323 \usepackage[final]{pdfpages}
5324 \usepackage{verbatim}
5325 %% Uncomment the following lines, if you want to produce thumbnails.
5326 %%\usepackage{pdflscape}
5327 %%\usepackage{thumbpdf}
5328
5329 \newcounter{example}
5330 \setcounter{example}{1}
5331
5332 \newenvironment{example}
5333 {\par\vskip\topsep%
5334 \noindent\textbf{Example \arabic{example}:}%
5335 \stepcounter{example}%
5336 \par\vskip\topsep%
5337 \minipage{.9\linewidth}%
5338 \verbatim}
5339 {\endverbatim%
5340 \endminipage\par\vskip\topsep}
5341
5342 \begin{document}
5343
5344 \title{A Demonstration of the \texttt{pdfpages} Package}
5345 \author{Andreas MATTHIAS}
5346 \maketitle
5347
5348 This is a demonstration of the \texttt{pdfpages} package.
5349 It is \textit{not} the documentation of the package.
5350 To get the documentation run: `latex pdfpages.dtx'
5351
5352 \tableofcontents
5353
5354 \section{Inserting Pages:}
5355 \begin{example}
5356 \includepdf[pages=3-5]{dummy.pdf}
5357 \end{example}
5358 \includepdf[pages=3-5]{dummy.pdf}
5359
5360 \section{Using the \texttt{nup} Option}
5361 Arranging several logical pages on one sheet of paper.
5362
5363 \begin{example}
5364 \includepdf[nup=2x1, landscape, pages=4-7]{dummy.pdf}
5365 \end{example}
5366 \includepdf[nup=2x1, landscape, pages=4-7]{dummy.pdf}
5367
5368 Use the option \texttt{turn=false}, if the pages
5369 should not be displayed in landscape orientation.
5370 (If the last two pages were not displayed in
5371 landscape orientation, you use a PDF viewer that
5372 does not support this option.)
5373
5374 \begin{example}
5375 \includepdf[nup=2x1, landscape,
5376 pages=4-7, turn=false]{dummy.pdf}
5377 \end{example}
5378 \includepdf[nup=2x1, landscape,
5379 pages=4-7, turn=false]{dummy.pdf}
5380
5381 \begin{example}
5382 \includepdf[nup=1x2, pages=1-4]{dummy-l.pdf}
5383 \end{example}
5384 \includepdf[nup=1x2, pages=1-4]{dummy-l.pdf}
5385
5386 \noindent
5387 With the option \texttt{pages} special pages and
5388 ranges of pages can be selected.
5389
5390 \begin{example}
5391 \includepdf[nup=3x2, pages={1,4-6,8,10}]{dummy.pdf}
5392 \end{example}
5393 \includepdf[nup=3x2, pages={1,4-6,8,10}]{dummy.pdf}
5394
5395 \noindent
5396 A column-major layout can be achieved with the
5397 option \texttt{column}.
5398
5399 \begin{example}
5400 \includepdf[nup=2x2, pages=1-4, column]{dummy.pdf}
5401 \end{example}
5402 \includepdf[nup=2x2, pages=1-4, column]{dummy.pdf}
5403
5404
5405 \noindent
5406 Sometimes it might be useful to put an empty page
5407 at the beginning.
5408 \begin{example}
5409 \includepdf[nup=2x2, pages={{},5-7}]{dummy.pdf}
5410 \end{example}
5411 \includepdf[nup=2x2, pages={{},5-7}]{dummy.pdf}
5412
5413
5414 \section{Changing Layout}
5415
5416 To put some space between the logical pages, use the option
5417 \texttt{delta}.
5418
5419 Any options of \verb|\includegraphics| are allowed in
5420 \verb|\includepdf| as well. See the \texttt{scale}
5421 option in the next example.
5422 \begin{example}
5423 \includepdf[nup=2x2, pages=3-6, scale=.8,
5424 delta=8mm 11mm, frame]{dummy.pdf}
5425 \end{example}
5426 \includepdf[nup=2x2, pages=3-6, scale=.8,
5427 delta=8mm 11mm, frame]{dummy.pdf}
5428
5429 \noindent
5430 By default the output is centered, as you could see in
5431 the last examples. With the \texttt{offset} option it is
5432 possible to displace the output.
5433
5434 \begin{example}
5435 \includepdf[nup=2x2, pages=3-6, scale=.8,
5436 offset=5mm 7mm, frame]{dummy.pdf}
5437 \end{example}
5438 \includepdf[nup=2x2, pages=3-6, scale=.8,
5439 offset=5mm 7mm, frame]{dummy.pdf}
5440
5441
5442 \noindent
5443 To remove the header and the footer of the inserted
5444 document use the \texttt{trim} and \texttt{clip}
5445 options of the \texttt{graphicx} package.
5446
5447 \begin{example}
5448 \includepdf[nup=2x2, pages=1-4,
5449 trim=0 40mm 0 40mm,
5450 clip, pagecommand={}]{dummy.pdf}
5451 \end{example}
5452
5453
5454 \noindent The option
5455 \verb|pagecommand={\thispagestyle{empty}}|
5456 is set by default. If you don't want the page style
5457 to be set to empty, you can remove this default
5458 setting by using the \texttt{pagecommand} option
5459 as follows:
5460 \verb|pagecommand={}|.
5461
5462 \includepdf[nup=2x2, pages=1-4,
5463 trim=0 40mm 0 40mm,
5464 clip, pagecommand={}]{dummy.pdf}
5465
5466
5467 \noindent
5468 You like the crazy way? Then try this one \texttt{;-)}
5469 \begin{example}
5470 \includepdf[pages={3,4}, nup=2x1,
5471 landscape, scale=1.1,
5472 angle=30, delta=0 -85mm]{dummy.pdf}
5473 \end{example}
5474 \includepdf[pages={3,4}, nup=2x1,
5475 landscape, scale=1.1,
5476 angle=30, delta=0 -85mm]{dummy.pdf}
5477
5478
5479 \end{document}
5480 %</example1>
5481 %
5482 %
5483 %
5484 %<*example2>
5485 \documentclass[a4paper,12pt]{article}
5486 \usepackage[final]{pdfpages}
5487 \usepackage{verbatim}
5488 %% Uncomment the following lines, if you want to produce thumbnails.
5489 %%\usepackage{pdflscape}
5490 %%\usepackage{thumbpdf}
5491 \usepackage[bookmarksopen]{hyperref}
5492
5493 \newcounter{example}
5494 \setcounter{example}{1}
5495
5496 \newenvironment{example}
5497 {\par\vskip\topsep%
5498 \noindent\textbf{Example \arabic{example}:}%
5499 \stepcounter{example}%
5500 \par\vskip\topsep%
5501 \minipage{.9\linewidth}%
5502 \verbatim}
5503 {\endverbatim%
5504 \endminipage\vskip\topsep}
5505
5506 \newcommand{\meta}[1]{\ensuremath\langle\texttt{#1}\ensuremath\rangle}
5507 \newcommand{\link}[2]{\meta{#1}.\meta{#2}}
5508
5509 \newcommand*{\bookmark}[3][0]{%
5510 \pdfoutline user {<< /S /GoTo /D (#3) >>} count #1 {#2}}
5511
5512
5513 \begin{document}
5514
5515 \title{A Demonstration of the Hypertext Operations\\
5516 of the \texttt{pdfpages} Package}
5517 \author{Andreas MATTHIAS}
5518 \maketitle
5519
5520 This is a demonstration of the \texttt{pdfpages} package.
5521 It is \textit{not} the documentation of the package.
5522 To get the documentation run: `latex pdfpages.dtx'
5523
5524 \tableofcontents
5525
5526 \section{Hyperlinks}
5527 \subsection{Links to the inserted Pages}
5528
5529 Hyperlinks are created by using the option \texttt{link}
5530 of the \verb|\includepdf| command. Each inserted page
5531 gets a link name consisting of the filename and
5532 the page number: \link{filename}{page number}
5533
5534 \begin{example}
5535 \includepdf[pages=1-2, link]{dummy.pdf}
5536 \end{example}
5537
5538 In this example the two pages have the link names
5539 `\texttt{dummy.pdf.1}' and `\texttt{dummy.pdf.2}'.
5540 Setting links to these
5541 pages, can be done easily with the \verb|\hyperlink|
5542 macro from the \texttt{hyperref.sty} package:
5543
5544 \bigskip
5545 \verb|\hyperlink{dummy.pdf.1}{Page 1}|\hskip10pt \hyperlink{dummy.pdf.1}{Page 1}\par
5546 \verb|\hyperlink{dummy.pdf.2}{Page 2}|\hskip10pt \hyperlink{dummy.pdf.2}{Page 2}
5547 \bigskip
5548
5549 This way you can refer to the \hyperlink{dummy.pdf.1}{first}
5550 and the \hyperlink{dummy.pdf.2}{second page}.
5551
5552 \includepdf[pages=1-2, link]{dummy.pdf}
5553
5554
5555 Inserting the same page twice would result in two
5556 identical link names. To prevent this use the option
5557 \texttt{linkname} to specify another name for the links.
5558
5559 \begin{example}
5560 \includepdf[pages=1-2, nup=2x1, landscape,
5561 link, linkname=mylink]{dummy.pdf}
5562 \end{example}
5563
5564 \noindent
5565 Now the links are called `\texttt{mylink.1}' and
5566 `\texttt{mylink.2}'.
5567
5568 \bigskip
5569 \verb|\hyperlink{mylink.1}{Page 1}|\hskip10pt \hyperlink{mylink.1}{Page 1}\par
5570 \verb|\hyperlink{mylink.2}{Page 2}|\hskip10pt \hyperlink{mylink.2}{Page 2}
5571
5572 \includepdf[pages=1-2, nup=2x1, landscape,
5573 link, linkname=mylink]{dummy.pdf}
5574
5575 \subsection{Links to the original Document}
5576
5577 Each page can be a hyperlink to the document from
5578 which it was extracted. This can be done with the
5579 option \texttt{linktodoc}.
5580
5581 Click on the inserted pages and see what happens.
5582
5583 \begin{example}
5584 \includepdf[pages=1-4, nup=2x2, linktodoc]{dummy.pdf}
5585 \end{example}
5586 \includepdf[pages=1-4, nup=2x2, linktodoc]{dummy.pdf}
5587
5588
5589 \section{Article Threads}
5590
5591 In a PDF document one or more article threads may be defined.
5592 An article thread is a logical connected sequence of content
5593 items.
5594
5595 With the option \texttt{thread} the inserted pages become
5596 an article thread.
5597
5598 \begin{example}
5599 \includepdf[pages=1-4, nup=2x2, column,
5600 landscape, thread]{dummy-l.pdf}
5601 \end{example}
5602
5603 In Acrobat Reader the mouse pointer changes to a hand with
5604 a little arrow in it when moved over an article thread.
5605 By clicking on the page you can easily follow the logical
5606 structure of the article thread.
5607
5608 \includepdf[pages=1-4, nup=2x2, column,
5609 landscape, thread]{dummy-l.pdf}
5610
5611 \end{document}
5612 %</example2>
5613 %
5614 %
5615 %<*example3>
5616 \documentclass[a4paper]{book}
5617 \usepackage{pdfpages}
5618 \usepackage{verbatim}
5619 \usepackage[plainpages=false, pdfpagelabels,
5620 bookmarksopen]{hyperref}
5621
5622 \begin{document}
5623 \tableofcontents
5624
5625 \chapter{How to create a toc}
5626
5627 The next pages were inserted using the following command:
5628
5629 \begin{verbatim}
5630 \includepdf[pages=1-6,
5631 pagecommand={},
5632 addtotoc={1, chapter, 0, Main chapter, cha:main,
5633 1, section, 1, First section, sec:first,
5634 3, section, 1, Second section, sec:second},
5635 trim=0 120 0 120, clip]{dummy.pdf}
5636 \end{verbatim}
5637
5638 \noindent
5639 See Chapter \ref{cha:main} (\nameref{cha:main}) on page
5640 \pageref{cha:main}.\par\noindent
5641 See Section \ref{sec:first} (\nameref{sec:first}) on page
5642 \pageref{sec:first}.\par\noindent
5643 See Section \ref{sec:second} (\nameref{sec:second}) on page
5644 \pageref{sec:second}.
5645
5646 \includepdf[pages=1-6,
5647 pagecommand={},
5648 addtotoc={1, chapter, 0, Main chapter, cha:main,
5649 1, section, 1, First section, sec:first,
5650 3, section, 1, Second section, sec:second},
5651 trim=0 120 0 120, clip]{dummy.pdf}
5652
5653 \end{document}
5654 %</example3>
5655 %
5656 %<*installer>
5657 \input docstrip
5658 \askforoverwritefalse
5659 \keepsilent
5660
5661 \preamble
5662 \endpreamble
5663
5664 \declarepreamble\package
5665
5666 This file is part of the pdfpages package.
5667
5668 \endpreamble
5669
5670 \declarepreamble\example
5671
5672 This file demonstrates how to use the pdfpages package.
5673 \endpreamble
5674
5675 \generate{\usepreamble\package
5676 \file{pdfpages.sty}{\from{pdfpages.dtx}{package}}}
5677 \generate{\usepreamble\package
5678 \file{pppdftex.def}{\from{pdfpages.dtx}{pppdftexdef}}}
5679 \generate{\usepreamble\package
5680 \file{ppluatex.def}{\from{pdfpages.dtx}{ppluatexdef}}}
5681 \generate{\usepreamble\package
5682 \file{ppvtex.def}{\from{pdfpages.dtx}{ppvtexdef}}}
5683 \generate{\usepreamble\package
5684 \file{ppxetex.def}{\from{pdfpages.dtx}{ppxetexdef}}}
5685 \generate{\usepreamble\package
5686 \file{ppdvips.def}{\from{pdfpages.dtx}{ppdvipsdef}}}
5687 \generate{\usepreamble\package
5688 \file{ppdvipdfmx.def}{\from{pdfpages.dtx}{ppdvipdfmxdef}}}
5689 \generate{\usepreamble\package
5690 \file{ppnull.def}{\from{pdfpages.dtx}{ppnulldef}}}
5691
5692 %% \generate{\usepreamble\package
5693 %% \file{pdfpages.drv}{\from{pdfpages.dtx}{driver}}}
5694
5695 \generate{\usepreamble\example
5696 \file{pdf-ex.tex}{\from{pdfpages.dtx}{example1}}}
5697 \generate{\usepreamble\example
5698 \file{pdf-hyp.tex}{\from{pdfpages.dtx}{example2}}}
5699 \generate{\usepreamble\example
5700 \file{pdf-toc.tex}{\from{pdfpages.dtx}{example3}}}
5701
5702 \Msg{**************************************************************}
5703 \Msg{*}
5704 \Msg{* To finish the installation you have to move the following}
5705 \Msg{* files into a directory searched by LaTeX:}
5706 \Msg{*}
5707 \Msg{* \space\space pdfpages.sty}
5708 \Msg{* \space\space pppdftex.def}
5709 \Msg{* \space\space ppvtex.def}
5710 \Msg{* \space\space ppxetex.def}
5711 \Msg{* \space\space ppdvips.def}
5712 \Msg{* \space\space ppnull.def}
5713 \Msg{*}
5714 \Msg{* To produce the documentation, run the following}
5715 \Msg{* file through LaTeX:}
5716 \Msg{*}
5717 \Msg{* \space\space pdfpages.dtx}
5718 \Msg{*}
5719 \Msg{* The following files are examples demonstrating how to use}
5720 \Msg{* the pdfpages package.}
5721 \Msg{*}
5722 \Msg{* \space\space pdf-ex.tex}
5723 \Msg{* \space\space pdf-hyp.tex}
5724 \Msg{* \space\space pdf-toc.tex}
5725 \Msg{*}
5726 \Msg{* Happy TeXing!}
5727 \Msg{*}
5728 \Msg{**************************************************************}
5729 \endbatchfile
5730 %</installer>
5731 %
5732 %\fi
5733 \endinput
5734 %%%
5735 %%% Local Variables: ***
5736 %%% fill-column: 76 ***
5737 %%% End: ***