Debian Codegraph @

texmf-dist/source/latex-dev/base/ltspace.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2026
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: ltspace.dtx
32 %<*driver>
33 % \fi
34 \ProvidesFile{ltspace.dtx}
35 [2025/12/17 v1.3t LaTeX Kernel (spacing)]
36 % \iffalse
37 \documentclass{ltxdoc}
38 \GetFileInfo{ltspace.dtx}
39 \title{\filename}
40 \date{\filedate}
41 \author{%
42 Johannes Braams\and
43 David Carlisle\and
44 Alan Jeffrey\and
45 Leslie Lamport\and
46 Frank Mittelbach\and
47 Chris Rowley\and
48 Rainer Sch\"opf}
49 \begin{document}
50 \MaintainedByLaTeXTeam{latex}
51 \maketitle
52 \DocInput{\filename}
53 \end{document}
54 %</driver>
55 % \fi
56 %
57 %
58 % \changes{v1.1a}{1994/05/16}{(ASAJ) Split from ltinit.dtx.}
59 % \changes{v1.2f}{1995/05/25}{Macros moved to ltlists.dtx}
60 % \changes{v1.2n}{1996/04/22}{Documentation Improvements}
61 % \changes{v1.2o}{1996/06/22}{Documentation of problems added}
62 % \changes{v1.2q}{1996/07/27}{Further documentation of problems}
63 % \changes{v1.2r}{1996/07/27}{Correct documentation of problems}
64 % \changes{v1.2w}{1998/08/17}{Documentation fixes.}
65 % \changes{v1.3j}{2019/08/27}{Make various commands robust}
66 % \changes{v1.3l}{2020/03/07}{Moved \cs{thinspace}, \cs{negthinspace}
67 % and \cs{,} to ltmath.dtx (gh/303)}
68 %
69 %
70 % \section{Spacing}
71 %
72 % This section deals with spacing, and line- and page-breaking.
73 %
74 % \subsection{User Commands}
75 %
76 % \DescribeMacro\nopagebreak\oarg{i} : \meta{i} = 0,...,4.
77 %
78 % Default argument = 4. Puts a penalty into the vertical list
79 % output as follows:\\
80 % 0 : penalty = 0\\
81 % 1 : penalty = |\@lowpenalty|\\
82 % 2 : penalty = |\@medpenalty|\\
83 % 3 : penalty = |\@highpenalty|\\
84 % 4 : penalty = 10000
85 %
86 % \DescribeMacro\pagebreak\oarg{i} :
87 % same as \nopagebreak except negatives of its penalty
88 %
89 % \DescribeMacro\linebreak\oarg{i} : analog of the above
90 %
91 % \DescribeMacro\nolinebreak\oarg{i} : analog of the above
92 %
93 % \DescribeMacro\samepage :
94 % inhibits page breaking most places by setting the
95 % following penalties to 10000:\\
96 % |\interlinepenalty|\\
97 % |\predisplaypenalty|\\
98 % |\postdisplaypenalty|\\
99 % |\interdisplaylinepenalty|\\
100 % |\@beginparpenalty|\\
101 % |\@endparpenalty|\\
102 % |\@itempenalty|\\
103 % |\@secpenalty|\\
104 % |\interfootnotelinepenalty|
105 %
106 % \DescribeMacro{\\} : initially defined to be |\newline|
107 %
108 % |\\|\oarg{length} : initially defined to be
109 % |\vspace|\marg{length}|\newline|\\
110 % Note: |\\*| adds a |\vadjust{\penalty 10000}|
111 %
112 % OBSOLETE COMMANDS (which never made it into the manual):
113 %
114 % |\obeycr| : defines <CR> == |\\\relax|\\
115 % |\restorecr| : restores <CR> to its usual meaning.
116 %
117 %
118 % \MaybeStop{}
119 %
120 % \subsection{Chris' comments}
121 %
122 % There are several aspects of the handling of space in horizontal
123 % mode that are inconsistent or do not work well in some cases.
124 % These are largely concerned with ignoring the effect of space
125 % tokens that would otherwise typeset an inter-word space.
126 %
127 % Negating the effect of such space tokens is achieved by two
128 % mechanisms:
129 % \begin{itemize}
130 % \item |\unskip| is used to remove the glue just added by
131 % a space that has already had its effect; it is sometimes
132 % invoked after an |\ifdim| test on |\lastskip| (see below);
133 % \item |\ignorespaces| is used to ignore space-tokens yet to come.
134 % \end{itemize}
135 %
136 % The test done on |\lastskip| is sometimes for equality with zero and
137 % sometimes for being positive. Recall also that the test is only on
138 % the natural length of the glue and that no glue cannot be
139 % distinguished from glue whose natural length is zero: to summarise,
140 % a pretty awful test. It is not clear why these tests are not all
141 % the same; I think that they should all be for equality. One place
142 % where |\unskip| is often used is just before a |\par| (which itself
143 % internally does an |\unskip|) and one bit of code (in |\@item|) even
144 % has two |\unskips| before a |\par|. These uses may be fossil code
145 % but if they are necessary, maybe |\@killglue| would be even safer.
146 %
147 % Such removal of glue by |\unskip| may sometimes have the wrong result,
148 % removing not the glue from a space-token but other explicit glue;
149 % this is sometimes not what is intended.
150 %
151 % A common way to prevent such removal is to add an |\hskip\z@| after
152 % the glue that should not be removed. This protects that glue
153 % against one |\unskip| with no test but not against more than one.
154 % It does work for `tested |\unskip|s'. This is used
155 % by |\hspace*| but not by |\hspace|; this is inconsistent as the star
156 % is supposed to prevent removal only at the beginning of a line, not
157 % at the end, or in a tabular, etc.
158 %
159 % If this reason for removing glue were the only consideration then a
160 % tested-|\unskip| and protection by |\hskip\z@| would suffice but
161 % would need to be consistently implemented.
162 %
163 % However, the class of invisibles, commands and environments tries to
164 % be even cleverer: one of these tries to leave only one inter-word
165 % space whenever there is one before it and one after it; and it does
166 % this quite well.
167 %
168 % But problems can arise when there is not a space-token on
169 % both sides of it; in particular, when an invisible appears at the
170 % beginning or end of a piece of text the method still leaves one space
171 % token whereas usually in these cases it should leave none.
172 %
173 % Also, the current rules do not work well when more than one such
174 % command appears consecutively, separated by space-tokens; it leaves
175 % glue between every other invisible.
176 %
177 % There is also a question about what these commands should do when
178 % they occur next to spaces that do not come from space tokens but,
179 % for example, from |\hspace|. Should they still produce `just one
180 % space'? If so, which one? It is good to note that the manual
181 % is sufficiently cautious about invisibles that we are not obliged to
182 % make anything work.
183 %
184 % Another interesting side-road to explore is whether the space-tokens
185 % either side of an |\hspace{...}| should be ignored.
186 %
187 % One alternative to the current algorithm that is often suggested is
188 % that all glue around the invisible should be consolidated into a
189 % space after it (usually without stating how much glue should be put
190 % there). The command |\nolinebreak| is implemented this way (and
191 % |\linebreak| should also be). This does not work correctly for the
192 % following common case:
193 % \begin{verbatim}
194 % ... some text
195 % \index{some-word}
196 % some-word and more text.
197 % \end{verbatim}
198 % This is optimal coding since it is normal to index a word that gets
199 % split across a page-break on its starting page. This would, on the
200 % other hand, fix another common (and documented) failure of the
201 % current system: when the invisible is the last thing in a paragraph
202 % the space before it is not removed and, worse, it is also hidden
203 % from the paragraph-ending mechanism so that an `empty' line can be
204 % created at the end of the paragraph.
205 %
206 % Another deficiency (I think) of the current system is that the
207 % following is treated as having the |\index| command between the
208 % paragraphs, which is probably not what the author intended (since
209 % there is no empty line after it).
210 % \begin{verbatim}
211 %
212 % \index{beginnings}
213 % Beginnings of paragraphs ...
214 % \end{verbatim}
215 %
216 % I know of no algorithm that will handle satisfactorily even
217 % all the most common cases; note that it could be that the best
218 % algorithm may be different for different invisibles since,
219 % for example, the common uses and expected behaviour of
220 % |\index|, |\marginpar|, |\linebreak|, |\pagebreak| and
221 % |\vspace| are somewhat different. [For example, is
222 % |\vspace| ever used in the middle of a paragraph?]
223 %
224 % One method that can (and is) used to make invisible commands produce
225 % no space when used at the beginning of text is to put in some glue
226 % that is nearly enough the same as no glue or glue of zero length in
227 % all respects except for the precise test for not being exactly equal
228 % to zero; examples of such glue are |\hskip 1sp| and, possibly better
229 % but more complex, |\hskip -1sp \hskip 1sp|. However, this only works
230 % when it is known that user-supplied text is about to start.
231 %
232 % Some similar concerns apply to the handling of space and penalties
233 % in vertical mode; there is an extra hurdle here as |\unskip| does
234 % not work on the main vertical list. The complexity of the tests done
235 % by |\addvspace| have never been explained.
236 %
237 % The implementation of space hacks etc for vertical mode is another
238 % major area that needs further attention; my earlier experiments
239 % did not produce much improvement over the current unsatisfactory
240 % situation.
241 %
242 % One particular problem is what happens when the following very
243 % natural coding is used (part of the problem here is that this looks
244 % like an hmode problem, but it is not):
245 % \begin{verbatim}
246 % ... end of text.
247 %
248 % \begin{enumerate}
249 % \item \label{item:xxx} Item text.
250 % \end{enumerate}
251 % \end{verbatim}
252 %
253 % \subsection{Some immediate actions}
254 %
255 % \begin{itemize}
256 % \item Fix bug in |\linebreak|.
257 % \item Fix bug in |\\*|.
258 % \item Reimplement |\\|, etc, removing extra |\vadjust|s and getting
259 % better error trapping (this seems to involve a lot more tokens).
260 % \item Investigate whether |\\|, etc need to be errors in vmode; I
261 % think that they could be noops (maybe with a warning).
262 % \item Make all(?) |\unskips| include test for zero skip (rather than
263 % other tests or no test).
264 % \item Consider replacing |\hskip 1sp| by something better (here
265 % called an `infinitesimal' skip).
266 % \item Look at all |\hskip\z@| (or similar) to see if they should be
267 % changed to an `infinitesimal' skip.
268 % \item Resolve the inconsistency between |\hspace| and |\hspace*|.
269 % \item Remove unnecessary |\unskips|.
270 % \item Investigate and rationalise the `newline' code.
271 % \item Find better algorithms for all sorts of things or, easier(?),
272 % fix \TeX{} itself.
273 % \end{itemize}
274 %
275 % \subsection{The code}
276 %
277 % \begin{macrocode}
278 %<*2ekernel>
279 \message{spacing,}
280 % \end{macrocode}
281 %
282 % \begin{macrocode}
283 %</2ekernel>
284 %<*2ekernel|latexrelease>
285 %<latexrelease>\IncludeInRelease{2019/10/01}%
286 %<latexrelease> {\pagebreak}{Make commands robust}%
287 % \end{macrocode}
288 %
289 % \begin{macro}{\pagebreak}
290 % \begin{macro}{\nopagebreak}
291 % \changes{v1.2h}{1995/07/05}{Reimplemented both using \cs{@no@pgbk}}
292 % \changes{v1.2j}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
293 % \begin{macrocode}
294 \DeclareRobustCommand\pagebreak{\@testopt{\@no@pgbk-}4}
295 \DeclareRobustCommand\nopagebreak{\@testopt\@no@pgbk4}
296 % \end{macrocode}
297 % \end{macro}
298 % \end{macro}
299 %
300 % \begin{macro}{\linebreak}
301 % \begin{macro}{\nolinebreak}
302 % \changes{v1.2u}{1996/10/29}{Reimplemented both using \cs{@no@lnbk}}
303 % \changes{v1.2j}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
304 % \begin{macrocode}
305 \DeclareRobustCommand\linebreak{\@testopt{\@no@lnbk-}4}
306 \DeclareRobustCommand\nolinebreak{\@testopt\@no@lnbk4}
307 % \end{macrocode}
308 % \end{macro}
309 % \end{macro}
310 %
311 % \begin{macro}{\samepage}
312 % \changes{v1.3p}{2023/03/22}{Add \cs{predisplaypenalty} setting (gh/1022)}
313 % \begin{macrocode}
314 \DeclareRobustCommand\samepage{\interlinepenalty\@M
315 \predisplaypenalty\@M
316 \postdisplaypenalty\@M
317 \interdisplaylinepenalty\@M
318 \@beginparpenalty\@M
319 \@endparpenalty\@M
320 \@itempenalty\@M
321 \@secpenalty\@M
322 \interfootnotelinepenalty\@M}
323 % \end{macrocode}
324 % \end{macro}
325 %
326 % \begin{macrocode}
327 %</2ekernel|latexrelease>
328 %<latexrelease>\EndIncludeInRelease
329 %<latexrelease>\IncludeInRelease{0000/00/00}%
330 %<latexrelease> {\pagebreak}{Make commands robust}%
331 %<latexrelease>
332 %<latexrelease>\kernel@make@fragile\pagebreak
333 %<latexrelease>\kernel@make@fragile\nopagebreak
334 %<latexrelease>\kernel@make@fragile\linebreak
335 %<latexrelease>\kernel@make@fragile\nolinebreak
336 %<latexrelease>\kernel@make@fragile\samepage
337 %<latexrelease>
338 %<latexrelease>\EndIncludeInRelease
339 %<*2ekernel>
340 % \end{macrocode}
341 %
342 %
343 %
344 % \begin{macro}{\@no@pgbk}
345 % \changes{v1.2h}{1995/07/05}{Macro replaces \cs{@pgbk}
346 % and \cs{@nopgbk}}
347 % \begin{macrocode}
348 \def\@no@pgbk #1[#2]{%
349 \ifvmode
350 \penalty #1\@getpen{#2}%
351 \else
352 \@bsphack
353 \vadjust{\penalty #1\@getpen{#2}}%
354 \@esphack
355 \fi}
356 % \end{macrocode}
357 % \end{macro}
358 %
359 %
360 % \begin{macro}{\@no@lnbk}
361 % \changes{v1.2u}{1996/10/29}{Macro replaces \cs{@lnbk}
362 % and \cs{@nolnbk}}
363 % \begin{macrocode}
364 \def\@no@lnbk #1[#2]{%
365 \ifvmode
366 \@nolnerr
367 \else
368 \@tempskipa\lastskip
369 \unskip
370 \penalty #1\@getpen{#2}%
371 \ifdim\@tempskipa>\z@
372 \hskip\@tempskipa
373 \ignorespaces
374 \fi
375 \fi}
376 % \end{macrocode}
377 % \end{macro}
378 %
379 %
380 % \begin{macro}{\\}
381 % \changes{v1.2a}{1994/11/11}{(DPC) Make robust}
382 % \changes{v1.2d}{1994/11/14}{(DPC) Macro modified}
383 %
384 % \changes{v1.2u}{1996/10/29}{Corrected and rationalised code}
385 % The purpose of the new code is to fix a few bugs; however, it also
386 % attempts to optimize the following, in order of priority:
387 % \begin{enumerate}
388 % \item efficient execution of plain |\\|;
389 % \item efficient execution of |\\[...]|;
390 % \item memory use;
391 % \item name-space use.
392 % \end{enumerate}
393 % The changes should make no difference to the typeset output.
394 % It appears to be safe to use |\reserved@e| and |\reserved@f| here
395 % (other reserved macros are somewhat disastrous).
396 %
397 % These changes made |\newline| even less robust than it had been,
398 % so now it is explicitly robust, like |\\|.
399 % \begin{macro}{\@normalcr}
400 % The internal definition of the `normal' definition of |\\|.
401 % \changes{v1.3k}{2019/11/02}{Make also \cs{@normalcr} robust}
402 % \begin{macrocode}
403 %</2ekernel>
404 %<*2ekernel|latexrelease>
405 %<latexrelease>\IncludeInRelease{2020/02/02}%
406 %<latexrelease> {\@normalcr}{Make robust}%
407 \protected\def\@normalcr{%
408 \let \reserved@e \relax
409 \let \reserved@f \relax
410 \@ifstar{\let \reserved@e \vadjust \let \reserved@f \nobreak
411 \@xnewline}%
412 \@xnewline}
413 % \end{macrocode}
414 %
415 % \begin{macrocode}
416 \let\\\@normalcr
417 %</2ekernel|latexrelease>
418 %<latexrelease>\EndIncludeInRelease
419 %<latexrelease>\IncludeInRelease{0000/00/00}%
420 %<latexrelease> {\@normalcr}{Make robust}%
421 %<latexrelease>
422 %<latexrelease>\DeclareRobustCommand\\{%
423 %<latexrelease> \let \reserved@e \relax
424 %<latexrelease> \let \reserved@f \relax
425 %<latexrelease> \@ifstar{\let \reserved@e \vadjust \let \reserved@f \nobreak
426 %<latexrelease> \@xnewline}%
427 %<latexrelease> \@xnewline}
428 %<latexrelease>\expandafter\let\expandafter\@normalcr
429 %<latexrelease> \csname\expandafter\@gobble\string\\ \endcsname
430 %<latexrelease>
431 %<latexrelease>\EndIncludeInRelease
432 %<*2ekernel>
433 % \end{macrocode}
434 % \end{macro}
435 % \end{macro}
436 %
437 %
438 %
439 % \begin{macro}{\@vspace@calcify}
440 % Helper command to produce a \cs{vskip} that is first run through
441 % \cs{setlength}. This way the \texttt{calc} package can operate on
442 % the argument value.
443 % \changes{v1.3m}{2020/04/21}{Support calc syntax (gh/152)}
444 % \changes{v1.3o}{2022/11/28}{Support calc syntax without a group (gh/967)}
445 % \begin{macrocode}
446 %</2ekernel>
447 %<*2ekernel|latexrelease>
448 %<latexrelease>\IncludeInRelease{2020/10/01}%
449 %<latexrelease> {\@vspace@calcify}{Add calc support}%
450 \def\@vspace@calcify#1{\setlength\sp@ce@skip{#1}\vskip\sp@ce@skip}
451 %</2ekernel|latexrelease>
452 %<latexrelease>\EndIncludeInRelease
453 % \end{macrocode}
454 %
455 % \begin{macrocode}
456 %<latexrelease>\IncludeInRelease{0000/00/00}%
457 %<latexrelease> {\@vspace@calcify}{Add calc support}%
458 %<latexrelease>
459 %<latexrelease>\let\@vspace@calcify\@undefined
460 %<latexrelease>\EndIncludeInRelease
461 %<*2ekernel>
462 % \end{macrocode}
463 % \end{macro}
464 %
465 %
466
467
468 % \begin{macro}{\newline}
469 % A simple form of the `normal' definition of |\\|.
470 % \changes{v1.2v}{1997/05/07}{Made completely robust.}
471 % \begin{macrocode}
472 \DeclareRobustCommand\newline{\@normalcr\relax}
473 % \end{macrocode}
474 % \end{macro}
475 %
476 % \begin{macro}{\@xnewline}
477 % \begin{macrocode}
478 \def\@xnewline{\@ifnextchar[% ] bracket matching
479 \@newline
480 {\@gnewline\relax}}
481 % \end{macrocode}
482 % \end{macro}
483 %
484 % \begin{macro}{\@newline}
485 % \changes{v1.3m}{2020/04/21}{Support calc syntax (gh/152)}
486 % \begin{macrocode}
487 %</2ekernel>
488 %<*2ekernel|latexrelease>
489 %<latexrelease>\IncludeInRelease{2020/10/01}%
490 %<latexrelease> {\@newline}{\newline calc support}%
491 \def\@newline[#1]{\let \reserved@e \vadjust
492 \@gnewline {\@vspace@calcify{#1}}}
493 %</2ekernel|latexrelease>
494 %<latexrelease>\EndIncludeInRelease
495 % \end{macrocode}
496 %
497 % \begin{macrocode}
498 %<latexrelease>\IncludeInRelease{0000/00/00}%
499 %<latexrelease> {\@newline}{\newline calc support}%
500 %<latexrelease>
501 %<latexrelease>\def\@newline[#1]{\let \reserved@e \vadjust
502 %<latexrelease> \@gnewline {\vskip #1}}
503 %<latexrelease>\EndIncludeInRelease
504 %<*2ekernel>
505 % \end{macrocode}
506 % \end{macro}
507 %
508 %
509 %
510 % \begin{macro}{\@gnewline}
511 % \changes{v1.2u}{1996/10/29}{Added macro}
512 % The |\nobreak| added to prevent null lines when |\\|
513 % ends an overfull line. Change made 24 May 89 as suggested by
514 % Frank Mittelbach and Rainer Sch\"opf
515 % \changes{v1.2h}{1995/07/05}{Use \cs{break}}
516 % \begin{macrocode}
517 \def\@gnewline #1{%
518 \ifvmode
519 \@nolnerr
520 \else
521 \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break
522 \fi}
523 % \end{macrocode}
524 % \end{macro}
525 %
526 %
527 % \begin{macro}{\@getpen}
528 % \begin{macrocode}
529 \def\@getpen#1{\ifcase #1 \z@ \or \@lowpenalty\or
530 \@medpenalty \or \@highpenalty
531 \else \@M \fi}
532 % \end{macrocode}
533 % \end{macro}
534 %
535 %
536 % \begin{macro}{\if@nobreak}
537 % \changes{v1.2p}{1996/07/26}{put \cs{global} inside definition}
538 % Switch used to avoid page breaks caused by |\label| after a
539 % section heading, etc. It should be \textbf{GLOBALLY} set true
540 % after the |\nobreak| and \textbf{globally} set false by the
541 % next invocation of |\everypar|.
542 %
543 % Commands that reset |\everypar| should globally set it false if
544 % appropriate.
545 % \begin{macrocode}
546 \def\@nobreakfalse{\global\let\if@nobreak\iffalse}
547 \def\@nobreaktrue {\global\let\if@nobreak\iftrue}
548 \@nobreakfalse
549 % \end{macrocode}
550 % \end{macro}
551 %
552 %
553 %
554 % \begin{macro}{\@savsk}
555 % \begin{macro}{\@savsf}
556 % Registers used to save the space factor and last skip.
557 % \begin{macrocode}
558 \newdimen\@savsk
559 \newcount\@savsf
560 % \end{macrocode}
561 % \end{macro}
562 % \end{macro}
563 %
564 %
565 %
566 %
567 % \begin{macro}{\@bsphack}
568 % \changes{LaTeX2e}{1993/12/08}
569 % {Command reimplemented; late birthday present for Chris}
570 % \changes{LaTeX2e}{1993/12/08}{Command reimplemented}
571 % \changes{LaTeX2e}{1993/12/16}{Corrected optimisation}
572 % |\@bsphack| and |\@esphack|
573 % used by macros such as |\index| and
574 % |\begin{@float}| \ldots |\end{@float}|
575 % that want to be invisible --- i.e.,
576 % not leave any extra space when used in the middle of text. Such
577 % a macro should begin with |\@bsphack| and end with |\@esphack|.
578 % The macro in question should not create any text, nor change the
579 % mode.
580 %
581 % Before giving the current definition we give an extended definition
582 % that is currently not used (because it doesn't work as advertised:-)
583 %
584 % These are generalised hacks which attempt to do sensible things
585 % when `invisible commands' appear in vmode too.
586 %
587 % They need to cope with space in both hmode (plus spacefactor) and
588 % vmode, and also cope with breaks etc. In vmode this means
589 % ensuring that any following |\addvspace|, etc sees the correct
590 % glue in |\lastskip|.
591 %
592 % In fact, these improved versions should be used for other cases
593 % of `whatsits, thingies etc' which should be invisible. They are
594 % only for commands, not environments (see notes on |\@Esphack|).
595 %
596 % BTW, anyone know why the standard hacks are surrounded by
597 % |\ifmmode\else| rather than simply |\ifhmode|?
598 %
599 % And are there any cases where saving the spacefactor is
600 % essential? I have some extensions where it is, but it does not
601 % appear to be so in the standard uses.
602 %\begin{verbatim}
603 %\def \@bsphack{%
604 % \relax \ifvmode
605 % \@savsk \lastskip
606 % \ifdim \lastskip=\z@
607 % \else
608 % \vskip -\lastskip
609 % \fi
610 % \else
611 % \ifhmode
612 % \@savsk \lastskip
613 % \@savsf \spacefactor
614 % \fi
615 % \fi
616 %}
617 %\end{verbatim}
618 % I think that, in vmode, it is the safest to put
619 % in a |\nobreak| immediately after such things since writes,
620 % inserts etc followed by glue give valid breakpoints and, in
621 % general, it is possible to create breaks but impossible to
622 % destroy them.
623 %\begin{verbatim}
624 %\def \@esphack{%
625 % \relax \ifvmode
626 % \nobreak
627 % \ifdim \@savsk=\z@
628 % \else
629 % \vskip\@savsk
630 % \fi
631 % \else
632 % \ifhmode
633 % \spacefactor \@savsf
634 % \ifdim \@savsk>\z@
635 % \ignorespaces
636 % \fi
637 % \fi
638 % \fi
639 %}
640 %\end{verbatim}
641 % For the moment we are going to ignore the vertical versions until
642 % they are correct.
643 % \changes{LaTeX2e}{1993/12/19}{There seem to be problems with selfmade
644 % birthday presents}
645 % \begin{macrocode}
646 \def\@bsphack{%
647 \relax
648 \ifhmode
649 \@savsk\lastskip
650 \@savsf\spacefactor
651 \fi}
652 % \end{macrocode}
653 % \end{macro}
654 %
655 % \begin{macro}{\@esphack}
656 % Companion to |\@bsphack|. If this command is not properly paired
657 % with |\@bsphack| one might end up with a low-level \TeX{} error:
658 % ``BAD spacefactor''. One possible cause is calling |\@bsphack| in
659 % vertical mode, then doing something that gets you (sometimes) into
660 % horizontal mode and finally calling |\@esphack|. Even if no error
661 % is generated that is wrong, because |\@esphack| will then use the
662 % saved values for |\@savsk| and |\@savsf| from some earlier
663 % invocation of |\@bsphack| which will have nothing to do with the
664 % current situation.
665 % \changes{v1.3d}{2015/01/11}{Allow hyphenation (Donald Arseneau pr/3498) (latexrelease)}
666 % \begin{macrocode}
667 %</2ekernel>
668 %<latexrelease>\IncludeInRelease{2026/06/01}%
669 %<latexrelease> {\@esphack}{chained space hacks}%
670 %<*2ekernel|latexrelease>
671 \def\@esphack{%
672 \relax
673 \ifhmode
674 \spacefactor\@savsf
675 \ifdim\@savsk>\z@
676 % \end{macrocode}
677 % \changes{v1.3f}{2015/11/07}
678 % {Only space if there is no space at the end of the hlist latex/4443}
679 % \begin{macrocode}
680 \ifdim\lastskip=\z@
681 % \end{macrocode}
682 % If there is more than one space hack in succession (with a space
683 % in between) \LaTeX{} still ended up with more than one space
684 % because the \cs{z@skip} prevented the second space hack from
685 % recognizing that no space should be added. To avoid this we add a
686 % special \enquote{zero} space that looks like a positive space to
687 % \cs{lastskip}.
688 %
689 % There is a side effect though: if the space hack is the last thing in a
690 % paragraph the \texttt{1sp} is dropped and we actually allow the
691 % last line to be over by 1sp, but this is better than the extra
692 % space introduced in the past.
693 % \changes{v1.3t}{2025/12/17}
694 % {Prevent generating an extra space when chained (gh/1910)}
695 % \begin{macrocode}
696 \nobreak
697 % \hskip\z@skip
698 \hskip-1sp\relax\hskip1sp\relax
699 \fi
700 \ignorespaces
701 \fi
702 % \end{macrocode}
703 % \changes{v1.3i}{2018/10/10}
704 % {Don't introduce breakpoints if @nobreak is true and after sections}
705 % \begin{macrocode}
706 \else
707 \ifvmode
708 \if@nobreak\nobreak\else\if@noskipsec\nobreak\fi\fi
709 \fi
710 % \end{macrocode}
711 %
712 % \begin{macrocode}
713 \fi
714 }%
715 %</2ekernel|latexrelease>
716 %<latexrelease>\EndIncludeInRelease
717 % \end{macrocode}
718 %
719 % \begin{macrocode}
720 %<latexrelease>\IncludeInRelease{2018/10/10}%
721 %<latexrelease> {\@esphack}{hyphenation and nobreak after space hack}%
722
723 %<latexrelease>\def\@esphack{%
724 %<latexrelease> \relax
725 %<latexrelease> \ifhmode
726 %<latexrelease> \spacefactor\@savsf
727 %<latexrelease> \ifdim\@savsk>\z@
728 %<latexrelease> \ifdim\lastskip=\z@
729 %<latexrelease> \nobreak \hskip\z@skip
730 %<latexrelease> \fi
731 %<latexrelease> \ignorespaces
732 %<latexrelease> \fi
733 %<latexrelease> \else
734 %<latexrelease> \ifvmode
735 %<latexrelease> \if@nobreak\nobreak\else\if@noskipsec\nobreak\fi\fi
736 %<latexrelease> \fi
737 %<latexrelease> \fi}%
738 %<latexrelease>\EndIncludeInRelease
739 % \end{macrocode}
740 %
741 % \begin{macrocode}
742 %<latexrelease>\IncludeInRelease{2015/10/01}%
743 %<latexrelease> {\@esphack}{hyphenation and nobreak after space hack}%
744 %<latexrelease>\def\@esphack{%
745 %<latexrelease> \relax
746 %<latexrelease> \ifhmode
747 %<latexrelease> \spacefactor\@savsf
748 %<latexrelease> \ifdim\@savsk>\z@
749 %<latexrelease> \ifdim\lastskip=\z@
750 %<latexrelease> \nobreak \hskip\z@skip
751 %<latexrelease> \fi
752 %<latexrelease> \ignorespaces
753 %<latexrelease> \fi
754 %<latexrelease> \fi}%
755 %<latexrelease>\EndIncludeInRelease
756 %<latexrelease>\IncludeInRelease{2015/01/01}%
757 %<latexrelease> {\@esphack}{hyphenation and nobreak after space hack}%
758 %<latexrelease>\def\@esphack{%
759 %<latexrelease> \relax
760 %<latexrelease> \ifhmode
761 %<latexrelease> \spacefactor\@savsf
762 %<latexrelease> \ifdim\@savsk>\z@
763 %<latexrelease> \nobreak \hskip\z@skip
764 %<latexrelease> \ignorespaces
765 %<latexrelease> \fi
766 %<latexrelease> \fi}%
767 %<latexrelease>\EndIncludeInRelease
768 %<latexrelease>\IncludeInRelease{0000/00/00}%
769 %<latexrelease> {\@esphack}{hyphenation and nobreak after space hack}%
770 %<latexrelease>\def\@esphack{%
771 %<latexrelease> \relax
772 %<latexrelease> \ifhmode
773 %<latexrelease> \spacefactor\@savsf
774 %<latexrelease> \ifdim\@savsk>\z@
775 %<latexrelease> \ignorespaces
776 %<latexrelease> \fi
777 %<latexrelease> \fi}%
778 %<latexrelease>\EndIncludeInRelease
779 %<*2ekernel>
780 % \end{macrocode}
781 % \end{macro}
782 %
783 % \begin{macro}{\@Esphack}
784 % A variant of |\@esphack| that sets the |@ignore| switch to
785 % true (as |\@esphack| used to do previously).
786 % This is currently used only for floats and similar environments.
787 % \changes{v1.2s}{1996/08/02}{Remove \cs{global} before \cs{@ignore...}}
788 % \changes{v1.3d}{2015/01/11}{Allow hyphenation (Donald Arseneau pr/3498) (latexrelease)}
789 % \begin{macrocode}
790 %</2ekernel>
791 %<latexrelease>\IncludeInRelease{2015/01/01}%
792 %<latexrelease> {\@Esphack}{hyphenation after space hack}%
793 %<*2ekernel|latexrelease>
794 \def\@Esphack{%
795 \relax
796 \ifhmode
797 \spacefactor\@savsf
798 \ifdim\@savsk>\z@
799 \nobreak \hskip\z@skip
800 \@ignoretrue
801 \ignorespaces
802 \fi
803 \fi}%
804 %</2ekernel|latexrelease>
805 %<latexrelease>\EndIncludeInRelease
806 %<latexrelease>\IncludeInRelease{0000/00/00}%
807 %<latexrelease> {\@Esphack}{hyphenation after space hack}%
808 %<latexrelease>\def\@Esphack{%
809 %<latexrelease> \relax
810 %<latexrelease> \ifhmode
811 %<latexrelease> \spacefactor\@savsf
812 %<latexrelease> \ifdim\@savsk>\z@
813 %<latexrelease> \@ignoretrue
814 %<latexrelease> \ignorespaces
815 %<latexrelease> \fi
816 %<latexrelease> \fi}%
817 %<latexrelease>\EndIncludeInRelease
818 %<*2ekernel>
819 % \end{macrocode}
820 % \end{macro}
821 %
822 %
823 % \begin{macro}{\@vbsphack}
824 % \changes{LaTeX2e}{1993/12/08}{Command added}
825 % Another variant which is useful for invisible things which should
826 % not live in vmode (this is how some people feel about marginals).
827 %
828 % If it occurs in vmode then it enters hmode and ensures that
829 % |\@savsk| is nonzero so that the |\ignorespaces| is put in later.
830 % It is not used at present.
831 % \changes{v1.2f}{1995/05/25}{(CAR) not used so `removed'.}
832 %\begin{verbatim}
833 % \def \@vbsphack{ %
834 % \relax \ifvmode
835 % \leavevmode
836 % \@savsk 1sp
837 % \@savsf \spacefactor
838 % \else
839 % \ifhmode
840 % \@savsk \lastskip
841 % \@savsf \spacefactor
842 % \fi
843 % \fi
844 % }
845 %\end{verbatim}
846 % \end{macro}
847 %
848 %
849 % \subsection{Vertical spacing}
850 %
851 %
852 % \LaTeX\ supports the plain \TeX\ commands
853 % |\smallskip|, |\medskip| and |\bigskip|.
854 % However, it redefines them using |\vspace| instead of |\vskip|.
855 %
856 % Extra vertical space is added by the command
857 % |\addvspace|\marg{skip},
858 % which adds a vertical skip of \meta{skip} to the document.
859 % The sequence\\
860 % |\addvspace|\marg{s1} |\addvspace|\marg{s2}
861 % is equivalent to\\
862 % |\addvspace|\marg{maximum of s1, s2}.
863 %
864 % |\addvspace| should be used only in vertical mode, and gives an
865 % error if it's not. The |\addvspace| command does \emph{not} add
866 % vertical space if |@minipage| is true. The minipage environment uses
867 % this to inhibit the addition of extra vertical space at the beginning.
868 %
869 % Penalties are put into the vertical list with the
870 % |\addpenalty|\marg{penalty}
871 % command. It works properly when |\addpenalty| and |\addvspace|
872 % commands are mixed.
873 %
874 % The |@nobreak| switch is set true used when in vertical mode and no
875 % page break should occur. (Right now, it is used only by the section
876 % heading commands to inhibit page breaking after a heading.)
877 %
878 %
879 % \begin{macro}{\@xaddvskip}
880 % Internal macro for |\vspace| handling the case that space has
881 % previously been added.
882 % \begin{macrocode}
883 \def\@xaddvskip{%
884 \ifdim\lastskip<\@tempskipb
885 \vskip-\lastskip
886 \vskip\@tempskipb
887 \else
888 \ifdim\@tempskipb<\z@
889 \ifdim\lastskip<\z@
890 \else
891 \advance\@tempskipb\lastskip
892 \vskip-\lastskip
893 \vskip \@tempskipb
894 \fi
895 \fi
896 \fi}
897 % \end{macrocode}
898 % \end{macro}
899 %
900 %
901 % \begin{macro}{\addvspace}
902 % \changes{v1.2b}{1994/11/12}{Corrected error message}
903 % \changes{v1.2c}{1994/11/13}{Recorrected error message}
904 % Add vertical space taking into account space already added, as
905 % described above.
906 % \changes{v1.3m}{2020/04/21}{Support calc syntax (gh/152)}
907 % \changes{v1.3s}{2024/09/10}{Drop unnecessary \cs{@noitemerr} and
908 % instead generate \cs{@LRmoderr} if we are in restricted hmode (gh/1460)}
909 % \begin{macrocode}
910 %</2ekernel>
911 %<*2ekernel|latexrelease>
912 %<latexrelease>\IncludeInRelease{2024/11/01}%
913 %<latexrelease> {\addvspace}{drop unnecessary no-item error}%
914 \protected\def\addvspace#1{%
915 % \end{macrocode}
916 % When this is encountered in hmode, we check whether we are in an hbox and if so
917 % generate a \LaTeX{} error, as otherwise this would cause a bunch
918 % of low-level errors. In unrestricted hmode we simply switch to vmode by
919 % issuing a \cs{par}.
920 % \begin{macrocode}
921 \ifhmode \ifinner \@LRmoderr \else \par \fi \fi
922 % \end{macrocode}
923 %
924 % \begin{macrocode}
925 \if@minipage\else
926 \ifdim \lastskip =\z@
927 \@vspace@calcify{#1}%
928 \else
929 \setlength\@tempskipb{#1}%
930 \@xaddvskip
931 \fi
932 \fi
933 }
934 %</2ekernel|latexrelease>
935 %<latexrelease>\EndIncludeInRelease
936 % \end{macrocode}
937 %
938 % \begin{macrocode}
939 %<latexrelease>\IncludeInRelease{2020/10/01}%
940 %<latexrelease> {\addvspace}{\addvspace calc support}%
941 %<latexrelease>\def\addvspace#1{%
942 %<latexrelease> \ifvmode
943 %<latexrelease> \if@minipage\else
944 %<latexrelease> \ifdim \lastskip =\z@
945 %<latexrelease> \@vspace@calcify{#1}%
946 %<latexrelease> \else
947 %<latexrelease> \setlength\@tempskipb{#1}%
948 %<latexrelease> \@xaddvskip
949 %<latexrelease> \fi
950 %<latexrelease> \fi
951 %<latexrelease> \else
952 %<latexrelease> \@noitemerr
953 %<latexrelease> \fi}
954 %<latexrelease>\EndIncludeInRelease
955 % \end{macrocode}
956 %
957 % \begin{macrocode}
958 %<latexrelease>\IncludeInRelease{0000/00/00}%
959 %<latexrelease> {\addvspace}{\addvspace calc support}%
960 %<latexrelease>
961 %<latexrelease>\def\addvspace#1{%
962 %<latexrelease> \ifvmode
963 %<latexrelease> \if@minipage\else
964 %<latexrelease> \ifdim \lastskip =\z@
965 %<latexrelease> \vskip #1\relax
966 %<latexrelease> \else
967 %<latexrelease> \@tempskipb#1\relax
968 %<latexrelease> \@xaddvskip
969 %<latexrelease> \fi
970 %<latexrelease> \fi
971 %<latexrelease> \else
972 %<latexrelease> \@noitemerr
973 %<latexrelease> \fi}
974 %<latexrelease>\EndIncludeInRelease
975 %<*2ekernel>
976 % \end{macrocode}
977 % \end{macro}
978 %
979 % \begin{macro}{\addpenalty}
980 % \changes{v1.2b}{1994/11/12}{Corrected error message}
981 % \changes{v1.2c}{1994/11/13}{Recorrected error message}
982 % \changes{v1.1h}{2015/01/09}{Donald Arseneau's fix from PR/377703 (latexrelease)}
983 % \changes{v1.3s}{2024/09/10}{Drop unnecessary \cs{@noitemerr} and
984 % instead generate \cs{@LRmoderr} if we are in restricted hmode (gh/1460)}
985 % \begin{macrocode}
986 %</2ekernel>
987 %<latexrelease>\IncludeInRelease{2024/11/01}%
988 %<latexrelease> {\addpenalty}{\addpenalty drop error}%
989 %<*2ekernel|latexrelease>
990 % \end{macrocode}
991 % \begin{macrocode}
992 \protected\def\addpenalty#1{%
993 % \end{macrocode}
994 % See description of \cs{addvspace} for documentation of the next
995 % line of code.
996 % \begin{macrocode}
997 \ifhmode \ifinner \@LRmoderr \else \par \fi \fi
998 % \end{macrocode}
999 % Fix provided by Donald (though the original fix was not good
1000 % enough). In 2005 Plamen Tanovski discovered that this fix wasn't
1001 % good enough either as the \cs{vskip} kept getting bigger if
1002 % several \cs{addpenalty} commands followed each other. Donald
1003 % kindly send a new fix.
1004 % \begin{macrocode}
1005 \if@minipage
1006 \else
1007 \if@nobreak
1008 \else
1009 \ifdim\lastskip=\z@
1010 \penalty#1\relax
1011 \else
1012 \@tempskipb\lastskip
1013 % \end{macrocode}
1014 % We have to make sure the final \cs{vskip} seen by \TeX\ is the
1015 % correct one, namely \cs{@tempskipb}. However, we may have to
1016 % adjust for \cs{prevdepth} when placing the penalty; that
1017 % should not affect the skip we pass on to \TeX.
1018 % \changes{v1.3e}{2015/01/14}{Avoid adding redundant skips (DPC)}
1019 % \begin{macrocode}
1020 \begingroup
1021 \@tempskipa\@tempskipb
1022 \advance \@tempskipb
1023 \ifdim\prevdepth>\maxdepth\maxdepth\else
1024 % \end{macrocode}
1025 % If |\prevdepth| is -1000pt due to |\nointerlineskip| we better
1026 % not add it!
1027 % \begin{macrocode}
1028 \ifdim \prevdepth = -\@m\p@ \z@ \else \prevdepth \fi
1029 \fi
1030 \vskip -\@tempskipb
1031 \penalty#1%
1032 \ifdim\@tempskipa=\@tempskipb
1033 % \end{macrocode}
1034 % Do nothing if the |\prevdepth| check made no adjustment.
1035 % \begin{macrocode}
1036 \else
1037 % \end{macrocode}
1038 % Combine the prevdepth adjustment into a single skip.
1039 % \begin{macrocode}
1040 \advance\@tempskipb -\@tempskipa
1041 \vskip \@tempskipb
1042 \fi
1043 % \end{macrocode}
1044 % The final skip is always the specified length.
1045 % \begin{macrocode}
1046 \vskip \@tempskipa
1047 \endgroup
1048 \fi
1049 \fi
1050 \fi
1051 }
1052 %</2ekernel|latexrelease>
1053 %<latexrelease>\EndIncludeInRelease
1054 % \end{macrocode}
1055 %
1056 % \begin{macrocode}
1057 %<latexrelease>\IncludeInRelease{2015/01/01}%
1058 %<latexrelease> {\addpenalty}{\addpenalty}%
1059 %<latexrelease>\def\addpenalty#1{%
1060 %<latexrelease> \ifvmode
1061 %<latexrelease> \if@minipage
1062 %<latexrelease> \else
1063 %<latexrelease> \if@nobreak
1064 %<latexrelease> \else
1065 %<latexrelease> \ifdim\lastskip=\z@
1066 %<latexrelease> \penalty#1\relax
1067 %<latexrelease> \else
1068 %<latexrelease> \@tempskipb\lastskip
1069 %<latexrelease> \begingroup
1070 %<latexrelease> \@tempskipa\@tempskipb
1071 %<latexrelease> \advance \@tempskipb
1072 %<latexrelease> \ifdim\prevdepth>\maxdepth\maxdepth\else
1073 %<latexrelease> \ifdim \prevdepth = -\@m\p@ \z@ \else \prevdepth \fi
1074 %<latexrelease> \fi
1075 %<latexrelease> \vskip -\@tempskipb
1076 %<latexrelease> \penalty#1%
1077 %<latexrelease> \ifdim\@tempskipa=\@tempskipb
1078 %<latexrelease> \else
1079 %<latexrelease> \advance\@tempskipb -\@tempskipa
1080 %<latexrelease> \vskip \@tempskipb
1081 %<latexrelease> \fi
1082 %<latexrelease> \vskip \@tempskipa
1083 %<latexrelease> \endgroup
1084 %<latexrelease> \fi
1085 %<latexrelease> \fi
1086 %<latexrelease> \fi
1087 %<latexrelease> \else
1088 %<latexrelease> \@noitemerr
1089 %<latexrelease> \fi}%
1090 % \end{macrocode}
1091 %
1092 % \begin{macrocode}
1093 %<latexrelease>\EndIncludeInRelease
1094 %<latexrelease>\IncludeInRelease{0000/00/00}%
1095 %<latexrelease> {\addpenalty}{\addpenalty}%
1096 %<latexrelease>\def\addpenalty#1{%
1097 %<latexrelease> \ifvmode
1098 %<latexrelease> \if@minipage
1099 %<latexrelease> \else
1100 %<latexrelease> \if@nobreak
1101 %<latexrelease> \else
1102 %<latexrelease> \ifdim\lastskip=\z@
1103 %<latexrelease> \penalty#1\relax
1104 %<latexrelease> \else
1105 %<latexrelease> \@tempskipb\lastskip
1106 %<latexrelease> \vskip -\lastskip
1107 %<latexrelease> \penalty#1%
1108 %<latexrelease> \vskip\@tempskipb
1109 %<latexrelease> \fi
1110 %<latexrelease> \fi
1111 %<latexrelease> \fi
1112 %<latexrelease> \else
1113 %<latexrelease> \@noitemerr
1114 %<latexrelease> \fi}%
1115 %<latexrelease>\EndIncludeInRelease
1116 %<*2ekernel>
1117 % \end{macrocode}
1118 % \end{macro}
1119 %
1120 %
1121 %
1122 % \begin{macro}{\vspace}
1123 % \changes{v1.2m}{1996/01/20}{Made robust}
1124 % \begin{macro}{\@vspace}
1125 % \begin{macro}{\@vspacer}
1126 % \changes{v1.2f}{1995/05/25}
1127 % {(CAR) macros modified to be more efficient}
1128 % \changes{v1.2f}{1995/05/25}{(CAR) \cs{@restorepar} added to avoid
1129 % possible infinite tail recursion caused by a typo in the argument.}
1130 % The new code for these commands depends on the following facts:
1131 % \begin{itemize}
1132 % \item The value of prevdepth is changed only when a box or rule
1133 % is created and added to a vertical list;
1134 % \item The value of prevdepth is used only when a box is created
1135 % and added to a vertical list;
1136 % \item The value of prevdepth is always local to the building of
1137 % one vertical list.
1138 % \end{itemize}
1139 % \begin{macrocode}
1140 \DeclareRobustCommand\vspace{\@ifstar\@vspacer\@vspace}
1141 % \end{macrocode}
1142 %
1143 % \begin{macrocode}
1144 %</2ekernel>
1145 %<*2ekernel|latexrelease>
1146 %<latexrelease>\IncludeInRelease{2020/10/01}%
1147 %<latexrelease> {\@vspace}{Support calc in \vspace}%
1148 % \end{macrocode}
1149 % We support calc syntax in the argument and therefore use \cs{setlength}.
1150 % \changes{v1.3m}{2020/04/21}{Support calc syntax (gh/152)}
1151 % \begin{macrocode}
1152 \def\@vspace #1{%
1153 \ifvmode
1154 \@vspace@calcify{#1}%
1155 \vskip\z@skip
1156 \else
1157 \@bsphack
1158 \vadjust{\@restorepar
1159 \@vspace@calcify{#1}%
1160 \vskip\z@skip
1161 }%
1162 \@esphack
1163 \fi}
1164 % \end{macrocode}
1165 %
1166 % \begin{macrocode}
1167 \def\@vspacer#1{%
1168 \ifvmode
1169 \dimen@\prevdepth
1170 \hrule \@height\z@
1171 \nobreak
1172 \@vspace@calcify{#1}%
1173 \vskip\z@skip
1174 \prevdepth\dimen@
1175 \else
1176 \@bsphack
1177 \vadjust{\@restorepar
1178 \hrule \@height\z@
1179 \nobreak
1180 \@vspace@calcify{#1}%
1181 \vskip\z@skip}%
1182 \@esphack
1183 \fi}
1184 %</2ekernel|latexrelease>
1185 %<latexrelease>\EndIncludeInRelease
1186 %<latexrelease>\IncludeInRelease{0000/00/00}%
1187 %<latexrelease> {\@vspace}{Support calc in \vspace}%
1188 %<latexrelease>
1189 %<latexrelease>\def\@vspace #1{%
1190 %<latexrelease> \ifvmode
1191 %<latexrelease> \vskip #1
1192 %<latexrelease> \vskip\z@skip
1193 %<latexrelease> \else
1194 %<latexrelease> \@bsphack
1195 %<latexrelease> \vadjust{\@restorepar
1196 %<latexrelease> \vskip #1
1197 %<latexrelease> \vskip\z@skip
1198 %<latexrelease> }%
1199 %<latexrelease> \@esphack
1200 %<latexrelease> \fi}
1201 %<latexrelease>\def\@vspacer#1{%
1202 %<latexrelease> \ifvmode
1203 %<latexrelease> \dimen@\prevdepth
1204 %<latexrelease> \hrule \@height\z@
1205 %<latexrelease> \nobreak
1206 %<latexrelease> \vskip #1
1207 %<latexrelease> \vskip\z@skip
1208 %<latexrelease> \prevdepth\dimen@
1209 %<latexrelease> \else
1210 %<latexrelease> \@bsphack
1211 %<latexrelease> \vadjust{\@restorepar
1212 %<latexrelease> \hrule \@height\z@
1213 %<latexrelease> \nobreak
1214 %<latexrelease> \vskip #1
1215 %<latexrelease> \vskip\z@skip}%
1216 %<latexrelease> \@esphack
1217 %<latexrelease> \fi}
1218 %<latexrelease>\EndIncludeInRelease
1219 %<*2ekernel>
1220 % \end{macrocode}
1221 % \end{macro}
1222 % \end{macro}
1223 % \end{macro}
1224 %
1225 % \begin{macro}{\smallskip}
1226 % \begin{macro}{\medskip}
1227 % \begin{macro}{\bigskip}
1228 % \begin{macrocode}
1229 \def\smallskip{\vspace\smallskipamount}
1230 \def\medskip{\vspace\medskipamount}
1231 \def\bigskip{\vspace\bigskipamount}
1232 % \end{macrocode}
1233 % \end{macro}
1234 % \end{macro}
1235 % \end{macro}
1236 %
1237 % \begin{macro}{\smallskipamount}
1238 % \begin{macro}{\medskipamount}
1239 % \begin{macro}{\bigskipamount}
1240 % \begin{macrocode}
1241 \newskip\smallskipamount \smallskipamount=3pt plus 1pt minus 1pt
1242 \newskip\medskipamount \medskipamount =6pt plus 2pt minus 2pt
1243 \newskip\bigskipamount \bigskipamount =12pt plus 4pt minus 4pt
1244 % \end{macrocode}
1245 % \end{macro}
1246 % \end{macro}
1247 % \end{macro}
1248 %
1249 %
1250 %
1251 % \subsection{Horizontal space (and breaks)}
1252 %
1253 % \begin{macro}{\nobreakdashes}
1254 % \changes{v1.3}{2004/02/04}{Macro added}
1255 % \changes{v1.3a}{2004/02/15}{Added spacefactor setting}
1256 % This idea is borrowed from the \textsf{amsmath} package but
1257 % here we define a robust command.
1258 %
1259 % This command is a low-level command designed for use only before
1260 % hyphens or dashes (such as |-|, |--|, or |---|).
1261 %
1262 % It could probably be better implemented: it may need its own
1263 % private token register and temporary command.
1264 %
1265 % Setting the hyphen in a box and then unboxing it means that the
1266 % normal penalty will not be added after it---and if the penalty is
1267 % not there a break will not be taken (unless an explicit penalty
1268 % or glue follows, thus the final \verb=\nobreak=).
1269 %
1270 % Note that even if it is not followed by a `-', it still leaves
1271 % vmode and sets the spacefactor; so use it carefully!
1272 %
1273 % \begin{macrocode}
1274 \DeclareRobustCommand{\nobreakdashes}{%
1275 \leavevmode
1276 \toks@{}%
1277 \def\reserved@a##1{\toks@\expandafter{\the\toks@-}%
1278 \futurelet\@let@token \reserved@b}%
1279 \def\reserved@b {\ifx\@let@token -%
1280 \expandafter\reserved@a
1281 \else
1282 \setbox\z@ \hbox{\the\toks@\nobreak}%
1283 \unhbox\z@
1284 \spacefactor\sfcode`\-
1285 \fi}%
1286 \futurelet\@let@token \reserved@b
1287 }
1288 % \end{macrocode}
1289 % \end{macro}
1290 %
1291 % \begin{macro}{\nobreakspace}
1292 % \changes{v1.2k}{1995/12/04}{Macro added}
1293 % \changes{v1.3r}{2023/10/26}{Protected definition for tilde}
1294 % \begin{macro}{\@xobeysp}
1295 % \changes{v1.2t}{1996/09/28}{Moved from ltmiscen.dtx and redefined to
1296 % use \cs{nobreakspace }}
1297 %
1298 % This is a robust command that produces a horizontal space at
1299 % which, in paragraph-mode, a line-break is not possible. We then
1300 % define an active |~| to expand to it since this is the documented
1301 % behaviour of |~|. One reason for introducing this is that some
1302 % 8-bit input encodings have a slot for such a space and we do not
1303 % want to use active characters as the \LaTeX{} internal commands.
1304 %
1305 % The braces in the definition of |~| are needed to ensure that a
1306 % following space is preserved when reading to/from internal files.
1307 % \changes{v1.2l}{1995/12/04}{braces added to definition of tilde}
1308 %
1309 % We need to keep \cs{@xobeysp} as it is widely used; so here it is
1310 % let to the non-robust command \cs{nobreakspace }.
1311 %
1312 % The fragile version of |~| needs a brace group after \cs{nobreakspace}
1313 % to prevent loss of spaces if it occurs in an expansion context. That's
1314 % not an issue with the updated \cs{protected} definition, so we keep the
1315 % code shorter and avoid that.
1316 % \begin{macrocode}
1317 \DeclareRobustCommand{\nobreakspace}{%
1318 \leavevmode\nobreak\ }
1319 \catcode `\~=13
1320 %</2ekernel>
1321 %<latexrelease>\IncludeInRelease{2023/11/01}%
1322 %<latexrelease> {\tilde}{Protected tilde}%
1323 %<*2ekernel|latexrelease>
1324 \protected\edef~{%
1325 \noexpand\ifincsname\noexpand\expandafter\string~%
1326 \noexpand\else
1327 \noexpand\expandafter\noexpand\nobreakspace
1328 \noexpand\fi
1329 }
1330 %</2ekernel|latexrelease>
1331 %<latexrelease>\EndIncludeInRelease
1332 %<latexrelease>\IncludeInRelease{0000/00/00}%
1333 %<latexrelease> {\tilde}{Protected tilde}%
1334 %<latexrelease>\def~{\nobreakspace{}}
1335 %<latexrelease>\EndIncludeInRelease
1336 %<*2ekernel>
1337 \expandafter\let\expandafter\@xobeysp\csname nobreakspace \endcsname
1338 % \end{macrocode}
1339 % \end{macro}
1340 % \end{macro}
1341 %
1342 % \begin{macro}{\@xobeytab}
1343 % \changes{v1.3q}{2023/06/14}{Macro added}
1344 % Equivalent to the space case with the default settings.
1345 % \begin{macrocode}
1346 %</2ekernel>
1347 %<latexrelease>\IncludeInRelease{2023/11/01}%
1348 %<latexrelease> {\@xobeytab}{Obeyed tabs}%
1349 %<*2ekernel|latexrelease>
1350 \let\@xobeytab\@xobeysp
1351 %</2ekernel|latexrelease>
1352 %<latexrelease>\EndIncludeInRelease
1353 %<latexrelease>\IncludeInRelease{0000/00/00}%
1354 %<latexrelease> {\@xobeytab}{Obeyed tabs}%
1355 %<latexrelease>\let\@xobeytab\@undefined
1356 %<latexrelease>\EndIncludeInRelease
1357 %<*2ekernel>
1358 % \end{macrocode}
1359 % \end{macro}
1360 %
1361 %
1362 % \begin{macro}{\@}
1363 % Placed before a '.', makes it a sentence-ending period. Does the
1364 % right thing for other punctuation marks as well. Does this by
1365 % setting spacefactor to 1000.
1366 % \changes{v1.3b}{2014/12/30}{\cs{@} discards spaces when moving
1367 % (pr3039)(latexrelease)}
1368 % \begin{macrocode}
1369 %</2ekernel>
1370 %<latexrelease>\IncludeInRelease{2015/01/01}%
1371 %<latexrelease> {\@}{Space after \@}%
1372 %<*2ekernel|latexrelease>
1373 % \end{macrocode}
1374 % \begin{macrocode}
1375 \def\@{\spacefactor\@m{}}%
1376 %</2ekernel|latexrelease>
1377 %<latexrelease>\EndIncludeInRelease
1378 %<latexrelease>\IncludeInRelease{0000/00/00}%
1379 %<latexrelease> {\@}{Space after \@}%
1380 %<latexrelease>\def\@{\spacefactor\@m}%
1381 %<latexrelease>\EndIncludeInRelease
1382 %<*2ekernel>
1383 % \end{macrocode}
1384 % \end{macro}
1385 %
1386 %
1387 % \begin{macro}{\hspace}
1388 % \changes{v1.0o}{1994/05/11}{Use \cs{DeclareRobustCommand}. ASAJ.}
1389 % \begin{macrocode}
1390 \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
1391 % \end{macrocode}
1392 % \end{macro}
1393 %
1394 % \begin{macro}{\@hspace}
1395 % \changes{LaTeX2e}{1993/08/05}
1396 % {(RmS) Removed superfluous \cs{leavevmode} in \cs{@hspace} and
1397 % \cs{@hspacer}, as suggested by CAR.}
1398 % \changes{v1.3m}{2020/04/21}{Support calc syntax (gh/152)}
1399 % \changes{v1.3o}{2022/11/28}{Support calc syntax correctly (gh/967)}
1400 % \begin{macrocode}
1401 %</2ekernel>
1402 %<*2ekernel|latexrelease>
1403 %<latexrelease>\IncludeInRelease{2020/10/01}%
1404 %<latexrelease> {\@hspace}{Support calc with \hspace}%
1405 % \end{macrocode}
1406 % We use a private register to calculate the space (if \pkg{calc} is used). Previously
1407 % we used a group but that results in
1408 % \cs{everypar} etc.\ being executed inside the group if the \cs{hspace} starts a paragraph.
1409 % This is a bug fix so
1410 % we do not provide rollback to the incorrect intermediate version.
1411 % \begin{macrocode}
1412 \newskip\sp@ce@skip
1413 \def\@hspace#1{\setlength\sp@ce@skip{#1}\hskip\sp@ce@skip}
1414 %</2ekernel|latexrelease>
1415 %<latexrelease>\EndIncludeInRelease
1416 % \end{macrocode}
1417 %
1418 % \begin{macrocode}
1419 %<latexrelease>\IncludeInRelease{0000/00/00}%
1420 %<latexrelease> {\@hspace}{Support calc with \hspace}%
1421
1422 %<latexrelease>
1423 %<latexrelease>\def\@hspace#1{\hskip #1\relax}
1424 %<latexrelease>\EndIncludeInRelease
1425 %<*2ekernel>
1426 % \end{macrocode}
1427 % \end{macro}
1428 %
1429 %
1430 % \begin{macro}{\@hspacer}
1431 % Extra |\hskip 0pt| added 1985/17/12 to guard
1432 % against a following |\unskip|
1433 % |\relax| added 13 Oct 88 for usual \TeX\ lossage
1434 % replaced both changes by |\hskip\z@skip| 27 Nov 91
1435 % \begin{macrocode}
1436 \def\@hspacer#1{\vrule \@width\z@\nobreak
1437 \@hspace{#1}\hskip \z@skip}
1438 % \end{macrocode}
1439 % \end{macro}
1440 %
1441 %
1442 %
1443 % \begin{macro}{\fill}
1444 % \begin{macrocode}
1445 \newskip\fill
1446 \fill = 0pt plus 1fill
1447 % \end{macrocode}
1448 % \end{macro}
1449 %
1450 %
1451 %
1452 % \begin{macro}{\stretch}
1453 % \begin{macrocode}
1454 \def\stretch#1{\z@ \@plus #1fill\relax}
1455 % \end{macrocode}
1456 % \end{macro}
1457 %
1458 %
1459 % \begin{macrocode}
1460 %</2ekernel>
1461 %<*2ekernel|latexrelease>
1462 %<latexrelease>\IncludeInRelease{2018/12/01}%
1463 %<latexrelease> {\thinspace}{Start LR-mode}%
1464 % \end{macrocode}
1465 %
1466 % \begin{macro}{\enspace}
1467 % \changes{v1.3h}{2018/09/24}{Start LR-mode if necessary (gh/49)}
1468 % \begin{macrocode}
1469 \DeclareRobustCommand\enspace{\leavevmode@ifvmode\kern.5em }
1470 % \end{macrocode}
1471 % \end{macro}
1472 %
1473 % \begin{macro}{\leavevmode@ifvmode}
1474 % Leave vmode but only if we are really in vmode, otherwise the
1475 % expansion is empty (which is not the case with the default definition).
1476 % \changes{v1.3h}{2018/09/24}{Macro added (gh/49)}
1477 % \begin{macrocode}
1478 \protected\def\leavevmode@ifvmode{\ifvmode\expandafter\indent\fi}
1479 % \end{macrocode}
1480 % \end{macro}
1481 %
1482 % \begin{macrocode}
1483 %</2ekernel|latexrelease>
1484 %<latexrelease>\EndIncludeInRelease
1485 %<latexrelease>\IncludeInRelease{0000/00/00}%
1486 %<latexrelease> {\thinspace}{Start LR-mode}%
1487 %<latexrelease>\def\thinspace{\kern .16667em }
1488 %<latexrelease>\def\negthinspace{\kern-.16667em }
1489 %<latexrelease>\def\enspace{\kern.5em }
1490 %<latexrelease>\let\leavevmode@ifvmode\@undefined
1491 %<latexrelease>\EndIncludeInRelease
1492 %<*2ekernel>
1493 % \end{macrocode}
1494 %
1495 %
1496 %
1497 % \begin{macro}{\enskip}
1498 % \begin{macro}{\quad}
1499 % \begin{macro}{\qquad}
1500 % \begin{macrocode}
1501 \def\enskip{\hskip.5em\relax}
1502 \def\quad{\hskip1em\relax}
1503 \def\qquad{\hskip2em\relax}
1504 % \end{macrocode}
1505 % \end{macro}
1506 % \end{macro}
1507 % \end{macro}
1508 %
1509 % \changes{v1.3n}{2020/05/06}{Made softhyphen active in TU engines}
1510 %
1511 % For Unicode engines, make the Unicode soft hyphen an active
1512 % character defined as \cs{-}.
1513 %
1514 % \begin{macrocode}
1515 \ifx\Umathcode\@undefined\else
1516 \catcode "AD=13
1517 \def^^ad{\-}
1518 \fi
1519 % \end{macrocode}
1520 %
1521 % \begin{macro}{\obeycr}
1522 % \begin{macro}{\restorecr}
1523 % The following definitions will probably get deleted or moved to
1524 % compatibility mode soon.
1525 %
1526 % \changes{v1.2g}{1995/06/11}
1527 % {(CAR) \cs{relax} added to stop silent eating of *.}
1528 % \begin{macrocode}
1529 {\catcode`\^^M=13 \gdef\obeycr{\catcode`\^^M13 \def^^M{\\\relax}%
1530 \@gobblecr}%
1531 {\catcode`\^^M=13 \gdef\@gobblecr{\@ifnextchar
1532 \@gobble\ignorespaces}}
1533 \gdef\restorecr{\catcode`\^^M5 }}
1534 % \end{macrocode}
1535 % \end{macro}
1536 % \end{macro}
1537 %
1538 % \begin{macrocode}
1539 %</2ekernel>
1540 % \end{macrocode}
1541 %
1542 % \Finale
1543 \endinput