%=====================================================================================================================================
% Package akkparskip by Igor Akkerman (c) 2004, 2005
% Package providing a non empty paragraph skip with list and section environment corrections.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License (latest version).
%
% The latest version of this license can be found at
%     http://www.latex-project.org/lppl.txt
%
% This file may only be distributed together with the full 'AkkTeX' bundle.
%=====================================================================================================================================
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{akkparskip}[2005/04/30 by Igor Akkerman (c) 2004, 2005 v1.3.2 Package providing a non empty paragraph skip with list and section environment corrections.]
%=====================================================================================================================================

\RequirePackage{akksection}

\makeatletter

\newcommand \akk@layoutlist {%
    % ------------------------------------------------------------------------------
    % set default labelsep
    % (as set for the article class) 
    %
    \setlength   \labelsep     \akk@default@labelsep%
    % ------------------------------------------------------------------------------
    % set default labelwidth
    % (as set in size10.clo for the article class)
    %
    \setlength   \labelwidth    \leftmargin%
    \addtolength \labelwidth    {-\labelsep}%
    % ------------------------------------------------------------------------------
    % set default rightmargin
    %
    \setlength   \rightmargin   \akk@default@rightmargin%
    % ------------------------------------------------------------------------------
    % set default listparindent
    %
    \setlength   \listparindent \akk@default@listparindent%
    % ------------------------------------------------------------------------------
    % set default itemindent
    %
    \setlength   \itemindent    \akk@default@itemindent%
    % ------------------------------------------------------------------------------
    % set default topsep
    % (set it to the default topsep value of the article class
    %  minus the parskip since we don't need it before and after the list)
    %
    \setlength   \topsep        \akk@default@topsep%
    \addtolength \topsep        {-\parskip}%
    % ------------------------------------------------------------------------------
    % set default partopsep
    % (set it to our parskip value)
    %
    \setlength   \partopsep   \akk@default@partopsep%
    % ------------------------------------------------------------------------------
    % set default parsep
    % (set it to our parskip value)
    %
    \setlength   \parsep      \akk@default@parsep%
    % ------------------------------------------------------------------------------
    % set default itemsep
    % (set it to the default itemsep value minus the parsep since we don't need it)
    %
    \setlength   \itemsep     \akk@default@itemsep%
    \addtolength \itemsep     {-\parsep}%
    % ------------------------------------------------------------------------------
}

\let \akk@orig@listI   \@listI
\let \akk@orig@listi   \@listi
\let \akk@orig@listii  \@listii
\let \akk@orig@listiii \@listiii
\let \akk@orig@listiv  \@listiv
\let \akk@orig@listv   \@listv
\let \akk@orig@listvi  \@listvi

\newcommand \akk@default@listI {%
    \setlength \leftmargin \leftmargini%
    \akk@layoutlist%
}
\let \akk@default@listi \akk@default@listI
     
\newcommand \akk@default@listii {%
    \setlength \leftmargin \leftmarginii%
    \akk@layoutlist%
}
     
\newcommand \akk@default@listiii {%
    \setlength \leftmargin \leftmarginiii%
    \akk@layoutlist%
}
 
\newcommand \akk@default@listiv {%
    \setlength \leftmargin \leftmarginiv%
    \akk@layoutlist%
}

\newcommand \akk@default@listv {%
    \setlength \leftmargin \leftmarginv%
    \akk@layoutlist%
}

\newcommand \akk@default@listvi {%
    \setlength \leftmargin \leftmarginvi%
    \akk@layoutlist%
}

% --------------------------------------------------------------------------------------------------------------------------------------------------------------------

% original values of the article class
\newlength \akk@orig@parskip
\newlength \akk@orig@parindent
\newlength \akk@orig@labelsep
\newlength \akk@orig@rightmargin
\newlength \akk@orig@listparindent
\newlength \akk@orig@itemindent
\newlength \akk@orig@topsep
\newlength \akk@orig@partopsep
\newlength \akk@orig@parsep
\newlength \akk@orig@itemsep

% actual default values of this style
\newlength \akk@default@parskip
\newlength \akk@default@parindent
\newlength \akk@default@labelsep
\newlength \akk@default@rightmargin
\newlength \akk@default@listparindent
\newlength \akk@default@itemindent
\newlength \akk@default@topsep
\newlength \akk@default@partopsep
\newlength \akk@default@parsep
\newlength \akk@default@itemsep

% skips before and after sections
\newlength \akk@@beforesectionskip
\newlength \akk@@beforesubsectionskip
\newlength \akk@@beforesubsubsectionskip
\newlength \akk@@beforeparagraphskip
\newlength \akk@@aftersectionskip
\newlength \akk@@aftersubsectionskip
\newlength \akk@@aftersubsubsectionskip
\newlength \akk@@afterparagraphskip

% get the original values of the article class
\setlength \akk@orig@parskip          \parskip
\setlength \akk@orig@parindent        \parindent
\setlength \akk@orig@labelsep         \labelsep
\setlength \akk@orig@rightmargin      \rightmargin
\setlength \akk@orig@listparindent    \listparindent
\setlength \akk@orig@itemindent       \itemindent
\setlength \akk@orig@topsep           \topsep
\setlength \akk@orig@partopsep        \partopsep
\setlength \akk@orig@parsep           \parsep
\setlength \akk@orig@itemsep          \itemsep

% set the actual default values of this style
\setlength \akk@default@parindent     \z@
\setlength \akk@default@parskip       {0.71125\baselineskip plus 2pt} % = 3mm bei 10pt
\setlength \akk@default@labelsep      \akk@orig@labelsep
\setlength \akk@default@rightmargin   \z@
\setlength \akk@default@listparindent \z@
\setlength \akk@default@itemindent    \z@
\setlength \akk@default@topsep        \akk@orig@topsep
\setlength \akk@default@partopsep     \akk@default@parskip
\setlength \akk@default@parsep        \akk@default@parskip
\setlength \akk@default@itemsep       \akk@orig@itemsep

\newcommand \akk@setoriginalvalues {%
    \let \@listI   \akk@orig@listI%
    \let \@listi   \akk@orig@listi%
    \let \@listii  \akk@orig@listii%
    \let \@listiii \akk@orig@listiii%
    \let \@listiv  \akk@orig@listiv%
    \let \@listv   \akk@orig@listv%
    \let \@listvi  \akk@orig@listvi%
    \setlength \parskip       \akk@orig@parskip%
    \setlength \parindent     \akk@orig@parindent%
    \setlength \labelsep      \akk@orig@labelsep%
    \setlength \rightmargin   \akk@orig@rightmargin%
    \setlength \listparindent \akk@orig@listparindent%
    \setlength \itemindent    \akk@orig@itemindent%
    \setlength \topsep        \akk@orig@topsep%
    \setlength \partopsep     \akk@orig@partopsep%
    \setlength \parsep        \akk@orig@parsep%
    \setlength \itemsep       \akk@orig@itemsep%
}

\newcommand \akk@setdefaultvalues {%
    \let \@listI   \akk@default@listI%
    \let \@listi   \akk@default@listi%
    \let \@listii  \akk@default@listii%
    \let \@listiii \akk@default@listiii%
    \let \@listiv  \akk@default@listiv%
    \let \@listv   \akk@default@listv%
    \let \@listvi  \akk@default@listvi%
    \setlength \parskip       \akk@default@parskip%
    \setlength \parindent     \akk@default@parindent%
    \setlength \labelsep      \akk@default@labelsep%
    \setlength \rightmargin   \akk@default@rightmargin%
    \setlength \listparindent \akk@default@listparindent%
    \setlength \itemindent    \akk@default@itemindent%
    \setlength \topsep        \akk@default@topsep%
    \setlength \partopsep     \akk@default@partopsep%
    \setlength \parsep        \akk@default@parsep%
    \setlength \itemsep       \akk@default@itemsep%
    \akk@layoutlist%
}

% \akk@beforesectionskip {<sectionname>} {<skip before section>}
\newcommand \akk@beforesectionskip[2] {%
    \expandafter \setlength \csname akk@@before#1skip\endcsname {-\akk@default@parskip}%
    \expandafter \addtolength \csname akk@@before#1skip\endcsname {#2}%
}

% \akk@aftersectionskip {<sectionname>} {<skip after section>}
\newcommand \akk@aftersectionskip[2] {%
    \expandafter \setlength \csname akk@@after#1skip\endcsname {-\akk@default@parskip}%
    \expandafter \addtolength \csname akk@@after#1skip\endcsname {#2}%
}

\akk@beforesectionskip {section}       {3.5ex \@plus 1ex \@minus .2ex}
\akk@aftersectionskip  {section}       {2.3ex \@plus.2ex}

\akk@beforesectionskip {subsection}    {3.25ex\@plus 1ex \@minus .2ex}
\akk@aftersectionskip  {subsection}    {1.5ex \@plus .2ex}

\akk@beforesectionskip {subsubsection} {3.25ex\@plus 1ex \@minus .2ex}
\akk@aftersectionskip  {subsubsection} {1.5ex \@plus .2ex}

\akk@beforesectionskip {paragraph}     {2ex   \@plus 1ex \@minus .2ex}
\akk@aftersectionskip  {paragraph}     {.3ex  \@plus .2ex}

% \akk@startsection{<name>}{<ebene>}{<einzug>}{<einziehen?>}{<vorabstand>}{<eingebettet?>}{<nachabstand>}{stil}
\renewcommand \section       {\akk@startsection {section}       {1} {0pt} {false} {\akk@@beforesectionskip}       {false} {\akk@@aftersectionskip}       {\normalfont\Large\bfseries}}
\renewcommand \subsection    {\akk@startsection {subsection}    {2} {0pt} {false} {\akk@@beforesubsectionskip}    {false} {\akk@@aftersubsectionskip}    {\normalfont\large\bfseries}}
\renewcommand \subsubsection {\akk@startsection {subsubsection} {3} {0pt} {false} {\akk@@beforesubsubsectionskip} {false} {\akk@@aftersubsubsectionskip} {\normalfont\normalsize\bfseries}}
\renewcommand \paragraph     {\akk@startsection {paragraph}     {4} {0pt} {false} {\akk@@beforeparagraphskip}     {false} {\akk@@afterparagraphskip} {\normalfont\bfseries}}

\akk@setdefaultvalues

\makeatother
