%%
%% This is file `xtheorem.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xtheorem.dtx  (with options: `package,trace')
%% 
%% Not for distribution
%% File xtheorem.dtx
%%  (C) Copyright 1999 Achim Blumensath
%%  (C) Copyright 2004 2006 2008 LaTeX3 Project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the ``xtheorem bundle'' (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/cgi-bin/cvsweb.cgi/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
\GetIdInfo$Id: xtheorem.dtx 754 2008-08-03 19:30:38Z morten $
          {Experimental theorem package}
\ProvidesExplPackage
  {\filename}{\filedate}{\fileversion}{\filedescription}
\RequirePackage{xparse}
\RequirePackage{template}
\DeclareTemplateType{theoremstyle}{3}

\skip_new:N \TS_pre_skip
\skip_new:N \TS_post_skip
\dim_new:N  \TS_head_indent_dim
\skip_new:N \TS_head_sep_skip

\DeclareTemplate{theoremstyle}{std}{3}
{
  pre-skip    =l  [\DelayEvaluation{\topsep}]     \TS_pre_skip,
  post-skip   =l  [\DelayEvaluation{\topsep}]     \TS_post_skip,
  body-style  =f0 [\itshape]                      \TS_body_style_tlp,
  head-style  =f0 [\bfseries]                     \TS_head_style_tlp,
  note-style  =f0 [\fontseries\mddefault\upshape] \TS_note_style_tlp,
  head-punct  =f0 [.]                             \TS_head_punct_tlp,
  head-format =f3 [\IfNoValueF{#1}{#1\IfNoValueF{#2}{\space}}
                   \IfNoValueF{#2}{\textup{#2}}
                   \IfNoValueF{#3}{\space{\TS_note_style_tlp(#3)}}]
                                                  \TS_head_format:nnn,
  head-indent      =l  [0pt]                      \TS_head_indent_dim,
  head-sep         =l  [5pt plus 1pt minus 1pt]   \TS_head_sep_skip,
  post-head-action =f0 []                         \TS_post_head_action_tlp
}
{
  \DoParameterAssignments
  \if_mode_horizontal:
    \prg_whiledo:nT{
      \int_compare:nNnT \etex_lastnodetype:D = \c_eleven
    }{\tex_unskip:D}
    \par
  \fi:
  \normalfont
  \trivlist
  \let:NN\thmheadnl\scan_stop:
  \@topsep\TS_pre_skip
  \@topsepadd\TS_post_skip
  \IfNoValueF{#1}
    {\refstepcounter{#1}}
  \deferred@thm@head{
    \TS_head_style_tlp
    \skip_horizontal:N \TS_head_indent_dim
    \IfNoValueTF{#1}
      {\TS_head_format:nnn{#2}{#1}{#3}}
      {\TS_head_format:nnn{#2}{\cs_use:c{the#1}}{#3}}
    \TS_head_punct_tlp
    \TS_post_head_action_tlp
    \skip_horizontal:N\TS_head_sep_skip
  }
  \TS_body_style_tlp
  \ignorespaces
}
\let:NN\adjust@parskip@nobreak \@nbitem
\toks_new:N\dth@everypar
\toks_set:Nn \dth@everypar{
  \@minipagefalse
  \global\@newlistfalse
  \if@inlabel
    \global\@inlabelfalse
    \begingroup
      \setbox\z@\lastbox
      \ifvoid\z@ \kern-\itemindent \fi
    \endgroup
    \unhbox\@labels
  \fi
  \if@nobreak
    \@nobreakfalse
    \clubpenalty\@M
  \else
    \clubpenalty\@clubpenalty
    \everypar{}
  \fi
}
\def\deferred@thm@head#1{%
  \if@inlabel \indent \par \fi % eject a section head if one is pending
  \if@nobreak
    \adjust@parskip@nobreak
  \else
    \addpenalty\@beginparpenalty
    \addvspace\@topsep
    \addvspace{-\parskip}%
  \fi
  \global\@inlabeltrue
  \everypar\dth@everypar
  \sbox\@labels{\normalfont#1}%
  \ignorespaces
}
\DeclareInstance{theoremstyle}{plain}{std}{}

\DeclareInstance{theoremstyle}{definition}{std}
{
  body-style = \normalfont
}

\DeclareInstance{theoremstyle}{remark}{std}
{
  pre-skip   = \DelayEvaluation{0.5\topsep},
  post-skip  = \DelayEvaluation{0.5\topsep},
  body-style = \normalfont,
  head-style = \itshape
}
\def:Npn\@endtheorem{\endtrivlist\@endpefalse }
\DeclareDocumentCommand{\newtheorem}{smmomo}
{
  \exp_args:Nc\@ifdefinable{#3}
  {
    \IfBooleanTF{#1}
    {
      \DeclareDocumentEnvironment{#3}{o}
        {\UseInstance{theoremstyle}{#2}{\NoValue}{#5}{##1}}
        {\@endtheorem}
    }
    {
      \IfNoValueTF{#4}
      {
        \IfNoValueTF{#6}
        {
          \newcounter{#3}
        }
        {
          \newcounter{#3}[#6]
          \gdef:cpx{the#3}{\exp_not:c{the#6}
            \@thmcountersep\@thmcounter{#3}}
        }
        \DeclareDocumentEnvironment{#3}{o}
          {\UseInstance{theoremstyle}{#2}{#3}{#5}{##1}}
          {\@endtheorem}
      }
      {
        \cs_if_free:cTF{c@#4}
        {
          \@nocounterr{#4}
        }
        {
          \gdef:cpx{the#3}{\exp_not:c{the#4}}
          \DeclareDocumentEnvironment{#3}{o}
            {\UseInstance{theoremstyle}{#2}{#4}{#5}{##1}}
            {\@endtheorem}
        }
      }
    }
  }
}
\endinput
%%
%% End of file `xtheorem.sty'.
