Debian Codegraph @

texmf-dist/source/latex/koma-script/scrkernel-pseudolengths.dtx

raw
1 % \iffalse meta-comment
2 % ======================================================================
3 % scrkernel-pseudolengths.dtx
4 % Copyright (c) Markus Kohm, 2002-2023
5 %
6 % This file is part of the LaTeX2e KOMA-Script bundle.
7 %
8 % This work may be distributed and/or modified under the conditions of
9 % the LaTeX Project Public License, version 1.3c of the license.
10 % The latest version of this license is in
11 % http://www.latex-project.org/lppl.txt
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2005/12/01 or later and of this work.
14 %
15 % This work has the LPPL maintenance status "author-maintained".
16 %
17 % The Current Maintainer and author of this work is Markus Kohm.
18 %
19 % This work consists of all files listed in MANIFEST.md.
20 % ======================================================================
21 %%% From File: $Id: scrkernel-pseudolengths.dtx 4032 2023-04-17 09:45:11Z kohm $
22 %<option>%%% (run: option)
23 %<body>%%% (run: body)
24 %<*dtx>
25 \ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
26 \begingroup
27 \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
28 \filedate$Date: 2023-04-17 11:45:11 +0200 (Mo, 17. Apr 2023) $
29 \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
30 \filerevision$Revision: 4032 $
31 \edef\reserved@a{%
32 \noexpand\endgroup
33 \noexpand\ProvidesFile{scrkernel-pseudolengths.dtx}%
34 [\filedate\space\filerevision\space
35 KOMA-Script source
36 (pseudo length)]
37 }%
38 \reserved@a
39 \documentclass[USenglish]{koma-script-source-doc}
40 \usepackage{babel}
41 \usepackage{hvlogos}
42 \setcounter{StandardModuleDepth}{2}
43 \begin{document}
44 \DocInput{scrkernel-pseudolengths.dtx}
45 \end{document}
46 %</dtx>
47 % \fi^^A meta-comment
48 %
49 % \changes{v2.95}{2002/06/20}{first version after splitting \file{scrclass.dtx}}
50 % \changes{v3.36}{2022/02/14}{switch over from \cls*{scrdoc} to
51 % \cls*{koma-script-source-doc}}
52 % \changes{v3.36}{2022/02/14}{whole implementation documentation in English}
53 % \changes{v3.40}{2023/04/17}{guide names changed}
54 %
55 % \GetFileInfo{scrkernel-pseudolengths.dtx}
56 % \title{Handling of Lengths Stored in Macros for
57 % \href{https://komascript.de}{\KOMAScript} Letter Class and Packages}
58 % \author{\href{mailto:[email protected]}{Markus Kohm}}
59 % \date{Revision \fileversion{} of \filedate}
60 % \maketitle
61 % \begin{abstract}
62 % \file{scrkernel-pseudolength.dtx} provides storing lengths in macros. This
63 % feature has been introduced with \cls*{scrlttr2} in 2002, because at that
64 % time there where only 256 skip registers for \LaTeX{} lengths and
65 % \cls*{scrlttr2} needs several lengths to specify the positions of several
66 % notepaper elements. Some time later The \LaTeX{} Team (at long last) has
67 % decided to recommend \eTeX{} as \TeX{} engine for
68 % \LaTeX.\!\footnote{Currently \pdfTeX{} with \eTeX{} extensions is the
69 % recommended \TeX{} engine for \LaTeX.} \,Therefore the usage of the so
70 % called \emph{pseudo lengths} in \KOMAScript{} wouldn't be necessary any
71 % longer. But they exist and will be used at least for compatibility also in
72 % future versions of \cls*{scrlttr2} and \pkg*{scrletter}.
73 % \end{abstract}
74 % \tableofcontents
75 %
76 % \section{User Manual}
77 %
78 % You can find the user documentation the commands implemented here in the
79 % \KOMAScript{} manual, either the German \file{scrguide-de.pdf} or the
80 % English \file{scrguide-en.pdf}.
81 %
82 % \MaybeStop{\PrintIndex}
83 %
84 % \section{Implementation of Package \pkg*{typearea} and Additional Class
85 % Features}
86 %
87 % \begin{macrocode}
88 %<*letter>
89 % \end{macrocode}
90 %
91 % \subsection{Options}
92 % The method of pseudo lengths is not influenced by options.
93 %
94 %
95 % \subsection{Commands and macros for pseudo lengths}
96 %
97 % For the calculation of the positions of several elements of the notepaper
98 % several lengths are needed. To not use a lot \LaTeX{} lengths (and therefore
99 % \TeX{} skip registers) they are stored in macros. So we also need some
100 % additional commands to not only store lengths values in macros but also for
101 % arithmetic operations on such macros and even to test, if a pseudo lengths
102 % exists or not.
103 %
104 %
105 % \begin{command}{\Ifplength}
106 % \changes{v3.27}{2019/03/29}{added}
107 % \begin{macro}{\if@plength}
108 % \changes{v3.27}{2019/03/29}{added}
109 % \changes{v3.36}{2022/02/14}{deprecated}
110 % Test whether or not a given pseudo-length (\texttt{\#1}) already exists. If
111 % so execute argument \texttt{\#2}, otherwise \texttt{\#3}.
112 % \begin{macrocode}
113 %<*body>
114 \newcommand*{\Ifplength}[1]{%
115 \@ifundefined{ltr@len@#1}{\@secondoftwo}{\@firstoftwo}%
116 }
117 \newcommand*{\if@plength}{%
118 %<class> \ClassWarning{\KOMAClassName}{%
119 %<package> \PackageWarning{scrletter}{%
120 Internal macro `\string\if@plength' is deprecated.\MessageBreak
121 Please use `\string\Ifplength' instead}%
122 \Ifplength
123 }
124 % \end{macrocode}
125 % \end{macro}^^A \if@plength
126 % \end{command}^^A \Ifplength
127 %
128 %
129 % \begin{command}{\newplength}
130 % \changes{v2.8q}{2001/10/06}{added}
131 % \changes{v2.8q}{2001/10/06}{retired compatibility to
132 % \cls[https://www.ctan.org/pkg/koma-script-obsolete]{scrlettr}}
133 % \changes{v3.26}{2018/04/26}{user command instead of internal macro}
134 % \changes{v3.27}{2019/03/29}{changed error message}
135 % \begin{macro}{\@newplength}
136 % \changes{v3.36}{2022/02/14}{deprecated}
137 % Define a new pseudo length (\texttt{\#1}) and initialize it with 0.
138 % \begin{macrocode}
139 \newcommand*{\newplength}[1]{%
140 \@ifundefined{ltr@len@#1}{%
141 \expandafter\let\csname ltr@len@#1\endcsname=\z@%
142 }{%
143 %<class> \ClassError{scrlttr2}%
144 %<package> \PackageError{scrletter}%
145 {%
146 pseudo-length \expandafter\string\csname ltr@len@#1\endcsname
147 already defined%
148 }{%
149 You've tried to define a new pseudo-length using\MessageBreak
150 \string\@newplength\space
151 or \string\newplength.\MessageBreak
152 Please, try another name%
153 }%
154 }%
155 }
156 \newcommand*{\@newplength}{%
157 %<class> \ClassWarning{\KOMAClassName}{%
158 %<package> \PackageWarning{scrletter}{%
159 Internal macro `\string\@newplength' is deprecated.\MessageBreak
160 Please use `\string\newplength' instead}%
161 \newplength
162 }
163 % \end{macrocode}
164 % \end{macro}
165 % \end{command}
166 %
167 %
168 % \begin{command}{\useplength}
169 % \changes{v2.8q}{2001/10/06}{added}
170 % \changes{v2.97c}{2007/09/17}{with \eTeX{} using \cs{dimexpr} instead of \cs{number}}
171 % \changes{v3.25}{2017/11/29}{\eTeX{} is mandatory}
172 % \changes{v3.25}{2017/11/29}{\cs{dimexpr} replaced by \cs{glueexpr}}
173 % Read the value of a pseudo length like a skip register. This can be done
174 % using \cs{glueexpr}.
175 % \begin{macrocode}
176 \newcommand*{\useplength}[1]{%
177 \glueexpr \csname ltr@len@#1\endcsname\relax}%
178 % \end{macrocode}
179 % \end{command}
180 %
181 % \begin{command}{\setlengthtoplength}
182 % \changes{v2.8q}{2001/10/06}{added}
183 % Set a real \LaTeX{} length (usually a \TeX{} skip, but \TeX{} dimensions are
184 % also valid) to a multiple of a pseudo length. The factor is given by the
185 % optional argument \texttt{\#1}. The length is mandatory argument \textrm{\#2}
186 % and the name of the pseudo length the also mandatory \texttt{\#3}.
187 % \begin{macrocode}
188 \newcommand*{\setlengthtoplength}[3][]{%
189 \setlength{#2}{\useplength{#3}}%
190 \setlength{#2}{#1#2}}
191 % \end{macrocode}
192 % \end{command}
193 %
194 % \begin{command}{\setplength}
195 % \changes{v2.8q}{2001/10/06}{added}
196 % \changes{v3.25}{2017/11/29}{\cs{glueexpr} eingefügt}
197 % \changes{v3.36}{2018/04/26}{user command instead of internal macro}
198 % \begin{macro}{\@setplength}
199 % \changes{v3.36}{2022/02/14}{deprecated}
200 % We also need a command to set a pseudo length (\texttt{\#2}) to a new value
201 % (\texttt{\#3}). Locally we use a length to do so, because we want error
202 % messages about illegal values here and not when using the pseudo value. Once
203 % more an optional factor (\texttt{\#1}) is provided (but does not make much sense).
204 % \begin{macrocode}
205 \newcommand*{\setplength}[3][]{%
206 \begingroup%
207 \setlength{\@tempskipa}{\glueexpr #3\relax}%
208 \setlength{\@tempskipa}{#1\@tempskipa}%
209 \edef\@tempa{\noexpand\endgroup%
210 \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*%
211 \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempskipa}%
212 }%
213 \@tempa
214 }
215 \newcommand*{\@setplength}{%
216 %<class> \ClassWarning{\KOMAClassName}{%
217 %<package> \PackageWarning{scrletter}{%
218 Internal macro `\string\@setplength' is deprecated.\MessageBreak
219 Please use `\string\setplength' instead}%
220 \setplength
221 }
222 % \end{macrocode}
223 % \end{macro}
224 % \end{command}
225 %
226 %
227 % \begin{command}{\setplengthtowidth,\setplengthtoheight,\setplengthtodepth,
228 % \setplengthtototalheight}
229 % \changes{v3.26}{2018/04/26}{added}
230 % First three commands are similar to \cs{settowidth}, \cs{settoheight} and
231 % \cs{settodepth} but with pseudo length instead of a \LaTeX{} length. The
232 % last one is a combination of \cs{setplengthtoheight} + \cs{setplengthtodepth}.
233 % \begin{macrocode}
234 \newcommand*{\setplengthtowidth}[3][]{%
235 \begingroup
236 \settowidth{\@tempdima}{#3}%
237 \setlength{\@tempdima}{#1\@tempdima}%
238 \edef\@tempa{\noexpand\endgroup
239 \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*%
240 \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}%
241 }%
242 \@tempa
243 }
244 \newcommand*{\setplengthtoheight}[3][]{%
245 \begingroup
246 \settoheight{\@tempdima}{#3}%
247 \setlength{\@tempdima}{#1\@tempdima}%
248 \edef\@tempa{\noexpand\endgroup
249 \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*%
250 \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}%
251 }%
252 \@tempa
253 }
254 \newcommand*{\setplengthtodepth}[3][]{%
255 \begingroup
256 \settodepth{\@tempdima}{#3}%
257 \setlength{\@tempdima}{#1\@tempdima}%
258 \edef\@tempa{\noexpand\endgroup
259 \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*%
260 \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}%
261 }%
262 \@tempa
263 }
264 \newcommand*{\setplengthtototalheight}[3][]{%
265 \begingroup
266 \settoheight{\@tempdima}{#3}%
267 \settodepth{\@tempdimb}{#3}%
268 \addtolength{\@tempdima}{\@tempdimb}%
269 \setlength{\@tempdima}{#1\@tempdima}%
270 \edef\@tempa{\noexpand\endgroup
271 \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*%
272 \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempdima}%
273 }%
274 \@tempa
275 }
276 % \end{macrocode}
277 % \end{command}
278 %
279 %
280 % \begin{command}{\addtolengthplength}
281 % \changes{v2.8q}{2001/10/06}{added}
282 % This provides a plus operation of a pseudo length \texttt{\#3} to a \LaTeX{}
283 % length \texttt{\#2}. Again an optional factor \texttt{\#1} is possible.
284 % \begin{macrocode}
285 \newcommand*{\addtolengthplength}[3][]{%
286 \begingroup%
287 \setlengthtoplength[{#1}]{\@tempskipa}{#3}%
288 \edef\@tempa{\endgroup%
289 \noexpand\addtolength{#2}{\the\@tempskipa}}%
290 \@tempa%
291 }
292 % \end{macrocode}
293 % \end{command}
294 %
295 %
296 % \begin{command}{\addtoplength}
297 % \changes{v2.8q}{2001/10/06}{added}
298 % \changes{v3.25}{2017/11/29}{using \cs{glueexpr}}
299 % \changes{v3.36}{2018/04/26}{user command instead of internal macro}
300 % \begin{macro}{\@addtoplength}
301 % \changes{v3.36}{2022/02/14}{deprecated}
302 % This provides a plus operation for one pseudo length \texttt{\#3} to another
303 % pseudo length \texttt{\#2}. Again an optional factor \texttt{\#1} is possible.
304 % \begin{macrocode}
305 \newcommand*{\addtoplength}[3][]{%
306 \begingroup%
307 \setlength{\@tempskipa}{\glueexpr #3\relax}%
308 \setlength{\@tempskipa}{#1\@tempskipa}%
309 \addtolengthplength{\@tempskipa}{#2}%
310 \edef\@tempa{\noexpand\endgroup%
311 \noexpand\expandafter\noexpand\renewcommand\noexpand\expandafter*%
312 \noexpand\csname ltr@len@#2\noexpand\endcsname{\the\@tempskipa}%
313 }%
314 \@tempa%
315 }
316 \newcommand*{\@addtoplength}{%
317 %<class> \ClassWarning{\KOMAClassName}{%
318 %<package> \PackageWarning{scrletter}{%
319 Internal macro `\string\@addtoplength' is deprecated.\MessageBreak
320 Please use `\string\addtoplength' instead}%
321 \addtoplength}
322 %</body>
323 % \end{macrocode}
324 % \end{macro}
325 % \end{command}
326 %
327 %
328 % \begin{macrocode}
329 %</letter>
330 % \end{macrocode}
331 %
332 % \Finale
333 % \PrintChanges
334 %
335 \endinput
336 % Local Variables:
337 % mode: doctex
338 % ispell-local-dictionary: "en_US"
339 % eval: (flyspell-mode 1)
340 % TeX-master: t
341 % TeX-engine: luatex-dev
342 % 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"))
343 % End: