% \iffalse meta-comment
%
% Copyright (C) 2008 by Ulrich M. Schwarz
%
% This file may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3a.
% The license can be obtained from
% http://www.latex-project.org/lppl/lppl-1-3a.txt
%
% \fi
%
%\iffalse (hide this from DocInput)
%<*driver>
\makeatletter
\ifx\documentclass\@twoclasserror\else
  \expandafter\@firstofone
\fi{%
  \makeatother
  %% we are either \RequirePackage'd
  %% (which we won't support) or compiled directly.
  %% If we are compiled directly, yield the manual.
  %% Otherwise, this looks like a debugging session
  %% that directly uses the dtx file instead of the sty.
  \input{thmtools-manual.tex}
  \endinput
}
%</driver>
%<*thmtools>
%\fi
%    \begin{macrocode}
% common abbreviations and marker macros.
\let\@xa\expandafter
\let\@nx\noexpand
\def\thmt@quark{\thmt@quark}
\newtoks\thmt@toks


% a scratch counter, mostly for fake hyperlinks
\newcounter{thmt@dummyctr}%
\def\theHthmt@dummyctr{dummy.\arabic{thmt@dummyctr}}%
\def\thethmt@dummyctr{}%

\newcommand\thmt@mkextendingkeyhandler[3]{%
% #1: family
% #2: prefix for file
% #3: key hint for error
  \kv@set@family@handler{#1}{%
    \IfFileExists{#2-##1.sty}{%
      \PackageInfo{thmtools}%
        {Automatically pulling in `#2-##1'}%
      \RequirePackage{#2-##1}%
      \ifcsname KV@#1@##1\endcsname
        \csname KV@#1@##1\endcsname{##2}%
      \else
        \PackageError{thmtools}%
        {#3 `##1' not known}
        {I don't know what that key does.\MessageBreak
         I've even loaded the file `#2-##1.sty', but that didn't help.
        }%
      \fi
    }{%
      \PackageError{thmtools}%
      {#3 `##1' not known}
      {I don't know what that key does by myself,\MessageBreak
       and no file `#2-##1.sty' to tell me seems to exist.
      }%
    }%
  }
}

\RequirePackage{thm-patch, thm-kv, 
  thm-autoref, thm-listof, 
  thm-restate}

% Glue code for the big players.  
\@ifpackageloaded{amsthm}{%
  \RequirePackage{thm-amsthm}
}{}
\@ifpackageloaded{ntheorem}{%
  \RequirePackage{thm-ntheorem}
}{}
\@ifclassloaded{beamer}{%
  \RequirePackage{thm-beamer}
}{}
%    \end{macrocode}

%\iffalse
%</thmtools>
%\fi
