summaryrefslogtreecommitdiff
path: root/info/examples/tip/genhead.tip
blob: 44588f7dfdbe9bb8afaf2d7eddaa02d1a03e759c (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
% This macro source file is from the four volume series
% "TeX in Practice" by Stephan von Bechtolsheim, published
% 1993 by Springer-Verlag, New York.
% Copyright 1993 Stephan von Bechtolsheim.
% No warranty or liability is assumed.
% This macro may be copied freely if no fees other than
% media cost or shipping charges are charged and as long
% as this copyright and the following source code itself
% is not changed. Please see the series for further information.
%
% Version: 1.0
% Date: May 1, 1993
%
%
% This source code is documented in 11.5.5, p. II-93.
% Original source in file "par2.TEX", starting line 2264.
\wlog{L: "genhead.tip" ["par2.TEX," l. 2264, p. II-93]}%
% This file DOES belong to format "texip."
\InputD{vsmax.tip}
\InputD{box-mac.tip}
\InputD{parin.tip}
\newtoks\EveryHeading
\EveryHeading = {}
\catcode`\@ = 11
\newcount\@GenericHeadingCount
\newcount\@GenericHeadingIndent
\def\LineBreakHeading{%
    \errmessage{%
        \string\LineBreakHeading/\string\LineBreakToc:
            can only be used inside a heading.}%
}
\let\LineBreakToc = \LineBreakHeading
\def\IgnoreInRunnningHead #1{%
    #1%
}
\def\GenericHeading #1#2#3#4#5{% 
    \par
    \the\EveryHeading
    \@GenericHeadingCount = #1
    \@GenericHeadingIndent = #5
    \MaxVskip{#2}%
    \ifdim\leftskip = 0pt
    \else
        \message{\string\GenericHeading: \noexpand\leftskip
            is non-zero, forgotten to terminate a list?}%
    \fi
    \begingroup 
    \interlinepenalty = 10000
    \parindent = 0pt
    \parskip = 0pt
    \ifnum #4 = 1
        \hyphenpenalty = 10000
    \fi
    \ifnum #3 = 1
        \rightskip = 0pt plus 50pt
    \fi
    \@GenericHeading
}
\def\@GenericHeading #1#2#3#4#5#6#7{%
        #3%
        \def\LineBreakHeading{\hfil\break}%
        \def\LineBreakToc{ }%
        \ifdim #4 > 0pt
            \ifnum\@GenericHeadingIndent = 0
                \hangindent = #4
                \hangafter = 1
                \leavevmode
                \hbox to #4{#5\hfil}% 
            \else
                \leavevmode
                \hbox to #4{#5\hfil}% 
            \fi             
        \else
            \setbox0 = \hbox{#5\hskip -#4}
            \ifnum\@GenericHeadingIndent = 0
                \hangindent = \wd0
                \hangafter = 1
                \leavevmode
                \box0
            \else
                \leavevmode
                \box0
            \fi
        \fi
        #6% 
        \if\NameDefinedConditional{WriteToAuxSpecial}%
            \def\LineBreakToc{\hfil\break}%
            \def\LineBreakHeading{ }%
            \WriteToAuxSpecial{toc}{\the\@GenericHeadingCount}% 
                {#5}{#7}{\PrintCounter{PageNo}}%
        \fi
        \par
    \endgroup
    \nobreak
    \vskip #1
    \ifnum #2 = 0
        \SuppressNextParIndent
    \fi
}
\catcode`\@ = 12