summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scrkernel-pseudolengths.dtx
blob: b3d2f623cfcb298b8e0780405180c90533034a52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
% \CheckSum{223}
% \iffalse meta-comment
% ======================================================================
% scrkernel-pseudolengths.dtx
% Copyright (c) Markus Kohm, 2006-2019
%
% 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.txt.
% ----------------------------------------------------------------------
% scrkernel-pseudolengths.dtx
% Copyright (c) Markus Kohm, 2006-2019
%
% Dieses Werk darf nach den Bedingungen der LaTeX Project Public Lizenz,
% Version 1.3c, verteilt und/oder veraendert werden.
% Die neuste Version dieser Lizenz ist
%   http://www.latex-project.org/lppl.txt
% und Version 1.3c ist Teil aller Verteilungen von LaTeX
% Version 2005/12/01 oder spaeter und dieses Werks.
%
% Dieses Werk hat den LPPL-Verwaltungs-Status "author-maintained"
% (allein durch den Autor verwaltet).
%
% Der Aktuelle Verwalter und Autor dieses Werkes ist Markus Kohm.
% 
% Dieses Werk besteht aus den in manifest.txt aufgefuehrten Dateien.
% ======================================================================
% \fi
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \iffalse
%%% From File: $Id: scrkernel-pseudolengths.dtx 3262 2019-10-10 08:25:29Z kohm $
%<option>%%%            (run: option)
%<body>%%%            (run: body)
%<*dtx>
% \fi
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
  \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
  \filedate$Date: 2019-10-10 10:25:29 +0200 (Thu, 10 Oct 2019) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 1872 $
  \edef\reserved@a{%
    \noexpand\endgroup
    \noexpand\ProvidesFile{scrkernel-pseudolengths.dtx}%
                          [\filedate\space\filerevision\space
                           KOMA-Script source
                          (pseudo length)]
  }%
\reserved@a
% \iffalse
\documentclass{scrdoc}
\usepackage[english,ngerman]{babel}
\CodelineIndex
\RecordChanges
\GetFileInfo{scrkernel-pseudolengths.dtx}
\title{\KOMAScript{} \partname\ \texttt{\filename}%
  \footnote{Dies ist Version \fileversion\ von Datei \texttt{\filename}.}}
\date{\filedate}
\author{Markus Kohm}

\begin{document}
  \maketitle
  \tableofcontents
  \DocInput{\filename}
\end{document}
%</dtx>
% \fi
%
% \selectlanguage{ngerman}
%
% \changes{v2.95}{2006/03/22}{%
%   erste Version aus der Aufteilung von \textsf{scrclass.dtx}}
%
% \section{Pseudo-Längen für Briefe}
%
% Pseudo-Längen wurden für \textsf{scrlttr2} eingeführt, um Längenregister zu
% sparen. Tatsächlich hat das \LaTeX-Team kurz darauf entschieden, dass
% künftig \eTeX{} die empfohlene Maschine für \LaTeX{} sein soll, wodurch die
% Einführung von Pseudo-Längen nachträglich überflüssig wurde. Es gibt sie nun
% aber einmal und aus Gründen der Kompatiblität wird es sie für Briefe auch
% weiterhin geben.
%
% \StopEventually{\PrintIndex\PrintChanges}
%
% \iffalse
%<*letter>
% \fi
%
% \iffalse
%<*option>
% \fi
%
% \subsection{Option}
% Das Prinzip der Pseudo-Längen wird nicht durch Optionen beeinflusst.
%
%
% \iffalse
%</option>
%<*body>
% \fi
%
% \subsection{Anweisungen für Pseudo-Längen}
%
% Zu Berechnung der Feldpositionen werden verschiedene Dimensions-Variablen
% benötigt. Um jedoch nicht unnötig viele Längenregister zu verbrauchen, wird
% hier mit einer Pseudo-Längen-Arithmetik gearbeitet.
%
% \selectlanguage{english}%^^A
% \begin{macro}{\Ifplength}
% \changes{v3.27}{2019/03/29}{new}%^^A
% \begin{macro}{\if@plength}
% \changes{v3.27}{2019/03/29}{new (internal)}%^^A
% Test whether or not a given pseudo-length (\texttt{\#1}) already exists. If
% so execute the second argument, otherwise the third. It's somehow
% inconsistent to use \cs{Ifplength} instead of \cs{ifplength}, but as it does
% not act as a \TeX{} switch but a \LaTeX{} command it is better not to use
% \cs{if\dots}.
%    \begin{macrocode}
\newcommand*{\if@plength}[1]{%
  \@ifundefined{ltr@len@#1}{\@secondoftwo}{\@firstoftwo}%
}
\newcommand*{\Ifplength}{\if@plength}
%    \end{macrocode}
% \end{macro}%^^A\Ifplength
% \end{macro}%^^A\if@plength
% \selectlanguage{ngerman}%^^A
%
% \begin{macro}{\@newplength}
% \changes{v2.8q}{2001/10/06}{Neu}%^^A
% \changes{v2.8q}{2001/10/06}{Kompatibilität zu \texttt{scrlettr.cls}%^^A
%   aufgegeben}
% \changes{v3.27}{2019/03/29}{Fehlermeldung angepasst}%^^A
% Dieses Makro definiert eine neue Pseude-Länge und setzt sie auf den
% Wert 0. Eine Pseudo-Länge ist ein Makro, das eine Länge enthält.
%    \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}%
    }%
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newplength}
% \changes{v3.26}{2018/04/26}{Neu}
% Anweisung auf Anwenderebene verfügbar.
%    \begin{macrocode}
\newcommand*{\newplength}{\@newplength}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\useplength}
% \changes{v2.8q}{2001/10/06}{Neu}%^^A
% \changes{v2.97c}{2007/09/17}{\cs{dimexpr} statt \cs{number} verwendet,
% wenn \eTeX{} verwendet wird}
% \changes{v3.25}{2017/11/29}{\eTeX{} ist zwingend}
% \changes{v3.25}{2017/11/29}{\cs{dimexpr} durch \cs{glueexpr} ersetzt}%^^A
% Natürlich muss auf eine solche Pseudo-Länge auch wieder lesend
% zugeriffen werden können. Wir definieren dies hier so, dass es
% außerdem möglich ist, ein Vorzeichen oder einen Faktor zu verwenden. Dafür
% wird allerdings \eTeX{} benötigt.
%    \begin{macrocode}
\newcommand*{\useplength}[1]{%
  \glueexpr \csname ltr@len@#1\endcsname\relax}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setlengthtoplength}
% \changes{v2.8q}{2001/10/06}{Neu}%^^A
% Eine echte Länge soll auf das Vielfache einer Pseudo-Länge gesetzt
% werden. Dabei wird der Faktor als optionaler Parameter übergeben.
% Der erste obligatorische Parameter ist die Länge, der zweite
% obligatorische Parameter ist die Pseudo-Länge.
%    \begin{macrocode}
\newcommand*{\setlengthtoplength}[3][]{%
  \setlength{#2}{\useplength{#3}}%
  \setlength{#2}{#1#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@setplength}
% \changes{v2.8q}{2001/10/06}{Neu}%^^A
% \changes{v3.25}{2017/11/29}{\cs{glueexpr} eingefügt}%^^A
% Natürlich wird ebenfalls eine Möglichkeit benötigt, einer
% Pseudo-Länge einen Wert zuzuweisen. Dies geschieht unter lokaler
% Anwendung einer Länge, damit sichergestellt ist, dass eine
% Längenangabe übergeben wird. Dabei wird das zuvor definierte Makro
% \cs{setlengthtoplength} verwendet.
%    \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
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setplength}
% \changes{v3.26}{2018/04/26}{Neu}%^^A
% Anweisung auf Anwenderebene verfügbar.
%    \begin{macrocode}
\newcommand*{\setplength}{\@setplength}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setplengthtowidth}
% \changes{v3.26}{2018/04/26}{Neu}
% \begin{macro}{\setplengthtoheight}
% \changes{v3.26}{2018/04/26}{Neu}
% \begin{macro}{\setplengthtodepth}
% \changes{v3.26}{2018/04/26}{Neu}
% \begin{macro}{\setplengthtototalheight}
% \changes{v3.26}{2018/04/26}{Neu}
% Man kann auch die Breite, Höhe, Tiefe oder Höhe + Tiefe eines Inhalts
% verwenden, um eine Pseudolänge zu definieren.
%    \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{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\addtolengthplength}
% \changes{v2.8q}{2001/10/06}{Neu}%^^A
% Wenn wir schon dabei sind, soll statt dem Setzen auch das Addieren
% funktionieren. Hier ist die Erschwernis, dass der Faktor nur für
% die Pseudo-Länge und nicht für das Endergebnis gelten soll.
%    \begin{macrocode}
\newcommand*{\addtolengthplength}[3][]{%
  \begingroup%
    \setlengthtoplength[{#1}]{\@tempskipa}{#3}%
    \edef\@tempa{\endgroup%
      \noexpand\addtolength{#2}{\the\@tempskipa}}%
    \@tempa%
  }
%    \end{macrocode}
%
% \begin{macro}{\@addtoplength}
% \changes{v2.8q}{2001/10/06}{Neu}%^^A
% \changes{v3.25}{2017/11/29}{\cs{glueexpr} eingefügt}%^^A
% Ebenso wird ein Makro benötigt, mit dem zu einer Pseudo-Länge das
% Vielfache eines Wertes addiert werden kann.
%    \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%
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\addtoplength}
% \changes{v3.26}{2018/04/26}{Neu}
% Anweisung auf Anwenderebene verfügbar.
%    \begin{macrocode}
\newcommand*{\addtoplength}{\@addtoplength}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</body>
% \fi
%
% \iffalse
%</letter>
% \fi
%
% \Finale
%
\endinput
%
% end of file `scrkernel-pseudolengths.dtx'
%%% Local Variables:
%%% mode: doctex
%%% TeX-master: t
%%% End: