Debian Codegraph @

texmf-dist/source/latex/prelim2e/prelim2e.dtx

raw
1 % \iffalse meta-comment
2 %
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %
5 % Copyright (C) Martin Schröder, 1994–2001
6 % Marei Peischl (peiTeX) <[email protected]>, 2020
7 %
8 % This work may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.3c
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % This work has the LPPL maintenance status `maintained'.
17 %
18 % The Current Maintainer of this work is
19 % Marei Peischl <[email protected]>.
20 %
21 % This work consists of the files
22 % README.md
23 % prelim2e.dtx
24 % prelim2e.ins
25 % and the derived files
26 % prelim2e.sty
27 % prelim2e.pdf
28 %
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 %
31 % \fi
32 % \changes{v1.01}{1995/05/02}{Date added to \cs{NeedsTeXFormat}}
33 % \changes{v2.00}{2020/11/24}{Complete rework to use the kernel methods instead of everyshi}
34 % \iffalse
35 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
36 %<package>\ProvidesExplPackage{prelim2e}
37 %<package> {2020/11/24}{2.0}{prelim2e Package}
38 %
39 %<*driver>
40 \ProvidesFile{prelim2e.drv}
41 [2020/11/24 v2.0 Driver for prelim2e Package]
42 \documentclass{l3doc}
43 \usepackage{url}
44 \DeclareUrlCommand\CTANlink{\def\UrlLeft{CTAN:\space}\def\UrlRight{}\urlstyle{tt}}
45 \usepackage{geometry}
46 \usepackage[scrtime]{prelim2e}
47 \GetFileInfo{prelim2e.sty}
48 \EnableCrossrefs
49 \RecordChanges % Gather update information
50 %%\DisableCrossrefs% Say \DisableCrossrefs if index is ready
51 \OnlyDescription % comment out for implementation details
52 %%\OldMakeIndex % use if your MakeIndex is pre-v2.9
53 \setcounter{IndexColumns}{2}
54 \oddsidemargin=2cm
55 \marginparwidth=2.5cm
56 % onecolumn glossary
57 \begin{document}
58 \DocInput{prelim2e.dtx}
59 \end{document}
60 %</driver>
61 % \fi
62 %
63 % \CheckSum{104}
64 %
65 % \CharacterTable
66 % {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
67 % 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
68 % Digits \0\1\2\3\4\5\6\7\8\9
69 % Exclamation \! Double quote \" Hash (number) \#
70 % Dollar \$ Percent \% Ampersand \&
71 % Acute accent \' Left paren \( Right paren \)
72 % Asterisk \* Plus \+ Comma \,
73 % Minus \- Point \. Solidus \/
74 % Colon \: Semicolon \; Less than \<
75 % Equals \= Greater than \> Question mark \?
76 % Commercial at \@ Left bracket \[ Backslash \\
77 % Right bracket \] Circumflex \^ Underscore \_
78 % Grave accent \` Left brace \{ Vertical bar \|
79 % Right brace \} Tilde \~}
80 %
81 %
82 %
83 % \renewcommand{\PrelimWords}{^^A
84 % \package{prelim2e} package --
85 % Version \fileversion --
86 % Documentation \LaTeX{}ed^^A
87 % }
88 %
89 % \changes{v1.00}{1995/01/26}{New}
90 % \changes{v1.21}{1998/08/09}{Documentation improved}
91 % \changes{v1.22}{1999/06/08}{Moved to LPPL}
92 % \changes{v1.3}{2009/05/29}{LPPL 1.3}
93 %
94 % \newcommand*{\option}[1]{\textnormal{\sffamily#1}}
95 % \newcommand*{\package}[1]{\textnormal{\sffamily#1}}
96 % \newcommand*{\NEWfeature}[1]{%
97 % \hskip 1sp \marginpar{\small\sffamily\raggedright
98 % New feature\\#1}}
99 % \newcommand*{\NEWdescription}[1]{%
100 % \hskip 1sp \marginpar{\small\sffamily\raggedright
101 % New description\\#1}}
102 %
103 % \pagestyle{headings}
104 %
105 %
106 % ^^A -----------------------------
107 %
108 % \title{\unskip
109 % The \package{prelim2e} package^^A
110 % }
111 % \author{Martin Schröder\thanks{maintained by Marei Peischl <[email protected]>}}
112 % \maketitle
113 %
114 % ^^A -----------------------------
115 %
116 %
117 % \begin{abstract}
118 % This package allows the marking of (preliminary) versions of a
119 % document on the output.
120 % \end{abstract}
121 %
122 % ^^A -----------------------------
123 %
124 % \tableofcontents
125 %
126 % ^^A -----------------------------
127 %
128 % \section{Introduction}
129 % ^^A
130 % This package allows the marking of (preliminary) versions of a
131 % document.
132 % This is done using the command \cs{PrelimText}, whose expansion
133 % is added \emph{below the footer} of every page of a document (look
134 % at the bottom of this page for an example).
135 %
136 % ^^A -----------------------------
137 %
138 % \section{Requirements}
139 % Version 2.00 requires the kernel hook management and is no longer
140 % useable with LaTeX versions older than 2020/10/01. In case you have
141 % any understandable reason, which requires the old implementation,
142 % feel free to contact the maintainer.
143 %
144 % ^^A -----------------------------
145 %
146 % \section{Usage}
147 % ^^A
148 % Simply using this package via
149 % \mbox{\cs{usepackage}\texttt{\{}\package{prelim2e}\texttt{\}}} produces a
150 % text in the form of ``Preliminary version -- \today''.
151 %
152 % \begin{function}{\PrelimText,\PrelimWords}
153 % The text is produced by the commands \cs{PrelimText} and
154 % \cs{PrelimWords}, which can be changed via \cs{renewcommand} or by
155 % using options at the \cs{usepackage} command (see
156 % section~\ref{sec:options}).
157 %
158 % The footer for this documentation was produced by changing
159 % \cs{PrelimWords} to
160 %\begin{verbatim}
161 % \renewcommand*{\PrelimWords}{%
162 % \textsf{prelim2e} package --
163 % Version \fileversion --
164 % Documentation \LaTeX{}ed%
165 % }
166 %\end{verbatim}
167 % \end{function}
168 %
169 % \begin{function}{\PrelimTextStyle}
170 % The style of the Text can be controlled by \cs{PrelimTextStyle}. This can also be adjusted using \cs{renewcommand*}. The default is set empty, but will use the default font in footnotesie.
171 % \end{function}
172 %
173 % ^^A -----------------------------
174 %
175 % \section{Options}
176 % \label{sec:options}
177 % ^^A
178 % The package has the following options:
179 % \nopagebreak
180 % \begin{description}
181 % \item[\normalfont\option{danish}]
182 % \changes{v1.23}{2001/02/17}{\option{danish} option added}
183 % \NEWfeature{2001/02/17}
184 % This sets the text to ``Forel\o{}big version''.
185 % It does not use the \package{babel} package.
186 % \item[\normalfont\option{draft}]
187 % If this option is used a text appears below the normal
188 % pagebody.
189 % It is the default.
190 % \item[\normalfont\option{final}]
191 % If this option is used \package{prelim2e} produces no text.
192 % \item[\normalfont\option{english}]
193 % This sets the text to ``Preliminary version''.
194 % It is the default.
195 % \item[\normalfont\option{french}]
196 % \changes{v1.20}{1997/05/12}{\option{french} option added}
197 % \NEWfeature{1997/05/12}
198 % This sets the text to ``Version pr\'eliminaire''.
199 % It does not use the \package{french} or \package{babel} package.
200 % \item[\normalfont\option{german}]
201 % This sets the text to ``Vorl\"aufige Version''.
202 % It does not use the \package{german} or \package{babel} package.
203 % \item[\normalfont\option{italian}]
204 % \changes{v1.23}{2001/02/17}{\option{italian} option added}
205 % \NEWfeature{2001/02/17}
206 % This sets the text to ``Versione preliminare''.
207 % It does not use the \package{babel} package.
208 % \item[\normalfont\option{norsk}]
209 % \changes{v1.3}{2009/05/29}{\option{norsk} option added}
210 % \NEWfeature{2009/05/29}
211 % This sets the text to ``Forel\o{}pig versjon''.
212 % It does not use the \package{babel} package.
213 % \item[\normalfont\option{time}]
214 % \changes{v1.10}{1996/01/01}{\option{time} option added}
215 % \NEWdescription{1997/05/12}
216 % This adds the time at the beginning of the current \LaTeX{}
217 % to the text.
218 % The time is produced using the \cs{thistime} command, which may
219 % be provided by the \package{scrtime} package\cite{package:scrtime}.
220 % If you don't use the \package{scrtime} package (e.\,g. by
221 % specifying the \option{scrtime} option), you must
222 % provide it yourself or by some other package.
223 % \item[\normalfont\option{scrtime}]
224 % \changes{v1.20}{1997/05/12}{\option{scrtime} option added}
225 % \NEWfeature{1997/05/12}
226 % This loads the \package{scrtime} package\cite{package:scrtime}
227 % (part of the KOMA-Script bundle), which provides the
228 % \cs{thistime} command used by the \option{time} option.
229 % The \option{scrtime} option implies the \option{time} option.
230 % \end{description}
231 % All other options are passed to the \package{scrtime} package if the
232 % \option{scrtime} option is selected.
233 %
234 %
235 % ^^A -----------------------------
236 %
237 % \section{Required packages}
238 % ^^A
239 % The package requires the following packages:
240 % \begin{description}
241 % \item[\normalfont\package{scrtime}\cite{package:scrtime}]
242 % \changes{v1.10}{1996/01/01}{\package{scrtime} instead of
243 % \package{printtim}}
244 % \NEWdescription{1997/05/12}
245 % It is used to typeset the current time and is needed if the
246 % \option{scrtime} option is selected.
247 % \end{description}
248 %
249 %
250 % ^^A -----------------------------
251 %
252 % \section{Putting more things at the bottom}
253 % ^^A
254 % Another package you might like to use with \package{prelim2e} is
255 % \package{vrsion}\cite{package:vrsion}.
256 % This allows the definition and maintenance of a version number like
257 % 3.14159 \emph{within \LaTeX}, which can be put at the bottom of every
258 % page using \package{prelime2e}.
259 %
260 %
261 % ^^A -----------------------------
262 %
263 % ^^A -----------------------------
264 %
265 % \section{Acknowledgements}
266 % ^^A
267 % The idea of this package is based on
268 % \texttt{prelim.sty}\cite{package:prelim} for \LaTeX2.09 by Robert
269 % Tolksdorf (\texttt{[email protected]}).
270 % It provides nearly the same functionality as \package{prelim2e}, but
271 % in a very dirty way: it uses a modified output routine and does not
272 % work with \LaTeXe.
273 %
274 % The time functionality now uses the \package{scrtime} package by
275 % Markus Kohm (\texttt{[email protected]}).
276 %
277 % Rowland Bartlett (\texttt{[email protected]})
278 % brought forth the idea of separating the \option{time} option and the
279 % \package{scrtime} package;
280 % Daniel Courjon (\texttt{[email protected]}) provided
281 % the text for the \option{french} option,
282 % Arne J\o{}rgensen (\texttt{[email protected]})
283 % provided the text for the \option{danish} option,
284 % Davide Giovanni Maria Salvetti (\texttt{[email protected]})
285 % and Riccardo Murri (\texttt{[email protected]})
286 % both provided the text for the \option{italian} option,
287 % and Sveinung Heggen (\texttt{[email protected]}) provided the
288 % text for the \option{norsk} option.
289 %
290 % As usual Rebecca Stiels improved the quality of this documentation.
291 %
292 %
293 % ^^A -----------------------------
294 %
295 % \begin{thebibliography}{1}
296 % \raggedright
297 % \bibitem{package:prelim}
298 % Mats Dahlgren.
299 % \newblock \package{vrsion} -- a \LaTeX{} Macro for version
300 % Numbering of Files.
301 % \newblock \CTANlink{tex-archive/macros/latex/contrib/supported/vrsion/vrsion.dtx}.
302 % \newblock \LaTeXe{} package.
303 % \bibitem{package:scrtime}
304 % Markus Kohm.
305 % \newblock The \package{KOMA}-timedate-bundle.
306 % \newblock \CTANlink{tex-archive/macros/latex/contrib/supported/koma-script/scrtime.dtx}.
307 % \newblock \LaTeXe{} package.
308 % \bibitem{package:vrsion}
309 % Robert Tolksdorf.
310 % \newblock Kennzeichnung von Vorversionen eines Dokuments.
311 % \newblock \CTANlink{tex-archive/macros/latex209/contrib/prelim/}.
312 % \newblock \LaTeX2.09 package.
313 % \end{thebibliography}
314 %
315 % \StopEventually{\PrintChanges}
316 %
317 % ^^A -----------------------------
318 %
319 % \section{The implementation}
320 % \begin{macrocode}
321 %<*package>
322 % \end{macrocode}
323 % \begin{macrocode}
324 %<@@=prelim>
325 % \end{macrocode}
326
327 %
328 % ^^A -----------------------------
329 %
330 % \subsection{Initial Code}
331 % The implementation of version 2.00 requires a the kernel's hook management.
332 % Therefore we test if it's available and throw an error message if not.
333 %
334 % \begin{macrocode}
335 \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
336 \IfFormatAtLeastTF{2020/10/01}{}{%
337 \PackageError{prelim2e}{
338 Format file is too old. Please update your LaTeX distribution.
339 }{
340 prelim2e of version 2.0 requires a format version of at least 2020/10/01
341 }%
342 }
343 % \end{macrocode}
344
345 % ^^A
346 % \begin{variable}{\g_prelim_draft_bool}
347 % \cs{g_prelim_draft_bool} is used to flag the use of the \option{draft}
348 % or \option{final} option.
349 % \begin{macrocode}
350 \bool_new:N \g_prelim_draft_bool
351 % \end{macrocode}
352 % \end{variable}
353 %
354 % \begin{variable}{\g_prelim_time_bool}
355 % \changes{v1.10}{1996/01/01}{new}
356 % \cs{g_prelim_time_bool} is used to flag the use of the \option{time}
357 % option.
358 % \begin{macrocode}
359 \bool_new:N \g_prelim_time_bool
360 % \end{macrocode}
361 % \end{variable}
362 %
363 % \begin{variable}{\g_prelim_scrtime_bool}
364 % \changes{v1.20}{1997/05/12}{new}
365 % \cs{g_prelim_scrtime_bool} is used to flag the use of the \option{scrtime}
366 % option.
367 % \begin{macrocode}
368 \bool_new:N \g_prelim_scrtime_bool
369 % \end{macrocode}
370 % \end{variable}
371 %
372 %
373 % \begin{macro}{\PrelimWords}
374 % \cs{PrelimWords} holds the language-dependend text used in
375 % \cs{PrelimText}
376 % \begin{macrocode}
377 \newcommand*{\PrelimWords}{}
378 % \end{macrocode}
379 % \end{macro}
380 %
381 %
382 % ^^A -----------------------------
383 %
384 % \subsection{Declaration of options}
385 %
386 % ^^A -----------------------------
387 %
388 %
389 % \subsubsection{\option{draft} option}
390 % ^^A
391 % The \option{draft} and \option{final} option control the behavior
392 % of \package{prelim2e}: Only if \option{final} is used in
393 % \cs{documentclass} or
394 % \mbox{\cs{usepackage}\texttt{\{}\package{prelim2e}\texttt{\}}} text is
395 % produced.
396 % \begin{macrocode}
397 \DeclareOption{draft}{\bool_gset_true:N \g_prelim_draft_bool}
398 \DeclareOption{final}{\bool_gset_false:N \g_prelim_draft_bool}
399 % \end{macrocode}
400 %
401 %
402 % ^^A -----------------------------
403 %
404 % \subsubsection{Language options}
405 % ^^A
406 % \option{danish}, \option{english}, \option{french}, \option{german},
407 % \option{italian} and \option{norsk} control the content of \cs{PrelimWords}.
408 % \changes{v1.20}{1997/05/12}{\option{french} option added}
409 % \changes{v1.23}{2001/02/17}{\option{danish} option added}
410 % \changes{v1.23}{2001/02/17}{\option{italian} option added}
411 % \changes{v1.3}{2009/05/29}{\option{norsk} option added}
412 % \begin{macrocode}
413 \DeclareOption{danish}{%
414 \renewcommand{\PrelimWords}{Forel\o{}big~version}}
415 \DeclareOption{english}{%
416 \renewcommand{\PrelimWords}{Preliminary~version}}
417 \DeclareOption{french}{%
418 \renewcommand{\PrelimWords}{Version~pr\'eliminaire}}
419 \DeclareOption{german}{%
420 \renewcommand{\PrelimWords}{Vorl\"aufige~Version}}
421 \DeclareOption{italian}{%
422 \renewcommand{\PrelimWords}{Versione~preliminare}}
423 \DeclareOption{norsk}{%
424 \renewcommand{\PrelimWords}{Forel\o{}pig~versjon}}
425 % \end{macrocode}
426 %
427 %
428 % ^^A -----------------------------
429 %
430 % \subsubsection{Time options}
431 % ^^A
432 % \changes{v1.10}{1996/01/01}{\option{time} option added}
433 % \option{time} controls the output of the current time at
434 % \cs{PrelimWords}.
435 % \begin{macrocode}
436 \DeclareOption{time}{\@prelim@timetrue}
437 % \end{macrocode}
438 %
439 % \changes{v1.20}{1997/05/12}{\option{scrtime} option added}
440 % \option{scrtime} controls the loading of the \package{scrtime}
441 % package.
442 % It implies \option{time}.
443 % \begin{macrocode}
444 \DeclareOption{scrtime}{
445 \bool_gset_true:N \g_prelim_scrtime_bool
446 \bool_gset_true:N \g_prelim_time_bool
447 }
448 % \end{macrocode}
449 %
450 %
451 % ^^A -----------------------------
452 %
453 % \subsubsection{Other options}
454 % ^^A
455 % \changes{v1.20}{1997/05/12}{check \cs{if@prelim@scrtime}}
456 % \changes{v1.10}{1996/01/01}{\cs{DeclareOption*} added}
457 % All unused options are passed to the \package{scrtime} package if
458 % the \option{scrtime} option is selected.
459 % \begin{macrocode}
460 \DeclareOption*{%
461 \bool_if:NT \g_prelim_scrtime_bool {
462 \PassOptionsToPackage{\CurrentOption}{scrtime}%
463 }
464 }
465 % \end{macrocode}
466 %
467 %
468 % ^^A -----------------------------
469 %
470 % \subsection{Executing options}
471 % ^^A
472 % The default options are \option{draft} and \option{english}.
473 % \begin{macrocode}
474 \ExecuteOptions{draft,english}
475 \ProcessOptions\relax
476 % \end{macrocode}
477 %
478 %
479 % ^^A -----------------------------
480 %
481 % \subsection{Loading packages}
482 % ^^A
483 % \changes{v1.20}{1997/05/12}{check \cs{if@prelim@scrtime}}
484 % \changes{v2.00}{2020/11/24}{remove \package{everyshi}}
485 % We need the \package{scrtime} package if the \option{scrtime} option is specified.
486 % \begin{macrocode}
487 \bool_if:NT \g_prelim_scrtime_bool {
488 \RequirePackage{scrtime}
489 }
490 % \end{macrocode}
491 %
492 %
493 % ^^A -----------------------------
494 %
495 % \subsection{Producing the text}
496 % ^^A
497 % \begin{macro}{\PrelimText}
498 % \changes{v1.10}{1996/01/01}{\cs{thistime} instead of \cs{PrintTime}}
499 % \cs{PrelimText} produces the text which is put below the page.
500 % It can be changed via \cs{renewcommand}.
501 % The style of the text is controlled by \cs{PrelimTextStyle}.
502 % We first have to reset the style and size, otherwise the settings in
503 % effect at the point of text where \cs{ouput} is called would be used.
504 % \begin{macrocode}
505 \newcommand{\PrelimText}{
506 \textnormal{
507 \footnotesize
508 \PrelimTextStyle
509 \PrelimWords{}~--~\today~
510 \bool_if:NT \g_prelim_time_bool {
511 \ --~
512 \thistime~
513 }
514 }
515 }
516 % \end{macrocode}
517 % \end{macro}
518 % \begin{macro}{\PrelimTextStyle}
519 % \cs{PrelimTextStyle} controls the style of the text produced by
520 % \cs{PrelimText}.
521 % It's default is empty.
522 % \begin{macrocode}
523 \newcommand{\PrelimTextStyle}{}
524 % \end{macrocode}
525 % \end{macro}
526 %
527 %
528 % ^^A -----------------------------
529 %
530 % \subsection{Putting the text below the page}
531 % ^^A
532 % \changes{v2.00}{2020/11/24}{Use \LaTeX{} kernel method instead of everyshi}
533 % We put the text below the page via \cs{AddtoHook{shipout/foreground}}.
534 % This is done by \cs{\__prelim_every_shipout:}.
535 %
536 % Save the shipout origins to macros to adjust the position of the the
537 % PrelimText similar to the older versions of prelim2e.
538 % \begin{macrocode}
539 \tl_const:Nx \c__prelim_horigin_tl {
540 \tl_if_exist:NTF \c__shipout_horigin_tl {
541 \c__shipout_horigin_tl
542 } {
543 1in
544 }
545 }
546
547 \tl_const:Nx \c__prelim_vorigin_tl {
548 \tl_if_exist:NTF \c__shipout_vorigin_tl {
549 \c__shipout_vorigin_tl
550 } {
551 1in
552 }
553 }
554
555 % \end{macrocode}
556 % \begin{function}{\__prelim_every_shipout:}
557 % \changes{v1.10}{1996/01/01}{\cs{hbox to}$\rightarrow$\cs{hb@xt@}}
558 % \changes{v1.24}{2004/03/28}{Bugfix: Add missing \%.
559 % Bug reported by Carsten Heinz (\texttt{[email protected]}).}
560 % \cs{@Prelim@EveryShipout} puts the text produced by \cs{PrelimText}
561 % below the page. We do this using expl3-Syntax to directly access the measures of
562 % the shipout box.
563 % \begin{macrocode}
564 \cs_new:Nn \__prelim_every_shipout: {
565 % \end{macrocode}
566 % We calculate the text position to match the implementation for versions before 2.0.
567 % \begin{macrocode}
568 \put(\c__shipout_horigin_tl,\dim_eval:n {
569 -\c__shipout_vorigin_tl-\l_shipout_box_ht_plus_dp_dim-\topskip
570 })
571 {
572 \vbox_to_ht:nn {0pt} {
573 \hbox_to_wd:nn {\l_shipout_box_wd_dim} {
574 \let\protect\relax
575 \hfill\PrelimText\hfill
576 }
577 }
578 }
579 }
580 % \end{macrocode}
581 % \end{function}
582 %
583 %
584 % ^^A -----------------------------
585 %
586 % \subsection{Tieing \package{prelim2e} into the system}
587 % ^^A
588 % \cs{@Prelim@EveryShipout} is tied into the system using the
589 % kernel's hook management.
590 % But only if the \option{draft} option is used.
591 % \begin{macrocode}
592 \bool_if:NT \g_prelim_draft_bool {
593 \AddToHook{shipout/foreground}{\__prelim_every_shipout:}
594 }
595 % \end{macrocode}
596 %
597 % \begin{macrocode}
598 %</package>
599 % \end{macrocode}
600 %
601 %
602 % ^^A -----------------------------
603 %
604 % \Finale
605 % ^^A