summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/fancyhdr/extramarks.sty
blob: 4f4070d5b00dab920e541cf5afc757bd30cf1a60 (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
% Extra marks for latex. Version 2.0.
% Piet van Oostrum, 
% Dept of Computer and Information Sciences, University of Utrecht,
% Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
% Telephone: +31 30 2532180. Email: piet@cs.uu.nl
% ========================================================================
% LICENCE:
% This file may be distributed under the terms of the LaTeX Project Public
% License, as described in lppl.txt in the base LaTeX distribution.
% Either version 1 or, at your option, any later version.
% ========================================================================
% MODIFICATION HISTORY:
% Oct 11, 2000
% version 1.99e
% Added a few % marks to get rid of unwanted spaces, and \endinput.
% Added LPPL license clause.
% March 12, 2002
% version 2.0beta
% Adapted for the new implementation of marks in LaTeX to solve bug
% latex/3203. 
% Added symmetric commands \firstrightmark, \lastleftmark, \firstleftxmark,
% \firstrightxmark, \lastrightxmark, \lastleftxmark, \topleftxmark and
% \toprightxmark.
% March 3, 2004
% version 2.0
% Release.

% This package gives you two additional marks. 
% \extramarks{m1}{m2} define two extra marks for headers/footers 
% (especially for use with fancyheadings), which can be retrieved 
% by \firstxmark and \lastxmark resp. Usually m1 is what would 
% appear at the top of the page, m2 at the bottom of the page.
% Typical usage:
% \pagestyle{fancy}
% \lhead{\firstxmark}
% \rfoot{\lastxmark}
%
% \extramarks{}{Continued on next page...}
% text text text text text text text text text text text text text text text 
% text text text text text text text text text text text text text text text 
% text text text text text text text text text text text text text text text 
% text text text text text text text text text text text text text text text 
% text text text text text text text text text text text text text text text 
% \extramarks{Continued}{}
% \extramarks{}{}

% This package also provides two extra handles to the standard LaTeX marks,
% namely \firstleftmark and \lastrightmark (the standard \leftmark and
% \rightmark of LaTeX always give you the last and first, respectively.
% These are the complementary values). For symmetry reasons \firstrightmark
% is an alias for \rightmark and \lastleftmark is an alias for \leftmark

% Similarly there are now \firstleftxmark \firstrightxmark \lastrightxmark
% \lastleftxmark. Here first and last apply to the position on the page,
% left and right select the m1 and m2 values, respectively.
 
% Note: there is an extra command \topxmark, but this doesn't work properly
% if marginpars or floats are used, as LaTeX clobbers TeX's topmark in this
% case. 

\newtoks\@temptokenb

%Just in case.
\providecommand\unrestored@protected@xdef{%
   \let\protect\@unexpandable@protect
   \xdef
}

\def\markboth#1#2{%
  \begingroup
    \let\label\relax \let\index\relax \let\glossary\relax
    \expandafter\@markboth\@themark{#1}{#2}%
    \@temptokena \expandafter{\@themark}%
    \mark{\the\@temptokena}%
  \endgroup
  \if@nobreak\ifvmode\nobreak\fi\fi}
% This definitions is in latex.ltx. No use to duplicate here
%\def\markright#1{%
%  \begingroup
%    \let\label\relax \let\index\relax \let\glossary\relax
%    \expandafter\@markright\@themark {#1}%
%    \@temptokena \expandafter{\@themark}%
%    \mark{\the\@temptokena}%
%  \endgroup
%  \if@nobreak\ifvmode\nobreak\fi\fi}

% Old definition:
%\def\@markboth#1#2#3#4#5#6{\gdef\@themark{{#5}{#6}{#3}{#4}}}
%\def\@markright#1#2#3#4#5{\gdef\@themark{{#1}{#5}{#3}{#4}}}

% Note: put #3#4 in toks register.
\def\@markboth#1#2#3#4#5#6{\@temptokena {{#3}{#4}}%
  \unrestored@protected@xdef\@themark{{#5}{#6}\the\@temptokena}}

% Note: put #1 and #3#4 in toks register.
% Maybe I can get rid of the extra temptokenb by doing the expansion of #5
% to a temp separately.
\def\@markright#1#2#3#4#5{\@temptokena {#1}\@temptokenb {{#3}{#4}}%
  \unrestored@protected@xdef\@themark{{\the\@temptokena}{#5}\the\@temptokenb}}

\def\@leftmark#1#2#3#4{#1} 
\def\@rightmark#1#2#3#4{#2}

\def\leftmark{\expandafter\@leftmark
      \botmark\@empty\@empty\@empty\@empty}
\def\rightmark{\expandafter\@rightmark
      \firstmark\@empty\@empty\@empty\@empty}
\def\firstleftmark{\expandafter\@leftmark
      \firstmark\@empty\@empty\@empty\@empty}
\def\lastrightmark{\expandafter\@rightmark
      \botmark\@empty\@empty\@empty\@empty}
\let\firstrightmark \rightmark
\let\lastleftmark \leftmark

\def\@themark{{}{}{}{}}

\def\extramarks#1#2{%
  \begingroup
    \let\label\relax \let\index\relax \let\glossary\relax
    \expandafter\@markextra\@themark{#1}{#2}%
    \@temptokena \expandafter{\@themark}%
    \mark{\the\@temptokena}%
  \endgroup
  \if@nobreak\ifvmode\nobreak\fi\fi}
%Note Put #1#2 in toks register
\def\@markextra#1#2#3#4#5#6{\@temptokena {{#1}{#2}}%
  \unrestored@protected@xdef\@themark{\the\@temptokena{#5}{#6}}}
\def\firstleftxmark{\expandafter\@leftxmark
      \firstmark\@empty\@empty\@empty\@empty}
\def\firstrightxmark{\expandafter\@rightxmark
      \firstmark\@empty\@empty\@empty\@empty}
\def\topleftxmark{\expandafter\@leftxmark
      \topmark\@empty\@empty\@empty\@empty}
\def\toprightxmark{\expandafter\@rightxmark
      \topmark\@empty\@empty\@empty\@empty}
\def\lastleftxmark{\expandafter\@leftxmark
      \botmark\@empty\@empty\@empty\@empty}
\def\lastrightxmark{\expandafter\@rightxmark
      \botmark\@empty\@empty\@empty\@empty}
\let\firstxmark\firstleftxmark
\let\lastxmark\lastrightxmark
\let\topxmark\topleftxmark
\def\@leftxmark#1#2#3#4{#3}
\def\@rightxmark#1#2#3#4{#4}
\endinput