%%
%% This is file `scrjura.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% scrjura.dtx  (with options: `package')
%% scrlogo.dtx  (with options: `logo')
%% 
%% Copyright (c) 2007-2009
%% Markus Kohm and any individual authors listed elsewhere in this file.
%% 
%% This file was generated from file(s) of the KOMA-Script bundle.
%% ---------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, version 1.3b of the license.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3b or later is part of all distributions of LaTeX
%% version 2005/12/01 or later and of this work.
%% 
%% This work has the LPPL maintenance status "author-maintained".
%% 
%% The Current Maintainer and author of this work is Markus Kohm.
%% 
%% This file may only be distributed together with the files
%% `scrlogo.dtx' and `scrjura.dtx'. You may however distribute the files
%% `scrlogo.dtx' and `scrjura.dtx' without this file.
%% See also `scrjura.dtx' for additional information.
%% 
%% If this file is a beta version, you are not allowed to distribute it.
%% 
%% Currently there is only a short german manual at `scrjura.dtx', that
%% should also be found as `scrjura.pdf'.
%% 
%% The KOMA-Script bundle (but maybe not this file) was based upon the
%% LaTeX2.09 Script family created by Frank Neukam 1993 and the LaTeX2e
%% standard classes created by The LaTeX3 Project 1994-1996.
%% 
%%% From File: scrjura.dtx
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{scrjura}
                [2008/01/23 v0.4b alpha
                (package)%
                ]

\@ifpackageloaded{hyperref}{%
  \PackageError{scrjura}{Package hyperref already loaded}{%
    If you want to use package scrjura with package hyperref, you have to
    use\MessageBreak
    package scrjura before package hyperref.\MessageBreak
    To solve the problem, you just should move the loading of package
    hyperref\MessageBreak
    behind the loading of package scrjura.}%
}
\DeclareOption{contract}{%
  \g@addto@macro\document\contract%
}
\newif\if@juratotoc
\DeclareOption{juratotoc}{\@juratotoctrue}
\newcommand*{\Paragraphmark}[1]{}
\DeclareOption{markright}{%
  \renewcommand*{\Paragraphmark}[1]{\markright{#1}}%
}
\DeclareOption{markboth}{%
  \renewcommand*{\Paragraphmark}[1]{\markboth{#1}{#1}}%
}
\DeclareOption{parcitename}{%
  \AtEndOfPackage{\renewcommand*{\parciteformat}[1]{\parname~#1}}%
}
\DeclareOption{sentencecitename}{%
  \AtEndOfPackage{\renewcommand*{\sentenceciteformat}[1]{\sentencename~#1}}%
}
\ProcessOptions\relax
\RequirePackage{keyval}
\newcommand*{\contract}{%
  \renewcommand*{\contract}{%
    \contract@nest@error{contract}%
  }%
  \let\@doendpe\contract@doendpe
  \let\Paragraph\contract@paragraph
  \let\c@Paragraph\c@contractParagraph
  \edef\cl@Paragraph{\cl@Paragraph\cl@contractParagraph}%
  \let\SubParagraph\contract@subparagraph
  \let\c@SubParagraph\c@contractSubParagraph
  \edef\cl@SubParagraph{\cl@SubParagraph\cl@contractSubParagraph}%
  \let\Par\contract@everypar
  \let\Sentence\contract@sentence
}
\let\if@jura@skiphyperref\iftrue
\let\cl@Paragraph\@empty
\let\cl@SubParagraph\@empty
\newcounter{contractParagraph}
\renewcommand*{\thecontractParagraph}{%
  {\S~\arabic{contractParagraph}}}
\newcounter{contractSubParagraph}
\@addtoreset{SubParagraph}{Paragraph}
\renewcommand*{\thecontractSubParagraph}{%
  {\theParagraph\alph{contractSubParagraph}}}
\define@key{contract}{title}{%
  \def\contract@title{#1}%
  \ifx\contract@entry\relax\def\contract@entry{\contract@title}\fi
  \ifx\contract@head\relax\def\contract@head{\contract@title}\fi
}
\define@key{contract}{entry}{\def\contract@entry{#1}}
\define@key{contract}{noentry}[]{\let\contract@entry\relax}
\define@key{contract}{head}{\def\contract@head{#1}}
\define@key{contract}{nohead}[]{\let\contract@head\relax}
\define@key{contract}{number}{\def\contract@number{#1}}
\newcommand*{\contract@preskip}{2\baselineskip}
\newcommand*{\contract@postskip}{\baselineskip}
\define@key{contract}{preskip}{\def\contract@preskip{#1}}
\define@key{contract}{postskip}{\def\contract@postskip{#1}}
\newif\ifcontract@dummy
\define@key{contract}{dummy}[true]{\csname contract@dummy#1\endcsname}
\newcommand*{\contract@paragraph@font}{\sffamily\bfseries\large\@hangfrom}
\newcounter{@AbsParagraph}
\newcommand*{\theH@AbsParagraph}{P-\arabic{@AbsParagraph}}
\newcommand*{\theHParagraph}{\theH@AbsParagraph}
\newcommand*{\theHSubParagraph}{\theH@AbsParagraph}
\newcommand*{\contract@paragraph}[1]{%
  \ManualPar\parnumbertrue
  \let\contract@title\relax
  \let\contract@entry\relax
  \let\contract@head\relax
  \let\contract@number\relax
  \contract@dummyfalse
  \ifx\relax#1\relax\else\setkeys{contract}{#1}\fi
  \ifcontract@dummy\else
    \@afterindentfalse
    \addvspace{\contract@preskip}%
  \fi
  \ifx\contract@number\relax
    \let\p@Paragraph\@empty
    \let\theParagraph\thecontractParagraph
    \refstepcounter{Paragraph}%
  \else
    \begingroup
      \let\@elt\@stpelt
      \cl@Paragraph
    \endgroup
    \protected@edef\theParagraph{\S~\contract@number}%
    \protected@edef\@currentlabel{\theParagraph}%
  \fi
  \stepcounter{@AbsParagraph}%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname if@skiphyperref\endcsname\relax
  \else
    \expandafter\let\csname if@jura@skiphyperref\expandafter\endcsname
    \csname if@skiphyperref\endcsname
  \fi
  \if@jura@skiphyperref\else
    \hyper@refstepcounter{@AbsParagraph}%
    \typeout{absolute Nummer: \the@AbsParagraph^^JLabel: `\@currentHref'}%
  \fi
  \let\theSubParagraph\theParagraph
  \ifcontract@dummy\else
    \begingroup
      \contract@paragraph@font \theParagraph
      \ifx\contract@title\relax\else\enskip\contract@title\fi
    \endgroup
    \ifx\contract@entry\relax\else
      \addcontentsline{toc}{cpar}{%
        \protect\numberline{\theParagraph}\contract@entry
      }%
      \addcontentsline{cpa}{cpar}{%
        \protect\numberline{\theParagraph}\contract@entry
      }%
    \fi
    \ifx\contract@head\relax\else
      \expandafter\Paragraphmark\expandafter{%
        \expandafter\theSubParagraph\expandafter\enskip\contract@head}%
    \fi
    \par\nobreak\vskip\contract@postskip
    \jura@afterheading{contract}%
  \fi
}
\newcommand*{\contract@subparagraph}[1]{%
  \ManualPar\parnumbertrue
  \let\contract@title\relax
  \let\contract@entry\relax
  \let\contract@head\relax
  \let\contract@number\relax
  \contract@dummyfalse
  \ifx\relax#1\relax\else\setkeys{contract}{#1}\fi
  \ifcontract@dummy\else
    \@afterindentfalse
    \vskip\contract@preskip
  \fi
  \ifx\contract@number\relax
    \let\p@SubParagraph\@empty
    \let\theSubParagraph\thecontractSubParagraph
    \refstepcounter{SubParagraph}%
  \else
    \begingroup
      \let\@elt\@stpelt
      \cl@SubParagraph
    \endgroup
    \protected@edef\theSubParagraph{\theParagraph\contract@number}%
    \protected@edef\@currentlabel{\theSubParagraph}%
  \fi
  \stepcounter{@AbsParagraph}%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname if@skiphyperref\endcsname\relax
  \else
    \expandafter\let\csname if@jura@skiphyperref\expandafter\endcsname
    \csname if@skiphyperref\endcsname
  \fi
  \if@jura@skiphyperref\else
    \hyper@refstepcounter{@AbsParagraph}%
    \typeout{absolute Nummer: \the@AbsParagraph^^JLabel: `\@currentHref'}%
  \fi
  \ifcontract@dummy\else
    \begingroup
      \contract@paragraph@font \theSubParagraph
      \ifx\contract@title\relax\else\enskip\contract@title\fi
    \endgroup
    \ifx\contract@entry\relax\else
      \addcontentsline{toc}{cpar}{%
        \protect\numberline{\theSubParagraph}\contract@entry
      }%
      \addcontentsline{cpa}{cpar}{%
        \protect\numberline{\theSubParagraph}\contract@entry
      }%
    \fi
    \ifx\contract@head\relax\else
      \expandafter\Paragraphmark\expandafter{%
        \expandafter\theSubParagraph\expandafter\enskip\contract@head}%
    \fi
    \par\nobreak\vskip\contract@postskip
    \jura@afterheading{contract}%
  \fi
}
\newcommand*{\AutoPar}{%
  \expandafter\let\expandafter\jura@everypar
  \csname \jura@type @everypar\endcsname
}
\newcommand*{\ManualPar}{%
  \let\jura@everypar\relax
}
\newcommand*{\jura@afterheading}[1]{%
  \@nobreaktrue
  \everypar{%
    \if@nobreak
      \@nobreakfalse
      \clubpenalty \@M
      \if@afterindent \else
        {\setbox\z@\lastbox}%
      \fi
    \else
      \clubpenalty \@clubpenalty
      \everypar{%
        \jura@everypar
      }%
    \fi
    \jura@everypar
  }%
  \def\jura@type{#1}%
  \AutoPar
}
\newcommand*{\jura@everypar}{}
\CheckCommand*\@doendpe{\@endpetrue
  \def\par{\@restorepar\everypar{}\par\@endpefalse}\everypar
  {{\setbox\z@\lastbox}\everypar{}\@endpefalse}}
\newcommand*{\contract@doendpe}{%
  \@endpetrue
  \def\par{%
    \@restorepar\everypar{%
      \csname jura@everypar\endcsname
    }%
    \par\@endpefalse
  }%
  \everypar{%
    {\setbox\z@\lastbox}\everypar{%
      \csname jura@everypar\endcsname
    }%
    \@endpefalse
  }%
}
\newcommand*{\l@cpar}[2]{%
  \if@juratotoc
    \@dottedtocline{\value{juratoclevel}}{1.5em}{2em}{#1}{#2}%
  \fi
}
\newcounter{juratoclevel}
\setcounter{juratoclevel}{2}%
\DeclareRobustCommand*{\jura@separator}[1]{#1}
\newif\ifparnumber
\newcounter{par}
\renewcommand*{\thepar}{\arabic{par}}
\newcommand*{\theHpar}{\theH@AbsParagraph-\Roman{par}}
\newcommand*{\parformat}{(\thepar)}
\renewcommand*\p@par{{\theSubParagraph\jura@separator{\nobreakspace}}}
\@addtoreset{par}{Paragraph}
\@addtoreset{par}{SubParagraph}
\newcommand*{\contract@everypar}{%
  \ifparnumber
    \refstepcounter{par}%
    \refstepcounter{sentence}%
    \begingroup
      \protected@write\@auxout{}{%
        \string\newmaxpar{contractpars}{\theSubParagraph}{\arabic{par}}}%
      \getmaxpar\@tempa{contractpars}{\theSubParagraph}%
      \typeout{Stored max is \@tempa}%
      \ifnum \@tempa>\@ne
        \parformat\nobreakspace
      \fi
    \endgroup
  \else
    \setcounter{sentence}{0}\refstepcounter{sentence}%
  \fi
}
\newcommand*{\refParagraph}[1]{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \ref{#1}%
  \else
    \begingroup
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter\def
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter\@tempb
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter{%
        \expandafter\expandafter\expandafter\@gobble\csname r@#1\endcsname}%
      \def\@tempc##1##2\@nil{##1}%
      \let\jura@separator\@gobble
      \protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
        \csname r@#1\endcsname\noexpand\@nil}%
      \protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
        \@tempa\@nil}%
      \let\@@protect\protect
      \let\protect\noexpand
      \expandafter\edef\csname r@#1\endcsname{{\@tempa}\@tempb}%
      \let\protect\@@protect
      \ref{#1}%
    \endgroup
  \fi
}
\newcommand*{\refPar}[1]{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \ref{#1}%
  \else
    \begingroup
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter\def
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter\@tempb
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter{%
        \expandafter\expandafter\expandafter\@gobble\csname r@#1\endcsname}%
      \def\@tempc##1##2\@nil{##1}%
      \let\jura@separator\@gobble
      \protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
        \csname r@#1\endcsname\noexpand\@nil}%
      \def\@tempc##1##2##3\@nil{##2}%
      \protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
        \@tempa{%
          \protect\G@refundefinedtrue
          \nfss@text{\reset@font\bfseries ??}%
          \@latex@warning{Reference `#1' on page \thepage \space
            with undefined par number}%
        }\noexpand\@nil}%
      \let\@@protect\protect
      \let\protect\noexpand
      \expandafter\edef\csname r@#1\endcsname{{\@tempa}\@tempb}%
      \let\protect\@@protect
      \ref{#1}%
    \endgroup
  \fi
}
\newcommand*{\refSentence}[1]{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \ref{#1}%
  \else
    \begingroup
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter\def
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter\@tempb
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter{%
        \expandafter\expandafter\expandafter\@gobble\csname r@#1\endcsname}%
      \def\@tempc##1##2\@nil{##1}%
      \let\jura@separator\@gobble
      \protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
        \csname r@#1\endcsname\noexpand\@nil}%
      \def\@tempc##1##2##3##4\@nil{##3}%
      \protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
        \@tempa{}{%
          \protect\G@refundefinedtrue
          \nfss@text{\reset@font\bfseries ??}%
          \@latex@warning{Reference `#1' on page \thepage \space
            with undefined sentence number}%
        }\noexpand\@nil}%
      \let\@@protect\protect
      \let\protect\noexpand
      \expandafter\edef\csname r@#1\endcsname{{\@tempa}\@tempb}%
      \let\protect\@@protect
      \ref{#1}%
    \endgroup
  \fi
}
\newcounter{sentence}[par]
\renewcommand*{\thesentence}{\arabic{sentence}}
\newcommand*{\theHsentence}{\theHpar-\arabic{sentence}}
\renewcommand*{\p@sentence}{\expandafter\p@@sentence}
\newcommand*{\p@@sentence}[1]{\p@par{{\par@cite{\thepar}}%
    \jura@separator{\nobreakspace}}{\sentence@cite{#1}}}
\newcommand*{\contract@sentence}{%
  \refstepcounter{sentence}%
  \ensuremath{^{\mbox{\fontsize\sf@size\z@\selectfont\thesentence}}}%
}
\DeclareRobustCommand*{\par@cite}[1]{\parciteformat{#1}}
\newcommand*{\parciteformat}[1]{\@Roman{\numexpr #1\relax}}
\DeclareRobustCommand*{\sentence@cite}[1]{\sentenceciteformat{#1}}
\newcommand*{\sentenceciteformat}[1]{\@arabic{\numexpr #1\relax}}
\newcommand*{\parname}{Paragraph}
\AtBeginDocument{%
  \@ifundefined{captionsgerman}{}{%
    \addto\captionsgerman{\def\parname{Absatz}}%
    \addto\captionsgerman{\def\sentencename{Satz}}%
    \ifnum \l@german=\language\selectlanguage{german}\fi
  }%
  \@ifundefined{captionsngerman}{}{%
    \addto\captionsngerman{\def\parname{Absatz}}%
     \addto\captionsngerman{\def\sentencename{Satz}}%
   \ifnum \l@ngerman=\language\selectlanguage{ngerman}\fi
  }%
}
\newcommand*{\newmaxpar}[3]{%
  \begingroup
    \protected@edef\@tempa{#2}\@onelevel@sanitize\@tempa
    \expandafter\xdef\csname max@#1@\@tempa\endcsname{#3}%
  \endgroup
}
\newcommand*{\getmaxpar}[3]{%
  \begingroup
    \protected@edef\@tempa{#3}%
    \@onelevel@sanitize\@tempa
    \expandafter\ifx \csname max@#2@\@tempa\endcsname\relax
      \edef\@tempa{\endgroup\edef\noexpand#1{\expandafter\the\value{par}}}%
    \else
      \edef\@tempa{\endgroup
        \edef\noexpand#1{\csname max@#2@\@tempa\endcsname}}%
    \fi
  \@tempa
}
%%% From File: scrlogo.dtx
\@ifundefined{KOMAScript}{%
  \DeclareRobustCommand{\KOMAScript}{\textsf{K\kern.05em O\kern.05em%
      M\kern.05em A\kern.1em-\kern.1em Script}}}{}
\endinput
%%
%% End of file `scrjura.sty'.
