% \iffalse meta-comment
% ======================================================================
% scrkernel-paragraphs.dtx
% Copyright (c) Markus Kohm, 2002-2023
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in MANIFEST.md.
% ======================================================================
%%% From File: $Id: scrkernel-paragraphs.dtx 4032 2023-04-17 09:45:11Z kohm $
%
% \end{macrocode}
% Because of the currently complicated initialization, i.e., when switching
% between \cs{parskip=absolute} and \cs{parskip=relative}, we currently define
% \cs{par@updaterelative} not before the class options has been processed. New
% values are only set, if between the last \cs{setparsizes} and the current
% \cs{par@updaterelative} (e.g. inside \cs{selectfont}) the user has not
% changed the \TeX{} variables. If he has changed the \TeX{} variables instead
% of using \cs{setparsizes} we think, he does not want any other change. And
% because of to be able to do the tests inside a group without permanent
% change of \cs{reserved@a} we use three additional helpers.
% \begin{macrocode}
%<*body>
\newcommand*{\par@updaterelative}{%
\begingroup
\edef\reserved@a{\the\parindent}\ifx\reserved@a\f@parindent
\aftergroup\parindent@update
%<*trace>
\else
\ClassInfo{\KOMAClassName}{\string\parindent\space not changed}%
%
\fi
\edef\reserved@a{\the\parskip}\ifx\reserved@a\f@parskip
\aftergroup\parskip@update
%<*trace>
\else
\ClassInfo{\KOMAClassName}{\string\parskip\space not changed}%
%
\fi
\edef\reserved@a{\the\parfillskip}\ifx\reserved@a\f@parfillskip
\aftergroup\parfillskip@update
%<*trace>
\else
\ClassInfo{\KOMAClassName}{\string\parfillskip\space not changed}%
%
\fi
\endgroup
}
\newcommand*{\parindent@update}{%
\scr@defaultunits\parindent\scr@parindent
\begingroup
\let\reserved@b\endgroup
\edef\reserved@a{\the\parindent}\ifx\reserved@a\f@parindent\else
\def\reserved@b{\endgroup\edef\f@parindent{\the\parindent}}%
% \ClassInfo{\KOMAClassName}{\string\parindent=\the\parindent}%
\fi
\reserved@b
}
\newcommand*{\parskip@update}{%
\scr@defaultunits\parskip\scr@parskip
\begingroup
\let\reserved@b\endgroup
\edef\reserved@a{\the\parskip}\ifx\reserved@a\f@parskip\else
\def\reserved@b{\endgroup\edef\f@parskip{\the\parskip}}%
% \ClassInfo{\KOMAClassName}{\string\parskip=\the\parskip}%
\fi
\reserved@b
}
\newcommand*{\parfillskip@update}{%
\scr@defaultunits\parfillskip\scr@parfillskip
\begingroup
\let\reserved@b\endgroup
\edef\reserved@a{\the\parfillskip}\ifx\reserved@a\f@parfillskip\else
\def\reserved@b{\endgroup\edef\f@parfillskip{\the\parfillskip}}%
% \ClassInfo{\KOMAClassName}{\string\parfillskip=\the\parfillskip}%
\fi
\reserved@b
}
%
% \end{macrocode}
% \end{macro}^^A \parindent@update,\parskip@update,\parfillskip@update}
% \end{macro}^^A \par@updaterelative
% \end{macro}^^A \default@par@update
% \end{macro}^^A \par@update
% \end{macro}^^A \scr@parskip,\scr@parfillskip
% \end{macro}^^A \scr@parindent
% \end{macro}^^A \f@parskip,\f@parfillskip
% \end{macro}^^A \f@parindent
% \end{command}^^A \setparsizes
%
% \begin{option}{parskip}
% \changes{v2.8i}{2001/07/22}{added}
% \changes{v2.95}{2006/03/11}{changed into \pkg{keyval} option}
% \changes{v3.08}{2010/12/14}{value \opt{\quotechar=never} added}
% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}.}
% \changes{v3.17}{2015/03/10}{using value storage}
% \changes{v3.25}{2017/09/27}{typo fix in \cs{FamilyKeyStateUnknownValue}}
% \changes{v3.26b}{2019/02/01}{\cs{baselineskip} replaced by 1\cs{baselineskip}}
% \changes{v3.39}{2022/11/11}{initial dot removed from member argument of
% option storage commands}
% \begin{option}{parindent,parskip-,parskip+,parskip*,
% halfparskip,halfparskip-,halfparskip+,halfparskip*}
% \changes{v2.8i}{2001/07/22}{added}
% \changes{v2.95}{2006/03/11}{obsolete}
% \changes{v2.97d}{2007/10/03}{\cs{PackageInfo} replaced by
% \cs{PackageInfoNoLine}}
% \changes{v3.01a}{2008/11/20}{deprecated}
% \changes{v3.99}{2022/11/16}{removed from \KOMAScript~4}
% Originally we have had nine options for all the paragraph indent and skip
% settings. Using \pkg*{scrbase} we have only one option with additional
% settings for relative and absolute values and paragraph indent without glue
% for paragraph skip.
% \begin{macrocode}
%<*option>
\KOMA@key{parskip}[true]{%
\begingroup
\KOMA@set@ncmdkey{parskip}{@tempa}{%
{never}{0},%
{false}{1},{off}{1},{no}{1},%
{full-}{2},%
{half-}{3},%
{full}{4},{true}{4},{on}{4},{yes}{4},%
{half}{5},%
{full+}{6},%
{half+}{7},%
{full*}{8},%
{half*}{9},%
{relative}{10},%
{absolute}{11}%
}{#1}%
\ifx\FamilyKeyState\FamilyKeyStateProcessed
\aftergroup\FamilyKeyStateProcessed
\ifcase\number\@tempa% 0
\endgroup
\setparsizes{1em}{\z@}{\z@ \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{never}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 1
\endgroup
\setparsizes{1em}{\z@ \@plus \p@}{\z@ \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{false}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 2
\endgroup
\setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
\z@ \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{full-}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 3
\endgroup
\setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
\z@ \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{half-}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 4
\endgroup
\setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
1em \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{full}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 5
\endgroup
\setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
1em \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{half}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 6
\endgroup
\setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
.3333\linewidth\@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{full+}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 7
\endgroup
\setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
.3333\linewidth \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{half+}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 8
\endgroup
\setparsizes{\z@}{1\baselineskip \@plus .1\baselineskip}{%
.25\linewidth \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{full*}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 9
\endgroup
\setparsizes{\z@}{.5\baselineskip \@plus .5\baselineskip}{%
.25\linewidth \@plus 1fil}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{half*}%
\if@atdocument\AfterKOMAoptions{\selectfont}\fi
\or% 10
\endgroup
\KOMA@kav@remove{\KOMAClassFileName}{parskip}{absolute}%
\KOMA@kav@remove{\KOMAClassFileName}{parskip}{relative}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{relative}%
\ifx\par@updaterelative\undefined
\expandafter\AtEndOfClass
\else
\expandafter\@firstofone
\fi
{%
\ifx\par@update\default@par@update
\let\par@update\par@updaterelative
\fi
\let\default@par@update=\par@updaterelative
}%
\or%11
\endgroup
\KOMA@kav@remove{\KOMAClassFileName}{parskip}{absolute}%
\KOMA@kav@remove{\KOMAClassFileName}{parskip}{relative}%
\KOMA@kav@add{\KOMAClassFileName}{parskip}{absolute}%
\ifx\par@updaterelative\undefined
\expandafter\AtEndOfClass
\else
\expandafter\@firstofone
\fi
{%
\ifx\par@update\default@par@update
\let\par@update\relax
\fi
\let\default@par@update=\relax
}%
\else% should never be
\endgroup
\fi
\else
\endgroup
\FamilyKeyStateUnknownValue
\fi
}
%<*!v4>
\KOMA@DeclareDeprecatedOption{parskip-}{parskip=full-}
\KOMA@DeclareDeprecatedOption{parskip+}{parskip=full+}
\KOMA@DeclareDeprecatedOption{parskip*}{parskip=full*}
\KOMA@DeclareDeprecatedOption{halfparskip}{parskip=half}
\KOMA@DeclareDeprecatedOption{halfparskip-}{parskip=half-}
\KOMA@DeclareDeprecatedOption{halfparskip+}{parskip=half+}
\KOMA@DeclareDeprecatedOption{halfparskip*}{parskip=half*}
\KOMA@DeclareDeprecatedOption{parindent}{parskip=false}
%!v4>
\KOMA@kav@add{\KOMAClassFileName}{parskip}{false}
\KOMA@kav@add{\KOMAClassFileName}{parskip}{absolute}
%
% \end{macrocode}
% \end{option}^^A parindent … halfparskip*
% \end{option}^^A parskip
%
% \changes{v2.8i}{2001/07/22}{don't change \cs{baselinestretch}}
%
% \begin{length}{\lineskip,\normallineskip}
% The minimum line skip.
% \begin{macrocode}
%<*body>
\setlength{\lineskip}{\p@}
\setlength{\normallineskip}{\p@}
% \end{macrocode}
% \end{length}
%
% \begin{command}{\selectfont}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.33}{2021/01/21}{from \LaTeX{} 2021/06/01 use hook instead of
% patch}
% \begin{macro}{\scr@selectfont,\scr@new@selectfont}
% \changes{v2.95}{2006/04/14}{added}
% \changes{v3.10}{2010/09/28}{\pkg{everysel} support fixed}
% \changes{v3.10}{2010/09/28}{\pkg{tracefnt} supported}
% \changes{v3.10b}{2011/03/13}{\pkg{everysel} can be loaded inside
% \cs{begin\{document\}}}
% Because of \opt{parskip=relative} we need a hook to activate the changes of
% the paragraph values. A good place to do so is \cs{selectfont}. With
% \KOMAScript{} 3.00 we needed to patch this command. But from \LaTeX{}
% 2021/06/01 we can use a new generic hook.
% \begin{description}
% \item[Note:] We use 2021/05/01 instead of the official \LaTeX{} release date,
% because there were relevant earlier \LaTeX{} developer releases with that
% date.
% \end{description}
% \begin{macrocode}
\IfLTXAtLeastTF{2021/05/01}{%
\AddToHook{selectfont}{\par@update}%
\AfterPackage{everysel}{%
\IfPackageAtLeastTF{everysel}{2021/01/18}{}{%
\ClassError{\KOMAClassName}{%
incompatible `everysel' detected
}{%
You are using an old version of `everysel' in combination with a
LaTeX\MessageBreak
version >= 2021/06/01 and KOMA-Script >= 3.33. This combination
is\MessageBreak
not supported.\MessageBreak
You could switch back to an older LaTeX using package
`latexrelease'.\MessageBreak
But I recommend to update `everysel'%
}%
}%
}%
\AfterPackage{tracefnt}{%
\IfPackageAtLeastTF{tracefnt}{2020/12/22}{}{%
\ClassError{\KOMAClassName}{%
incompatible `tracefnt' detected
}{%
`tracefnt' is a LaTeX base package and therefore should be updated
together\MessageBreak
with LaTeX kernel. So this should never happen! Please check
your\MessageBreak
LaTeX installation%
}%
}%
}%
}{%
\newcommand*{\scr@selectfont}{}
\expandafter\let\expandafter\scr@selectfont\csname selectfont \endcsname
\BeforePackage{everysel}{%
\AtBeginDocument{%
\expandafter\ifx\csname selectfont \endcsname\scr@new@selectfont\else
\ClassWarningNoLine{\KOMAClassName}{%
discard change of \string\selectfont}%
\fi
\expandafter\let\csname selectfont \endcsname\scr@selectfont
}%
}%
\AfterPackage{everysel}{%
\scr@ifundefinedorrelax{@EverySelectfont@Init}{%
\expandafter\ifx\csname selectfont \endcsname\scr@new@selectfont
\ClassWarningNoLine{\KOMAClassName}{%
\string\selectfont\space already changed}%
\else
\expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}%
\expandafter\let\expandafter\scr@new@selectfont
\csname selectfont \endcsname
\fi
}{%
\g@addto@macro\@EverySelectfont@Init{%
\expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}%
\expandafter\let\expandafter\scr@new@selectfont
\csname selectfont \endcsname
}%
}%
}%
\AfterPackage{tracefnt}{%
\expandafter\let\expandafter\scr@selectfont\csname selectfont \endcsname
\expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}%
\expandafter\let\expandafter\scr@new@selectfont\csname selectfont \endcsname
}%
\expandafter\g@addto@macro\csname selectfont \endcsname{\par@update}
\newcommand*{\scr@new@selectfont}{}
\expandafter\let\expandafter\scr@new@selectfont\csname selectfont \endcsname
}
% \end{macrocode}
% \end{macro}^^A \scr@selectfont,\scr@new@selectfont
% \end{command}^^A \selectfont
%
% \begin{macro}{\scr@defaultunits}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.19}{2015/08/22}{\cs{setlength} replaced because of \pkg{tikz}}
% \begin{macro}{\scr@@defaultunits}
% \changes{v2.95}{2004/11/05}{added}
% \begin{macro}{\scr@@@defaultunits}
% \changes{v2.95}{2004/11/05}{added}
% \changes{v3.19}{2015/08/22}{\cs{setlength} and \cs{addtolength} replaced
% because of \pkg{tikz}}
% Above we've already used \cs{scr@defaultunits} inside
% \cs{par@updaterelative}. This is very similar to the \LaTeX{} kernel macro
% \cs{@defaultunits}, but accepts dimensions or skips as first and second
% value.
% \begin{macrocode}
\newcommand*{\scr@defaultunits}[2]{%
\begingroup
\edef\@tempa{#2}%
\expandafter\scr@@defaultunits\expandafter#1\@tempa plusplus\@nnil
\edef\@tempa{\noexpand\endgroup\noexpand#1\the\glueexpr #1\relax}%
\@tempa
}
\newcommand*{\scr@@defaultunits}{}
\def\scr@@defaultunits#1#2plus#3plus#4\@nnil{%
\ifx\relax#3\relax
\scr@@@defaultunits#1{}#2minusminus\@nnil
\else
\scr@@@defaultunits#1{#2}#3minusminus\@nnil
\fi
}
\newcommand*{\scr@@@defaultunits}{}
\def\scr@@@defaultunits#1#2#3minus#4minus#5\@nnil{%
\ifx\relax#2\relax
\@defaultunits\@tempskipa#3pt\relax\@nnil
#1\@tempskipa
\else
\@defaultunits\@tempskipa\z@\@plus#3pt\relax\@nnil
#1\@tempskipa
\@defaultunits\@tempskipa#2pt\relax\@nnil
\advance#1\@tempskipa
\fi
\ifx\relax#4\relax\else
\@defaultunits\@tempskipa\z@\@minus #4pt\relax\@nnil
\advance#1\@tempskipa
\fi
}
%