%%
%% This is file `combinedgraphics.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% combinedgraphics.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright 2009 Christian Schneider <software(at)chschneider(dot)eu>
%% 
%% ion@addto@macro: identical to l@addto@macro from koma-script
%%                  bundle v2.9t
%% Copyright 1994-2004 Markus Kohm and Frank Neukam
%% 
%% Thanks to Markus Kohm for permitting to use his code in this package.
%% Please do not bother Markus with questions or bugs concering this package!
%% 
%% This file is part of combinedgraphics.
%% 
%% combinedgraphics is free software: you can redistribute it and/or modify
%% it under the terms of the GNU General Public License version 3 as
%% published by the Free Software Foundation, not any later version.
%% 
%% combinedgraphics is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%% GNU General Public License for more details.
%% 
%% You should have received a copy of the GNU General Public License
%% along with combinedgraphics.  If not, see <http://www.gnu.org/licenses/>.
%% 
%% WARNING: THIS IS ALPHA SOFTWARE AND MAY CONTAIN SERIOUS BUGS!
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{combinedgraphics}
  [2011/06/15 v0.1.1-alpha inclusion of combined EPS/LaTeX graphics]
\RequirePackage{keyval}
\RequirePackage{graphicx}
\RequirePackage{color}
\newif\ifcgr@vecfirst
\newcommand*\cgr@defopts{\define@key{cgr}}
\newcommand*\cgr@setopts{\setkeys{cgr}}
\cgr@defopts{textfontcmd}{\gdef\cgr@textfont@default{\@nameuse{#1}}}
\cgr@defopts{textcolorcmd}{\gdef\cgr@textcolor@default{\@nameuse{#1}}}
\cgr@defopts{vecscale}{\gdef\cgr@vecscale@default{#1}}
\cgr@defopts{vecinclude}{\gdef\cgr@vecinclude@default{#1}}
\cgr@defopts{vecfirst}{\gdef\cgr@vecfirst@default{#1}}
\DeclareOption*{%
  \expandafter\cgr@setopts\expandafter{\CurrentOption}%
}
\ProcessOptions\relax
\newcommand*\cgr@defopts@combgrphcs{\define@key{cgr@combgrphcs}}
\newcommand*\cgr@setopts@combgrphcs{\setkeys{cgr@combgrphcs}}
\cgr@defopts@combgrphcs{textfont}{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty%
    \def\cgr@textfont{}%
  \else%
    \def\cgr@textfont{%
      #1%
      \def\SetFigFont{\cgr@gobblefive}%     %% Xfig <= 3.2.4
      \def\SetFigFontNFSS{\cgr@gobblefive}% %% Xfig >= 3.2.5-alpha
    }%
  \fi%
}
\cgr@defopts@combgrphcs{textcolor}{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty%
    \def\cgr@textcolor{}%
  \else%
    \def\cgr@textcolor{%
      #1%
      \def\color{\cgr@gobble@optone}%
    }%
  \fi%
}
\cgr@defopts@combgrphcs{vecscale}{%
  \def\cgr@vecscale{#1}%
  \def\setlength{\cgr@setlength}%
  \def\includegraphics{\cgr@includegraphics}%
}
\cgr@defopts@combgrphcs{vecinclude}{%
  \def\cgr@vecinclude{\@nameuse{cgr@requires@graphics#1}}%
}
\cgr@defopts@combgrphcs{vecfirst}{%
  \@nameuse{cgr@vecfirst#1}%
}
\cgr@defopts@combgrphcs{vecfile}{%
  \def\cgr@vecfile{#1}%
  \cgr@setopts@combgrphcs{vecinclude=overwrite}%
}
\cgr@defopts@combgrphcs{angle}{%
  \ifx\cgr@curr@scaleopts\@empty%
    \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{\rotatebox{#1}}%
  \else%
    \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{]}%
    \cgr@raddto@macro[expand]{\cgr@curr@pic}{\cgr@curr@scaleopts}%
    \cgr@raddto@macro{\cgr@curr@pic}{\rotatebox[}%
    \def\cgr@curr@scaleopts{}%
  \fi%
}
\cgr@defopts@combgrphcs{origin}{\cgr@addto@macro{\cgr@curr@scaleopts}{%
  origin=#1,}%
}
\cgr@defopts@combgrphcs{x}{\cgr@addto@macro{\cgr@curr@scaleopts}{x=#1,}}
\cgr@defopts@combgrphcs{y}{\cgr@addto@macro{\cgr@curr@scaleopts}{y=#1,}}
\cgr@defopts@combgrphcs{units}{\cgr@addto@macro{\cgr@curr@scaleopts}{units=#1,}}
\cgr@defopts@combgrphcs{scale}{%
  \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{\scalebox{#1}}%
}
\cgr@defopts@combgrphcs{hscale}{%
  \def\cgr@curr@hscale{#1}%
  \ifx\cgr@curr@vscale\@empty%
  \else%
    \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{]}%
    \cgr@raddto@macro[expand]{\cgr@curr@pic}{\cgr@curr@vscale}%
    \cgr@raddto@macro{\cgr@curr@pic}{[}%
    \cgr@raddto@macro[expand,groupsecond]{\cgr@curr@pic}{\cgr@curr@hscale}%
    \cgr@raddto@macro{\cgr@curr@pic}{\scalebox}%
    \def\cgr@curr@hscale{}%
    \def\cgr@curr@vscale{}%
  \fi%
}
\cgr@defopts@combgrphcs{vscale}{%
  \def\cgr@curr@vscale{#1}%
  \ifx\cgr@curr@hscale\@empty%
  \else%
    \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{]}%
    \cgr@raddto@macro[expand]{\cgr@curr@pic}{\cgr@curr@vscale}%
    \cgr@raddto@macro{\cgr@curr@pic}{[}%
    \cgr@raddto@macro[expand,groupsecond]{\cgr@curr@pic}{\cgr@curr@hscale}%
    \cgr@raddto@macro{\cgr@curr@pic}{\scalebox}%
    \def\cgr@curr@hscale{}%
    \def\cgr@curr@vscale{}%
  \fi%
}
\cgr@defopts@combgrphcs{height}{%
  \def\cgr@curr@height{#1}%
  \ifx\cgr@curr@width\@empty%
  \else%
    \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
      \cgr@curr@height%
    }%
    \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
    \cgr@raddto@macro{\cgr@curr@pic}{\resizebox}%
    \def\cgr@curr@height{}%
    \def\cgr@curr@width{}%
  \fi%
}
\cgr@defopts@combgrphcs{totalheight}{%
  \def\cgr@curr@totalheight{#1}%
  \ifx\cgr@curr@width\@empty%
  \else%
    \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
      \cgr@curr@totalheight%
    }%
    \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
    \cgr@raddto@macro{\cgr@curr@pic}{\resizebox*}%
    \def\cgr@curr@totalheight{}%
    \def\cgr@curr@width{}%
  \fi%
}
\cgr@defopts@combgrphcs{width}{%
  \def\cgr@curr@width{#1}%
  \ifx\cgr@curr@height\@empty%
    \ifx\cgr@curr@totalheight\@empty%
    \else%
      \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
        \cgr@curr@totalheight%
      }%
      \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
      \cgr@raddto@macro{\cgr@curr@pic}{\resizebox*}%
      \def\cgr@curr@totalheight{}%
      \def\cgr@curr@width{}%
    \fi%
  \else%
    \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
      \cgr@curr@height%
    }%
    \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
    \cgr@raddto@macro{\cgr@curr@pic}{\resizebox}%
    \def\cgr@curr@height{}%
    \def\cgr@curr@totalheight{}%
    \def\cgr@curr@width{}%
  \fi%
}
\cgr@defopts@combgrphcs{keepaspectratio}[]{%
  \ifx\cgr@curr@height\@empty%
    \ifx\cgr@curr@totalheight\@empty%
      \ifx\cgr@curr@width\@empty%
      \else%
        \cgr@setopts@combgrphcs{height=!}%
      \fi%
    \else%
      \cgr@setopts@combgrphcs{width=!}%
    \fi%
  \else%
    \cgr@setopts@combgrphcs{width=!}%
    \def\cgr@curr@totalheight{}%
  \fi%
}
\long\def\cgr@curr@pic{}
\newif\ifcgr@requires@graphics\cgr@requires@graphicstrue
\def\cgr@requires@graphicsauto{}
\def\cgr@requires@graphicsoverwrite{%
  \cgr@requires@graphicstrue%
  \def\includegraphics{\cgr@gobble@optone}%
}
\def\cgr@textfont{}
\def\cgr@textcolor{}
\def\cgr@vecscale{1}
\def\cgr@vecinclude{\cgr@requires@graphicsauto}
\cgr@vecfirsttrue
\def\cgr@vecfile{}
\def\cgr@curr@hscale{}
\def\cgr@curr@vscale{}
\def\cgr@curr@scaleopts{}
\def\cgr@curr@height{}
\def\cgr@curr@width{}
\def\cgr@curr@totalheight{}
\newcommand{\includecombinedgraphics}[2][]{%
  \begingroup%
    \global\cgr@requires@graphicstrue%
    \setbox\@tempboxa\hbox{%
      \def\includegraphics{%
        \global\cgr@requires@graphicsfalse\cgr@gobble@optone%
      }%
      \input{#2}%
    }%
    \cgr@addto@macro{\cgr@curr@pic}{%
      %% from basic macro options
      \cgr@vecinclude\cgr@textfont\cgr@textcolor%
      %% inclusion of vector graphics part
      \ifcgr@requires@graphics%
        \ifcgr@vecfirst%
          \begin{picture}(0,0)%
            \cgr@includegraphics@orig[scale=\cgr@vecscale]{\cgr@vecfile}%
          \end{picture}%
        \else%
          \def\picture{\cgr@picture}%
          \def\endpicture{%
            \put(\cgr@picture@xoffs,\cgr@picture@yoffs)%
              {\cgr@includegraphics@orig[scale=\cgr@vecscale]{\cgr@vecfile}}%
            \cgr@endpicture@orig%
          }%
        \fi%
      \fi%
      %% inclusion of \LaTeX{} part
      \input{#2}%
    }%
    \@ifundefined{cgr@vecscale@default}{}{%
      \cgr@setopts@combgrphcs{vecscale=\cgr@vecscale@default}%
    }%
    \@ifundefined{cgr@textfont@default}{}{%
      \cgr@setopts@combgrphcs{textfont=\cgr@textfont@default}%
    }%
    \@ifundefined{cgr@textcolor@default}{}{%
      \cgr@setopts@combgrphcs{textcolor=\cgr@textcolor@default}%
    }%
    \@ifundefined{cgr@vecinclude@default}{}{%
      \cgr@setopts@combgrphcs{vecinclude=\cgr@vecinclude@default}%
    }%
    \@ifundefined{cgr@vecfirst@default}{}{%
      \cgr@setopts@combgrphcs{vecfirst=\cgr@vecfirst@default}%
    }%
    \def\cgr@vecfile{#2}%
    \cgr@setopts@combgrphcs{#1}%
    \cgr@curr@pic%
  \endgroup%
}
\long\def\cgr@gobblefive#1#2#3#4#5{}
\long\def\cgr@gobble@optone{\@ifstar{\cgr@gobble@optone}{\cgr@gobble@optone@}}
\long\def\cgr@gobble@optone@{\@ifnextchar [{\cgr@gobble@optone@@}{\@gobble}}
\long\def\cgr@gobble@optone@@[#1]{\cgr@gobble@optone@}
\let\cgr@setlength@orig=\setlength
\def\cgr@setlength#1#2{%
  \ifx#1\unitlength%
    \@tempdima=#2%
    \cgr@setlength@orig{#1}{\cgr@vecscale\@tempdima}%
    \def\setlength{\cgr@setlength@orig}%
  \else%
    \cgr@setlength@orig{#1}{#2}%
  \fi%
}
\let\cgr@includegraphics@orig=\includegraphics
\def\cgr@includegraphics{%
  \@ifstar{%
    \cgr@includegraphics@s@%
  }{%
    \cgr@includegraphics@%
  }%
}
\def\cgr@includegraphics@{%
  \@ifnextchar [{%
    \cgr@includegraphics@@%
  }{%
    \cgr@includegraphics@orig[scale=\cgr@vecscale]%
  }%
}
\def\cgr@includegraphics@@[#1]{%
  \@ifnextchar [{%
    \cgr@includegraphics@@@[#1]%
  }{%
    \cgr@includegraphics@orig[#1,scale=\cgr@vecscale]%
  }%
}
\def\cgr@includegraphics@@@[#1][#2]{%
  \cgr@includegraphics@orig[#1][#2,scale=\cgr@vecscale]%
}
\def\cgr@includegraphics@s@{%
  \@ifnextchar [{%
    \cgr@includegraphics@s@@%
  }{%
    \cgr@includegraphics@orig*[scale=\cgr@vecscale]%
  }%
}
\def\cgr@includegraphics@s@@[#1]{%
  \@ifnextchar [{%
    \cgr@includegraphics@s@@@[#1]%
  }{%
    \cgr@includegraphics@orig*[#1,scale=\cgr@vecscale]%
  }%
}
\def\cgr@includegraphics@s@@@[#1][#2]{%
  \cgr@includegraphics@orig*[#1][#2,scale=\cgr@vecscale]%
}
\let\cgr@picture@orig=\picture
\let\cgr@endpicture@orig=\endpicture
\long\def\cgr@picture(#1,#2){%
  \@ifnextchar({%
    \cgr@picture@(#1,#2)%
  }{%
    \cgr@picture@(#1,#2)(0,0)%
  }%
}
\def\cgr@picture@(#1,#2)(#3,#4){%
  \def\cgr@picture@xoffs{#3}%
  \def\cgr@picture@yoffs{#4}%
  \cgr@picture@orig(#1,#2)(#3,#4)%
}
\newcommand{\cgr@addto@macro}[2]{%
  \begingroup\toks@\expandafter{#1#2}%
    \edef\@tempa{\endgroup\def\noexpand#1{\the\toks@}}%
  \@tempa%
}
\newcommand*\cgr@defopts@raddto{\define@key{cgr@raddto}}
\newcommand*\cgr@setopts@raddto{\setkeys{cgr@raddto}}
\newif\ifcgr@raddto@expand\cgr@raddto@expandfalse
\newif\ifcgr@raddto@groupfirst\cgr@raddto@groupfirstfalse
\newif\ifcgr@raddto@groupsecond\cgr@raddto@groupsecondfalse
\cgr@defopts@raddto{expand}[true]{\@nameuse{cgr@raddto@expand#1}}
\cgr@defopts@raddto{groupfirst}[true]{\@nameuse{cgr@raddto@groupfirst#1}}
\cgr@defopts@raddto{groupsecond}[true]{\@nameuse{cgr@raddto@groupsecond#1}}
\newtoks\cgr@token@a
\newtoks\cgr@token@b
\newcommand{\cgr@raddto@macro}[3][]{%
  \begingroup%
    \cgr@setopts@raddto{#1}%
    \cgr@token@a\expandafter{#2}%
    \ifcgr@raddto@expand%
      \cgr@token@b\expandafter{#3}%
    \else%
      \cgr@token@b{#3}%
    \fi%
    \ifcgr@raddto@groupfirst%
      \ifcgr@raddto@groupsecond%
        \edef\@tempa{\endgroup%
          \def\noexpand#2{{\the\cgr@token@b}{\the\cgr@token@a}}%
        }%
      \else%
        \edef\@tempa{\endgroup%
          \def\noexpand#2{\the\cgr@token@b{\the\cgr@token@a}}%
        }%
      \fi%
    \else%
      \ifcgr@raddto@groupsecond%
        \edef\@tempa{\endgroup%
          \def\noexpand#2{{\the\cgr@token@b}\the\cgr@token@a}%
        }%
      \else%
        \edef\@tempa{\endgroup%
          \def\noexpand#2{\the\cgr@token@b\the\cgr@token@a}%
        }%
      \fi%
    \fi%
  \@tempa%
}
\endinput
%%
%% End of file `combinedgraphics.sty'.
