summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/AkkTeX/akksection.sty
blob: 4328da0261a5875175417f65dc47088e057756d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
%=====================================================================================================================================
% Package akksection by Igor Akkerman (c) 2004, 2005
% Package providing an alternative section definition command.
%
% 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{akksection}[2005/04/30 by Igor Akkerman (c) 2004, 2005 v1.0.2 Package providing an alternative section definition command.]
%=====================================================================================================================================

\makeatletter

\newif\if@embedded

% \akk@startsection{<name>}{<ebene>}{<einzug>}{<einziehen?>}{<vorabstand>}{<eingebettet?>}{<nachabstand>}{stil}
\def\akk@startsection#1#2#3#4#5#6#7#8{%
    \if@noskipsec \leavevmode \fi%
    \par%
    \@tempskipa #5\relax%
    \csname @afterindent#4\endcsname%
    \if@nobreak%
        \everypar{}%
    \else%
        \addpenalty\@secpenalty\addvspace\@tempskipa%
    \fi%
    \@ifstar{%
        \akk@ssect{#3}{#4}{#5}{#6}{#7}{#8}%
    }{%
        \@dblarg{\akk@sect{#1}{#2}{#3}{#5}{#6}{#7}{#8}}%
    }%
}

% \akk@sect{<name>}{<ebene>}{<einzug>}{<vorabstand>}{<eingebettet?>}}{<nachabstand>}{<stil>}[<toc_eintrag>]{<label>}
\def\akk@sect#1#2#3#4#5#6#7[#8]#9{%
    \ifnum #2>\c@secnumdepth%
        \let\@svsec\@empty%
    \else%
        \refstepcounter{#1}%
        \protected@edef\@svsec{\@seccntformat{#1}\relax}%
    \fi%
    \@tempskipa #6\relax%
    \csname @embedded#5\endcsname%
    \if@embedded%
        \def\@svsechd{%
            #7{\hskip #3\relax\@svsec #9}%
            \csname #1mark\endcsname{#8}%
            \addcontentsline{toc}{#1}{%
                \ifnum #2>\c@secnumdepth%
                \else%
                    \protect\numberline{\csname the#1\endcsname}%
                \fi%
                #8%
            }%
        }%
    \else%
        \begingroup%
            #7{%
                \@hangfrom{\hskip #3\relax\@svsec}%
                \interlinepenalty \@M #9\@@par%
            }%
        \endgroup%
        \csname #1mark\endcsname{#8}% 
        \addcontentsline{toc}{#1}{%
            \ifnum #2>\c@secnumdepth
            \else%
                \protect\numberline{\csname the#1\endcsname}%
            \fi%
            #8%
        }%
    \fi%
    \akk@xsect{#5}{#6}%
}

% \akk@ssect{<einzug>}{<einziehen?>}{<vorabstand>}{<eingebettet?>}{<nachabstand>}{<stil>}{<label>}
\def\akk@ssect#1#2#3#4#5#6#7{%
    \csname @embedded#4\endcsname%
    \if@embedded%
        \def\@svsechd{#6{\hskip #1\relax #7}}%
    \else%
        \begingroup%
            #6{%
                \@hangfrom{\hskip #1}%
                \interlinepenalty \@M #7\@@par%
            }%
        \endgroup%
    \fi%
    \akk@xsect{#4}{#5}%
}

% \akk@xsect{<eingebettet>}{<nachabstand>}
\def\akk@xsect#1#2{%
    \@tempskipa #2\relax%
    \csname @embedded#1\endcsname%
    \if@embedded%
        \@nobreakfalse%
        \global\@noskipsectrue%
        \everypar{%
            \if@noskipsec%
                \global\@noskipsecfalse%
                {\setbox\z@\lastbox}%
                \clubpenalty\@M%
                \begingroup \@svsechd \endgroup%
                \unskip%
                \@tempskipa #2\relax%
                \hskip \@tempskipa%
            \else%
                \clubpenalty \@clubpenalty%
                \everypar{}%
            \fi%
        }%
    \else%
        \par \nobreak%
        \vskip \@tempskipa%
        \@afterheading%
    \fi%
    \ignorespaces%
}

\makeatother