diff options
Diffstat (limited to 'macros/latex/contrib/koma-script/scrkernel-pseudolengths.dtx')
-rw-r--r-- | macros/latex/contrib/koma-script/scrkernel-pseudolengths.dtx | 342 |
1 files changed, 342 insertions, 0 deletions
diff --git a/macros/latex/contrib/koma-script/scrkernel-pseudolengths.dtx b/macros/latex/contrib/koma-script/scrkernel-pseudolengths.dtx new file mode 100644 index 0000000000..cf0a555b47 --- /dev/null +++ b/macros/latex/contrib/koma-script/scrkernel-pseudolengths.dtx @@ -0,0 +1,342 @@ +% \iffalse meta-comment +% ====================================================================== +% scrkernel-pseudolengths.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-pseudolengths.dtx 3874 2022-06-05 10:38:02Z kohm $ +%<option>%%% (run: option) +%<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-pseudolengths.dtx}% + [\filedate\space\filerevision\space + KOMA-Script source + (pseudo length)] + }% +\reserved@a +\documentclass[USenglish]{koma-script-source-doc} +\usepackage{babel} +\usepackage{hvlogos} +\setcounter{StandardModuleDepth}{2} +\begin{document} +\DocInput{scrkernel-pseudolengths.dtx} +\end{document} +%</dtx> +% \fi^^A meta-comment +% +% \changes{v2.95}{2002/06/20}{first version after splitting \file{scrclass.dtx}} +% \changes{v3.36}{2022/02/14}{switch over from \cls*{scrdoc} to +% \cls*{koma-script-source-doc}} +% \changes{v3.36}{2022/02/14}{whole implementation documentation in English} +% +% \GetFileInfo{scrkernel-pseudolengths.dtx} +% \title{Handling of Lengths Stored in Macros for +% \href{https://komascript.de}{\KOMAScript} Letter Class and Packages} +% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}} +% \date{Revision \fileversion{} of \filedate} +% \maketitle +% \begin{abstract} +% \file{scrkernel-pseudolength.dtx} provides storing lengths in macros. This +% feature has been introduced with \cls*{scrlttr2} in 2002, because at that +% time there where only 256 skip registers for \LaTeX{} lengths and +% \cls*{scrlttr2} needs several lengths to specify the positions of several +% notepaper elements. Some time later The \LaTeX{} Team (at long last) has +% decided to recommend \eTeX{} as \TeX{} engine for +% \LaTeX.\!\footnote{Currently \pdfTeX{} with \eTeX{} extensions is the +% recommended \TeX{} engine for \LaTeX.} \,Therefore the usage of the so +% called \emph{pseudo lengths} in \KOMAScript{} wouldn't be necessary any +% longer. But they exist and will be used at least for compatibility also in +% future versions of \cls*{scrlttr2} and \pkg*{scrletter}. +% \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 Package \pkg*{typearea} and Additional Class +% Features} +% +% \begin{macrocode} +%<*letter> +% \end{macrocode} +% +% \subsection{Options} +% The method of pseudo lengths is not influenced by options. +% +% +% \subsection{Commands and macros for pseudo lengths} +% +% For the calculation of the positions of several elements of the notepaper +% several lengths are needed. To not use a lot \LaTeX{} lengths (and therefore +% \TeX{} skip registers) they are stored in macros. So we also need some +% additional commands to not only store lengths values in macros but also for +% arithmetic operations on such macros and even to test, if a pseudo lengths +% exists or not. +% +% +% \begin{command}{\Ifplength} +% \changes{v3.27}{2019/03/29}{added} +% \begin{macro}{\if@plength} +% \changes{v3.27}{2019/03/29}{added} +% \changes{v3.36}{2022/02/14}{deprecated} +% Test whether or not a given pseudo-length (\texttt{\#1}) already exists. If +% so execute argument \texttt{\#2}, otherwise \texttt{\#3}. +% \begin{macrocode} +%<*body> +\newcommand*{\Ifplength}[1]{% + \@ifundefined{ltr@len@#1}{\@secondoftwo}{\@firstoftwo}% +} +\newcommand*{\if@plength}{% +%<class> \ClassWarning{\KOMAClassName}{% +%<package> \PackageWarning{scrletter}{% + Internal macro `\string\if@plength' is deprecated.\MessageBreak + Please use `\string\Ifplength' instead}% + \Ifplength +} +% \end{macrocode} +% \end{macro}^^A \if@plength +% \end{command}^^A \Ifplength +% +% +% \begin{command}{\newplength} +% \changes{v2.8q}{2001/10/06}{added} +% \changes{v2.8q}{2001/10/06}{retired compatibility to +% \cls[https://www.ctan.org/pkg/koma-script-obsolete]{scrlettr}} +% \changes{v3.26}{2018/04/26}{user command instead of internal macro} +% \changes{v3.27}{2019/03/29}{changed error message} +% \begin{macro}{\@newplength} +% \changes{v3.36}{2022/02/14}{deprecated} +% Define a new pseudo length (\texttt{\#1}) and initialize it with 0. +% \begin{macrocode} +\newcommand*{\newplength}[1]{% + \@ifundefined{ltr@len@#1}{% + \expandafter\let\csname ltr@len@#1\endcsname=\z@% + }{% +%<class> \ClassError{scrlttr2% +%<package> \PackageError{scrletter% + }{% + pseudo-length \expandafter\string\csname ltr@len@#1\endcsname + already defined% + }{% + You've tried to define a new pseudo-length using\MessageBreak + \string\@newplength\space + or \string\newplength.\MessageBreak + Please, try another name% + }% + }% +} +\newcommand*{\@newplength}{% +%<class> \ClassWarning{\KOMAClassName}{% +%<package> \PackageWarning{scrletter}{% + Internal macro `\string\@newplength' is deprecated.\MessageBreak + Please use `\string\newplength' instead}% + \newplength +} +% \end{macrocode} +% \end{macro} +% \end{command} +% +% +% \begin{command}{\useplength} +% \changes{v2.8q}{2001/10/06}{added} +% \changes{v2.97c}{2007/09/17}{with \eTeX{} using \cs{dimexpr} instead of \cs{number}} +% \changes{v3.25}{2017/11/29}{\eTeX{} is mandatory} +% \changes{v3.25}{2017/11/29}{\cs{dimexpr} replaced by \cs{glueexpr}} +% Read the value of a pseudo length like a skip register. This can be done +% using \cs{glueexpr}. +% \begin{macrocode} +\newcommand*{\useplength}[1]{% + \glueexpr \csname ltr@len@#1\endcsname\relax}% +% \end{macrocode} +% \end{command} +% +% \begin{command}{\setlengthtoplength} +% \changes{v2.8q}{2001/10/06}{added} +% Set a real \LaTeX{} length (usually a \TeX{} skip, but \TeX{} dimensions are +% also valid) to a multiple of a pseudo length. The factor is given by the +% optional argument \texttt{\#1}. The length is mandatory argument \textrm{\#2} +% and the name of the pseudo length the also mandatory \texttt{\#3}. +% \begin{macrocode} +\newcommand*{\setlengthtoplength}[3][]{% + \setlength{#2}{\useplength{#3}}% + \setlength{#2}{#1#2}} +% \end{macrocode} +% \end{command} +% +% \begin{command}{\setplength} +% \changes{v2.8q}{2001/10/06}{added} +% \changes{v3.25}{2017/11/29}{\cs{glueexpr} eingefügt} +% \changes{v3.36}{2018/04/26}{user command instead of internal macro} +% \begin{macro}{\@setplength} +% \changes{v3.36}{2022/02/14}{deprecated} +% We also need a command to set a pseudo length (\texttt{\#2}) to a new value +% (\texttt{\#3}). Locally we use a length to do so, because we want error +% messages about illegal values here and not when using the pseudo value. Once +% more an optional factor (\texttt{\#1}) is provided (but does not make much sense). +% \begin{macrocode} +\newcommand*{\setplength}[3][]{% + \begingroup% + \setlength{\@tempskipa}{\glueexpr #3\relax}% + \setlength{\@tempskipa}{#1\@tempskipa}% + \edef\@tempa{\noexpand\endgroup% + \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*% + \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempskipa}% + }% + \@tempa +} +\newcommand*{\@setplength}{% +%<class> \ClassWarning{\KOMAClassName}{% +%<package> \PackageWarning{scrletter}{% + Internal macro `\string\@setplength' is deprecated.\MessageBreak + Please use `\string\setplength' instead}% + \setplength +} +% \end{macrocode} +% \end{macro} +% \end{command} +% +% +% \begin{command}{\setplengthtowidth,\setplengthtoheight,\setplengthtodepth, +% \setplengthtototalheight} +% \changes{v3.26}{2018/04/26}{added} +% First three commands are similar to \cs{settowidth}, \cs{settoheight} and +% \cs{settodepth} but with pseudo length instead of a \LaTeX{} length. The +% last one is a combination of \cs{setplengthtoheight} + \cs{setplengthtodepth}. +% \begin{macrocode} +\newcommand*{\setplengthtowidth}[3][]{% + \begingroup + \settowidth{\@tempdima}{#3}% + \setlength{\@tempdima}{#1\@tempdima}% + \edef\@tempa{\noexpand\endgroup + \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*% + \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}% + }% + \@tempa +} +\newcommand*{\setplengthtoheight}[3][]{% + \begingroup + \settoheight{\@tempdima}{#3}% + \setlength{\@tempdima}{#1\@tempdima}% + \edef\@tempa{\noexpand\endgroup + \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*% + \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}% + }% + \@tempa +} +\newcommand*{\setplengthtodepth}[3][]{% + \begingroup + \settodepth{\@tempdima}{#3}% + \setlength{\@tempdima}{#1\@tempdima}% + \edef\@tempa{\noexpand\endgroup + \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*% + \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}% + }% + \@tempa +} +\newcommand*{\setplengthtototalheight}[3][]{% + \begingroup + \settoheight{\@tempdima}{#3}% + \settodepth{\@tempdimb}{#3}% + \addtolength{\@tempdima}{\@tempdimb}% + \setlength{\@tempdima}{#1\@tempdima}% + \edef\@tempa{\noexpand\endgroup + \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*% + \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}% + }% + \@tempa +} +% \end{macrocode} +% \end{command} +% +% +% \begin{command}{\addtolengthplength} +% \changes{v2.8q}{2001/10/06}{added} +% This provides a plus operation of a pseudo length \texttt{\#3} to a \LaTeX{} +% length \texttt{\#2}. Again an optional factor \texttt{\#1} is possible. +% \begin{macrocode} +\newcommand*{\addtolengthplength}[3][]{% + \begingroup% + \setlengthtoplength[{#1}]{\@tempskipa}{#3}% + \edef\@tempa{\endgroup% + \noexpand\addtolength{#2}{\the\@tempskipa}}% + \@tempa% +} +% \end{macrocode} +% \end{command} +% +% +% \begin{command}{\addtoplength} +% \changes{v2.8q}{2001/10/06}{added} +% \changes{v3.25}{2017/11/29}{using \cs{glueexpr}} +% \changes{v3.36}{2018/04/26}{user command instead of internal macro} +% \begin{macro}{\@addtoplength} +% \changes{v3.36}{2022/02/14}{deprecated} +% This provides a plus operation for one pseudo length \texttt{\#3} to another +% pseudo length \texttt{\#2}. Again an optional factor \texttt{\#1} is possible. +% \begin{macrocode} +\newcommand*{\addtoplength}[3][]{% + \begingroup% + \setlength{\@tempskipa}{\glueexpr #3\relax}% + \setlength{\@tempskipa}{#1\@tempskipa}% + \addtolengthplength{\@tempskipa}{#2}% + \edef\@tempa{\noexpand\endgroup% + \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*% + \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempskipa}% + }% + \@tempa% +} +\newcommand*{\@addtoplength}{% +%<class> \ClassWarning{\KOMAClassName}{% +%<package> \PackageWarning{scrletter}{% + Internal macro `\string\@addtoplength' is deprecated.\MessageBreak + Please use `\string\addtoplength' instead}% + \addtoplength} +%</body> +% \end{macrocode} +% \end{macro} +% \end{command} +% +% +% \begin{macrocode} +%</letter> +% \end{macrocode} +% +% \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: |