diff options
Diffstat (limited to 'macros/latex/contrib/koma-script/scrkernel-miscellaneous.dtx')
-rw-r--r-- | macros/latex/contrib/koma-script/scrkernel-miscellaneous.dtx | 1117 |
1 files changed, 1117 insertions, 0 deletions
diff --git a/macros/latex/contrib/koma-script/scrkernel-miscellaneous.dtx b/macros/latex/contrib/koma-script/scrkernel-miscellaneous.dtx new file mode 100644 index 0000000000..54bde0d193 --- /dev/null +++ b/macros/latex/contrib/koma-script/scrkernel-miscellaneous.dtx @@ -0,0 +1,1117 @@ +% \iffalse meta-comment +% ====================================================================== +% scrkernel-miscellaneous.dtx +% Copyright (c) Markus Kohm, 2002-2022 +% +% 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-miscellaneous.dtx 3874 2022-06-05 10:38:02Z kohm $ +%<init>%%% (run: init) +%<option>%%% (run: option) +%<execoption>%%% (run: execoption) +%<body>%%% (run: body) +%<*dtx> +\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi +\begingroup + \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}} + \filedate$Date: 2022-06-05 12:38:02 +0200 (So, 05. Jun 2022) $ + \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}} + \filerevision$Revision: 3874 $ + \edef\reserved@a{% + \noexpand\endgroup + \noexpand\ProvidesFile{scrkernel-miscellaneous.dtx}% + [\filedate\space\filerevision\space + KOMA-Script source + (miscellaneous, maybe everything or nothing)] + }% +\reserved@a +\documentclass[USenglish]{koma-script-source-doc} +\usepackage{babel} +\setcounter{StandardModuleDepth}{2} +\begin{document} +\DocInput{scrkernel-miscellaneous.dtx} +\end{document} +%</dtx> +% \fi +% +% \changes{v2.95}{2002/07/01}{first version after splitting \file{scrclass.dtx}} +% \changes{v3.36}{2022/03/01}{switch over from \cls*{scrdoc} to +% \cls*{koma-script-source-doc}} +% \changes{v3.36}{2022/03/01}{whole implementation documentation in English} +% +% \GetFileInfo{scrkernel-miscellaneous.dtx} +% \title{All the Code of +% \href{https://komascript.de}{\KOMAScript} not Fitting into another File} +% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}} +% \date{Revision \fileversion{} of \filedate} +% \maketitle +% \begin{abstract} +% Currently \file{scrkernel-miscellaneous.dtx} is a mess of miscellaneous +% code. There is a big, fat \textbf{ToDo} to change this! +% \end{abstract} +% \tableofcontents +% +% \section{User Manual} +% +% You can find the user documentation the commands implemented here in the +% \KOMAScript{} manual, either the German \file{scrguide} or the English +% \file{scrguien}. +% +% \MaybeStop{\PrintIndex} +% +% +% \section{Implementation of Special Requirements of Package \pkg*{scrletter}} +% +% The \pkg*{scrletter} depends on some features of the \KOMAScript{} +% classes. However, a special user request was to make it work with the +% standard classes too. So we need additional code to detect not using a +% \KOMAScript{} class and to make this work. +% \begin{description} +% \item[ToDo:] Can we move this code into a letter file or use a new file only +% used for package \pkg*{scrletter}? +% \end{description} +% \begin{macrocode} +%<*package&letter&init> +\scr@ifundefinedorrelax{KOMAClassName}{% + \PackageWarningNoLine{scrletter}{% + Cannot detect any KOMA-Script class.\MessageBreak + Package `scrletter' is an extension to\MessageBreak + KOMA-Script classes.\MessageBreak + Usage with another class is not recommended% + \@ifclassloaded{article}{}{% + \@ifclassloaded{report}{}{% + \@ifclassloaded{book}{}{% + \MessageBreak and can result in several errors% + }% + }% + }% + }% + \RequirePackage{scrextend}% +% \end{macrocode} +% +% \begin{command}{\setparsizes} +% \changes{v3.23}{2017/02/22}{simple fallback definition} +% \begin{macro}{\par@updaterelative} +% \changes{v3.23}{2017/02/22}{empty fallback definition} +% If \pkg*{scrletter} is not used with a \KOMAScript{} class \cs{setparsizes} +% would not be available. But it is used in \cs{vb@t@z}, \cs{@addrfield}, +% \cs{@datefield}, \cs{@makelettertitle}, \cs{@subjfield}, \cs{opening}, +% \cs{closing}. Instead of changing the implementation of all these commands +% and macros, we define a very simple version of \cs{setparsizes}. And in case +% of using this simple version \cs{par@updaterelative} would become a +% do-nothing macro. This does work in case of the commands and macros listed +% above. But maybe it does not work in other cases. +% \begin{description} +% \item[ToDo:] Can we move this code into \file{scrkernel-paragraphs.dtx} or +% use a new file only for package \pkg*{scrletter}? +% \end{description} +% \begin{macrocode} + \providecommand*{\setparsizes}[3]{% + \setlength{\parindent}{#1}% + \setlength{\parskip}{#2}% + \setlength{\parfillskip}{#3}% + } + \providecommand*{\par@updaterelative}{} +% \end{macrocode} +% \end{macro}^^A \par@updaterelative +% \end{command}^^A \setparsizes +% \begin{macrocode} +}{} +%</package&letter&init> +% \end{macrocode} +% +% \begin{macro}{\scr@renewforletter,\@renewforletter,\do@renewforletter@list, +% \do@renewforletter} +% \changes{v3.20}{2014/04/10}{added} +% \changes{v3.25}{2017/11/15}{removed} +% \end{macro} +% +% +% \section{Implementation of the Draft Mode} +% +% The \KOMAScript{} classes provide two draft options, the general one and a +% more specific. +% \begin{description} +% \item[ToDo:] Should we move this to \file{scrkernel-paragraphs.dtx}? +% \end{description} +% +% \begin{option}{draft} +% \changes{v2.95}{2002/12/05}{re-implemented using \pkg{keyval}} +% \changes{v3.17}{2015/03/12}{using internal value storage} +% \changes{v3.25}{2017/11/21}{respect option \opt{overfullrule}} +% \changes{v3.12}{2013/03/05}{using \cs{FamilyKeyState}} +% \begin{option}{final} +% \changes{v2.95}{2002/12/05}{obsolete} +% \changes{v2.97d}{2007/10/03}{\cs{PackageInfo} replaced by +% \cs{PackageInfoNoLine}} +% \changes{v3.01a}{2008/11/21}{standard instead of obsolete} +% \changes{v3.02c}{2008/02/17}{explicit optional argument for \pkg*{scrextend}} +% In draft mode classes usually show a rule for overfull boxes. Despite this +% is usually already handled by the class, package \pkg*{scrextend} also +% provides the option, because of correct setting of the internal value +% storage also of option \opt{overfullrule}. +% \begin{macrocode} +%<*(class|extend)&option> +\KOMA@key{draft}[true]{% + \KOMA@set@ifkey{draft}{@tempswa}{#1}% + \ifx\FamilyKeyState\FamilyKeyStateProcessed + \if@tempswa + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{draft}{@tempswa}% + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{overfullrule}{@tempswa}% + \setlength{\overfullrule}{5pt}% + \else + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{draft}{@tempswa}% + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{overfullrule}{@tempswa}% + \setlength{\overfullrule}{\z@}% + \fi + \fi +} +%<class>\KOMA@kav@add{.\KOMAClassFileName}{draft}{false} +%<*package&extend> +\KOMA@kav@xadd{.scrextend.\scr@pkgextension}{draft}{% + \ifdim\overfullrule>\z@ true\else false\fi +} +%</package&extend> +\KOMA@DeclareStandardOption +%<package&extend>[scrextend] +{final}{draft=false} +% \end{macrocode} +% \begin{option}{overfullrule} +% \changes{v3.25}{2017/11/21}{added} +% Because option \opt{draft} can result in unwanted effects I've added a +% new option to explicite only change the overfull rule setting. However for +% \textsf{scrextend} and the \KOMAScript{} classes the result is the same. +% \begin{macrocode} +\KOMA@key{overfullrule}[true]{% + \KOMA@set@ifkey{overfullrule}{@tempswa}{#1}% + \ifx\FamilyKeyState\FamilyKeyStateProcessed + \if@tempswa + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{draft}{@tempswa}% + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{overfullrule}{@tempswa}% + \setlength{\overfullrule}{5pt}% + \else + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{draft}{@tempswa}% + \KOMA@kav@replacebool{.% +%<class> \KOMAClassFileName +%<package&extend> scrextend.\scr@pkgextension + }{overfullrule}{@tempswa}% + \setlength{\overfullrule}{\z@}% + \fi + \fi +} +%<class>\KOMA@kav@add{.\KOMAClassFileName}{overfullrule}{false} +%<*package&extend> +\KOMA@kav@xadd{.scrextend.\scr@pkgextension}{overfullrule}{% + \ifdim\overfullrule>\z@ true\else false\fi +} +%</package&extend> +%</(class|extend)&option> +% \end{macrocode} +% \end{option}^^A overfullrule +% \end{option}^^A final +% \end{option}^^A draft +% +% +% \section{Implementations for the Math Mode} +% +% \KOMAScript{} does not make something special for the math mode. +% \begin{description} +% \item[ToDo:] Should we move this to the special treatment of \pkg{amsmath} +% in \file{scrkernel-basics.dtx} or move it with the special treatment of +% \pkg{amsmath} in \file{scrkernel-basics.dtx} to a new file +% \file{scrkernel-math.dtx}? +% \end{description} +% +% \begin{option}{leqno,fleqno} +% The \KOMAScript{} classes but \cls*{scrlttr2} do support the standard +% class options \opt{leqno} and \opt{fleqn}. +% \begin{macrocode} +%<*class&!letter&option> +\DeclareOption{leqno}{\input{leqno.clo}} +\DeclareOption{fleqn}{\input{fleqn.clo}} +%</class&!letter&option> +% \end{macrocode} +% \end{option} +% +% \begin{counter}{equation} +% \changes{v3.37}{2022/08/24}{accidentally removed \cs{@addtoreset} added +% again} +% \begin{command}{\theequation} +% \changes{v2.97e}{2007/11/23}{chapter numbers only in main matter} +% \changes{v3.27}{2022/03/01}{\cs{relax} replaced by percent because of +% \pkg*{hyperref}} +% The \KOMAScript{} classes \cls*{scrbook} and \cls*{scrreprt} have a special +% treatment for equation numbers. For \cls*{scrreprt} the number just depends +% on the chapter number. But for \cls*{scrbook} it also depends on the active +% matter. +% \begin{description} +% \item[ToDo:] With \cs{counterwidth} instead of \cs{@addtoreset} the +% \cls*{scrreprt} code could be very simple. But currently we still support +% old \LaTeX{} kernels without \cs{counterwithin}. +% \item[ToDo:] Should we also add a definition for \cls*{scrartcl} as done for +% \cls*{article}, though the same definition is already the default of the +% \LaTeX{} kernel? +% \end{description} +% \begin{macrocode} +%<*(book|report)&body> +\@addtoreset{equation}{chapter} +\renewcommand*{\theequation}{% +%<*book> + \expandafter\ifnum\scr@v@is@gt{2.97d}% + \if@mainmatter\thechapter.\fi + \else +%</book> + \thechapter.% +%<book> \fi + \@arabic\c@equation +} + +%</(book|report)&body> +% \end{macrocode} +% \end{command}^^A \theequation +% \end{counter}^^A equation +% +% \section{Implementation of Special Handling of Sans-Serif Defaults} +% +% TeX.SX user \texttt{egreg} has stated in comment +% \url{https://tex.stackexchange.com/questions/289853}, that he does not use +% \KOMAScript{} because of the sans-serif defaults for headings. He like the +% ugly, bold fat Antiqua more. Moreover, he is not satisfied in being able to +% change the default using \cs{setkomafont}. So the \KOMAScript{} author has +% defined an option to do the change of all sans-serif defaults at once. As a +% joke the name of this options not only references \texttt{egreg} but is +% cumbersome long. +% \begin{description} +% \item[ToDo:] Should we move this option to \file{scrkernel-fonts.dtx}? +% \item[ToDo:] Should we add a more handy and serious option like +% \opt{nosfdefaults}? +% \end{description} +% +% \begin{option}{egegdoesnotlikesansseriftitles} +% \changes{v3.20}{2016/01/29}{added} +% \changes{v3.20a}{2016/05/19}{also for \cls*{scrlttr2}} +% \begin{macro}{\@gr@gsffamily} +% \changes{v3.20}{2016/01/29}{added} +% \changes{v3.20a}{2016/05/19}{also for \cls*{scrlttr2}} +% Used to switch on or off all the sans-serif defaults. +% \begin{macrocode} +%<*!(package&letter)&option> +\KOMA@ifkey{egregdoesnotlikesansseriftitles}{@egregdoesnotlikesansseriftitles} +\newcommand*{\@gr@gsffamily}{% + \if@egregdoesnotlikesansseriftitles\else\sffamily\fi +} +%</!(package&letter)&option> +% \end{macrocode} +% \end{macro}^^A \@gr@gsffamily +% \end{option}^^A egregdoesnotlikesansseriftitles +% +% +% \section{Implementation of the Execution and Processing of Options} +% +% After the definition of all options, some defaults have to be executed and +% all options have to be processed. +% \begin{description} +% \item[ToDo:] Can we move the execution of default to the files, where the +% corresponding options are defined? +% \item[ToDo:] Can we move the processing of options to +% \file{scrkernel-basics.dtx} where the command itself is defined? +% \end{description} +% +% \changes{v2.97c}{2007/04/19}{using \cs{KOMAExecuteOptions} instead of +% \cs{KOMAoptions} and \cs{KOMAProcessOptions} instead of +% \cs{ProcessOptions}} +% \changes{v2.97c}{2007/04/19}{options that are implicit defaults are not set +% explicitly} +% \changes{v2.97c}{2007/07/18}{removed \opt{twoside} from the default} +% \changes{v2.98c}{2008/03/10}{\opt{headings\quotechar=big} added to the +% default} +% \changes{v3.11c}{2013/03/04}{\opt{headings\quotechar=big} not with +% \cls*{scrlttr2}} +% \begin{macrocode} +%<*execoption> +%<*class> +\KOMAExecuteOptions{% + parskip=false,% +%<!letter> headings=big% +} +%</class> +\KOMAProcessOptions\relax +%</execoption> +% \end{macrocode} +% +% +% \section{Implementation of Temporary Switch to Single Column Mode} +% +% Sometimes we need to temporary switch to single column mode, e.g., to print +% a table of contents or similar. This is not needed for \cls*{scrlttr2} or +% \pkg*{scrletter}. +% \begin{description} +% \item[ToDo:] Should we move this to \file{scrkernel-paragraphs.dtx} or +% another file? Currently it is used in \file{scrkernel-index.dtx}, +% \file{scrkernel-notepaper.dtx}, and \file{scrkernel-title.dtx} (and also +% in \file{scrhack.dtx}, which also defines it of needed). +% \end{description} +% +% \begin{macro}{\@restonecolfalse,\@restonecoltrue,\if@restonecol} +% We need a local switch to be able to restore two column mode after locally +% switching to one column mode (or visa versa). For \pkg*{scrextend} this is a +% little bit complicated, because the switch could already exist in the used +% class. +% \begin{macrocode} +%<*!letter&body> +%<*!extend> +\newif\if@restonecol +%</!extend> +%<*extend> +\scr@ifundefinedorrelax{if@restonecol}{% + \expandafter\newif\csname if@restonecol\endcsname + \@restonecolfalse +}{} +%</extend> +%</!letter&body> +% \end{macrocode} +% \end{macro} +% +% \section{Implementation of the Dictum} +% +% Printing a \emph{dictum} is also not supported by letters. +% \begin{description} +% \item[ToDo:] Should we move this to \file{scrkernel-sections.dtx} or to a +% new file? +% \end{description} +% +% \begin{command}{\dictum} +% \changes{v2.8q}{2001/20/04}{added} +% \changes{v2.9l}{2003/01/28}{\cs{edef} replaced by \cs{def} ersetzt} +% \changes{v2.9q}{2004/04/19}{group added} +% \begin{command}{\dictumwidth, +% \raggeddictum,\raggeddictumtext,\raggeddictumauthor} +% \changes{v2.8q}{2001/20/04}{added} +% \begin{fontelement}{dictum} +% \changes{v2.8q}{2001/20/04}{added} +% \changes{v3.20}{2016/01/29}{\cs{sffamily} replaced by \cs{@gr@gsffamily}} +% \begin{fontelement}{dictumtext,dictumauthor} +% \changes{v2.8q}{2001/20/04}{added} +% \begin{command}{\dictumauthorformat} +% \changes{v2.8q}{2001/20/04}{added} +% \begin{command}{\dictumrule} +% \changes{v3.10}{2011/09/02}{added} +% The \emph{dictum} consist of a text, the dictum, and an optional +% author. Text and author are separated by a horizontal rule. +% \begin{macrocode} +%<*!letter&body> +\newcommand{\dictum}[2][]{\par% + \begingroup + \raggeddictum\parbox{\dictumwidth}{% + {\@dictumfont{\raggeddictumtext #2\strut\par}% + \def\@tempa{#1}\ifx\@tempa\@empty\else% + {\raggeddictumtext\dictumrule}% + \raggeddictumauthor\@dictumauthorfont\dictumauthorformat{#1}% + \strut\par% + \fi% + }% + }\par% + \endgroup +} +\newcommand*{\dictumrule}{\vskip-1ex\hrulefill\par}% +\newcommand*{\dictumwidth}{.3333\textwidth} +\newcommand*{\raggeddictum}{\raggedleft} +\newcommand*{\dictumauthorformat}[1]{(#1)} +\newcommand*{\raggeddictumtext}{\raggedright} +\newcommand*{\raggeddictumauthor}{\raggedleft} +\newkomafont{dictum}{\normalfont\normalcolor\@gr@gsffamily\small} +\newkomafont{dictumauthor}{\itshape} +\aliaskomafont{dictumtext}{dictum} +%</!letter&body> +% \end{macrocode} +% \end{command}^^A \dictumrule +% \end{command}^^A \dictumauthorformat +% \end{fontelement}^^A dictumtext,dictumauthor +% \end{fontelement}^^A dictum +% \end{command}^^A \dictumwidth,\raggeddictum…\raggeddictumauthor +% \end{command}^^A \dictum +% +% +% \section{Setting Default Lengths of \env{minipage} and Frames} +% +% \begin{description} +% \item[ToDo:] Should we move the default for \len{@mpfootins} to +% \file{scrkernel-footnotes.dtx}? +% \item[ToDo:] Do we really need to set initial values to \len{fboxsep} and +% \len{fboxrule}? The same defaults using |pt| instead of \cs{p@} are already +% used in the \LaTeX{} kernel. Wouldn't that be enough? +% \end{description} +% +% \begin{length}{@mpfootins} +% \begin{length}{fboxsep,fboxrule} +% We are using the same settings like the standard classes. +% \begin{macrocode} +%<*class&body> +\setlength{\skip\@mpfootins}{\skip\footins} +\setlength\fboxsep{3\p@} +\setlength\fboxrule{.4\p@} +%</class&body> +% \end{macrocode} +% \end{length} +% \end{length} +% +% +% \section{Implementation of Detection of Odd and Even Pages} +% +% \begin{description} +% \item[ToDo:] Should this code moved to \file{scrkernel-basics.dtx} or to a +% new one? +% \end{description} +% +% \begin{command}{\ifthispageodd,\Ifthispageodd} +% \changes{v2.8q}{2001/11/22}{added} +% \changes{v3.28}{2019/11/19}{\cs{ifthispageodd} renamed to \cs{Ifthispageodd}} +% Users often use |\ifodd\value{page}| to test, whether the current page is +% odd or even. But this is dramatically wrong, because of the asynchronous +% output of \TeX. So here we define a command +% \begin{quote} +% \Ifthispageodd\marg{then code}\marg{else code} +% \end{quote} +% that internally uses a label-like mechanism to do the decision. We do not +% really use \cs{label} and \cs{pageref}, because this would not work with +% Roman or alphabetic page numbers. So we use a direct write to the \file{aux} +% file instead. +% +% \begin{macro}{\new@tpo@label} +% \changes{v2.8q}{2001/11/22}{added} +% \changes{v2.95b}{2006/07/28}{using \cs{@newl@bel}} +% \changes{v3.20}{2016/03/25}{use after definition in the \file{aux}-file} +% Definition of a new \textbf{t}rue-\textbf{p}age-\textbf{o}dd label. To be +% used in the \file{aux} file. A fallback definition is also added to the +% \file{aux} file, so there wouldn't be an error, e.g., after removing package +% \pkg*{scrextend} from a document. +% \begin{macrocode} +%<*(class|extend)&body> +\newcommand*{\new@tpo@label}{\@newl@bel{tpo}} +\AtBeginDocument{% + \if@filesw + \immediate\write\@auxout{% + \string\providecommand*\string\new@tpo@label[2]{}% + }% + \fi +} +% \end{macrocode} +% \end{macro}^^A \new@tpo@label +% +% \begin{macro}{\scr@tpo} +% \changes{v2.8q}{2001/11/22}{added} +% We need a kind of counter with the actual usage number of +% \cs{Ifthispageodd}. +% \begin{macrocode} +\newcommand*{\scr@tpo}{0} +% \end{macrocode} +% \end{macro}^^A \scr@tpo +% +% \begin{macro}{\is@thispageodd} +% \changes{v2.8q}{2001/11/22}{added} +% \changes{v2.9l}{2003/01/28}{renamed \cs{if@thispageodd}} +% \changes{v2.95b}{2006/07/28}{using \cs{@newl@bel}} +% \changes{v3.17}{2015/03/23}{split into two macros} +% \begin{macro}{\is@thispageodd@setlabel} +% \changes{v3.17}{2015/03/23}{added} +% \changes{v3.20}{2016/03/25}{write to \file{aux} file only \cs{if@filesw}} +% \changes{v3.23}{2017/02/23}{empty macro after usage} +% The main workers of \cs{Ifthispageodd}. It is used to set +% \cs{ifthispagewasodd} depending on the information it adds to the \file{aux} +% file. +% \begin{description} +% \item[ToDo:] Why do we use an optional argument here? Are there any +% circumstances, when the optional argument is not the default +% \cs{is@thispageodd@setlabel}? +% \end{description} +% \begin{macrocode} +\newcommand*{\is@thispageodd}[1][\is@thispageodd@setlabel]{% + \@bsphack + \begingroup + \@tempcnta=\scr@tpo + \advance\@tempcnta by\@ne + \xdef\scr@tpo{\the\@tempcnta}% + \expandafter\ifx\csname tpo@\scr@tpo\endcsname\relax + \protect\G@refundefinedtrue +%<!extend> \ClassWarning{\KOMAClassName}{% +%<extend> \PackageWarning{scrextend}{% + odd/even page label number \scr@tpo\space undefined}% + \edef\@tempa{\the\value{page}}% + \else + \edef\@tempa{\csname tpo@\scr@tpo\endcsname}% + \fi + \ifodd\number\@tempa + \aftergroup\thispagewasoddtrue + \else + \aftergroup\thispagewasoddfalse + \fi + \endgroup + \edef\is@thispageodd@setlabel{% + \if@filesw + \unexpanded{\protected@write\@auxout{\let\arabic\relax}}{% + \noexpand\string + \noexpand\new@tpo@label{\scr@tpo}{\noexpand\arabic{page}}}% + \fi + \noexpand\def\noexpand\is@thispageodd@setlabel + {\unexpanded\expandafter{\is@thispageodd@setlabel}}% + }% + #1% + \@esphack +} +\newcommand*{\is@thispageodd@setlabel}{} +% \end{macrocode} +% \end{macro}^^A \is@thispageodd@setlabel +% \end{macro}^^A \is@thispageodd +% +% \begin{command}{\thispagewasoddfalse,\thispagewasoddtrue,\ifthispagewasodd} +% \changes{v2.9l}{2003/01/20}{added} +% Rolf Niepraschks asked for the possibility to check for the last decision, +% e.g., inside the \meta{then code} or \meta{else code}. So the definition of +% \cs{Ifthispageodd} has been changed not only to set such a switch, but also +% use it. +% \begin{macrocode} +\newif\ifthispagewasodd +% \end{macrocode} +% \end{command} +% +% With all these macros the user command is very easy. +% \changes{v3.31}{2020/04/27}{fixed class and package name in the warning} +% \changes{v3.32}{2020/08/06}{\cs{KOMAClassName} fixed} +% \begin{macrocode} +\providecommand*{\ifthispageodd}{% +%<class> \ClassWarning{\KOMAClassName}{% +%<extend> \PackageWarning{scrextend}{% + Usage of deprecated command + `\string\ifthispageodd'.\MessageBreak + The command has been renamed because of a\MessageBreak + recommendation of The LaTeX Project Team.\MessageBreak + Please replace `\string\ifthispageodd' by `\string\Ifthispageodd'% + }% + \Ifthispageodd +} +\newcommand{\Ifthispageodd}{% + \is@thispageodd + \ifthispagewasodd + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +%</(class|extend)&body> +% \end{macrocode} +% \end{command}^^A \ifthispageodd,\Ifthispageodd +% +% +% \section{Implementation of Notes to the Margin} +% +% \begin{description} +% \item[ToDo:] This has been moved newly to +% \file{scrkernel-miscellaneous.dtx}, but maybe we can find another suitable +% file? +% \end{description} +% +% \begin{command}{\marginline} +% \changes{v2.4l}{1997/02/06}{using the optional argument of \cs{marginpar}} +% \changes{v2.8q}{2001/11/27}{missing brace added} +% \changes{v3.36}{2022/02/22}{moved from \file{scrkernel-floats.dtx} to +% \file{scrkernel-miscellaneaous.dtx}} +% A very often wanted margin note feature is, to print all such notes in the +% left margin ragged-left and all such notes in the right margin +% ragged-right. So this is a simple shortcut for \cs{marginpar} with using +% almost the same argument twice. +% \begin{macrocode} +%<*(class|extend)&body> +\newcommand\marginline[1]{% + \marginpar[\raggedleft{#1}]{\raggedright #1}% +} +%</(class|extend)&body> +% \end{macrocode} +% \end{command} +% +% +% \section{Implementation of Subscripts} +% +% \begin{command}{\textsubscript} +% \changes{v2.8h}{2001/07/19}{added} +% \changes{v3.25}{2017/11/15}{define only if un-defined because of \LaTeX{} +% kernel change} +% \begin{macro}{\@textsubscript} +% \changes{v2.8h}{2001/07/19}{added} +% \changes{v3.10}{2011/09/05}{\cs{providecommand} instead of \cs{newcommand} +% because of \pkg{fixltx2e}} +% The \LaTeX{} kernel has \cs{textsuperscript}. But for several years +% \cs{textsubscript} was missing. For such old \LaTeX{} kernels, we define it +% similar to \cs{textsuperscript}. +% \begin{macrocode} +%<*(class|extend)&body> +\scr@ifundefinedorrelax{textsubscript}{% + \DeclareRobustCommand*\textsubscript[1]{% + \@textsubscript{\selectfont#1}% + }% +}{% + \scr@ifundefinedorrelax{textsubscript }{% + \DeclareRobustCommand*\textsubscript[1]{% + \@textsubscript{\selectfont#1}% + }% + }{}% +} +\providecommand*{\@textsubscript}[1]{% + {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}% +} +%</(class|extend)&body> +% \end{macrocode} +% \end{macro} +% \end{command}^^A \textsubscript +% +% +% \section{Implementation of an Invisible Strut} +% \label{sec:strut} +% +% \begin{description} +% \item[ToDo:] Maybe \file{scrkernel-basics.dtx} would be a good place for +% this and maybe is should become a user command and be used at several +% places, currently \cs{strut} is used. +% \end{description} +% +% \begin{macro}{\scr@endstrut} +% \changes{v3.25}{2017/11/15}{added} +% If we simply add \cs{strut} to the end of material which is assumed to be +% horizontal, white spaces at the end of such material could become relevant, +% even if the would not without the \cs{strut}. We can avoid this by adding +% \cs{unskip} before the \cs{strut}. But in this case, the last work before +% the \cs{strut} will not be hyphenated any more. If we are really in +% horizontal mode, we can use \cs{nobreak} before the \cs{strut} you once +% again allow hyphenation. +% \begin{description} +% \item[ToDo:] Should the \cs{unskip} also be moved behind \cs{ifhmode}? +% \end{description} +% \begin{macrocode} +%<*(class|letter|extend)&body> +\providecommand*{\scr@endstrut}{\unskip\ifhmode\nobreak\strut\fi} +%</(class|letter|extend)&body> +% \end{macrocode} +% \end{macro} +% +% +% \section{Warnings for Using Incompatible Packages} +% \label{sec:packagewarning} +% +% \begin{description} +% \item[ToDo:] This should be moved to a new file. +% \end{description} +% +% \changes{v3.12}{2013/07/08}{warnings about several incompatible packages +% added} +% +% \begin{macro}{\scr@package@not@recommended} +% \changes{v3.12}{2013/07/08}{added} +% \begin{macro}{\class@shoulddisablepackagewarning@list} +% \changes{v3.24}{2017/06/25}{added} +% Loading of several incompatible packages should result in warnings using: +% \begin{quote} +% \cs{scr@package@not@recommended}\marg{package}\marg{alternatives} +% \end{quote} +% Usually the warning contains information about \meta{alternatives}, but this +% argument can also be empty. Authors of classes can deactivate the warning, +% by adding a \meta{package} to the comma separated list +% \cs{class@shoulddisablepackagewarning@lis}. This has to be done, before +% loading the \KOMAScript{} class. However doing so is not recommended and the +% class author is responsible for the drawbacks. +% \begin{macrocode} +%<*class&body> +\newcommand*{\scr@package@not@recommended}[2]{% + \scr@ifundefinedorrelax{class@shoulddisablepackagewarning@list}{% + \@firstofone + }{% + \edef\reserved@a{% + \noexpand\in@{#1}{\class@shoulddisablepackagewarning@list}}% + \reserved@a + \ifin@\expandafter\@gobble\else\expandafter\@firstofone\fi + }{% + \BeforePackage{#1}{% + \ClassWarning{\KOMAClassName}{% + Usage of package `#1' together\MessageBreak + with a KOMA-Script class is not recommended.\MessageBreak + \if\relax\detokenize{#2}\relax\else + I'd suggest to use #2.\MessageBreak + \fi + Nevertheless, using requested\MessageBreak + package `#1'% + }% + }% + }% +}% +% \end{macrocode} +% \end{macro}^^A \class@shoulddisablepackagewarning@list +% Here are the not recommended packages and the alternatives: +% \begin{description} +% \item[\pkg{emptypage}:] is not needed, because there are corresponding +% options and features in \KOMAScript. +% \begin{macrocode} +\scr@package@not@recommended{emptypage}{% + option\MessageBreak + `cleardoublepage' with one of it's\MessageBreak + several values} +% \end{macrocode} +% \item[\pkg{fancyhdr}:] does not respect font settings of \KOMAScript{} and +% also breaks some other features. +% \changes{v3.24}{2017/06/25}{improved \pkg{fancyhdr} warning} +% \begin{macrocode} +\scr@package@not@recommended{fancyhdr}{% + \MessageBreak + package `scrlayer' or `scrlayer-scrpage', because\MessageBreak + they support KOMA-Script classes.\MessageBreak + With `fancyhdr' several features of class `\KOMAClassName'\MessageBreak + like options `headsepline', `footsepline' or command\MessageBreak + `\string\MakeMarkcase' and the commands `\string\setkomafont' and\MessageBreak + `\string\addtokomafont' for the page style elements need\MessageBreak + explicite user intervention to work} +% \end{macrocode} +% \item[\pkg{minitoc}:] +% \changes{v3.23}{2017/02/04}{\pkg{minitoc} is not recommended} +% re-defines, e.g., \cs{@sect} and therefore breaks all the extensions of +% \KOMAScript{} to this command. Currently not all impacts of the package has +% been explored. Currently there is only a workaround for the \cs{@sect} +% issue. See \autoref{sec:packageworkarounds} for more information. +% \begin{macrocode} +%<*!letter> +\scr@package@not@recommended{minitoc}{} +%</!letter> +% \end{macrocode} +% \item[\pkg{multitoc}:] +% \changes{v3.26}{2018/07/18}{\pkg{multitoc} not recommended} +% At least up to version 2.01 this breaks all additional lists/tables of +% contents, because the \cs{@starttoc} redefinition does not allow to use +% another extension but \file{toc}, \file{lof}, or \file{lot}. The package is +% also not needed, because the \env{multicols} environment can simply be added +% using \cs{BeforeStartingTOC} and \cs{AfterStartingTOC}. +% \begin{macrocode} +%<*!letter> +\scr@package@not@recommended{multitoc}{% + package `multicol' and, e.g.:\MessageBreak + \space\space + \string\BeforeStartingTOC{\string\begin{multicols}{2}}\MessageBreak + \space\space + \string\AfterStartingTOC{\string\end{multicols}}\MessageBreak + to make all ToCs two-columned.\MessageBreak + \@ifpackagelater{2018/07/18}{}{% + Note, package `multitoc' breaks additional\MessageBreak + ToCs generated by `\string\DeclareNewTOC' or\MessageBreak + packages like `listings' or `newcaption' and\MessageBreak + even the standard table of contents,\MessageBreak + list of figures or list of tables,\MessageBreak + if you omit the corresponding options `toc',\MessageBreak + `lof' or `lot'.% + }% +} +%</!letter> +% \end{macrocode} +% \item[\pkg{parskip}:] is an emergency fallback package for classes, that +% do not support paragraph skips themselves. +% \begin{macrocode} +\scr@package@not@recommended{parskip}{% + option\MessageBreak + `parskip' with one of it's several values} +% \end{macrocode} +% \item[\pkg{titleps}:] +% \changes{v3.16}{2015/01/21}{\pkg{titleps} not recommended} +% does not respect several font settings and other features of the +% \KOMAScript{} classes. +% \begin{macrocode} +\scr@package@not@recommended{titleps}{% + package `scrlayer-scrpage'} +% \end{macrocode} +% \item[\pkg{titlesec}:] +% \changes{v3.36}{2022/03/01}{bring back \pkg{titlesec} warning} +% breaks several \KOMAScript{} features and needs a lot +% of workarounds to not result in errors. Note, these workarounds have been +% removed from \KOMAScript{}, because they are very fragile and use internal +% macros of \pkg{titlesec}. +% \begin{macrocode} +%<*!letter> +\scr@package@not@recommended{titlesec}{% + KOMA-Script features\MessageBreak + like \string\setkomafont, \string\RedeclareSectionCommand, + \string\sectionlinesformat\MessageBreak + and several others to re-configure section\MessageBreak + headings} +%</!letter> +% \end{macrocode} +% \item[\pkg{sectsty}:] +% \changes{v3.27}{2019/07/24}{\pkg{sectsty} up to v2.0.2 is incompatible} +% uses up to version 2.0.2 internal commands of +% \KOMAScript{}, that has been removed already 2001 in \KOMAScript{} 2.8e. So +% it was never compatible with \KOMAScript~3. +% \begin{macrocode} +%<*!letter> +\AfterPackage*{sectsty}{% + \@ifpackagelater{sectsty}{2002/02/26}{% + \ClassInfo{\KOMAClassName}{Unknown `sectsty' release.\MessageBreak + Cross your fingers, that is compatible% + }% + }{% + \ClassWarning{\KOMAClassName}{% + Incompatible package `sectsty' loaded!\MessageBreak + Package `sectsty' up to version 2.0.2 is incompatible\MessageBreak + with KOMA-Script from version 2.8e released in 2001.\MessageBreak + You should avoid that package and configure the\MessageBreak + section titles of your document using the KOMA-Script\MessageBreak + user interface, e.g., \string\chapterlinesformat,\MessageBreak + \string\RedeclareSectionCommand\space etc. or you should ask\MessageBreak + the `sectsty' maintainer for a more compatible release.\MessageBreak + Ignoring this warning could result in several error\MessageBreak + messages and formatting issues after loading package\MessageBreak + `sectsty'% + }% + }% +} +%</!letter> +% \end{macrocode} +% \item[\pkg{tocbibind}:] +% \changes{v3.25}{2017/11/21}{Usage of \pkg{tocbibind} not recommended} +% \pkg{tocbibind} does several things, that break \KOMAScript, i.e.: +% \begin{itemize} +% \item usage of \cs{MakeUppercase} within running heads, +% \item usage of hard codes \texttt{toc} for the ToC entries, +% \item hard redefinition of \env{thebibliography}, +% \item hard redefinition of \env{theindex}, +% \item hard redefinition of \cs{tableofcontents}, +% \item hard redefinition of \cs{listoftables}, +% \item hard redefinition of \cs{listoffigures}, +% \item hard redefinition of \cs{@makechapterhead} +% \end{itemize} +% \begin{macrocode} +%<*!letter> +\scr@package@not@recommended{tocbibind}{% + options like `listof=totoc'\MessageBreak + or `bibliography=totoc', or commands like\MessageBreak + `\string\setuptoc{toc}{totoc}' instead of this package,\MessageBreak + because it breaks several KOMA-Script features of\MessageBreak + the list of figures, list of tables, bibliography,\MessageBreak + index and the running head% +} +%</!letter> +% \end{macrocode} +% \item[\pkg{tocloft}:] +% \changes{v3.26}{2018/07/18}{Usage of \textsf{tocloft} not recommended} +% redefines \cs{tableofcontents}, \cs{listoffigures}, +% \cs{listoftables}, \cs{l@part} \dots{} \cs{l@subparagraph} and breaks +% \KOMAScript, i.e.: +% \begin{itemize} +% \item commands \cs{BeforeTOCHead}, \cs{AfterTOCHead}, +% \cs{BeforeStartingTOC}, \cs{AfterStartingTOC}, +% \item almost all TOC features, +% \item options \opt{listof=totoc}, \opt{listof=numbered}, +% \item option \opt{listof=flat}, +% \item option \opt{listof=entryprefix}, +% \item all options of \cs{DeclareTOCEntryStyle}, +% \end{itemize} +% \begin{macrocode} +%<*!letter> +\scr@package@not@recommended{tocloft}{% + options like `listof=entryprefix',\MessageBreak + commands like `\string\listoflofentryname' or\MessageBreak + `\string\listoflotentryname', + and `\string\DeclareTOCStyleEntry' or\MessageBreak + `\string\RedeclareSectionCommand' + instead of this package,\MessageBreak + because it breaks several KOMA-Script features of\MessageBreak + the list of figures, list of tables and table of\MessageBreak + contents, i.e., options like `listof=numbered',\MessageBreak + `listof=flat or `toc=flat', commands like\MessageBreak + `\string\BeforeTOCHead{...}' and + `\string\AfterTOCHead{...}',\MessageBreak + `\string\BeforeStartingTOC{...}' and + \string\AfterStartingTOC{...}',\MessageBreak + all features of `\string\DeclareTOCStyleEntry',\MessageBreak + and the ToC entry features of `\string\DeclareSecionCommand'\MessageBreak + and `\string\RedeclareSectionCommand' of levels\MessageBreak + `part', +%<article> `chapter', + `section', `subsection',\MessageBreak + `subsubsection', `paragraph' and `subparagraph'% +} +%</!letter> +%</class&body> +% \end{macrocode} +% \end{description} +% \end{macro}^^A \scr@package@not@recommended +% +% \section{Workarounds for Incompatible Packages} +% \label{sec:packageworkarounds} +% +% \begin{description} +% \item[ToDo:] The code should be moved to the same file as the code of +% \autoref{sec:packagewarning} or maybe even to \pkg{scrhack}. +% \end{description} +% +% For some packages can be made compatible, patching some internal macros of +% these packages: +% \begin{description} +% \item[\pkg{minitoc}:] +% \changes{v3.23}{2017/02/04}{\pkg{minitoc} is incompatible} +% has some serious issues. The first issue is the hard re-definition of +% \cs{@sect} without respecting the changes the \KOMAScript{} classes +% already made. Here I'll try a ugly workaround for this, but is can +% break. So not using the package with a \KOMAScript{} class would be the +% better choice. +% \begin{macrocode} +%<*class&body> +%<*!letter> +\BeforePackage{minitoc}{% + \let\scr@mt@saved@sect\@sect +} +\AfterPackage{minitoc}{% + \def\@tempa#1#2#3#4#5#6[#7]#8{% + \ifnum #2<1 \relax + \addtocontents{toc}{\protect\sectbegin} + \fi + \stc@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}% + }% + \ifx\@sect\@tempa +% \end{macrocode} +% Note: There are several bugs in this definition (e.g. missing +% \cs{expandafter} and spurious spaced). Nevertheless its the original one +% from \pkg{minitoc} 61 and 62 and so I have to use it. +% \begin{macrocode} + \def\@tempa#1#2#3#4#5#6[#7]#8{ + \expandafter + \ifx\csname #1\endcsname\section\relax + \addcontentsline{lof}{xsect}{#7}% + \addcontentsline{lot}{xsect}{#7}% + \fi + \ifx\csname #1\endcsname\starsection\relax + \addcontentsline{lof}{xsect}{#7}% + \addcontentsline{lot}{xsect}{#7}% + \fi + \ifnum #2>\c@secnumdepth\relax + \let\@svsec\@empty + \else + \refstepcounter{#1}% + \edef\@svsec{\csname the#1\endcsname\hskip 1em}% + \fi + \@tempskipa #5\relax + \ifdim \@tempskipa>\z@ + \begingroup #6\relax + \@hangfrom{\hskip #3\relax\@svsec}% + {\interlinepenalty \@M #8\par}% + \endgroup + \csname #1mark\endcsname{#7}% + \addcontentsline{toc}{#1}{% + \ifnum #2>\c@secnumdepth\relax + \else + \protect\numberline{\csname the#1\endcsname}% + \fi + #7% + }% + \else + \def\@svsechd{#6\hskip #3\relax + \@svsec #8\csname #1mark\endcsname{#7}% + \addcontentsline{toc}{#1}{% + \ifnum #2>\c@secnumdepth\relax + \else + \protect\numberline{\csname the#1\endcsname} + \fi + #7}% + }% + \fi + \@xsect{#5}% + }% + \ifx\stc@sect\@tempa + \ClassWarning{\KOMAClassName}{% + Redefining minitoc's internal command + `\string\stc@sect'\MessageBreak + to prevent minitoc to destroy several features\MessageBreak + of KOMA-Script% + }% + \let\stc@sect\scr@mt@saved@sect + \else + \ClassInfo{\KOMAClassName}{% + Deactivating the `minitoc' workaround,\MessageBreak + because of unexpected definition of\MessageBreak + `\string\stc@sect'% + }% + \let\scr@mt@saved@sect\relax + \fi + \else + \ifx\@sect\scr@mt@saved@sect + \ClassInfo{\KOMAClassName}{% + Deactivating the `minitoc' workaround for + `\string\@sect',\MessageBreak + because it is not needed% + }% + \else + \ClassInfo{\KOMAClassName}{% + Deactivating the `minitoc' workaround,\MessageBreak + because of unexpected definition of\MessageBreak + `\string\@sect'% + }% + \fi + \let\scr@mt@saved@sect\relax + \fi +} +%</!letter> +%</class&body> +% \end{macrocode} +% \item[\pkg{titlesec}:] +% \changes{v3.13a}{2014/10/09}{\pkg{titlesec} is hardly incompatible} +% \changes{v3.27}{2019/07/23}{\pkg{titlesec} does not support +% KOMA-Script classes}% +% After several years \textsf{titlesec} still does not really support +% \KOMAScript{} classes and \KOMAScript{} would still need an ugly hack +% using internal \texttt{titlesec} macros and deactivating several features +% of \KOMAScript{} to make the package work. So IMO the better solution is +% to remove such hacks from the \KOMAScript{} classes. Maybe the +% \pkg{titlesec} author will support the \KOMAScript{} classes in some +% future, maybe not. If you really need to \pkg{titlesec} with a +% \KOMAScript{} class, see the ugly \texttt{standardsection} hack in +% \pkg*{scrhack}. +% \end{description} +% +% +% \Finale +% \PrintChanges +% +\endinput +% Local Variables: +% mode: doctex +% ispell-local-dictionary: "en_US" +% eval: (flyspell-mode 1) +% TeX-master: t +% TeX-engine: luatex-dev +% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx")) +% End: |