summaryrefslogtreecommitdiff
path: root/info/examples/tip/ts-outpu.tip
blob: 39902664bf7aa8f8e63a7cb93c676adbf74c9e2b (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
% 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 35.9.1, p. IV-122.
% Original source in file "o2.TEX", starting line 1834.
\wlog{L: "ts-outpu.tip" ["o2.TEX," l. 1834, p. IV-122]}%
% This file DOES belong to format "texip."
\InputD{namedef.tip}
\InputD{showpll.tip}
\InputD{new-midi.tip}
\InputD{topinfix.tip}
\InputD{nathd.tip}
\InputD{rangetst.tip}
\newif\ifWritePageLog
\WritePageLogfalse
\newwrite\PageLogStream
\def\WritePageLogFile{%
    \immediate\openout\PageLogStream = \jobname.plog
    \WritePageLogtrue
}
\newcount\BadnessSave
\ShowPlainListsfalse
\catcode`\@ = 11
\newcount\@PageLayoutCode
\def\SetPageLayout #1{% 
    \global\@PageLayoutCode = #1
    \CheckRange{\@PageLayoutCode}{0}{5}%
        {\string\SetPageLayout: }
}
\SetPageLayout{0}%
\def\@LeftRunningHead{}
\def\@RightRunningHead{}
\newcount\@SavedPageLayoutCode
\def\NewPageRightHandSpecial{% 
    \vfill
    \supereject
    \ifodd\count0
        \wlog{\string\NewPageRightHandSpecial: no empty
            page to generate (\string\count0 = \the\count0)}%
    \else
        \hbox{}
        \@SavedPageLayoutCode = \@PageLayoutCode
        \SetPageLayout{1}%
        \wlog{\string\NewPageRightHandSpecial: empty page
            generated,
            (\string\count0 = \the\count0).}%
        \vfill
        \eject
        \SetPageLayout{\@SavedPageLayoutCode}%
    \fi
}
\newdimen\OddPagesHorizontalShift
\newdimen\EvenPagesHorizontalShift
\newdimen\CurrentPageShift
\def\plainoutput{% 
    \@ShowPlainLists
    \edef\@LeftRunningHead{\@LeftRunningHead}%
    \edef\@RightRunningHead{\@RightRunningHead}%
    \ifnum\@PageLayoutCode = 0
    \else
        \headline = {}
        \footline = {}
    \fi
    \ifcase\@PageLayoutCode
    \or
    \or
        \global\@PageLayoutCode = 3
    \or
        \@PageLayoutCodeThree
    \or
        \global\@PageLayoutCode = 5
    \or
        \ifodd\count0
            \headline = {% 
                \small\rm
                \hfil
                \botmark
                \hskip 18pt
                \PrintCounter{PageNo}%
            }%
        \else
            \headline = {% 
                \small\rm
                \PrintCounter{PageNo}%
                \hskip 18pt
                \@LeftRunningHead
                \hfil
            }%
        \fi
    \else
        \errmessage{\string\plainoutput: \string\@PageLayoutCode
            out of range.}%
    \fi
    \setbox 4 = \vbox{%
        \pagebody
    }%
    \ifWritePageLog
        \immediate\write\PageLogStream{%
            Part name: \CurrentPartName, Page \the\count0
        }%
        \immediate\write\PageLogStream{%
            Page \the\count0:
            stretch: \the\pagestretch,
            shrink: \the\pageshrink,
            outputpenalty: \the\outputpenalty
        }%
        \immediate\write\PageLogStream{%
            pagefilstretch: \the\pagefilstretch,
            pagefillstretch: \the\pagefillstretch
        }%
        \immediate\write\PageLogStream{%
            ht 255: \the\ht255,
            dp 255: \the\dp255
        }%
        \NaturalHeight{\dimen0}{255}%
        \NaturalDepth{\dimen1}{255}%
        \immediate\write\PageLogStream{%
            Natural height: \the\dimen0,
            Natural depth:  \the\dimen1
        }%
        \dimen2 = \vsize
        \advance\dimen2 by -\dimen0
        \immediate\write\PageLogStream{%
            Ideal height: \the\vsize,
            Difference:  \the\dimen2
        }%
        \immediate\write\PageLogStream{%
            badness: \the\BadnessSave,
            height: \the\ht4,
            depth: \the\dp4
        }%
        \immediate\write\PageLogStream{}%
    \fi
    \setbox 5 = \vbox{%
        \makeheadline
        \box 4
        \makefootline
    }%
    \@MakeRobustMacros
    \ifodd\count0
        \CurrentPageShift = \OddPagesHorizontalShift
    \else
        \CurrentPageShift = \EvenPagesHorizontalShift
    \fi
    \wlog{Redefined \string\plainoutput (ts-outpu.tip):
        Shifting: shift amount is \the\CurrentPageShift\space\space
        (page is \the\pageno).}%
    \setbox 6 = \vbox{%
        \moveright\CurrentPageShift \box5
    }%
    \shipout\box6
    \advancepageno
    \ifnum\outputpenalty > -10000
    \else
        \dosupereject
    \fi
}
\def\@PageLayoutCodeThree{%
    \ifodd\count0
        \headline = {% 
            \small\rm
            \hfil
            \@RightRunningHead
            \hskip 18pt
            \PrintCounter{PageNo}%
        }%
    \else
        \headline = {% 
            \small\rm
            \PrintCounter{PageNo}%
            \hskip 18pt
            \@LeftRunningHead
            \hfil
        }%
    \fi
}
\catcode`\@ = 12