% \iffalse meta-comment
%
% Copyright 1993 1994 1995 The LaTeX3 Project and any individual
% authors listed elsewhere in this file. 
% 
% For further copyright information, and conditions for modification
% and distribution, see the file legal.txt, and any other copyright
% notices in this file.
% 
% This file is part of the LaTeX2e system.
% ----------------------------------------
%   This system is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 
%   For error reports concerning UNCHANGED versions of this file no
%   more than one year old, see bugs.txt.
% 
%   Please do not request updates from us directly.  Primary
%   distribution is through the CTAN archives.
% 
% 
% IMPORTANT COPYRIGHT NOTICE:
% 
% You are NOT ALLOWED to distribute this file alone.
% 
% You are allowed to distribute this file under the condition that it
% is distributed together with all the files listed in manifest.txt.
% 
% If you receive only some of these files from someone, complain!
% 
% 
% Permission is granted to copy this file to another file with a
% clearly different name and to customize the declarations in that
% copy to serve the needs of your installation, provided that you
% comply with the conditions in the file legal.txt.
% 
% However, NO PERMISSION is granted to produce or to distribute a
% modified version of this file under its original name.
%  
% You are NOT ALLOWED to change this file.
% 
% 
% 
% \fi
%
% \iffalse
%%% From File: ltspace.dtx
%<*driver>
% \fi
\ProvidesFile{ltspace.dtx}
             [1995/12/05 v1.2l LaTeX Kernel (spacing)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltspace.dtx}
\title{\filename}
\date{\filedate}
 \author{%
  Johannes Braams\and
  David Carlisle\and
  Alan Jeffrey\and
  Leslie Lamport\and
  Frank Mittelbach\and
  Chris Rowley\and
  Rainer Sch\"opf}
\begin{document}
\maketitle
 \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \CheckSum{467}
%
% \changes{v1.1a}{1994/05/16}{(ASAJ) Split from ltinit.dtx.}
% \changes{v1.2f}{1995/05/25}{Macros moved to ltlists.dtx}
%
%
% \section{Spacing}
%
% This section deals with spacing, and line- and page-breaking.
%
% \begin{oldcomments}
%
%
% USER COMMANDS:
% \nopagebreak[i] : i = 0,...,4.  Default argument = 4.  Puts a penalty
%                 into the vertical list output as follows:
%                   0 : penalty = 0
%                   1 : penalty = \@lowpenalty
%                   2 : penalty = \@medpenalty
%                   3 : penalty = \@highpenalty
%                   4 : penalty = 10000
% \pagebreak[i]   : same as \nopagebreak except negatives of its penalty
% \linebreak[i], \nolinebreak[i] : analogs of the above
% \samepage : inhibits page breaking most places by setting the
%              following penalties to 10000
%                    \interlinepenalty
%                    \postdisplaypenalty
%                    \interdisplaylinepenalty
%                    \@beginparpenalty
%                    \@endparpenalty
%                    \@itempenalty
%                    \@secpenalty
%                    \interfootnotelinepenalty
%
% \obeycr    : defines <CR> == \\\relax.
% \restorecr : restores <CR> to its usual meaning.
%
% \\         : initially defined to be \newline
% \\[LENGTH] : initially defined to be \vspace{LENGTH}\newline
%              Note: \\* adds a \vadjust{\penalty 10000}
%
% \end{oldcomments}
%
%
%
% \StopEventually{}
%
%
%    \begin{macrocode}
%<*2ekernel>
\message{spacing,}
%    \end{macrocode}
%
%  \begin{macro}{\pagebreak}
% \changes{v1.2h}{1995/07/05}{Reimplemented using \cs{@no@pgbk}}
%  \begin{macro}{\nopagebreak}
% \changes{v1.2h}{1995/07/05}{Reimplemented using \cs{@no@pgbk}}
% \changes{v1.2j}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
%    \begin{macrocode}
\def\pagebreak{\@testopt{\@no@pgbk-}4}
\def\nopagebreak{\@testopt\@no@pgbk4}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
%  \begin{macro}{\@no@pgbk}
% \changes{v1.2h}{1995/07/05}{Macro replaces \cs{@pgbk} 
%                 and \cs{@nopgbk}}
%    \begin{macrocode}
\def\@no@pgbk#1[#2]{\ifvmode \penalty #1\@getpen{#2}\else
\@bsphack\vadjust{\penalty #1\@getpen{#2}}\@esphack\fi}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\nolinebreak}
% \changes{v1.2j}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
%  \begin{macro}{\@nolnbk}
%    \begin{macrocode}
\def\nolinebreak{\@testopt\@nolnbk4}
\def\@nolnbk[#1]{\ifvmode \@nolnerr\else \@tempskipa\lastskip
     \unskip \penalty \@getpen{#1}\ifdim \@tempskipa >\z@
     \hskip\@tempskipa\ignorespaces\fi\fi}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\linebreak}
% \changes{v1.2j}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
%  \begin{macro}{\@lnbk}
%    \begin{macrocode}
\def\linebreak{\@testopt\@lnbk4}
\def\@lnbk[#1]{\ifvmode \@nolnerr\else
     \unskip\penalty -\@getpen{#1}\fi}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\samepage}
%    \begin{macrocode}
\def\samepage{\interlinepenalty\@M
   \postdisplaypenalty\@M
   \interdisplaylinepenalty\@M
   \@beginparpenalty\@M
   \@endparpenalty\@M
   \@itempenalty\@M
   \@secpenalty\@M
   \interfootnotelinepenalty\@M}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\newline}
% |\nobreak| added to |\newline| to prevent null lines when |\newline|
% ends an overfull line.  Change made 24 May 89 as suggested by
% Frank Mittelbach and Rainer Sch\"opf
% \changes{v1.2h}{1995/07/05}{Use \cs{break}}
%    \begin{macrocode}
\def\newline{\ifvmode \@nolnerr \else 
               \unskip\nobreak\hfil\break\fi}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\\}
% \changes{v1.2a}{1994/11/11}{(DPC) Make robust}
% \changes{v1.2d}{1994/11/14}{(DPC) macro modified}
%  \begin{macro}{\@normalcr}
% The internal definition of the `normal' definition of |\\|.
%    \begin{macrocode}
\DeclareRobustCommand\\{%
  \@ifstar
    {\vadjust{\penalty\@M}\@xnewline}%
    \@xnewline}
\expandafter\let\expandafter\@normalcr
     \csname\expandafter\@gobble\string\\ \endcsname
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\@xnewline}
%    \begin{macrocode}
\def\@xnewline{\@ifnextchar[\@newline\newline}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@newline}
%    \begin{macrocode}
\def\@newline[#1]{\ifhmode\unskip\fi\vspace{#1}\newline}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\@getpen}
%    \begin{macrocode}
\def\@getpen#1{\ifcase #1 \z@ \or \@lowpenalty\or
         \@medpenalty \or \@highpenalty
         \else \@M \fi}
%    \end{macrocode}
%  \end{macro}
%
%
% \begin{oldcomments}
% @nobreak : Switch used to avoid page breaks caused by \label after a
%      section heading, etc. It should be GLOBALLY set true after the
%      \nobreak and GLOBALLY set false by the next invocation of
%      \everypar. 
%      Commands that reset \everypar should globally set it false if
%      appropriate.
%
%    \begin{macrocode}
\newif\if@nobreak \@nobreakfalse
%    \end{macrocode}
%
% \@bsphack ... \@esphack
%     used by macros such as \index and \begin{@float} ... \end{@float}
%     that want to be invisible -- i.e.,
%     not leave any extra space when used in the middle of text.  Such
%     a macro should begin with \@bsphack and end with \@esphack
%     The macro in question should not create any text, nor change the
%     mode.
%
% \@Esphack is a variant of \@esphack that sets the @ignore switch to
%     true (as \@esphack used to do previously). This is currently used
%     only for float and similar environments.
%
% \end{oldcomments}
%
%
%    \begin{macrocode}
\newdimen\@savsk
\newcount\@savsf
%    \end{macrocode}
%
%
%
%
%  \begin{macro}{\@bsphack}
% \changes{LaTeX2e}{1993/12/08}
%         {Command reimplemented; late birthday present for Chris}
%  \begin{macro}{\@esphack}
% \changes{LaTeX2e}{1993/12/08}{Command reimplemented}
% \changes{LaTeX2e}{1993/12/16}{Corrected optimisation :-)}
% 
%    These are generalised hacks which attempt to do sensible things
%    when `invisible commands' appear in vmode too.
%
%    They need to cope with space in both hmode (plus spacefactor) and
%    vmode, and also cope with breaks etc.  In vmode this means
%    ensuring that any following |\addvspace|, etc sees the correct
%    glue in |\lastskip|.
%
%    In fact, these improved versions should be used for other cases
%    of `whatsits, thingies etc' which should be invisible.  They are
%    only for commands, not environments (see notes on |\@Esphack|).
%
%    BTW, anyone know why the standard hacks are surrounded by
%    |\ifmmode\else| rather than simply |\ifhmode|?
%
%    And are there any cases where saving the spacefactor is
%    essential?  I have some extensions where it is, but it does not
%    appear to be so in the standard uses.
%    \begin{macrocode}
%\def \@bsphack{%
%  \relax \ifvmode
%    \@savsk \lastskip
%    \ifdim \lastskip=\z@
%    \else
%      \vskip -\lastskip
%    \fi
%  \else
%    \ifhmode
%      \@savsk \lastskip
%      \@savsf \spacefactor
%    \fi
%  \fi
%}
%    \end{macrocode}
%    I think that, in vmode, it is the safest to put
%    in a |\nobreak| immediately after such things since writes,
%    inserts etc followed by glue give valid breakpoints and, in
%    general, it is possible to create breaks but impossible to
%    destroy them.
%    \begin{macrocode}
%\def \@esphack{%
%   \relax \ifvmode 
%     \nobreak    
%     \ifdim \@savsk=\z@ 
%     \else 
%       \vskip\@savsk
%     \fi
%   \else 
%     \ifhmode
%       \spacefactor \@savsf
%       \ifdim \@savsk>\z@ 
%         \ignorespaces
%       \fi 
%     \fi
%   \fi
%} 
%    \end{macrocode}
%    For the moment we are going to ignore the vertical versions until
%    they are correct.
% \changes{LaTeX2e}{1993/12/19}{There seem to be problems with selfmade
%                           birthday presents}
%    \begin{macrocode}
\def \@bsphack{%
   \relax \ifhmode
     \@savsk \lastskip
     \@savsf \spacefactor
   \fi
}
\def \@esphack{%
     \relax \ifhmode
       \spacefactor \@savsf
       \ifdim \@savsk>\z@
         \ignorespaces
       \fi
     \fi
}
\def \@Esphack{%
     \relax \ifhmode
       \spacefactor \@savsf
       \ifdim \@savsk>\z@
         \global\@ignoretrue
         \ignorespaces
       \fi
     \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
%  \begin{macro}{\@vbsphack}
% \changes{LaTeX2e}{1993/12/08}{Command added}
%    Another variant which is useful for invisible things which should
%    not live in vmode (this is how some people feel about marginals).
%
%    If it occurs in vmode then it enters hmode and ensures that
%    |\@savsk| is nonzero so that the |\ignorespaces| is put in later.  
%    It is not used at present.
% \changes{v1.2f}{1995/05/25}{(CAR) not used so `removed'.}
%    \begin{macrocode}
% \def \@vbsphack{ %
%    \relax \ifvmode
%      \leavevmode    
%      \@savsk 1sp
%      \@savsf \spacefactor
%    \else
%      \ifhmode
%        \@savsk \lastskip
%        \@savsf \spacefactor
%      \fi
%    \fi
% }
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{Vertical spacing}
%
% \begin{oldcomments}
%
% LaTeX supports the PLAIN TeX commands \smallskip, \medskip and
% \bigskip. 
% However, it redefines them using \vspace instead of \vskip.
%
% Extra vertical space is added by the command command \addvspace{SKIP},
% which adds a vertical skip of SKIP to the document.  The sequence
%         \addvspace{S1} \addvspace{S2}
% is equivalent to
%         \addvspace{maximum of S1, S2}.
% \addvspace should be used only in vertical mode, and gives an error if
% it's not.  The \addvspace command does NOT add vertical space if
% @minipage = T. The minipage environment uses this to inhibit
% the addition of extra vertical space at the beginning.
%
% Penalties are put into the vertical list with the \addpenalty{PENALTY}
% command.  It works properly when \addpenalty and \addvspace commands
% are mixed.
%
% The @nobreak switch is set true used when in vertical mode and no page
% break should occur.  (Right now, it is used only by the section
% heading commands to inhibit page breaking after a heading.)
%
%
% \addvspace{SKIP} ==
%  BEGIN
%   if vmode
%     then if @minipage
%            else if \lastskip =0
%                    then  \vskip SKIP
%                    else  if \lastskip < SKIP
%                             then  \vskip -\lastskip
%                                   \vskip SKIP
%                             else if SKIP < 0 and \lastskip >= 0
%                                    then \vskip -\lastskip
%                                         \vskip \lastskip + SKIP
%          fi      fi       fi      fi
%     else useful error message (CAR).
%   fi
%  END
%
%    \begin{macrocode}
\def\@xaddvskip{\ifdim \lastskip <\@tempskipb\vskip-\lastskip\vskip
             \@tempskipb
        \else  \ifdim \@tempskipb<\z@
                 \ifdim \lastskip <\z@
                    \else \advance\@tempskipb\lastskip
                           \vskip -\lastskip \vskip \@tempskipb
      \fi\fi\fi}
%    \end{macrocode}
%
% \end{oldcomments}
% 
%  \begin{macro}{\addvspace}
% \changes{v1.2b}{1994/11/12}{Corrected error message}
% \changes{v1.2c}{1994/11/13}{Recorrected error message}
%    
%    \begin{macrocode}
\def\addvspace#1{%
  \ifvmode
     \if@minipage\else
       \ifdim \lastskip =\z@
         \vskip #1\relax
       \else
       \@tempskipb#1\relax
         \@xaddvskip
       \fi
     \fi
  \else
    \@noitemerr
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\addpenalty}
% \changes{v1.2b}{1994/11/12}{Corrected error message}
% \changes{v1.2c}{1994/11/13}{Recorrected error message}
%    
%    \begin{macrocode}
\def\addpenalty#1{%
  \ifvmode
    \if@minipage
    \else
      \if@nobreak
      \else
        \ifdim\lastskip=\z@
          \penalty#1\relax
        \else
          \@tempskipb\lastskip
          \vskip -\lastskip
          \penalty#1%
          \vskip\@tempskipb
        \fi
      \fi
    \fi
  \else
    \@noitemerr
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\vspace}
% \begin{macro}{\@vspace}
% \begin{macro}{\@vspacer}
% \changes{v1.2f}{1995/05/25}
%         {(CAR) macros modified to be more efficient}
% \changes{v1.2f}{1995/05/25}{(CAR) \cs{@restorepar} added to avoid 
%   possible infinite tail recursion caused by a typo in the argument.}
%    The new code for these commands depends on the following facts:
%    \begin{itemize}
%      \item The value of prevdepth is changed only when a box or rule 
%        is created and added to a vertical list;
%      \item The value of prevdepth is used only when a box is created 
%        and added to a vertical list;
%      \item The value of prevdepth is always local to the building of 
%        one vertical list. 
%    \end{itemize}
%    \begin{macrocode}
\def\vspace{\@ifstar\@vspacer\@vspace}
\def\@vspace #1{%
  \ifvmode
    \vskip #1
    \vskip\z@skip
   \else
     \@bsphack
     \vadjust{\@restorepar
              \vskip #1
              \vskip\z@skip
              }%
     \@esphack
   \fi
}
\def\@vspacer #1{%
  \ifvmode
    \dimen@\prevdepth
    \hrule \@height\z@
    \nobreak
    \vskip #1
    \vskip\z@skip
    \prevdepth\dimen@
  \else
    \@bsphack
    \vadjust{\@restorepar
             \hrule \@height\z@
             \nobreak
             \vskip #1
             \vskip\z@skip
             }%
    \@esphack
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\smallskip}
% \begin{macro}{\medskip}
% \begin{macro}{\bigskip}
%    \begin{macrocode}
\def\smallskip{\vspace\smallskipamount}
\def\medskip{\vspace\medskipamount}
\def\bigskip{\vspace\bigskipamount}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%    
% \begin{macro}{\smallskipamount}
% \begin{macro}{\medskipamount}
% \begin{macro}{\bigskipamount}
%    \begin{macrocode}
\newskip\smallskipamount \smallskipamount=3pt plus 1pt minus 1pt
\newskip\medskipamount   \medskipamount  =6pt plus 2pt minus 2pt
\newskip\bigskipamount   \bigskipamount =12pt plus 4pt minus 4pt
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \subsection{Horizontal space}
%
% \begin{macro}{\nobreakspace}
% \changes{v1.2k}{1995/12/04}{(Macro added}
% 
%   This is a robust command that produces a horizontal space at
%   which, in paragraph-mode, a line-break is not possible.  We then
%   define an active |~| to expand to it since this is the documented
%   behaviour of |~|.  One reason for introducing this is that some
%   8-bit input encodings have a slot for such a space and we do not
%   want to use active characters as the \LaTeX{} internal commands.
%
%   The braces in the definition of |~| are needed to ensure that a
%   following space is preserved when reading to/from internal files.
% \changes{v1.2l}{1995/12/04}{(braces added to definition of tilde}
%    \begin{macrocode}
\DeclareRobustCommand{\nobreakspace}{%
   \leavevmode\nobreak\ }
\catcode `\~=13
\def~{\nobreakspace{}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%    \end{macrocode}
%
%
% \begin{macro}{\,}
%   Used in paragraph mode produces a |\thinspace|.  It has the
%   ordinary definition in math mode.  Useful for quotes inside quotes,
%   as in  |``\,`Foo', he said.''|
% \changes{v1.0o}{1994/05/11}{Use \cmd\DeclareRobustCommand. ASAJ.}
%    \begin{macrocode}
\DeclareRobustCommand{\,}{%
   \relax\ifmmode\mskip\thinmuskip\else\thinspace\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@}
%     Placed before a '.', makes it a sentence-ending period.  Does the
%     right thing for other punctuation marks as well.  Does this by
%     setting spacefactor to 1000.
%    \begin{macrocode}
\def\@{\spacefactor\@m}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\hspace}
% \changes{v1.0o}{1994/05/11}{Use \cmd\DeclareRobustCommand. ASAJ.}
%    \begin{macrocode}
\DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@hspace}
% \changes{LaTeX2e}{1993/08/05}
%    {(RmS) Removed superfluous \cs{leavevmode} in \cs{@hspace} and
%               \cs{@hspacer}, as suggested by CAR.}
%    \begin{macrocode}
\def\@hspace#1{\hskip #1\relax}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@hspacer}
%    \begin{macrocode}
\def\@hspacer#1{\vrule \@width\z@\nobreak
                \hskip #1\hskip \z@skip}
                      % extra \hskip 0pt added 12/17/85 to guard
                      % against a following \unskip
                      % \relax added 13 Oct 88 for usual TeX lossage
                      % replaced both changes by \hskip\z@skip 27 Nov 91
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\fill}
%    \begin{macrocode}
\newskip\fill 
\fill = 0pt plus 1fill
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\stretch}
%    \begin{macrocode}
\def\stretch#1{\z@ \@plus #1fill\relax}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\thinspace}
% \begin{macro}{\negthinspace}
% \begin{macro}{\enspace}
%    \begin{macrocode}
\def\thinspace{\kern .16667em }
\def\negthinspace{\kern-.16667em }
\def\enspace{\kern.5em }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\enskip}
% \begin{macro}{\quad}
% \begin{macro}{\qquad}
%    \begin{macrocode}
\def\enskip{\hskip.5em\relax}
\def\quad{\hskip1em\relax}
\def\qquad{\hskip2em\relax}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% 
%
% The following definitions will probably get deleted or moved to
% compatibility mode soon.
%
% \changes{v1.2g}{1995/06/11}
%                {(CAR) \cs{relax} added to stop silent eating of *.}
%    \begin{macrocode}
{\catcode`\^^M=13 \gdef\obeycr{\catcode`\^^M13 \def^^M{\\\relax}%
    \@gobblecr}%
{\catcode`\^^M=13 \gdef\@gobblecr{\@ifnextchar
\@gobble\ignorespaces}}
\gdef\restorecr{\catcode`\^^M5 }} 
%</2ekernel>
%    \end{macrocode}
%
% \Finale
\endinput

