summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/texsis/base/TXShead.tex
blob: 02633b97d19c7d3ebbacd1b36ed91a770bdc78f8 (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
%% file: TXShead.tex - Running Headlines - TeXsis version 2.18
%% @(#) $Id: TXShead.tex,v 18.0 1999/07/09 17:24:29 myers Exp $
%======================================================================*
% RUNNING HEADLINES (and footlines) with page numbers
%
%       This is an alternative definition of \makeheadline, which can be
% used to put the running headlines in the right position.  A new dimension
% called \headlineoffset specifies how much the headline is to be RAISED.
% The default, which is zero, puts the headline in the "usual" place.
% Similarly, \footlineoffset LOWERS the footline an extra bit. To meet
% the Yale Graduate School guidelines I used \headlineoffset=0.2in.
%
% This file is a part of TeXsis.
% (C) copyright 1991, 1997 by Eric Myers and Frank Paige
%======================================================================*
\message{Running Headlines.}

\newdimen\headlineoffset        \headlineoffset=0.0cm   % how much to raise
\newdimen\footlineoffset        \footlineoffset=0.0cm   % how much to lower

\newif\ifRunningHeads           \RunningHeadsfalse      % default: off
\newif\ifbookpagenumbers        \bookpagenumbersfalse   % default: off
\newif\ifrightn@m               \rightn@mtrue           % default: right


% re-define \makeheadline and \makefootline from Plain TeX to
% allow for moving the headlines up and footlines down

\def\makeheadline{\vbox to 0pt{\vskip-22.5pt
   \vskip-\headlineoffset              % raises the headline an extra bit
   \line{\vbox to 8.5pt{}\the\headline}\vss}\nointerlineskip}

\def\makefootline{\baselineskip=24pt    % normal skip to footline
   \vskip\footlineoffset                % lower the footline an extra bit
   \line{\the\footline}}


%   \Headline and \Footline actually create the running head and foot
% lines. We make \the\headline=\HeadLine and \the\footline=\FootLine. For
% the first page of a chapter there is no headline, and no page number. For
% subsequent pages there is a running head line with page number, and nothing
% at the bottom of the page. The text of the running head and foot lines is
% kept in \HeadText and \FootText. \chapter and \section make their arguments
% the running head text, but you can change this by re-defining \HeadText 
% immediately after calling these macros. By default the headline is written 
% in italics; you can change this yourself in \HeadText.

%-%\headline={\HeadLine}                           % headline executes \HeadLine


%       \HeadLine uses marks to turn off headline on first pages. \HeadText
% contains the text; \He@dText is set to it or \relax depending on 
% \ifRunningHeads.

\def\HeadLine{%
   \edef\firstm{{\XA\iffalse\firstmark\fi}}% chapternumber of \firstmark
   \edef\topm{{\XA\iffalse\topmark\fi}}% chapternumber of \topmark
   \ifRunningHeads                      % print running heads?
     \def\He@dText{{\HeadFont \HeadText}}% head text in \HeadFont
   \else\def\He@dText{\relax}\fi        % or nothing
   \ifbookpagenumbers                   % book-like numbering
      \ifodd\pageno\rightn@mtrue        %   odd numbers right
      \else\rightn@mfalse\fi            %   even numbers left
   \else\rightn@mtrue\fi                % or always right
   \tenrm                               % page number in Roman
   \ifx\topm\firstm                     % Marks the same?
     \ifrightn@m                        % number on right?
        {\hss\He@dText\hss\llap{\HeadFont\rm\PageNumber}}% 
     \else                              % or on left
        {\rlap{\HeadFont\rm\PageNumber}\hss\He@dText\hss}% 
      \fi 
   \else \hfill \fi}%                   % NOTHING ON FIRST PAGE of chapter

\def\HeadText{\hfill}

%-%\footline={\FootLine}

\def\FootLine{%
   \edef\firstm{%
      {\expandafter\iffalse\firstmark\fi}}% get first mark
   \edef\topm{% 
      {\expandafter\iffalse\topmark\fi}}% and top mark
   \ifx\topm\firstm \hss                % if not page 1, nothing
    \else {\hss\HeadFont \FootText \hss} \fi}    % print \FootText if page 1

\def\FootText{\hfill}                   % nothing by default

\def\HeadFont{\tenit}                   % default is 10pt Roman italic


% Page numbers are links to the table of contents, but they also
% have names so you can link to them.  You should be able to have both
% href= and name= in the same anchor, but that fails in HyperTeXview
% for now. 
 
\begingroup
  \catcode`<=12 \catcode`>=12 \catcode`\"=12 
  \gdef\PageLinkto#1{%
        \html{<a href="\hash sect.TOC">}% 
        \html{<a NAME="page.\the\pageno">}%
        {#1}\html{</a>}%
        \html{</a>}%
   }%
\endgroup

\def\PageNumber{\PageLinkto{\folio}}% default is just \folio


%-------------------------*
% In Plain TeX \nopagenumbers turns off the page numbering by making
% the footline \hfil.  In TeXsis, pagenumbers can appear on the
% headline instead, so we turn that off too.

\def\nopagenumbers{\headline={\hfil}\footline={\hfil}}%

% We'd like to turn it back on, or put them at the bottom.

\def\pagenumbers{\headline={\HeadLine}\footline={\FootLine}}
\def\bottompagenumbers{\footline={\hfill{\rm\PageNumber}\hfill}%
                \headline={\hfill}}

% -- This just sets the flag for odd/even page numbers

\def\bookpagenumbers{\bookpagenumberstrue}

%======================================================================*
% BINDING MARGIN
%        Add extra binding margin on left side for even pages and on 
% right side for odd ones. Assumes (for now) \hoffset=0pt.

% Just like standard \plainoutput except for \makeBindingMargin.
\def\plainoutput{%                      \plainoutput with binding margin
  \makeBindingMargin
  \shipout\vbox{\makeheadline\pagebody\makefootline}%
  \advancepageno
  \ifnum\outputpenalty>-\@MM \else\dosupereject\fi}

% Extra margin for binding
\newdimen\BindingMargin \BindingMargin=0pt

% Insert extra \BindingMargin on left side of odd numbered pages and right
% side of even numbered ones. But do nothing if \BindingMargin=0pt so as not
% to clobber user's \hoffset. The user must adjust other page dimensions by 
% hand.

\def\makeBindingMargin{%               add \BindingMargin in \output
   \ifdim\BindingMargin>0pt
   \ifodd\pageno\hoffset=\BindingMargin\else
   \hoffset=-\BindingMargin\fi\fi}

%>>> EOF TXShead.tex <<<