%%
%% This is file `pst-pdf.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pst-pdf.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2004 by Rolf Niepraschk <Rolf.Niepraschk@ptb.de>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pst-pdf}
    [2008/02/24 v1.1q PS graphics for pdfLaTeX (RN,HjG)]
\newcommand*\ppf@TeX@mode{-1}
\newcommand*\ppf@draft{false}
\newif\if@ppf@PST@used\@ppf@PST@usedtrue
\newif\if@ppf@tightpage \@ppf@tightpagetrue
\DeclareOption{active}{\OptionNotUsed}
\DeclareOption{inactive}{\def\ppf@TeX@mode{9}}
\DeclareOption{ignore}{\def\ppf@TeX@mode{999}}
\DeclareOption{pstricks}{\@ppf@PST@usedtrue}
\DeclareOption{nopstricks}{\@ppf@PST@usedfalse}
\DeclareOption{displaymath}{%
  \PassOptionsToPackage\CurrentOption{preview}}
\DeclareOption{draft}{\def\ppf@draft{true}}
\DeclareOption{final}{\def\ppf@draft{false}%
  \PassOptionsToPackage\CurrentOption{graphicx}}
\DeclareOption{notightpage}{\@ppf@tightpagefalse}%
\DeclareOption{tightpage}{\@ppf@tightpagetrue}%
\DeclareOption*{%
  \PassOptionsToPackage\CurrentOption{pstricks}}
\ProcessOptions\relax
\ifnum\ppf@TeX@mode=999\relax\expandafter\endinput\fi
\ifnum\ppf@TeX@mode=-1\relax
  \begingroup
    \chardef\x=0 %
    \@ifundefined{pdfoutput}{}{%
      \ifcase\pdfoutput\else
        \chardef\x=1 %
      \fi
    }%
    \@ifundefined{OpMode}{}{\chardef\x=2 }%
  \expandafter\endgroup
  \ifcase\x
    \def\ppf@TeX@mode{0}%
  \or
    \def\ppf@TeX@mode{1}%
  \else
    \def\ppf@TeX@mode{9}%
  \fi
\fi
\newcommand*\PDFcontainer{}
\edef\PDFcontainer{\jobname-pics.pdf}
\newcounter{pspicture}
\newcommand*\ppf@other@extensions[1]{}
\newcommand*\usepicture[2][]{}
\newcommand*\savepicture[1]{}
  \newenvironment*{pst-pdf-defs}%
  {%
    \endgroup
  }{%
    \begingroup
    \def\@currenvir{pst-pdf-defs}%
  }
\RequirePackage{graphicx}%
\let\ppf@Ginclude@graphics\Ginclude@graphics
\let\ppf@Gin@extensions\Gin@extensions
\let\ppf@Gin@ii\Gin@ii
\newif\if@ppf@pdftex@graphic
\newif\ifGin@frame\Gin@framefalse
\newif\ifGin@innerframe\Gin@innerframefalse
\newif\ifGin@showname\Gin@shownamefalse
\newif\ifGin@ignore\Gin@ignorefalse
\newif\ifpr@outer
\newcommand*\ppf@is@pdfTeX@graphic[5]{%
  \@ppf@pdftex@graphicfalse%
  \begingroup
    \edef\pdfTeXext{#2}%
    \def\Gin@setfile##1##2##3{%
      \edef\@tempb{##2}%
      \@for\@tempa:=\pdfTeXext\do{%
        \ifx\@tempa\@tempb\global\@ppf@pdftex@graphictrue\fi}}%
    \edef\Gin@extensions{#2,#3}%
    \pr@outerfalse\ppf@Ginclude@graphics{#1}%
  \endgroup
  \if@ppf@pdftex@graphic#4\else#5\fi
}
\ifcase\ppf@TeX@mode\relax
  \PackageInfo{pst-pdf}{%
    MODE: \ppf@TeX@mode\space (dvi -- extraction mode)}
  \nofiles
  \let\makeindex\@empty \let\makeglossary\@empty
  \AtBeginDocument{\overfullrule=\z@}%
  \if@ppf@PST@used\RequirePackage{pstricks}\fi
  \RequirePackage[active,dvips,tightpage]{preview}[2005/01/29]%
  \newcommand*\ppf@PreviewBbAdjust{}
  \newcommand*\ppf@RestoreBbAdjust{%
    \let\PreviewBbAdjust\ppf@PreviewBbAdjust}%
  \begingroup
    \let\AtBeginDocument\@gobble \let\PackageWarningNoLine\@gobbletwo
    \def\pdftexversion{121}\input{pdftex.def}%
    \edef\x{\endgroup\def\noexpand\ppf@other@extensions{\Gin@extensions}
    }%
  \x
  \AtBeginDocument{%
    \@ifpackageloaded{keyval}{%
      \def\KV@errx#1{\PackageInfo{keyval}{#1}}%
      }{}%
    \@ifpackageloaded{xkeyval}{%
      \def\XKV@err#1{\PackageInfo{xkeyval}{#1}}%
    }{}%
    \@for\@tempa:=\ppf@other@extensions\do{%
      \expandafter\let\csname Gin@rule@\@tempa\endcsname\relax}%
    \DeclareGraphicsRule{*}{eps}{*}{}}%
  \define@key{Gin}{innerframe}[true]{}%
  \define@key{Gin}{frame}[true]{}%
  \define@key{Gin}{ignore}[true]{}%
  \define@key{Gin}{showname}[true]{}%
  \define@key{Gin}{namefont}{}%
  \if@ppf@tightpage\else
    \def\PreviewBbAdjust{%
      -.5\paperwidth -.5\paperheight .5\paperwidth .5\paperheight}%
    \AtEndDocument{%
      \PackageWarningNoLine{pst-pdf}{Picture container needs cropping.}}%
  \fi
  \newenvironment{postscript}[1][]%
  {%
    \global\let\ppf@PreviewBbAdjust\PreviewBbAdjust
    \if@ppf@tightpage
      \begingroup
        \setkeys{Gin}{#1}%
        \xdef\PreviewBbAdjust{%
          -\Gin@vllx bp -\Gin@vlly bp \Gin@vurx bp \Gin@vury bp}%
      \endgroup
    \fi
    \ignorespaces
  }%
  {\aftergroup\ppf@RestoreBbAdjust}%
  \PreviewEnvironment{postscript}%
  \AtBeginDocument{%
    \@ifundefined{PSTricksLoaded}{}%
    {%
      \PreviewEnvironment{pspicture}%
      \@ifundefined{psmatrix}{}%
      {%
        \PreviewEnvironment{psmatrix}%
        \newcommand*\ppf@set@mode{}%
        \newcommand*\ppf@test@mmode{%
        \ifmmode
          \ifinner
            \let\ppf@set@mode=$%
          \else
            \def\ppf@set@mode{$$}%
          \fi
        \else
          \let\ppf@set@mode=\@empty
        \fi
        }%
        \let\ppf@psmatrix=\psmatrix
        \expandafter\let\expandafter\ppf@pr@psmatrix%
          \expandafter=\csname pr@\string\psmatrix\endcsname
        \let\ppf@endpsmatrix=\endpsmatrix
        \def\psmatrix{\ppf@test@mmode\ppf@psmatrix}
        \expandafter\def\csname pr@\string\psmatrix\endcsname{%
          \ppf@set@mode\ppf@pr@psmatrix}%
        \def\endpsmatrix{\ppf@endpsmatrix\ppf@set@mode}%
      }%
      \PreviewMacro[{{}*[]%
        ?\bgroup{#{#1}{{#1}}}{}%
        ?\bgroup{#{#1}{{#1}}}{}%
        ?({#{(#1)}{({#1})}}{}%
        ?({#{(#1)}{({#1})}}{}%
        ?({#{(#1)}{({#1})}}{}%
        }]{\pst@object}}
    \@ifundefined{tabularx}{}{%
      \newcolumntype{X}{c}%
      \expandafter\let\expandafter\tabularx\csname tabular*\endcsname
      \expandafter\let\expandafter\endtabularx\csname endtabular*\endcsname
    }%
    \@ifundefined{pfx@includegraphicx}{}{%
      \PreviewMacro[{{}{}}]{\pfx@includegraphicx}}%
  }%
  \def\Gscale@@box#1#2#3{%
    \toks@{\mbox}%
  }
  \def\Ginclude@graphics#1{%
    \ifpr@outer
      \ppf@is@pdfTeX@graphic{#1}{\ppf@other@extensions}{\Gin@extensions}%
      {\rule{10pt}{10pt}}%
      {\ppf@Ginclude@graphics{#1}}%
    \else
      \ppf@Ginclude@graphics{#1}%
    \fi
  }%
  \PreviewMacro[{{}}]{\ppf@Ginclude@graphics}%
  \let\pdfliteral\@gobble%
\or
  \PackageInfo{pst-pdf}{MODE: \ppf@TeX@mode\space (pdfTeX mode)}%
  \@temptokena{%
    \let\Gin@PS@file@header\@gobble\let\Gin@PS@literal@header\@gobble
    \let\Gin@PS@raw\@gobble\let\Gin@PS@restored\@gobble
    \@ifundefined{PSTricksLoaded}{}{%
      \PSTricksOff
      \@ifundefined{c@lor@to@ps}{\def\c@lor@to@ps#1 #2\@@{}}{}}}%
  \if@ppf@PST@used
    \let\ppf@temp\AtBeginDvi\let\AtBeginDvi\@gobble
    \RequirePackage{pstricks}\let\AtBeginDvi\ppf@temp
  \fi
  \the\@temptokena %%% ????
  \expandafter\AtBeginDocument\expandafter
    {\the\@temptokena\@temptokena{}}%
  \@ifundefined{PSTricksLoaded}{}
  {%
    \newtoks\ppf@temptoken
    \ppf@temptoken\expandafter{\the\output}%
    \let\output\@gobble
    \let\ppf@nofiles\nofiles \let\nofiles\relax
    \RequirePackage[active]{preview}[2005/01/29]%
    \let\shipout=\pr@shipout \let\nofiles\ppf@nofiles
    \output\expandafter{\the\ppf@temptoken}%
    \ppf@temptoken{}%
    \long\def\pr@startbox#1#2{%
    \ifpr@outer
      \toks@{#2}%
      \edef\pr@cleanup{\the\toks@}%
      \setbox\@tempboxa\vbox\bgroup
      \everydisplay{}%
      \pr@outerfalse%
      \expandafter\@firstofone
    \else
      \expandafter\@gobble
    \fi{#1}}%
    \def\pr@endbox{%
    \egroup
    \setbox\@tempboxa\box\voidb@x
    \ppf@@getpicture
    \pr@cleanup}%
    \AtBeginDocument{%
      \@ifundefined{pst@object}{}%
      {%
        \PreviewMacro[{{}*[]%
          ?\bgroup{#{#1}{{#1}}}{}%
          ?\bgroup{#{#1}{{#1}}}{}%
          ?({#{(#1)}{({#1})}}{}%
          ?({#{(#1)}{({#1})}}{}%
          ?({#{(#1)}{({#1})}}{}%
          }]{\pst@object}}%
      }%
    }%
  \begingroup
    \input{dvips.def}%
    \edef\x{\endgroup\def\noexpand\ppf@other@extensions{\Gin@extensions}}%
  \x
  \DeclareGraphicsRule{*}{eps}{*}{}%
  \define@key{Gin}{innerframe}[true]{%
    \lowercase{\Gin@boolkey{#1}}{innerframe}}%
  \define@key{Gin}{frame}[true]{%
    \lowercase{\Gin@boolkey{#1}}{frame}}%
  \define@key{Gin}{ignore}[true]{%
    \lowercase{\Gin@boolkey{#1}}{ignore}}%
  \define@key{Gin}{frame@@}{%
    \edef\@tempa{\toks@{\noexpand\frame{\the\toks@}}}%
    \ifcase#1\relax
      \ifGin@innerframe\else\let\@tempa\relax\fi
    \or
      \ifGin@frame\else\let\@tempa\relax\fi
    \fi
    \@tempa
  }%
  \define@key{Gin}{showname}[true]{%
    \lowercase{\Gin@boolkey{#1}}{showname}}%
  \define@key{Gin}{namefont}{%
    \begingroup
      \@temptokena\expandafter{\ppf@namefont#1}%
      \edef\x{\endgroup\def\noexpand\ppf@namefont{\the\@temptokena}}%
    \x
  }%
  \newcommand*\ppf@filename{}%
  \newcommand*\ppf@namefont{\tiny\ttfamily}%
  \newcommand*\ppf@Gin@keys{}%
  \let\ppf@Gin@setfile\Gin@setfile
  \def\Gin@setfile#1#2#3{\ppf@Gin@setfile{#1}{#2}{#3}%
    \xdef\ppf@filename{%
      #3\ifx\GPT@page\@empty\else(\GPT@page)\fi}}%
  \def\Gin@ii[#1]#2{%
    \begingroup
      \setkeys{Gin}{#1}%
      \@temptokena{#1}\def\@tempb{#2}%
      \ifx\@tempb\@empty\else
        \ppf@is@pdfTeX@graphic{#2}{\Gin@extensions}{\ppf@other@extensions}%
        {%
          \ifx\@tempb\PDFcontainer
            \@temptokena{page=\GPT@page}%
          \fi
        }%
        {%
          \refstepcounter{pspicture}%
          \@temptokena{page=\the\c@pspicture}\def\@tempb{\PDFcontainer}%
        }%
      \fi
      \ifGin@ignore\else
        \edef\@tempa{\noexpand\ppf@Gin@ii[frame@@=0,\the\@temptokena,
          frame@@=1]{\@tempb}}%
        \@tempa
        \ifGin@showname
          \ppf@namefont
          \raisebox{-\ht\strutbox}[0pt][0pt]{\llap{\ppf@filename}}%
          \gdef\ppf@filename{}%
        \fi
      \fi
    \endgroup
  }%
  \IfFileExists{\PDFcontainer}%
  {%
    \pdfximage{\PDFcontainer}%
    \edef\ppf@container@max{\the\pdflastximagepages}%
    \AtEndDocument{%
      \ifnum\c@pspicture>\z@
        \ifnum\c@pspicture=\ppf@container@max\else
          \PackageWarningNoLine{pst-pdf}{%
            `\PDFcontainer' contains \ppf@container@max\space pages
            \MessageBreak but \the\c@pspicture\space pages are requested:
            \MessageBreak File `\PDFcontainer' is no more valid!
            \MessageBreak Recreate it
          }%
        \fi
      \fi
    }%
  }%
  {%
    \def\ppf@container@max{0}%
    \AtEndDocument{%
      \ifnum\c@pspicture>\z@
        \filename@parse{\PDFcontainer}%
        \PackageWarningNoLine{pst-pdf}{%
          File `\PDFcontainer' not found.\MessageBreak
          Use the following commands to create it:\MessageBreak
          ----------------------------------------------------
          \MessageBreak
          latex \jobname.tex\MessageBreak
          dvips -o \filename@base.ps \jobname.dvi\MessageBreak
          ps2pdf \filename@base.ps\MessageBreak
          ----------------------------------------------------
        }%
      \fi
    }%
  }%
  \newcommand\ppf@isnum[1]{%
    \if!\ifnum9<1#1!\else_\fi\expandafter\@firstoftwo
    \else\expandafter\@secondoftwo\fi}%
  \newcommand*\ppf@set@mode{}%
  \newcommand*\ppf@test@mmode{%
  \ifmmode
    \ifinner
      \let\ppf@set@mode=$%
    \else
      \def\ppf@set@mode{$$}%
    \fi
  \else
    \let\ppf@set@mode=\@empty
  \fi
  }
  \newenvironment{postscript}[1][]
  {%
    \ppf@test@mmode
    \gdef\ppf@Gin@keys{}%
    \def\@tempa{postscript}\ifx\@tempa\@currenvir\gdef\ppf@Gin@keys{#1}\fi
    \expandafter\let\expandafter\pst@object
      \csname pr@\string\pst@object\endcsname
    \pr@outerfalse
    \@makeother\&%
    \def\Gin@ii[##1]##2{}\setbox\@tempboxa=\vbox\bgroup
    \ppf@set@mode
  }%
  {\ppf@set@mode\egroup\aftergroup\ppf@@getpicture}%
  \AtBeginDocument{%
    \@ifundefined{PSTricksLoaded}{}%
    {%
      \iffalse
        \PreviewEnvironment{pspicture}% Why doesn't it work?
        \g@addto@macro\pspicture{%
          %%\pr@outerfalse% necessary, or already there anyway?
          \@makeother\&% necessary?
          \def\Gin@ii[#1]#2{}%
        }%
        \g@addto@macro\endpspicture{\ppf@@getpicture}%
      \else
        \def\pst@@@picture[#1](#2,#3)(#4,#5){\postscript}%
        \def\endpspicture{\endpostscript\endgroup}%
      \fi
      \@ifundefined{psmatrix}{}%
      {\let\psmatrix=\postscript\let\endpsmatrix=\endpostscript}%
    }%
    \@ifundefined{pfx@includegraphicx}{}{%
      \let\includegraphics=\pfx@includegraphics
      \def\pfx@includegraphicx#1#2{\ppf@@getpicture}%
    }%
  }%
  \def\savepicture#1{%
    \expandafter\xdef\csname ppf@@@#1\endcsname{\the\pdflastximage}}%
  \renewcommand*\usepicture[2][]{%
    \@ifundefined{ppf@@@#2}%
    {%
      \ppf@isnum{#2}%
      {\ppf@getpicture{#1}{#2}}%
      {\@latex@error{picture `#2' undefined}\@ehc}%
    }%
    {%
      \begingroup
        \def\Ginclude@graphics##1{%
          \xdef\ppf@filename{#2}%
          \setbox\z@\hbox{\pdfrefximage\@nameuse{ppf@@@#2}}%
          \Gin@nat@height\ht\z@ \Gin@nat@width\wd\z@
          \def\Gin@llx{0} \let\Gin@lly\Gin@llx
          \Gin@defaultbp\Gin@urx{\Gin@nat@width}%
          \Gin@defaultbp\Gin@ury{\Gin@nat@height}%
          \Gin@bboxtrue\Gin@viewport@code
          \Gin@nat@height\Gin@ury bp%
          \advance\Gin@nat@height-\Gin@lly bp%
          \Gin@nat@width\Gin@urx bp%
          \advance\Gin@nat@width-\Gin@llx bp%
          \Gin@req@sizes
          \ht\z@\Gin@req@height \wd\z@\Gin@req@width
          \leavevmode\box\z@}%
        \define@key{Gin}{type}{}%
        \includegraphics[scale=1,#1]{}%
      \endgroup
    }}%
  \newcommand*\ppf@getpicture[2]{%
    \@tempcnta=#2\relax%
    \ifnum\@tempcnta>\ppf@container@max
      \PackageWarningNoLine{pst-pdf}{%
        pspicture No. \the\@tempcnta\space undefined}%
    \else
      \includegraphics[draft=\ppf@draft,#1,page=\the\@tempcnta]%
        {\PDFcontainer}%
    \fi
    \gdef\ppf@Gin@keys{}}%
  \newcommand*\ppf@@getpicture{%
    \ifpr@outer
      \refstepcounter{pspicture}%
      \expandafter\ppf@getpicture\expandafter{\ppf@Gin@keys}%
      {\the\c@pspicture}%
    \fi}%
  \renewenvironment*{pst-pdf-defs}%
  {%
    \endgroup
    \chardef\ppf@temp=\catcode`\&%
    \@makeother\&%
  }{%
    \catcode`\&=\ppf@temp
    \begingroup
    \def\@currenvir{pst-pdf-defs}%
  }
\else
  \PackageInfo{pst-pdf}{MODE: \ppf@TeX@mode\space (inactive mode)}%
  \newenvironment{postscript}[1][]{\ignorespaces}{}
  \let\ppf@is@pdfTeX@graphic\relax
\fi
\InputIfFileExists{pst-pdf.cfg}{%
  \PackageInfo{pst-pdf}{Local config file pst-pdf.cfg used}}{}
\endinput
%%
%% End of file `pst-pdf.sty'.
