1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
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 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
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
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.
31 %%% From File: ltspace.dtx
34 \ProvidesFile{ltspace.dtx}
35 [2016/07/04 v1.3g LaTeX Kernel (spacing)]
37 \documentclass{ltxdoc}
38 \GetFileInfo{ltspace.dtx}
50 \MaintainedByLaTeXTeam{latex}
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.}
69 % This section deals with spacing, and line- and page-breaking.
71 % \subsection{User Commands}
73 % \DescribeMacro\nopagebreak\oarg{i} : \meta{i} = 0,...,4.
75 % Default argument = 4. Puts a penalty into the vertical list
76 % output as follows:\\
78 % 1 : penalty = |\@lowpenalty|\\
79 % 2 : penalty = |\@medpenalty|\\
80 % 3 : penalty = |\@highpenalty|\\
83 % \DescribeMacro\pagebreak\oarg{i} :
84 % same as \nopagebreak except negatives of its penalty
86 % \DescribeMacro\linebreak\oarg{i} : analog of the above
88 % \DescribeMacro\nolinebreak\oarg{i} : analog of the above
90 % \DescribeMacro\samepage :
91 % inhibits page breaking most places by setting the
92 % following penalties to 10000:\\
93 % |\interlinepenalty|\\
94 % |\postdisplaypenalty|\\
95 % |\interdisplaylinepenalty|\\
96 % |\@beginparpenalty|\\
100 % |\interfootnotelinepenalty|
102 % \DescribeMacro{\\} : initially defined to be |\newline|
104 % |\\|\oarg{length} : initially defined to be
105 % |\vspace|\marg{length}|\newline|\\
106 % Note: |\\*| adds a |\vadjust{\penalty 10000}|
108 % OBSOLETE COMMANDS (which never made it into the manual):
110 % |\obeycr| : defines <CR> == |\\\relax|\\
111 % |\restorecr| : restores <CR> to its usual meaning.
116 % \subsection{Chris' comments}
118 % There are several aspects of the handling of space in horizontal
119 % mode that are inconsistent or do not work well in some cases.
120 % These are largely concerned with ignoring the effect of space
121 % tokens that would otherwise typeset an inter-word space.
123 % Negating the effect of such space tokens is achieved by two
126 % \item |\unskip| is used to remove the glue just added by
127 % a space that has already had its effect; it is sometimes
128 % invoked after an |\ifdim| test on |\lastskip| (see below);
129 % \item |\ignorespaces| is used to ignore space-tokens yet to come.
132 % The test done on |\lastskip| is sometimes for equality with zero and
133 % sometimes for being positive. Recall also that the test is only on
134 % the natural length of the glue and that no glue cannot be
135 % distinguished from glue whose natural length is zero: to summarise,
136 % a pretty awful test. It is not clear why these tests are not all
137 % the same; I think that they should all be for equality. One place
138 % where |\unskip| is often used is just before a |\par| (which itself
139 % internally does an |\unskip|) and one bit of code (in |\@item|) even
140 % has two |\unskips| before a |\par|. These uses may be fossil code
141 % but if they are necessary, maybe |\@killglue| would be even safer.
143 % Such removal of glue by |\unskip| may sometimes have the wrong result,
144 % removing not the glue from a space-token but other explicit glue;
145 % this is sometimes not what is intended.
147 % A common way to prevent such removal is to add an |\hskip\z@| after
148 % the glue that should not be removed. This protects that glue
149 % against one |\unskip| with no test but not against more than one.
150 % It does work for `tested |\unskip|s'. This is used
151 % by |\hspace*| but not by |\hspace|; this is inconsistent as the star
152 % is supposed to prevent removal only at the beginning of a line, not
153 % at the end, or in a tabular, etc.
155 % If this reason for removing glue were the only consideration then a
156 % tested-|\unskip| and protection by |\hskip\z@| would suffice but
157 % would need to be consistently implemented.
159 % However, the class of invisibles, commands and environments tries to
160 % be even cleverer: one of these tries to leave only one inter-word
161 % space whenever there is one before it and one after it; and it does
164 % But problems can arise when there is not a space-token on
165 % both sides of it; in particular, when an invisible appears at the
166 % beginning or end of a piece of text the method still leaves one space
167 % token whereas usually in these cases it should leave none.
169 % Also, the current rules do not work well when more than one such
170 % command appears consecutively, separated by space-tokens; it leaves
171 % glue between every other invisible.
173 % There is also a question about what these commands should do when
174 % they occur next to spaces that do not come from space tokens but,
175 % for example, from |\hspace|. Should they still produce `just one
176 % space'? If so, which one? It is good to note that the manual
177 % is sufficiently cautious about invisibles that we are not obliged to
178 % make anything work.
180 % Another interesting side-road to explore is whether the space-tokens
181 % either side of an |\hspace{...}| should be ignored.
183 % One alternative to the current algorithm that is often suggested is
184 % that all glue around the invisible should be consolidated into a
185 % space after it (usually without stating how much glue should be put
186 % there). The command |\nolinebreak| is implemented this way (and
187 % |\linebreak| should also be). This does not work correctly for the
188 % following common case:
192 % some-word and more text.
194 % This is optimal coding since it is normal to index a word that gets
195 % split across a page-break on its starting page. This would, on the
196 % other hand, fix another common (and documented) failure of the
197 % current system: when the invisible is the last thing in a paragraph
198 % the space before it is not removed and, worse, it is also hidden
199 % from the paragraph-ending mechanism so that an `empty' line can be
200 % created at the end of the paragraph.
202 % Another deficiency (I think) of the current system is that the
203 % following is treated as having the |\index| command between the
204 % paragraphs, which is probably not what the author intended (since
205 % there is no empty line after it).
209 % Beginnings of paragraphs ...
212 % I know of no algorithm that will handle satisfactorily even
213 % all the most common cases; note that it could be that the best
214 % algorithm may be different for different invisibles since,
215 % for example, the common uses and expected behaviour of
216 % |\index|, |\marginpar|, |\linebreak|, |\pagebreak| and
217 % |\vspace| are somewhat different. [For example, is
218 % |\vspace| ever used in the middle of a paragraph?]
220 % One method that can (and is) used to make invisible commands produce
221 % no space when used at the beginning of text is to put in some glue
222 % that is nearly enough the same as no glue or glue of zero length in
223 % all respects except for the precise test for not being exactly equal
224 % to zero; examples of such glue are |\hskip 1sp| and, possibly better
225 % but more complex, |\hskip -1sp \hskip 1sp|. However, this only works
226 % when it is known that user-supplied text is about to start.
228 % Some similar concerns apply to the handling of space and penalties
229 % in vertical mode; there is an extra hurdle here as |\unskip| does
230 % not work on the main vertical list. The complexity of the tests done
231 % by |\addvspace| have never been explained.
233 % The implementation of space hacks etc for vertical mode is another
234 % major area that needs further attention; my earlier experiments
235 % did not produce much improvement over the current unsatisfactory
238 % One particular problem is what happens when the following very
239 % natural coding is used (part of the problem here is that this looks
240 % like an hmode problem, but it is not):
245 % \item \label{item:xxx} Item text.
249 % \subsection{Some immediate actions}
252 % \item Fix bug in |\linebreak|.
253 % \item Fix bug in |\\*|.
254 % \item Reimplement |\\|, etc, removing extra |\vadjust|s and getting
255 % better error trapping (this seems to involve a lot more tokens).
256 % \item Investigate whether |\\|, etc need to be errors in vmode; I
257 % think that they could be noops (maybe with a warning).
258 % \item Make all(?) |\unskips| include test for zero skip (rather than
259 % other tests or no test).
260 % \item Consider replacing |\hskip 1sp| by something better (here
261 % called an `infinitesimal' skip).
262 % \item Look at all |\hskip\z@| (or similar) to see if they should be
263 % changed to an `infinitesimal' skip.
264 % \item Resolve the inconsistency between |\hspace| and |\hspace*|.
265 % \item Remove unnecessary |\unskips|.
266 % \item Investigate and rationalise the `newline' code.
267 % \item Find better algorithms for all sorts of things or, easier(?),
271 % \subsection{The code}
278 % \begin{macro}{\pagebreak}
279 % \begin{macro}{\nopagebreak}
280 % \changes{v1.2h}{1995/07/05}{Reimplemented both using \cs{@no@pgbk}}
281 % \changes{v1.2j}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
283 \def\pagebreak{\@testopt{\@no@pgbk-}4}
284 \def\nopagebreak{\@testopt\@no@pgbk4}
290 % \begin{macro}{\@no@pgbk}
291 % \changes{v1.2h}{1995/07/05}{Macro replaces \cs{@pgbk}
294 \def\@no@pgbk #1[#2]{%
296 \penalty #1\@getpen{#2}%
299 \vadjust{\penalty #1\@getpen{#2}}%
305 % \begin{macro}{\linebreak}
306 % \begin{macro}{\nolinebreak}
307 % \changes{v1.2u}{1996/10/29}{Reimplemented both using \cs{@no@lnbk}}
308 % \changes{v1.2j}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
310 \def\linebreak{\@testopt{\@no@lnbk-}4}
311 \def\nolinebreak{\@testopt\@no@lnbk4}
315 % \begin{macro}{\@no@lnbk}
316 % \changes{v1.2u}{1996/10/29}{Macro replaces \cs{@lnbk}
319 \def\@no@lnbk #1[#2]{%
325 \penalty #1\@getpen{#2}%
326 \ifdim\@tempskipa>\z@
334 % \begin{macro}{\samepage}
336 \def\samepage{\interlinepenalty\@M
337 \postdisplaypenalty\@M
338 \interdisplaylinepenalty\@M
343 \interfootnotelinepenalty\@M}
349 % \changes{v1.2a}{1994/11/11}{(DPC) Make robust}
350 % \changes{v1.2d}{1994/11/14}{(DPC) Macro modified}
352 % \changes{v1.2u}{1996/10/29}{Corrected and rationalised code}
353 % The purpose of the new code is to fix a few bugs; however, it also
354 % attempts to optimize the following, in order of priority:
356 % \item efficient execution of plain |\\|;
357 % \item efficient execution of |\\[...]|;
359 % \item name-space use.
361 % The changes should make no difference to the typeset output.
362 % It appears to be safe to use |\reserved@e| and |\reserved@f| here
363 % (other reserved macros are somewhat disastrous).
365 % These changes made |\newline| even less robust than it had been,
366 % so now it is explicitly robust, like |\\|.
367 % \begin{macro}{\@normalcr}
368 % The internal definition of the `normal' definition of |\\|.
370 \DeclareRobustCommand\\{%
371 \let \reserved@e \relax
372 \let \reserved@f \relax
373 \@ifstar{\let \reserved@e \vadjust \let \reserved@f \nobreak
376 \expandafter\let\expandafter\@normalcr
377 \csname\expandafter\@gobble\string\\ \endcsname
381 % \begin{macro}{\newline}
382 % A simple form of the `normal' definition of |\\|.
383 % \changes{v1.2v}{1997/05/07}{Made completely robust.}
385 \DeclareRobustCommand\newline{\@normalcr\relax}
389 % \begin{macro}{\@xnewline}
391 \def\@xnewline{\@ifnextchar[% ] bracket matching
397 % \begin{macro}{\@newline}
399 \def\@newline[#1]{\let \reserved@e \vadjust
400 \@gnewline {\vskip #1}}
404 % \begin{macro}{\@gnewline}
405 % \changes{v1.2u}{1996/10/29}{Added macro}
406 % The |\nobreak| added to prevent null lines when |\\|
407 % ends an overfull line. Change made 24 May 89 as suggested by
408 % Frank Mittelbach and Rainer Sch\"opf
409 % \changes{v1.2h}{1995/07/05}{Use \cs{break}}
415 \unskip \reserved@e {\reserved@f#1}\nobreak \hfil \break
421 % \begin{macro}{\@getpen}
423 \def\@getpen#1{\ifcase #1 \z@ \or \@lowpenalty\or
424 \@medpenalty \or \@highpenalty
430 % \begin{macro}{\if@nobreak}
431 % \changes{v1.2p}{1996/07/26}{put \cs{global} inside definition}
432 % Switch used to avoid page breaks caused by |\label| after a
433 % section heading, etc. It should be \textbf{GLOBALLY} set true
434 % after the |\nobreak| and \textbf{globally} set false by the
435 % next invocation of |\everypar|.
437 % Commands that reset |\everypar| should globally set it false if
440 \def\@nobreakfalse{\global\let\if@nobreak\iffalse}
441 \def\@nobreaktrue {\global\let\if@nobreak\iftrue}
448 % \begin{macro}{\@savsk}
449 % \begin{macro}{\@savsf}
450 % Registers used to save the space factor and last skip.
461 % \begin{macro}{\@bsphack}
462 % \changes{LaTeX2e}{1993/12/08}
463 % {Command reimplemented; late birthday present for Chris}
464 % \changes{LaTeX2e}{1993/12/08}{Command reimplemented}
465 % \changes{LaTeX2e}{1993/12/16}{Corrected optimisation :-)}
466 % |\@bsphack| and |\@esphack|
467 % used by macros such as |\index| and
468 % |\begin{@float}| \ldots |\end{@float}|
469 % that want to be invisible --- i.e.,
470 % not leave any extra space when used in the middle of text. Such
471 % a macro should begin with |\@bsphack| and end with |\@esphack|
472 % The macro in question should not create any text, nor change the
475 % Before giving the current definition we give an extended definition
476 % that is currently not used (because it doesn't work as advertised:-)
478 % These are generalised hacks which attempt to do sensible things
479 % when `invisible commands' appear in vmode too.
481 % They need to cope with space in both hmode (plus spacefactor) and
482 % vmode, and also cope with breaks etc. In vmode this means
483 % ensuring that any following |\addvspace|, etc sees the correct
484 % glue in |\lastskip|.
486 % In fact, these improved versions should be used for other cases
487 % of `whatsits, thingies etc' which should be invisible. They are
488 % only for commands, not environments (see notes on |\@Esphack|).
490 % BTW, anyone know why the standard hacks are surrounded by
491 % |\ifmmode\else| rather than simply |\ifhmode|?
493 % And are there any cases where saving the spacefactor is
494 % essential? I have some extensions where it is, but it does not
495 % appear to be so in the standard uses.
500 % \ifdim \lastskip=\z@
507 % \@savsf \spacefactor
512 % I think that, in vmode, it is the safest to put
513 % in a |\nobreak| immediately after such things since writes,
514 % inserts etc followed by glue give valid breakpoints and, in
515 % general, it is possible to create breaks but impossible to
527 % \spacefactor \@savsf
535 % For the moment we are going to ignore the vertical versions until
537 % \changes{LaTeX2e}{1993/12/19}{There seem to be problems with selfmade
549 % \begin{macro}{\@esphack}
550 % Companion to |\@bsphack|.
551 % \changes{v1.3d}{2015/01/11}{Allow hyphenation (Donald Arseneau pr/3498) (latexrelease)}
554 %<latexrelease>\IncludeInRelease{2015/10/01}%
555 %<latexrelease> {\@esphack}{hyphenation after space hack}%
556 %<*2ekernel|latexrelease>
563 % \changes{v1.3f}{2015/11/07}
564 % {Only space if there is no space at the end of the hlist latex/4443}
567 \nobreak \hskip\z@skip
572 %</2ekernel|latexrelease>
573 %<latexrelease>\EndIncludeInRelease
574 %<latexrelease>\IncludeInRelease{2015/01/01}%
575 %<latexrelease> {\@esphack}{hyphenation after space hack}%
576 %<latexrelease>\def\@esphack{%
577 %<latexrelease> \relax
578 %<latexrelease> \ifhmode
579 %<latexrelease> \spacefactor\@savsf
580 %<latexrelease> \ifdim\@savsk>\z@
581 %<latexrelease> \nobreak \hskip\z@skip
582 %<latexrelease> \ignorespaces
584 %<latexrelease> \fi}%
585 %<latexrelease>\EndIncludeInRelease
586 %<latexrelease>\IncludeInRelease{0000/00/00}%
587 %<latexrelease> {\@esphack}{hyphenation after space hack}%
588 %<latexrelease>\def\@esphack{%
589 %<latexrelease> \relax
590 %<latexrelease> \ifhmode
591 %<latexrelease> \spacefactor\@savsf
592 %<latexrelease> \ifdim\@savsk>\z@
593 %<latexrelease> \ignorespaces
595 %<latexrelease> \fi}%
596 %<latexrelease>\EndIncludeInRelease
601 % \begin{macro}{\@Esphack}
602 % A variant of |\@esphack| that sets the |@ignore| switch to
603 % true (as |\@esphack| used to do previously).
604 % This is currently used only for floats and similar environments.
605 % \changes{v1.2s}{1996/08/02}{Remove \cs{global} before \cs{@ignore...}}
606 % \changes{v1.3d}{2015/01/11}{Allow hyphenation (Donald Arseneau pr/3498) (latexrelease)}w
609 %<latexrelease>\IncludeInRelease{2015/01/01}%
610 %<latexrelease> {\@Esphack}{hyphenation after space hack}%
611 %<*2ekernel|latexrelease>
617 \nobreak \hskip\z@skip
622 %</2ekernel|latexrelease>
623 %<latexrelease>\EndIncludeInRelease
624 %<latexrelease>\IncludeInRelease{0000/00/00}%
625 %<latexrelease> {\@Esphack}{hyphenation after space hack}%
626 %<latexrelease>\def\@Esphack{%
627 %<latexrelease> \relax
628 %<latexrelease> \ifhmode
629 %<latexrelease> \spacefactor\@savsf
630 %<latexrelease> \ifdim\@savsk>\z@
631 %<latexrelease> \@ignoretrue
632 %<latexrelease> \ignorespaces
634 %<latexrelease> \fi}%
635 %<latexrelease>\EndIncludeInRelease
641 % \begin{macro}{\@vbsphack}
642 % \changes{LaTeX2e}{1993/12/08}{Command added}
643 % Another variant which is useful for invisible things which should
644 % not live in vmode (this is how some people feel about marginals).
646 % If it occurs in vmode then it enters hmode and ensures that
647 % |\@savsk| is nonzero so that the |\ignorespaces| is put in later.
648 % It is not used at present.
649 % \changes{v1.2f}{1995/05/25}{(CAR) not used so `removed'.}
655 % \@savsf \spacefactor
659 % \@savsf \spacefactor
667 % \subsection{Vertical spacing}
670 % \LaTeX\ supports the plain \TeX\ commands
671 % |\smallskip|, |\medskip| and |\bigskip|.
672 % However, it redefines them using |\vspace| instead of |\vskip|.
674 % Extra vertical space is added by the command
675 % |\addvspace|\marg{skip},
676 % which adds a vertical skip of \meta{skip} to the document.
678 % |\addvspace|\marg{s1} |\addvspace|\marg{s2}
680 % |\addvspace|\marg{maximum of s1, s2}.
682 % |\addvspace| should be used only in vertical mode, and gives an
683 % error if it's not. The |\addvspace| command does \emph{not} add
684 % vertical space if |@minipage| is true. The minipage environment uses
685 % this to inhibit the addition of extra vertical space at the beginning.
687 % Penalties are put into the vertical list with the
688 % |\addpenalty|\marg{penalty}
689 % command. It works properly when |\addpenalty| and |\addvspace|
690 % commands are mixed.
692 % The |@nobreak| switch is set true used when in vertical mode and no
693 % page break should occur. (Right now, it is used only by the section
694 % heading commands to inhibit page breaking after a heading.)
698 % \addvspace{SKIP} ==
702 % else if \lastskip =0
704 % else if \lastskip < SKIP
705 % then \vskip -\lastskip
707 % else if SKIP < 0 and \lastskip >= 0
708 % then \vskip -\lastskip
709 % \vskip \lastskip + SKIP
711 % else useful error message (CAR).
716 % \begin{macro}{\@xaddvskip}
717 % Internal macro for |\vspace| handling the case that space has
718 % previously been added.
721 \ifdim\lastskip<\@tempskipb
725 \ifdim\@tempskipb<\z@
728 \advance\@tempskipb\lastskip
738 % \begin{macro}{\addvspace}
739 % \changes{v1.2b}{1994/11/12}{Corrected error message}
740 % \changes{v1.2c}{1994/11/13}{Recorrected error message}
741 % Add vertical space taking into account space already added, as
747 \ifdim \lastskip =\z@
760 % \begin{macro}{\addpenalty}
761 % \changes{v1.2b}{1994/11/12}{Corrected error message}
762 % \changes{v1.2c}{1994/11/13}{Recorrected error message}
763 % \changes{v1.1h}{2015/01/09}{Donald Arseneau's fix from PR/377703 (latexrelease)}
766 %<latexrelease>\IncludeInRelease{2015/01/01}%
767 %<latexrelease> {\addpenalty}{\addpenalty}%
768 %<*2ekernel|latexrelease>
770 % Fix provided by Donald (though the original fix was not good
771 % enough). In 2005 Plamen Tanovski discovered that this fix wasn't
772 % good enough either as the \cs{vskip} kept getting bigger if
773 % several \cs{addpenalty} commands followed each other. Donald
774 % kindly send a new fix.
787 % We have to make sure the final \cs{vskip} seen by \TeX\ is the
788 % correct one, namely \cs{@tempskipb}. However we may have to
789 % adjust for \cs{prevdepth} when placing the penalty but that
790 % should not affect the skip we pass on to \TeX.
791 % \changes{v1.3e}{2015/01/14}{Avoid adding redundant skips (DPC)}
794 \@tempskipa\@tempskipb
796 \ifdim\prevdepth>\maxdepth\maxdepth\else
798 % If |\prevdepth| is -1000pt due to |\nointerlineskip| we better
801 \ifdim \prevdepth = -\@m\p@ \z@ \else \prevdepth \fi
805 \ifdim\@tempskipa=\@tempskipb
807 % Do nothing if the |\prevdepth| check made no adjustment.
811 % Combine the prevdepth adjustment into a single skip.
813 \advance\@tempskipb -\@tempskipa
817 % The final skip is always the specified length.
830 %</2ekernel|latexrelease>
831 %<latexrelease>\EndIncludeInRelease
832 %<latexrelease>\IncludeInRelease{0000/00/00}%
833 %<latexrelease> {\addpenalty}{\addpenalty}%
834 %<latexrelease>\def\addpenalty#1{%
835 %<latexrelease> \ifvmode
836 %<latexrelease> \if@minipage
837 %<latexrelease> \else
838 %<latexrelease> \if@nobreak
839 %<latexrelease> \else
840 %<latexrelease> \ifdim\lastskip=\z@
841 %<latexrelease> \penalty#1\relax
842 %<latexrelease> \else
843 %<latexrelease> \@tempskipb\lastskip
844 %<latexrelease> \vskip -\lastskip
845 %<latexrelease> \penalty#1%
846 %<latexrelease> \vskip\@tempskipb
850 %<latexrelease> \else
851 %<latexrelease> \@noitemerr
852 %<latexrelease> \fi}%
853 %<latexrelease>\EndIncludeInRelease
858 % \begin{macro}{\vspace}
859 % \changes{v1.2m}{1996/01/20}{Made robust}
860 % \begin{macro}{\@vspace}
861 % \begin{macro}{\@vspacer}
862 % \changes{v1.2f}{1995/05/25}
863 % {(CAR) macros modified to be more efficient}
864 % \changes{v1.2f}{1995/05/25}{(CAR) \cs{@restorepar} added to avoid
865 % possible infinite tail recursion caused by a typo in the argument.}
866 % The new code for these commands depends on the following facts:
868 % \item The value of prevdepth is changed only when a box or rule
869 % is created and added to a vertical list;
870 % \item The value of prevdepth is used only when a box is created
871 % and added to a vertical list;
872 % \item The value of prevdepth is always local to the building of
876 \DeclareRobustCommand\vspace{\@ifstar\@vspacer\@vspace}
883 \vadjust{\@restorepar
902 \vadjust{\@restorepar
914 % \begin{macro}{\smallskip}
915 % \begin{macro}{\medskip}
916 % \begin{macro}{\bigskip}
918 \def\smallskip{\vspace\smallskipamount}
919 \def\medskip{\vspace\medskipamount}
920 \def\bigskip{\vspace\bigskipamount}
926 % \begin{macro}{\smallskipamount}
927 % \begin{macro}{\medskipamount}
928 % \begin{macro}{\bigskipamount}
930 \newskip\smallskipamount \smallskipamount=3pt plus 1pt minus 1pt
931 \newskip\medskipamount \medskipamount =6pt plus 2pt minus 2pt
932 \newskip\bigskipamount \bigskipamount =12pt plus 4pt minus 4pt
940 % \subsection{Horizontal space (and breaks)}
942 % \begin{macro}{\nobreakdashes}
943 % \changes{v1.3}{2004/02/04}{(Macro added}
944 % \changes{v1.3a}{2004/02/15}{(Added spacefactor setting}
945 % This idea is borrowed from the \textsf{amsmath} package but
946 % here we define a robust command.
948 % This command is a low-level command designed for use only before
949 % hyphens or dashes (such as |-|, |--|, or |---|).
951 % It could probably be better implemented: it may need its own
952 % private token register and temporary command.
954 % Setting the hyphen in a box and then unboxing it means that the
955 % normal penalty will not be added after it---and if the penalty is
956 % not there a break will not be taken (unless an explicit penalty
957 % or glue follows, thus the final \verb=\nobreak=).
959 % Note that even if it is not followed by a `-', it still leaves
960 % vmode and sets the spacefactor; so use it carefully!
963 \DeclareRobustCommand{\nobreakdashes}{%
966 \def\reserved@a##1{\toks@\expandafter{\the\toks@-}%
967 \futurelet\@let@token \reserved@b}%
968 \def\reserved@b {\ifx\@let@token -%
969 \expandafter\reserved@a
971 \setbox\z@ \hbox{\the\toks@\nobreak}%
973 \spacefactor\sfcode`\-
975 \futurelet\@let@token \reserved@b
980 % \begin{macro}{\nobreakspace}
981 % \changes{v1.2k}{1995/12/04}{(Macro added}
982 % \begin{macro}{\@xobeysp}
983 % \changes{v1.2t}{1996/09/28}{Moved from ltmiscen.dtx and redefined to
984 % use \cs{nobreakspace }}
986 % This is a robust command that produces a horizontal space at
987 % which, in paragraph-mode, a line-break is not possible. We then
988 % define an active |~| to expand to it since this is the documented
989 % behaviour of |~|. One reason for introducing this is that some
990 % 8-bit input encodings have a slot for such a space and we do not
991 % want to use active characters as the \LaTeX{} internal commands.
993 % The braces in the definition of |~| are needed to ensure that a
994 % following space is preserved when reading to/from internal files.
995 % \changes{v1.2l}{1995/12/04}{(braces added to definition of tilde}
997 % We need to keep \cs{@xobeysp} as it is widely used; so here it is
998 % let to the non-robust command \cs{nobreakspace }.
1001 \DeclareRobustCommand{\nobreakspace}{%
1002 \leavevmode\nobreak\ }
1004 \def~{\nobreakspace{}}
1005 \expandafter\let\expandafter\@xobeysp\csname nobreakspace \endcsname
1015 % Used in paragraph mode produces a |\thinspace|. It has the
1016 % ordinary definition in math mode. Useful for quotes inside quotes,
1017 % as in |``\,`Foo', he said.''|
1018 % \changes{v1.0o}{1994/05/11}{Use \cs{DeclareRobustCommand}. ASAJ.}
1020 \DeclareRobustCommand{\,}{%
1021 \relax\ifmmode\mskip\thinmuskip\else\thinspace\fi
1027 % Placed before a '.', makes it a sentence-ending period. Does the
1028 % right thing for other punctuation marks as well. Does this by
1029 % setting spacefactor to 1000.
1030 % \changes{v1.3b}{2014/12/30}{\cs{@} discards spaces when moving
1031 % (pr3039)(latexrelease)}
1034 %<latexrelease>\IncludeInRelease{2015/01/01}%
1035 %<latexrelease> {\@}{Space after \@}%
1036 %<*2ekernel|latexrelease>
1039 \def\@{\spacefactor\@m{}}%
1040 %</2ekernel|latexrelease>
1041 %<latexrelease>\EndIncludeInRelease
1042 %<latexrelease>\IncludeInRelease{0000/00/00}%
1043 %<latexrelease> {\@}{Space after \@}%
1044 %<latexrelease>\def\@{\spacefactor\@m}%
1045 %<latexrelease>\EndIncludeInRelease
1051 % \begin{macro}{\hspace}
1052 % \changes{v1.0o}{1994/05/11}{Use \cs{DeclareRobustCommand}. ASAJ.}
1054 \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
1058 % \begin{macro}{\@hspace}
1059 % \changes{LaTeX2e}{1993/08/05}
1060 % {(RmS) Removed superfluous \cs{leavevmode} in \cs{@hspace} and
1061 % \cs{@hspacer}, as suggested by CAR.}
1063 \def\@hspace#1{\hskip #1\relax}
1068 % \begin{macro}{\@hspacer}
1069 % extra |\hskip 0pt| added 1985/17/12 to guard
1070 % against a following |\unskip|
1071 % |\relax| added 13 Oct 88 for usual \TeX\ lossage
1072 % replaced both changes by |\hskip\z@skip| 27 Nov 91
1074 \def\@hspacer#1{\vrule \@width\z@\nobreak
1075 \hskip #1\hskip \z@skip}
1081 % \begin{macro}{\fill}
1084 \fill = 0pt plus 1fill
1090 % \begin{macro}{\stretch}
1092 \def\stretch#1{\z@ \@plus #1fill\relax}
1099 % \begin{macro}{\thinspace}
1100 % \begin{macro}{\negthinspace}
1101 % \begin{macro}{\enspace}
1103 \def\thinspace{\kern .16667em }
1104 \def\negthinspace{\kern-.16667em }
1105 \def\enspace{\kern.5em }
1111 % \begin{macro}{\enskip}
1112 % \begin{macro}{\quad}
1113 % \begin{macro}{\qquad}
1115 \def\enskip{\hskip.5em\relax}
1116 \def\quad{\hskip1em\relax}
1117 \def\qquad{\hskip2em\relax}
1123 % \begin{macro}{\obeycr}
1124 % \begin{macro}{\restorecr}
1125 % The following definitions will probably get deleted or moved to
1126 % compatibility mode soon.
1128 % \changes{v1.2g}{1995/06/11}
1129 % {(CAR) \cs{relax} added to stop silent eating of *.}
1131 {\catcode`\^^M=13 \gdef\obeycr{\catcode`\^^M13 \def^^M{\\\relax}%
1133 {\catcode`\^^M=13 \gdef\@gobblecr{\@ifnextchar
1134 \@gobble\ignorespaces}}
1135 \gdef\restorecr{\catcode`\^^M5 }}