Debian Codegraph @

texmf-dist/source/latex/base/ltpage.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 %
30 % \iffalse
31 %%% From File: ltpage.dtx
32 %
33 %<*driver>
34 % \fi
35 \ProvidesFile{ltpage.dtx}
36 [2025/05/22 v1.0o LaTeX Kernel (page style setup)]
37 % \iffalse
38 \documentclass{ltxdoc}
39 \GetFileInfo{ltpage.dtx}
40 \title{\filename}
41 \date{\filedate}
42 \author{%
43 Johannes Braams\and
44 David Carlisle\and
45 Alan Jeffrey\and
46 Leslie Lamport\and
47 Frank Mittelbach\and
48 Chris Rowley\and
49 Rainer Sch\"opf}
50
51 \begin{document}
52 \MaintainedByLaTeXTeam{latex}
53 \maketitle
54 \DocInput{\filename}
55 \end{document}
56 %</driver>
57 % \fi
58 %
59 %
60 % \section{Page styles and related commands}
61 %
62 %
63 % \changes{v1.0a}{1994/03/07}{Initial version, split from ltherest.dtx}
64 % \changes{v1.0b}{1994/04/19}{Improve documentation}
65 % \changes{v1.0i}{1996/04/18}{Improve documentation}
66 % \changes{v1.0l}{2019/08/27}{Make various commands robust}
67 %
68 %
69 % \subsection{Page Style Commands}
70 %
71 % |\pagestyle|\marg{style} : sets the page style of the
72 % current and succeeding pages to \emph{style}
73 %
74 % |\thispagestyle|\marg{style} : sets the page style of the
75 % current page only to \emph{style}.
76 %
77 % To define a page style \emph{style}, you must define
78 % |\ps@|\emph{style} to set the page style parameters.
79 %
80 % \subsection{How a page style makes running heads and feet}
81 %
82 % The |\ps@|\ldots command defines the macros |\@oddhead|, |\@oddfoot|,
83 % |\@evenhead|, and |\@evenfoot| to define the running heads and feet.
84 % (See output routine.) To make headings determined by the sectioning
85 % commands, the page style defines the commands |\chaptermark|,
86 % |\sectionmark|, etc., where |\chaptermark|\marg{text} is called by
87 % |\chapter| to set a mark. The |\...mark| commands and the |\...head|
88 % macros are defined with the help of the following macros.
89 %
90 % (All the |\...mark| commands should be initialized to no-ops.)
91 %
92 % \subsection{marking conventions}
93 %
94 % \LaTeX\ extends \TeX's |\mark| facility by producing two kinds of marks
95 % a `left' and a `right' mark, using the following commands:\\
96 % |\markboth|\marg{left}\marg{right} : Adds both marks.\\
97 % |\markright|\marg{right} : Adds a 'right' mark.\\
98 % |\leftmark| :
99 % Used in the output routine, gets the current `left' mark.
100 % Works like \TeX's |\botmark.|\\
101 % |\rightmark| :
102 % Used in the output routine, gets the current `right' mark.
103 % Works like \TeX's |\firstmark|.
104 % The marking commands work reasonably well for right marks `numbered
105 % within' left marks---e.g., the left mark is changed by a |\chapter|
106 % command and the right mark is changed by a |\section| command.
107 % However, it does produce somewhat anomalous results if 2 |\markboth|'s
108 % occur on the same page.
109 %
110 % Commands like |\tableofcontents| that should set the marks in some
111 % page styles use a |\@mkboth| command, which is |\let| by the pagestyle
112 % command (|\ps@...|) to |\markboth| for setting the heading or to
113 % |\@gobbletwo| to do nothing.
114 %
115 % \MaybeStop{}
116 %
117 % \begin{macrocode}
118 %<*2ekernel>
119 % \end{macrocode}
120 %
121 % \begin{macro}{\pagestyle}
122 % User command to set the page style for this and following pages.
123 % \changes{LaTeX2e}{1994/01/24}
124 % {(DPC) Complain if pagestyle is undefined.}
125 % \changes{LaTeX2e}{1994/02/01}
126 % {(DPC) Modify to get nicer error message}
127 % \begin{macrocode}
128 \def\pagestyle#1{%
129 \@ifundefined{ps@#1}%
130 \undefinedpagestyle
131 {\@nameuse{ps@#1}}}
132 % \end{macrocode}
133 % \end{macro}
134 %
135 % \begin{macro}{\thispagestyle}
136 % User command to set the page style for this page only.
137 % \changes{LaTeX2e}{1994/02/01}
138 % {(DPC) Modify to get nicer error message}
139 % \begin{macrocode}
140 \def\thispagestyle#1{%
141 \@ifundefined{ps@#1}%
142 \undefinedpagestyle
143 {\global\@specialpagetrue\gdef\@specialstyle{#1}}}
144 % \end{macrocode}
145 % \end{macro}
146 %
147 %
148 % \begin{macro}{\ps@empty}
149 % The empty page style: No head or foot line.
150 % \begin{macrocode}
151 \def\ps@empty{%
152 \let\@mkboth\@gobbletwo\let\@oddhead\@empty\let\@oddfoot\@empty
153 \let\@evenhead\@empty\let\@evenfoot\@empty}
154 % \end{macrocode}
155 % \end{macro}
156 %
157 % \begin{macro}{\ps@plain}
158 % \changes{v1.0g}{1995/05/26}{removed \cs{rmfamily} (PR 1578)}
159 % The plain page style: No head, centred page number in foot.
160 % \begin{macrocode}
161 \def\ps@plain{\let\@mkboth\@gobbletwo
162 \let\@oddhead\@empty\def\@oddfoot{\reset@font\hfil\thepage
163 \hfil}\let\@evenhead\@empty\let\@evenfoot\@oddfoot}
164 % \end{macrocode}
165 % \end{macro}
166 %
167 % \begin{macro}{\@leftmark}
168 % \begin{macro}{\@rightmark}
169 % We implement |\@leftmark| and |\@rightmark| in terms of already
170 % defined commands to save token space. We can't get rid of them
171 % since they are sometimes used in applications.
172 % \begin{macrocode}
173 \let\@leftmark\@firstoftwo
174 \let\@rightmark\@secondoftwo
175 % \end{macrocode}
176 % \end{macro}
177 % \end{macro}
178 %
179 %
180 % \begin{macrocode}
181 %</2ekernel>
182 %<*2ekernel|latexrelease>
183 %<latexrelease>\IncludeInRelease{2025/06/01}%
184 %<latexrelease> {\markboth}{Drop legacy mark support}%
185 % \end{macrocode}
186 %
187 %
188 % \begin{macro}{\markboth}
189 % \begin{macro}{\markright}
190 % \changes{v1.0d}{1994/05/20}{Changed setting for \cs{protect}.}
191 % \changes{v1.0e}{1994/11/04}{Added \cs{@unexpandable@protect}.
192 % ASAJ.}
193 %
194 % User commands for setting \LaTeX\ marks.
195 %
196 % Test for |@nobreak| added 15 Apr 86 in |\markboth| and |\markright|
197 % letting |\label| and |\index| to |\relax| added 22 Feb 86 so these
198 % commands can appear in sectioning command arguments
199 % RmS 91/06/21 Same for |\glossary|
200 % \changes{v1.0k}{2000/06/02}{Tidied 1.0j reimplementation, CAR}
201 % \changes{v1.0k}{2000/06/02}{Small adjustment to give slightly less
202 % expansion, CAR}
203 % \changes{v1.0j}{2000/05/26}{Reimplementation to fix expansion
204 % error (pr/3203).}
205 % \changes{v1.0m}{2020/07/27}{Don't make the command \cs{long} (gh/354)}
206 % \changes{v1.0n}{2022/04/04}{Interface with new mark mechanism}
207 % \changes{v1.0o}{2024/11/16}{Drop legacy mark support}
208 % \begin{macrocode}
209 \ExplSyntaxOn
210 \DeclareRobustCommand*\markboth[2]{%
211 \mark_insert:nn{2e-left}{#1}
212 \mark_insert:nn{2e-right}{#2}
213 \tl_if_empty:nF{#2}{ \mark_insert:nn{2e-right-nonempty}{#2} }
214 }
215 % \end{macrocode}
216 %
217 % \changes{v1.0m}{2020/07/27}{Don't make the command \cs{long} (gh/354)}
218 % \changes{v1.0n}{2022/04/04}{Interface with new mark mechanism}
219 % \changes{v1.0o}{2024/11/16}{Drop legacy mark support}
220 % \begin{macrocode}
221 \DeclareRobustCommand*\markright[1]{%
222 \mark_insert:nn{2e-right}{#1}
223 \tl_if_empty:nF{#1}{ \mark_insert:nn{2e-right-nonempty}{#1} }
224 }
225 \ExplSyntaxOff
226 % \end{macrocode}
227 % \end{macro}
228 % \end{macro}
229 %
230 % \begin{macrocode}
231 %</2ekernel|latexrelease>
232 %<latexrelease>\EndIncludeInRelease
233 %<latexrelease>\IncludeInRelease{2022/06/01}%
234 %<latexrelease> {\markboth}{New mark support}%
235 %<latexrelease>\ExplSyntaxOn
236 %<latexrelease>\DeclareRobustCommand*\markboth[2]{%
237 %<latexrelease> \begingroup
238 %<latexrelease> \let\label\relax \let\index\relax \let\glossary\relax
239 %<latexrelease> \unrestored@protected@xdef\@themark {{#1}{#2}}%
240 %<latexrelease> \@temptokena \expandafter{\@themark}%
241 %<latexrelease> \mark_insert:nn{2e-left}{#1}
242 %<latexrelease> \mark_insert:nn{2e-right}{#2}
243 %<latexrelease> \tl_if_empty:nF{#2}{ \mark_insert:nn{2e-right-nonempty}{#2} }
244 %<latexrelease> \mark{\the\@temptokena}%
245 %<latexrelease> \endgroup
246 %<latexrelease> \if@nobreak\ifvmode\nobreak\fi\fi}
247 %<latexrelease>\DeclareRobustCommand*\markright[1]{%
248 %<latexrelease> \begingroup
249 %<latexrelease> \let\label\relax \let\index\relax \let\glossary\relax
250 %<latexrelease> \expandafter\@markright\@themark {#1}%
251 %<latexrelease> \@temptokena \expandafter{\@themark}%
252 %<latexrelease> \mark_insert:nn{2e-right}{#1}
253 %<latexrelease> \tl_if_empty:nF{#1}{ \mark_insert:nn{2e-right-nonempty}{#1} }
254 %<latexrelease> \mark{\the\@temptokena}%
255 %<latexrelease> \endgroup
256 %<latexrelease> \if@nobreak\ifvmode\nobreak\fi\fi}
257 %<latexrelease>\ExplSyntaxOff
258 %<latexrelease>\EndIncludeInRelease
259 %<latexrelease>\IncludeInRelease{2019/10/01}%
260 %<latexrelease> {\markboth}{Make commands robust}%
261 %<latexrelease>
262 %<latexrelease>\DeclareRobustCommand*\markboth[2]{%
263 %<latexrelease> \begingroup
264 %<latexrelease> \let\label\relax \let\index\relax \let\glossary\relax
265 %<latexrelease> \unrestored@protected@xdef\@themark {{#1}{#2}}%
266 %<latexrelease> \@temptokena \expandafter{\@themark}%
267 %<latexrelease> \mark{\the\@temptokena}%
268 %<latexrelease> \endgroup
269 %<latexrelease> \if@nobreak\ifvmode\nobreak\fi\fi}
270 %<latexrelease>\DeclareRobustCommand*\markright[1]{%
271 %<latexrelease> \begingroup
272 %<latexrelease> \let\label\relax \let\index\relax \let\glossary\relax
273 %<latexrelease> \expandafter\@markright\@themark {#1}%
274 %<latexrelease> \@temptokena \expandafter{\@themark}%
275 %<latexrelease> \mark{\the\@temptokena}%
276 %<latexrelease> \endgroup
277 %<latexrelease> \if@nobreak\ifvmode\nobreak\fi\fi}
278 %<latexrelease>
279 %<latexrelease>\EndIncludeInRelease
280 %<latexrelease>\IncludeInRelease{0000/00/00}%
281 %<latexrelease> {\markboth}{Make commands robust}%
282 %<latexrelease>
283 % \end{macrocode}
284 % Using \cs{kernel@make@fragile} doesn't really work if there are
285 % more redefinitions later on, so we have to repeat the above
286 % definition first and then undo it (or use \cs{def} directly).
287 % \begin{macrocode}
288 %<latexrelease>%\kernel@make@fragile\markboth
289 %<latexrelease>%\kernel@make@fragile\markright
290 %<latexrelease>\def\markboth#1#2{%
291 %<latexrelease> \begingroup
292 %<latexrelease> \let\label\relax \let\index\relax \let\glossary\relax
293 %<latexrelease> \unrestored@protected@xdef\@themark {{#1}{#2}}%
294 %<latexrelease> \@temptokena \expandafter{\@themark}%
295 %<latexrelease> \mark{\the\@temptokena}%
296 %<latexrelease> \endgroup
297 %<latexrelease> \if@nobreak\ifvmode\nobreak\fi\fi}
298 %<latexrelease>\def\markright#1{%
299 %<latexrelease> \begingroup
300 %<latexrelease> \let\label\relax \let\index\relax \let\glossary\relax
301 %<latexrelease> \expandafter\@markright\@themark {#1}%
302 %<latexrelease> \@temptokena \expandafter{\@themark}%
303 %<latexrelease> \mark{\the\@temptokena}%
304 %<latexrelease> \endgroup
305 %<latexrelease> \if@nobreak\ifvmode\nobreak\fi\fi}
306 %<latexrelease>
307 %<latexrelease>\EndIncludeInRelease
308 %<*2ekernel>
309 % \end{macrocode}
310 %
311 %
312 %
313 %
314 % \begin{macro}{\leftmark}
315 % \changes{v1.0j}{2000/05/26}{Use \cs{@empty} instead of brace group
316 % (pr/3203).}
317 % \begin{macro}{\rightmark}
318 % \changes{LaTeX2e}{1993/12/17}{Stopgap solution to mark \cs{leftmark}
319 % and \cs{rightmark} work without initializing mark until
320 % the problem is solved.}
321 % \changes{v1.0j}{2000/05/26}{Use \cs{@empty} instead of brace group
322 % (pr/3203).}
323 % \task{???}{mark initialization solved?}
324 % \begin{macrocode}
325 %</2ekernel>
326 %<*2ekernel|latexrelease>
327 %<latexrelease>\IncludeInRelease{2025/06/01}%
328 %<latexrelease> {\leftmark}{Use new mark mechanism}%
329 % \end{macrocode}
330 %
331 % \begin{macrocode}
332 \ExplSyntaxOn
333 \cs_new:Npn \leftmark {\mark_use_last:nn{page}{2e-left}}
334 \cs_new:Npn \rightmark {\mark_use_first:nn{page}{2e-right}}
335 \ExplSyntaxOff
336 %</2ekernel|latexrelease>
337 %<latexrelease>\EndIncludeInRelease
338 %<latexrelease>\IncludeInRelease{0000/00/00}%
339 %<latexrelease> {\leftmark}{Use new mark mechanism}%
340 %<latexrelease>
341 %<latexrelease>\def\leftmark{\expandafter\@leftmark\botmark\@empty\@empty}
342 %<latexrelease>\def\rightmark{\expandafter\@rightmark\firstmark\@empty\@empty}
343 % \end{macrocode}
344 %
345 % \begin{macro}{\@markright}
346 % \changes{v1.0j}{2000/05/26}{Reimplementation to fix expansion
347 % error (pr/3203).}
348 % \changes{v1.0k}{2000/06/02}{Small adjustment to give slightly less
349 % expansion, CAR}
350 % \begin{macro}{\mark}
351 % \changes{LaTeX2e}{1993/12/16}{Init \cs{mark} at begin document}
352 % \changes{LaTeX2e}{1993/12/17}{Removed init \cs{mark} at begin
353 % document, since it doesn't work.}
354 % \begin{macrocode}
355 %<latexrelease>\def\@themark{{}{}}
356 %<latexrelease>\def\@markright#1#2#3{\@temptokena {#1}%
357 %<latexrelease>\unrestored@protected@xdef\@themark{{\the\@temptokena}{#3}}}
358 %<latexrelease>\EndIncludeInRelease
359 %<*2ekernel>
360 % \end{macrocode}
361 % \end{macro}
362 % \end{macro}
363 % \end{macro}
364 % \end{macro}
365 %
366 %
367 %
368 %
369 % \begin{macro}{\raggedbottom}
370 % |\raggedbottom| typesets pages with no vertical stretch, so they have
371 % their natural height instead of all being exactly the
372 % same height. (Uses a space of .0001fil to avoid
373 % interfering with the 1fil space of |\newpage|.)
374 %
375 % \begin{macrocode}
376 \DeclareRobustCommand\raggedbottom{%
377 \def\@textbottom{\vskip \z@ \@plus.0001fil}\let\@texttop\relax}
378 % \end{macrocode}
379 % \end{macro}
380 %
381 % \begin{macro}{\flushbottom}
382 % |\flushbottom|:
383 % Inverse of |\raggedbottom| --- makes all pages the same height.
384 % \begin{macrocode}
385 \DeclareRobustCommand\flushbottom{%
386 \let\@textbottom\relax \let\@texttop\relax}
387 % \end{macrocode}
388 % \end{macro}
389 %
390 %
391 % \begin{macro}{\sloppy}
392 % |\sloppy| will never (well, hardly ever) produce overfull boxes, but
393 % may produce underfull ones. (14 June 85)
394 % \changes{LaTeX2e}{1993/12/18}{Added \cs{emergencystretch}}
395 % \changes{v1.0h}{1994/07/20}{Save a few tokens}
396 % \begin{macrocode}
397 \DeclareRobustCommand\sloppy{%
398 \tolerance 9999%
399 \emergencystretch 3em%
400 \hfuzz .5\p@
401 \vfuzz\hfuzz}
402 % \end{macrocode}
403 % \end{macro}
404 %
405 % \begin{environment}{sloppypar}
406 % A sloppypar environment is equivalent to |{\par \sloppy ... \par}|.
407 % \begin{macrocode}
408 \def\sloppypar{\par\sloppy}
409 \def\endsloppypar{\par}
410 % \end{macrocode}
411 % \end{environment}
412 %
413 % \begin{macro}{\fussy}
414 % \changes{v1.0f}{1995/04/24}{reset \cs{emergencystretch} latex/1344}
415 % Resets \TeX's parameters to their normal finicky values.
416 % \begin{macrocode}
417 \DeclareRobustCommand\fussy{%
418 \emergencystretch\z@
419 \tolerance 200%
420 \hfuzz .1\p@
421 \vfuzz\hfuzz}
422 % \end{macrocode}
423 % \end{macro}
424 %
425 % \begin{macro}{\overfullrule}
426 % \LaTeX\ default is no overfull box rule. Changed by document
427 % class option.
428 % \begin{macrocode}
429 \overfullrule 0pt
430 % \end{macrocode}
431 % \end{macro}
432 %
433 % \begin{macrocode}
434 %</2ekernel>
435 % \end{macrocode}
436 %
437 % \Finale
438 %