%%
%% This is file `pdfpages.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pdfpages.dtx  (with options: `package')
%% 
%% This is a pdfLaTeX package for including pages
%% of external PDF documents.
%% 
%% This file is part of the pdfpages package.
%% 
%%
%% \CharacterTable
%%  {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
%%   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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pdfpages}[2001/04/10 v0.1h4 Include pages of external PDF documents (AM)]
\begingroup
\@ifundefined{pdfoutput}
    {\PackageError{pdfpages}
            {You're either not using pdfLaTeX\MessageBreak
             or have turn off PDF output.\MessageBreak
             `pdfpages' works only with pdfLaTeX\MessageBreak
             and PDF output}
            {Use `pdflatex' instead of `latex'\MessageBreak
             and set output to PDF (use: \pdfoutput = 1)!}
     \expandafter\endinput
    }{}
\ifnum\pdfoutput=0
    \PackageError{pdfpages}
            {You don't produce PDF output, which\MessageBreak
             is required for the `pdfpages' package}
            {Set output to PDF. (use: \pdfoutput = 1)}
    \expandafter\endinput
\fi
\endgroup
\def\AM@ifdriverlater{\@ifl@ter{def}}
\AtBeginDocument{%
  \AM@ifdriverlater{pdftex}{2000/05/12}{}{%
      \PackageError{pdfpages}{%
           You have an old `pdftex.def'.\MessageBreak%
           There is no multipage support\MessageBreak%
           in `pdftex.def' < 0.02u.\MessageBreak%
           Update your `pdftex.def'}
           {Update your `pdftex.def'!}}
  \AM@ifdriverlater{pdftex}{2000/09/14}{}{%
      \PackageWarning{pdfpages}{%
           You have an old `pdftex.def'.\MessageBreak%
           There might be problems with\MessageBreak%
           the `trim' and `clip' options.\MessageBreak%
           Update your `pdftex.def'!\MessageBreak}}
}% AtBeginDocument
\RequirePackage{ifthen, graphicx, eso-pic, calc}
\newcommand{\AM@draft}{false}
\DeclareOption{draft}{\def\AM@draft{true}}
\DeclareOption{final}{\def\AM@draft{false}}
\ProcessOptions
\newboolean{AM@openright}\setboolean{AM@openright}{false}
\newboolean{AM@frame}\setboolean{AM@frame}{false}
\newboolean{AM@landscape}\setboolean{AM@landscape}{false}
\newboolean{AM@turn}\setboolean{AM@turn}{true}
\newboolean{AM@thread}\setboolean{AM@thread}{false}
\newboolean{AM@link}\setboolean{AM@link}{false}
\newboolean{AM@linktodoc}\setboolean{AM@linktodoc}{false}
\newboolean{AM@compatibility}\setboolean{AM@compatibility}{false}
\newcommand{\AM@xoffset}{0pt}\newcommand{\AM@yoffset}{0pt}
\newcommand{\AM@deltax}{0pt}\newcommand{\AM@deltay}{0pt}
\newcommand{\AM@xpos}{0pt}\newcommand{\AM@ypos}{0pt}
\newcommand{\AM@rotate}{0}
\newcommand{\AM@lscape@roti}{0}\newcommand{\AM@lscape@rotii}{0}
\newcommand{\AM@pagecommand}{\thispagestyle{empty}}
\newcommand{\AM@fbox}{}\newcommand{\AM@ph}{}
\newcommand{\AM@pagestemp}{1}
\newcommand{\AM@page}{}
\newcommand{\AM@pagei}{}\newcommand{\AM@pageii}{}
\newcommand{\AM@pageiii}{}\newcommand{\AM@pageiv}{}
\newcommand{\AM@@smallpage}{}\newcommand{\AM@smallpage}{\AM@@smallpage}
\newcommand{\AM@firstpage}{1}\newcommand{\AM@lastpage}{1}
\newcommand{\AM@nup}{1}
\newcommand{\AM@linkname}{}
\newcommand{\AM@threadname}{}
\newcommand{\AM@linkfit}{fitr}
\newcommand{\AM@linktodocfit}{/Fit}
\newcommand{\AM@setunit}{\setlength{\unitlength}{1pt}}
\newif\ifAM@thumbpdf
\newif\ifAM@pdflscape
\newcommand{\AM@setlscape}{}
\AtBeginDocument{%
  \@ifpackageloaded{thumbpdf}{\AM@thumbpdftrue}{\AM@thumbpdffalse}%
  \@ifpackageloaded{pdflscape}{\AM@pdflscapetrue}{\AM@pdflscapefalse}%
  \ifAM@thumbpdf
    \ifAM@pdflscape
      \def\AM@setlscape{\PLS@Rotate{90}}%
    \else
      \def\AM@setlscape{\pdfpageattr{/Rotate 90}\AM@thumbpdfwarning}\fi
  \else
    \def\AM@setlscape{\pdfpageattr{/Rotate 90}}\fi}
\newif\ifAM@thumbpdfwarning
\newcommand{\AM@thumbpdfwarning}{%
  \ifAM@thumbpdfwarning\else\global\AM@thumbpdfwarningtrue
  \PackageWarning{pdfpages}{%
    You are using `thumbpdf.sty' but not\MessageBreak
    `pdflscape.sty'. \MessageBreak
    Please include `pdflscape.sty' in  your document\MessageBreak
    to get a pleasant PDF document with thumbs.\MessageBreak}\fi}
\newcommand*{\includepdfset}[1]{\setkeys{Gin}{#1}}
\newcommand*{\includepdf}[2][]{%
  \begingroup% setkey
  \filename@parse{#2}
  \@ifundefined{filename@ext}
    {\def\AM@linkfilename{#2.pdf}}
    {\def\AM@linkfilename{#2}}%
  \def\AM@linkname{#2}%
  \def\AM@threadname{#2}%
  \setkeys{Gin}{draft=\AM@draft, #1}%
  \ifthenelse{\boolean{AM@compatibility}}
    {\def\AM@pagestemp{\AM@firstpage-\AM@lastpage}}{}%
  \ifthenelse{\boolean{AM@frame}}
         {\let\AM@fbox\fbox}{\let\AM@fbox\relax}%
  \expandafter\AM@pagenumbers\expandafter{\AM@pagestemp}%
  \ifthenelse{\boolean{AM@openright}}{\AM@openright}{}%
  \AM@setphantom
  \AM@filluppagelist
  \setlength{\fboxsep}{0pt}%
  \whiledo{\not\boolean{endofpagelist}}{%
    \newpage
    \ifthenelse{\boolean{AM@turn}}
      {\ifthenelse{\boolean{AM@landscape}}
         {\ifthenelse{\equal{1}{\AM@nup}}{\AM@setlscape}{}%
          \ifthenelse{\equal{4}{\AM@nup}}{\AM@setlscape}{}}
         {\ifthenelse{\equal{2}{\AM@nup}}{\AM@setlscape}{}}%
      }{}%
    \AM@getpages{\AM@nup}%
      \ifthenelse{\equal{1}{\AM@nup}}{%
         \def\AM@@smallpage{%
           \includegraphics[page=\AM@page, angle=\AM@lscape@rotii,
                            angle=\AM@rotate, #1]{#2}}%
         \AddToShipoutPicture{\AM@setunit%
           \let\AM@page\AM@pagei\AM@isphantom
           \AM@output{0}{\AM@smallpage}}%
        }{}%
      \ifthenelse{\equal{2}{\AM@nup}}{%
        \def\AM@@smallpage{%
          \includegraphics[page=\AM@page, angle=90,
                           angle=\AM@lscape@roti, angle=\AM@rotate,
                           scale=.7071, #1]{#2}}%
        \AddToShipoutPicture{\AM@setunit%
          \ifthenelse{\boolean{AM@landscape}}
            {\let\AM@page\AM@pagei\AM@isphantom
             \AM@output{1}{\AM@smallpage}%
             \let\AM@page\AM@pageii\AM@isphantom
             \AM@output{2}{\AM@smallpage}}
            {\let\AM@page\AM@pagei\AM@isphantom
             \AM@output{2}{\AM@smallpage}%
             \let\AM@page\AM@pageii\AM@isphantom
             \AM@output{1}{\AM@smallpage}}}%
      }{}%
      \ifthenelse{\equal{4}{\AM@nup}}{%
        \def\AM@@smallpage{%
          \includegraphics[page=\AM@page, angle=\AM@lscape@rotii,
                           angle=\AM@rotate, scale=.5, #1]{#2}}%
        \AddToShipoutPicture{\AM@setunit%
          \ifthenelse{\boolean{AM@landscape}}
            {\let\AM@page\AM@pagei\AM@isphantom
             \AM@output{5}{\AM@smallpage}%
             \let\AM@page\AM@pageii\AM@isphantom
             \AM@output{3}{\AM@smallpage}%
             \let\AM@page\AM@pageiii\AM@isphantom
             \AM@output{6}{\AM@smallpage}%
             \let\AM@page\AM@pageiv\AM@isphantom
             \AM@output{4}{\AM@smallpage}}
            {\let\AM@page\AM@pagei\AM@isphantom
             \AM@output{3}{\AM@smallpage}%
             \let\AM@page\AM@pageii\AM@isphantom
             \AM@output{4}{\AM@smallpage}%
             \let\AM@page\AM@pageiii\AM@isphantom
             \AM@output{5}{\AM@smallpage}%
             \let\AM@page\AM@pageiv\AM@isphantom
             \AM@output{6}{\AM@smallpage}}}%
     }{}%
    \AM@pagecommand
    \hskip0pt
    \newpage
    \ifAM@pdflscape\PLS@Rotate{0}\fi
    \ClearShipoutPicture
  }% whiledo
  \endgroup% setkey
  \ClearShipoutPicture
}% includepdf
\newif\ifphantompage
\newcommand{\AM@isphantom}{%
  \expandafter\ifx\expandafter\\\AM@page\\%
    \let\AM@page\AM@phantompage
    \let\AM@ph\phantom
    \phantompagefalse
  \else
    \let\AM@ph\relax
    \phantompagetrue
  \fi}
\newcommand{\AM@hyper}{%
  \ifphantompage
  \ifthenelse{\boolean{AM@link}}{%
    \pdfdest name {\AM@linkname.\AM@page}%
             \AM@linkfit}{}%
  \fi
  \ifthenelse{\boolean{AM@linktodoc}}{%
    \@tempcntb\AM@page\relax
    \advance\@tempcntb by -1
    \pdfannot width \wd\@tempboxa
              height \ht\@tempboxa
              depth \dp\@tempboxa
              {/Subtype /Link /Border [0 0 0]
               /A << /S /GoToR /F (\AM@linkfilename)
                     /D [\the\@tempcntb \AM@linktodocfit]
                     /NewWindow true >>}}{}%}%
  \ifphantompage
  \ifthenelse{\boolean{AM@thread}}{%
      \pdfthread width \wd\@tempboxa
                 height \ht\@tempboxa
                 depth \dp\@tempboxa
                 name {\AM@threadname}}{}%
  \fi}%
\newcommand{\AM@output}[2]{%
  \setbox\@tempboxa=\hbox{\AM@fbox{#2}}%
  \def\AM@add{+}%
  \if@twoside\ifodd\value{page}\else\def\AM@add{-}\fi\fi
  \ifcase#1 % nup=1
    \def\AM@xpos{.5\paperwidth - .5\wd\@tempboxa \AM@add\AM@xoffset}%
    \def\AM@ypos{.5\paperheight - .5\ht\@tempboxa - .5\dp\@tempboxa
                 \AM@add\AM@yoffset}%
  \or % nup=2
    \def\AM@xpos{.5\paperwidth - .5\wd\@tempboxa \AM@add\AM@xoffset}%
    \def\AM@ypos{.5\paperheight + \AM@deltay*\real{.5} + \AM@yoffset
                 - .5\fboxrule}%
  \or
    \def\AM@xpos{.5\paperwidth - .5\wd\@tempboxa \AM@add\AM@xoffset}%
    \def\AM@ypos{.5\paperheight - \ht\@tempboxa - \dp\@tempboxa
                 - \AM@deltay*\real{.5} + \AM@yoffset + .5\fboxrule}%
  \or % nup=4
    \def\AM@xpos{.5\paperwidth - \wd\@tempboxa \AM@add\AM@xoffset
                 + .5\fboxrule - \AM@deltax*\real{.5}}%
    \def\AM@ypos{.5\paperheight + \AM@deltay*\real{.5} + \AM@yoffset
                 - .5\fboxrule}%
  \or
    \def\AM@xpos{.5\paperwidth \AM@add\AM@xoffset
                 - .5\fboxrule + \AM@deltax*\real{.5}}%
    \def\AM@ypos{.5\paperheight + \AM@deltay*\real{.5} + \AM@yoffset
                 - .5\fboxrule}%
  \or
    \def\AM@xpos{.5\paperwidth - \wd\@tempboxa \AM@add\AM@xoffset
                 + .5\fboxrule - \AM@deltax*\real{.5}}%
    \def\AM@ypos{.5\paperheight - \ht\@tempboxa - \dp\@tempboxa
                 - \AM@deltay*\real{.5} + \AM@yoffset + .5\fboxrule}%
  \or
    \def\AM@xpos{.5\paperwidth \AM@add\AM@xoffset
                 - .5\fboxrule + \AM@deltax*\real{.5}}%
    \def\AM@ypos{.5\paperheight - \ht\@tempboxa - \dp\@tempboxa
                 - \AM@deltay*\real{.5} + \AM@yoffset + .5\fboxrule}%
  \fi
  \setlength{\@tempdima}{\AM@xpos}%
  \edef\AM@xpos{\strip@pt\@tempdima}%
  \setlength{\@tempdima}{\AM@ypos}%
  \edef\AM@ypos{\strip@pt\@tempdima}%
  \put(\AM@xpos,\AM@ypos){%
    \AM@ph{\raisebox{\dp\@tempboxa}{%
      \AM@hyper
      \box\@tempboxa}}}%
} % AM@output
\newcommand{\AM@pagelist}{}
\newcommand{\saveAM@pagelist}{}
\newboolean{endofpagelist}
\newcommand{\AM@pagenumbers}{1}
\def\AM@pagenumbers#1{%
  \AM@@pagenumbers#1,\END
  \let\saveAM@pagelist\AM@pagelist
  \edef\AM@pagelist{\saveAM@pagelist\noexpand\END}%
}
\newcommand{\AM@@pagenumbers}{}
\def\AM@@pagenumbers#1,#2{%
  \AM@pagearea#1-\END
  \ifx#2\END \def\AM@next{\relax}%
    \else \def\AM@next{\AM@@pagenumbers #2}%
  \fi
  \AM@next
}
\newcommand{\AM@pagearea}{}
\def\AM@pagearea#1-#2\END{%
  \ifx\\#2\\%
    \AM@addtopagelist{#1}%
  \else
    \AM@last#2
    \@tempcnta=#1
    \whiledo{\@tempcnta<\@tempcntb}{%
      \AM@addtopagelist{\the\@tempcnta}%
      \advance\@tempcnta by 1
    }%
  \fi}
\newcommand{\AM@last}{}
\def\AM@last#1-{%
  \@tempcntb=#1 \advance\@tempcntb by 1
  \def\lastpage{#1}%
}
\newcommand{\AM@addtopagelist}{}
\def\AM@addtopagelist#1{%
  \let\saveAM@pagelist\AM@pagelist
  \edef\AM@pagelist{\saveAM@pagelist#1,}%
}
\newcommand{\AM@openright}{}
\def\AM@openright{\expandafter\AM@@openright\AM@pagelist}
\newcommand{\AM@@openright}{}
\def\AM@@openright#1\END{%
  \edef\AM@pagelist{,#1\noexpand\END}%
}
\newcommand{\AM@getpages}{}
\def\AM@getpages#1{%
  \ifcase#1
    \or
    \expandafter\AM@getipages\AM@pagelist \or
    \expandafter\AM@getiipages\AM@pagelist \or\or
    \expandafter\AM@getivpages\AM@pagelist \fi
}

\newcommand{\AM@getipages}{}
\def\AM@getipages#1,#2\END{%
  \def\AM@pagei{#1}%
  %remove page from list
  \def\AM@pagelist{#2\END}%
  % checking end of list
  \ifx\\#2\\\setboolean{endofpagelist}{true}\fi
}
\newcommand{\AM@getiipages}{}
\def\AM@getiipages#1,#2,#3\END{%
  \def\AM@pagei{#1}%
  \def\AM@pageii{#2}%
  %remove pages from list
  \def\AM@pagelist{#3\END}%
  % checking end of list
  \ifx\\#3\\\setboolean{endofpagelist}{true}\fi
}
\newcommand{\AM@getivpages}{}
\def\AM@getivpages#1,#2,#3,#4,#5\END{%
  \def\AM@pagei{#1}%
  \def\AM@pageii{#2}%
  \def\AM@pageiii{#3}%
  \def\AM@pageiv{#4}%
  %remove pages from list
  \def\AM@pagelist{#5\END}%
  % checking end of list
  \ifx\\#5\\\setboolean{endofpagelist}{true}\fi
}
\newcommand{\AM@countpagelist}{}
\def\AM@countpagelist{%
  \@tempcnta=0 \expandafter\AM@@countpagelist\AM@pagelist}
\newcommand{\AM@@countpagelist}{}
\def\AM@@countpagelist#1,#2{%
  \ifx#2\END\def\AM@next{\relax}%
    \else\def\AM@next{\AM@@countpagelist #2}%
  \fi
  \advance\@tempcnta by 1
  \AM@next
}
\newcommand{\AM@filluppagelist}{}
\def\AM@filluppagelist{%
  \AM@countpagelist
  \@tempcntb=\@tempcnta
  \divide\@tempcntb by \AM@nup%
  \multiply\@tempcntb by \AM@nup%
  \advance\@tempcnta by -\@tempcntb
  \ifnum\@tempcnta=0
    \else
      \advance\@tempcnta by -\AM@nup%
      \multiply\@tempcnta by -1
  \fi
  \expandafter\AM@removeend\AM@pagelist
  \whiledo{\@tempcnta > 0}{%
    \let\saveAM@pagelist\AM@pagelist
    \edef\AM@pagelist{\saveAM@pagelist ,}%
    \advance\@tempcnta by -1
  }%
  \let\saveAM@pagelist\AM@pagelist
  \edef\AM@pagelist{\saveAM@pagelist\noexpand\END}%
}
\newcommand{\AM@removeend}{}
\def\AM@removeend#1\END{%
  \let\saveAM@pagelist\AM@pagelist
  \edef\AM@pagelist{#1}%
}
\newcommand{\AM@setphantom}{}
\def\AM@setphantom{\expandafter\AM@@setphantom\AM@pagelist}
\newcommand{\AM@@setphantom}{}
\def\AM@@setphantom#1,#2\END{%
  \ifx\\#1\\ \def\AM@next{\AM@@setphantom#2\END}%
  \else
    \edef\AM@phantompage{#1}%
    \def\AM@next{\relax}%
  \fi
  \AM@next
}
\define@key{Gin}{pages}{\def\AM@pagestemp{#1}}
\define@key{Gin}{nup}{\def\AM@nup{#1}}
\define@key{Gin}{deltax}{\AM@parse@deltax#1 \\}
\define@key{Gin}{deltay}{\AM@parse@deltay#1 \\}
\define@key{Gin}{offset}{\AM@parse@offset#1 \\}
\define@key{Gin}{frame}[true]{\setboolean{AM@frame}{#1}}
\define@key{Gin}{openright}[true]{\setboolean{AM@openright}{#1}}
\define@key{Gin}{pagecommand}{\renewcommand{\AM@pagecommand}{#1}}
\define@key{Gin}{rotate}{\def\AM@rotate{#1}}
\define@key{Gin}{landscape}[true]{\setboolean{AM@landscape}{#1}%
                                  \def\AM@lscape@roti{-90}%
                                  \def\AM@lscape@rotii{90}}
\define@key{Gin}{turn}[true]{\setboolean{AM@turn}{#1}}
\define@key{Gin}{firstpage}{\def\AM@firstpage{#1}%
                            \setboolean{AM@compatibility}{true}}
\define@key{Gin}{lastpage}{\def\AM@lastpage{#1}%
                           \setboolean{AM@compatibility}{true}}
\define@key{Gin}{thread}[true]{\setboolean{AM@thread}{#1}}
\define@key{Gin}{threadname}{\def\AM@threadname{#1}}
\define@key{Gin}{link}[true]{\setboolean{AM@link}{#1}}
\define@key{Gin}{linkfit}{\def\AM@linkfit{#1}}
\define@key{Gin}{linkname}{\def\AM@linkname{#1}}
\define@key{Gin}{linktodoc}[true]{\setboolean{AM@linktodoc}{#1}}
\define@key{Gin}{linktodocfit}{\def\AM@linktodocfit{#1}}
\define@key{Gin}{linkfilename}{\pdfstringdef\AM@linkfilename{#1}}
\def\AM@parse@deltax#1 #2\\{\AMGin@defaultbp\AM@deltax{#1}}
\def\AM@parse@deltay#1 #2\\{\AMGin@defaultbp\AM@deltay{#1}}
\def\AM@parse@offset#1 #2 #3\\{%
  \AMGin@defaultbp\AM@xoffset{#1}%
  \AMGin@defaultbp\AM@yoffset{#2}}
\def\AMGin@defaultbp#1#2{%
  \afterassignment\AMGin@def@bp\dimen@#2bp\relax{#1}{#2}}
\def\AMGin@def@bp#1\relax#2#3{%
   \if!#1!%
     \def#2{#3bp}%
    \else
      \dimen@.99626\dimen@
      \edef#2{\strip@pt\dimen@ bp}%
    \fi}
\endinput
%%
%% End of file `pdfpages.sty'.
