Debian Codegraph @

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

raw
1 %% \iffalse meta-comment
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % Copyright (C) Martin Schröder, 1996–2019
5 % Marei Peischl (peiTeX) <[email protected]>, 2021–2023
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either version 1.3c
9 % of this license or (at your option) any later version.
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.
14 %
15 % This work has the LPPL maintenance status `maintained'.
16 %
17 % The Current Maintainer of this work is
18 % Marei Peischl <[email protected]>.
19 %
20 %
21 % This work consists of the files
22 % README.md
23 % ragged2e.dtx
24 % ragged2e.ins
25 % and the derived file
26 % ragged2e.sty.
27 %
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29 %
30 % \fi
31 % \iffalse
32 \NeedsTeXFormat{LaTeX2e}[2021/06/01]
33 %<package>\ProvidesPackage{ragged2e}
34 %<package> [2023/06/22 v3.6 ragged2e Package]
35 %
36 %<*driver>
37 \documentclass[a4paper]{ltxdoc}
38 \usepackage[T1]{fontenc}
39 \usepackage{lmodern}
40 \usepackage{microtype}
41 \usepackage{url}
42 \usepackage{array}
43 \usepackage{tabularx}
44 \makeatletter
45 \IfFileExists{gitHeadInfo.gin}{
46 \newcommand*{\GI@githeadinfo@file}{gitHeadInfo.gin}
47 }{}
48 \makeatother
49 \usepackage{gitinfo2}
50 \usepackage{geometry}
51 \usepackage{booktabs}
52 \usepackage[document]{ragged2e}
53 \usepackage{hyperref}
54 \setlength{\RaggedRightRightskip}{0pt plus 4em}%
55 \GetFileInfo{ragged2e.sty}
56 \EnableCrossrefs
57 \RecordChanges % Gather update information
58 %%\DisableCrossrefs% Say \DisableCrossrefs if index is ready
59 \CodelineIndex % Index code by line number
60 %\OnlyDescription % comment out for implementation details
61 %%\OldMakeIndex % use if your MakeIndex is pre-v2.9
62 \setcounter{IndexColumns}{2}
63 % onecolumn glossary
64 \makeatletter
65 \renewenvironment{theglossary}{%
66 \glossary@prologue
67 \setlength\emergencystretch{5em}
68 \GlossaryParms \let\item\@idxitem \ignorespaces}{}
69 \makeatother
70 \setlength{\IndexMin}{40ex}
71 \setlength{\columnseprule}{.4pt}
72 \addtolength{\oddsidemargin}{3cm}
73 \addtolength{\textwidth}{-3cm}
74 \begin{document}
75 \DocInput{ragged2e.dtx}
76 \PrintIndex\PrintChanges
77 % Make sure that the index is not printed twice
78 % (ltxdoc.cfg might have a second \PrintIndex command)
79 \let\PrintChanges\relax
80 \let\PrintIndex\relax
81 \end{document}
82 %</driver>
83 % \fi
84 % \CheckSum{532}
85 %
86 %% \CharacterTable
87 %% {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
88 %% 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
89 %% Digits \0\1\2\3\4\5\6\7\8\9
90 %% Exclamation \! Double quote \" Hash (number) \#
91 %% Dollar \$ Percent \% Ampersand \&
92 %% Acute accent \' Left paren \( Right paren \)
93 %% Asterisk \* Plus \+ Comma \,
94 %% Minus \- Point \. Solidus \/
95 %% Colon \: Semicolon \; Less than \<
96 %% Equals \= Greater than \> Question mark \?
97 %% Commercial at \@ Left bracket \[ Backslash \\
98 %% Right bracket \] Circumflex \^ Underscore \_
99 %% Grave accent \` Left brace \{ Vertical bar \|
100 %% Right brace \} Tilde \~}
101 %%
102 % \pagestyle{headings}
103 %
104 % \newcommand*{\file}[1] {\texttt{#1}}
105 % \newcommand{\plain} {\texttt{plain}}
106 % \newcommand{\bs} {\texttt{\symbol{'134}}}
107 % \newcommand*{\env}[1] {\textsf{#1}}
108 % \newcommand*{\option}[1] {\textsf{#1}}
109 % \newcommand*{\package}[1] {\textsf{#1}}
110 % \newcommand*{\NEWfeature}[1]{%
111 % \hskip 1sp \marginpar{\small\sffamily\raggedright
112 % New feature\\#1}}
113 % \newcommand*{\NEWdescription}[1]{%
114 % \hskip 1sp \marginpar{\small\sffamily\raggedright
115 % New description\\#1}}
116 %
117 % \changes{v1.00}{1996/05/30}{New from \package{raggedright} V 1.21}
118 % \changes{v1.01}{1998/08/09}{Documentation improved}
119 % \changes{v1.02}{1999/06/08}{Moved to LPPL}
120 % \changes{v2.00}{2003/01/04}{Incorporated \package{raggedr}}
121 % \changes{v2.2}{2019/03/26}{Require a new version of \LaTeX (2017/03/29)}
122 %
123 % \hyphenation{flush-left rag-ged rag-ged-right}
124 %
125 % \newenvironment{Quote}{^^A
126 % \begin{quote}^^A
127 % \small^^A
128 % \fussy^^A
129 % }{^^A
130 % \end{quote}^^A
131 % }
132 %
133 % \renewcommand{\thefootnote}{\ensuremath{\fnsymbol{footnote}}}
134 %
135 % ^^A -----------------------------
136 %
137 % \changes{v2.2}{2019/03/26}{Move to git/gitlab, use \package{svninfo2}}
138 %
139 % \title{\unskip
140 % The \textsf{ragged2e}-package^^A
141 % \thanks{^^A
142 % The version number of this file is \fileversion,
143 % revision~\#\gitAbbrevHash, last revised \protect\gitAuthorIsoDate.}^^A
144 % }
145 % \author{Martin Schröder\\\url{https://gitlab.com/TeXhackse/ragged2e}\thanks{maintained by Marei Peischl}}
146 % \date{\filedate}
147 % \maketitle
148 %
149 % ^^A -----------------------------
150 %
151 % \begin{abstract}
152 % This package provides new commands and environments for setting
153 % ragged text which are easy to configure to allow hyphenation.
154 % An earlier attempt to do this was the style
155 % \package{raggedright}\,\cite{raggedri} by the same author.
156 % \end{abstract}
157 %
158 %
159 % ^^A -----------------------------
160 %
161 % \tableofcontents
162 %
163 % ^^A -----------------------------
164 %
165 % \begin{multicols}{2}
166 % \fussy
167 %
168 % \setlength{\parskip}{^^A
169 % .3\baselineskip plus.05\baselineskip minus.05\baselineskip}
170 %
171 % \changes{v2.2}{2019/07/28}{Change maintenance status of package}
172 % \changes{v3.0}{2021/02/05}{Change maintenance status}
173 % \section{The problem}
174 % ^^A
175 % \LaTeX{} has three commands (\cs{centering}, \cs{raggedleft}, and
176 % \cs{raggedright}) and three environments (\env{center},
177 % \env{flushleft}, and \env{flushright}) to typeset ragged text.
178 % The environments are based upon the commands (\env{center} uses
179 % \cs{centering}, \env{flushleft} \cs{raggedright}, and
180 % \env{flushright} \cs{raggedleft}).
181 %
182 % These commands have, however, one serious flaw: they render
183 % hyphenation almost impossible, and thus the text looks \emph{too}
184 % ragged, as the following example shows:
185 % \setcounter{unbalance}{2}
186 % \begin{multicols}{2}
187 % \small\fussy
188 % \raggedright
189 % \cs{raggedright}:\\
190 % ``The \LaTeX{} document preparation system is a special version
191 % of Donald Knuth's \TeX{} program.
192 % \TeX{} is a sophisticated program designed to produce
193 % high-quality typesetting, especially for mathematical text.''
194 % \cite[p\@. xiii]{lamport86}
195 %
196 % \newpage
197 % \RaggedRight
198 % \cs{RaggedRight}:\\
199 % ``The \LaTeX{} document preparation system is a special version
200 % of Donald Knuth's \TeX{} program.
201 % \TeX{} is a sophisticated program designed to produce
202 % high-quality typesetting, especially for mathematical text.''
203 % \cite[p\@. xiii]{lamport86}
204 % \end{multicols}
205 %
206 % \setcounter{unbalance}{0}
207 %
208 % ^^A -----------------------------
209 %
210 % \section{Old ``solutions''}
211 %
212 % ^^A -----------------------------
213 %
214 % \subsection{\LaTeX}
215 % ^^A
216 % \LaTeX{} defines e.\,g.\ \cs{raggedright} as follows:
217 % \changes{v3.1}{2021/12/15}{Use the updated definition of \cs{raggedright}}
218 % \begin{macrocode}
219 %<*latex>
220 \DeclareRobustCommand
221 \raggedright{%
222 \let\\\@centercr
223 \@rightskip\@flushglue
224 \rightskip\@rightskip
225 \finalhyphendemerits=\z@
226 \leftskip\z@skip
227 \parindent\z@}
228 % \end{macrocode}
229 % Initially, \cs{@flushglue} is defined as
230 % \begin{macrocode}
231 \@flushglue = 0pt plus 1fil
232 %</latex>
233 % \end{macrocode}
234 %
235 % Thus the \cs{rightskip} is set to |0pt plus 1fil|.
236 % Knuth, however warns \cite[p\@. 101]{KnuthTeXa}:
237 % \begin{Quote}
238 % ``For example, a person can set \cs{rightskip=0pt plus 1fil},
239 % and every line will be filled with space to the right.
240 % But this isn't a particularly good way to make ragged-right
241 % margins, because the infinte stretchability will assign zero
242 % badness to lines that are very short.
243 % To do a decent job of ragged-right setting, the trick is to set
244 % \cs{rightskip} so that it will stretch enough to make line breaks
245 % possible, yet not too much, because short lines should be
246 % considered bad.
247 % Furthermore the spaces between words should be fixed so that
248 % they do not stretch or shrink.''
249 % \end{Quote}
250 %
251 % ^^A -----------------------------
252 %
253 % \subsection{\plain{}}
254 % ^^A
255 % \plain{} \TeX{} defines an special version of
256 % \cs{raggedright}, which operates the way Knuth describes it;
257 % but which can not be used whith \LaTeX, because \LaTeX{} redefines
258 % \cs{raggedright}.
259 % \begin{macrocode}
260 %<*plain>
261 \def\raggedright{%
262 \rightskip\z@ plus2em
263 \spaceskip.3333em
264 \xspaceskip.5em\relax}
265 % \end{macrocode}
266 %
267 % \plain{} provides also a version of \cs{raggedright} for typewriter
268 % fonts
269 % \begin{macrocode}
270 \def\ttraggedright{%
271 \tt
272 \rightskip\z@ plus2em\relax}
273 %</plain>
274 % \end{macrocode}
275 %
276 % \end{multicols}
277 % \setlength{\parskip}{^^A
278 % .3\baselineskip plus.05\baselineskip minus.05\baselineskip}
279 %
280 % ^^A -----------------------------
281 %
282 % \section{Our solution}
283 %
284 % Since the \plain{} solution can not be used with \LaTeX, we have to
285 % redefine it and make it possible to configure it for personal
286 % preferences.
287 %
288 % ^^A -----------------------------
289 %
290 % \subsection{The macros}
291 % ^^A
292 % \DescribeMacro{\Centering}
293 % \DescribeMacro{\RaggedLeft}
294 % \DescribeMacro{\RaggedRight}
295 % \cs{Centering}, \cs{RaggedLeft}, and \cs{RaggedRight} can be used in
296 % the same way as \cs{centering}, \cs{raggedleft}, and
297 % \cs{raggedright}:
298 % Just type the command, and after that the whole text will be set
299 % centered, ragged-left or ragged-right.
300 %
301 % For example, we switched on \cs{RaggedRight} on the top of this
302 % text, and consequently this text was set
303 % ragged-right.\footnote{^^A
304 % For this documentation we also set \cs{RaggedRightRightskip}
305 % higher than usual (|0pt plus 4em| instead of |0pt plus 2em|)
306 % because of all the long command names which make linebreaking
307 % difficult.}
308 %
309 % \DescribeMacro{\justifying}
310 % \NEWfeature{2003/01/04}%
311 % \cs{justifying} switches back to justified text after ragged text
312 % has been switched on.
313 % \changes{v2.00}{2003/01/04}{New command \cs{justifying}}
314 %
315 % The new commands \cs{Centering}, \cs{RaggedLeft}, and
316 % \cs{RaggedRight} are fully compatible with their counterparts in
317 % \LaTeX, but implement the \plain{} solution and can be easily
318 % configured using the following parameters:
319 %
320 % ^^A -----------------------------
321 %
322 % \subsection{The parameters}
323 % ^^A
324 % \changes{v2.00}{2003/01/25}{Removed \cs{RaggedSpaceskip} and
325 % \cs{RaggedXSpaceskip}}%
326 % \begin{tabularx}{\linewidth}{lX}\toprule
327 % Command & Uses\tabularnewline \midrule
328 % \cs{Centering} & \cs{CenteringLeftskip},
329 % \cs{CenteringRightskip},
330 % \cs{CenteringParfillskip},
331 % \cs{CenteringParindent}
332 % \tabularnewline
333 % \cs{RaggedLeft} & \cs{RaggedLeftLeftskip},
334 % \cs{RaggedLeftRightskip},
335 % \cs{RaggedLeftParfillskip},
336 % \cs{RaggedLeftParindent}
337 % \tabularnewline
338 % \cs{RaggedRight} & \cs{RaggedRightLeftskip},
339 % \cs{RaggedRightRightskip},
340 % \cs{RaggedRightParfillskip},
341 % \cs{RaggedRightParindent}
342 % \tabularnewline
343 % \cs{justifying} & \cs{JustifyingParfillskip},
344 % \cs{JustifyingParindent}
345 % \tabularnewline
346 % \bottomrule
347 % \end{tabularx}
348 %
349 % All Parameters can be set with \cs{setlength}, e.\,g.\
350 % \begin{Quote}
351 % |\setlength{\RaggedRightRightskip}{0pt plus 1em}|
352 % \end{Quote}
353 % sets \cs{RaggedRightRightskip} to |0pt plus 1em|.
354 %
355 % \DescribeMacro{\CenteringLeftskip}
356 % \DescribeMacro{\RaggedLeftLeftskip}
357 % \DescribeMacro{\RaggedRightLeftskip}
358 % These are the \cs{leftskip}s inserted by \cs{Centering},
359 % \cs{RaggedLeft}, and \cs{RaggedRight}.
360 % \begin{Quote}
361 % \setlength{\tabcolsep}{.25em}
362 % \begin{tabularx}{\linewidth}{lX}
363 % ``\cs{leftskip} & (glue at left of justified lines)''
364 % \cite[p.~274]{KnuthTeXa}
365 % \end{tabularx}
366 % \end{Quote}
367 % \cs{leftskip} must be set to a finite value, to make hyphenation
368 % possible.
369 % Setting it to infinite values like |0pt plus 1fil| makes
370 % hyphenation almost impossible.
371 %
372 % \DescribeMacro{\CenteringRightskip}
373 % \DescribeMacro{\RaggedLeftRightskip}
374 % \DescribeMacro{\RaggedRightRightskip}
375 % These are the \cs{rightskip}s inserted by \cs{Centering},
376 % \cs{RaggedLeft}, and \cs{RaggedRight}.
377 % \begin{Quote}
378 % \setlength{\tabcolsep}{.25em}
379 % \begin{tabularx}{\linewidth}{lX}
380 % ``\cs{rightskip} & (glue at right of justified lines)''
381 % \cite[p.~274]{KnuthTeXa}
382 % \end{tabularx}
383 % \end{Quote}
384 % \cs{rightskip} must be set to a finite value, to make hyphenation
385 % possible.
386 % Setting it to infinite values like |0pt plus 1fil| makes
387 % hyphenation almost impossible.
388 %
389 % \DescribeMacro{\CenteringParfillskip}
390 % \DescribeMacro{\RaggedLeftParfillskip}
391 % \DescribeMacro{\RaggedRightParfillskip}
392 % \DescribeMacro{\JustifyingParfillskip}
393 % These are the \cs{parfillskip}s inserted by \cs{Centering},
394 % \cs{RaggedLeft}, \cs{RaggedRight}, and \cs{justifying}.
395 % \begin{Quote}
396 % \setlength{\tabcolsep}{.25em}
397 % \begin{tabularx}{\linewidth}{lX}
398 % ``\cs{parfillskip} & (additional \cs{rightskip} at end of paragraphs)''
399 % \cite[p.~274]{KnuthTeXa}
400 % \end{tabularx}
401 % \end{Quote}
402 % The normal setting for \cs{parfillskip} is |0pt plus 1fil|; the
403 % parameters are provided for testing combinations of
404 % \cs{}\{|left|$\mid$|right|\}|skip| and \cs{parfillskip}.
405 %
406 % \DescribeMacro{\CenteringParindent}
407 % \DescribeMacro{\RaggedLeftParindent}
408 % \DescribeMacro{\RaggedRightParindent}
409 % \DescribeMacro{\JustifyingParindent}
410 % These are the \cs{parindent}s used by \cs{Centering},
411 % \cs{RaggedLeft}, \cs{RaggedRight}, and \cs{justifying}.
412 % \begin{Quote}
413 % \setlength{\tabcolsep}{.25em}
414 % \begin{tabularx}{\linewidth}{lX}
415 % ``\cs{parindent} & (width of \cs{indent})''
416 % \cite[p.~274]{KnuthTeXa}
417 % \end{tabularx}
418 % \end{Quote}
419 % \cs{parindent} is the indent of the first line of a paragraph and
420 % should be set to |0pt|, since indented lines in ragged text
421 % do not look good.
422 %
423 % The parameters have the following initial setting:
424 % \begin{center}
425 % \begin{tabularx}{\linewidth}{l>{\ttfamily}X>{\ttfamily}X}\toprule
426 % Parameter & \normalfont\LaTeX{} setting
427 % & \normalfont\package{ragged2e} setting\footnotemark\\
428 % \midrule
429 % \cs{CenteringLeftskip} & 0pt plus 1fil
430 % & 0pt plus 2em\\
431 % \cs{RaggedLeftLeftskip} & 0pt plus 1fil
432 % & 0pt plus 2em\\
433 % \cs{RaggedRightLeftskip} & 0pt plus 0pt minus 0pt
434 % & 0pt plus 0pt minus 0pt\\
435 % \cs{CenteringRightskip} & 0pt plus 1fil
436 % & 0pt plus 2em\\
437 % \cs{RaggedLeftRightskip} & 0pt plus 0pt minus 0pt
438 % & 0pt plus 0pt minus 0pt \\
439 % \cs{RaggedRightRightskip} & 0pt plus 1fil
440 % & 0pt plus 2em\\
441 % \cs{CenteringParfillskip} & 0pt plus 0pt minus 0pt
442 % & 0pt plus 0pt minus 0pt \\
443 % \cs{RaggedLeftParfillskip} & 0pt plus 0pt minus 0pt
444 % & 0pt plus 0pt minus 0pt \\
445 % \cs{RaggedRightParfillskip}& 0pt plus 1fil
446 % & 0pt plus 1fil\\
447 % \cs{CenteringParindent} & 0pt
448 % & 0pt \\
449 % \cs{RaggedLeftParindent} & 0pt
450 % & 0pt \\
451 % \cs{RaggedRightParindent} & 0pt
452 % & 0pt \\
453 % \cs{JustifyingParfillskip} &
454 % & 0pt plus 1fil \tabularnewline
455 % \cs{JustifyingParindent} &
456 % & \cs{parindent} \tabularnewline
457 % \bottomrule
458 % \end{tabularx}
459 % \end{center}
460 % \footnotetext{^^A
461 % For proportional and monospaced fonts.}
462 %
463 % ^^A -----------------------------
464 %
465 % \subsection{The environments}
466 % ^^A
467 % \DescribeEnv{Center}
468 % \env{Center} is fully compatible with \env{center}, but uses
469 % \cs{Centering} instead of \cs{centering}.
470 %
471 % \DescribeEnv{FlushLeft}
472 % \env{FlushLeft} is fully compatible with \env{flushleft}, but uses
473 % \cs{RaggedRight} instead of \cs{raggedright}.
474 %
475 % \DescribeEnv{FlushRight}
476 % \env{FlushRight} is fully compatible with \env{flushright}, but uses
477 % \cs{RaggedLeft} instead of \cs{raggedleft}.
478 %
479 % \DescribeEnv{justify}
480 % \NEWfeature{2003/01/04}%
481 % \env{justify} is like the other environments but uses \cs{justifying}.
482 % \changes{v2.00}{2003/01/04}{New environment \env{justify}}
483 %
484 % E.\,g.\ \env{FlushLeft} can be used in the same way as
485 % \env{flushleft}:
486 % \begin{verse}
487 % \small
488 % |\begin{FlushLeft}|\\
489 % \meta{text, which is set ragged-right}\\
490 % |\end{FlushLeft}|
491 % \end{verse}
492 %
493 % ^^A -----------------------------
494 %
495 % \section{Options}
496 % ^^A
497 % This package has the following options:
498 % \changes{v2.00}{2003/01/04}{Allow all-lowercase versions of
499 % options and removed documentation of
500 % mixed-case versions.}
501 % \nopagebreak
502 % \begin{description}
503 % \item[\normalfont\option{originalcommands}]
504 % The \LaTeX-commands \cs{centering}, \cs{raggedleft}, and
505 % \cs{raggedright} and the \LaTeX-environments \env{center},
506 % \env{flushleft}, and \env{flushright} remain unchanged.\newline
507 % It is the default.
508 % \item[\normalfont\option{newcommands}]
509 % The \LaTeX-commands \cs{centering}, \cs{raggedleft}, and
510 % \cs{raggedright} and the \LaTeX-environments \env{center},
511 % \env{flushleft}, and \env{flushright} are set equal to their
512 % counterparts defined by \package{ragged2e}.
513 % Thus \cs{raggedright} invokes \cs{RaggedRight}.
514 % The original commands can be accessed unter the Names
515 % \cs{LaTeX}\meta{original name}, e.\,g.\ \cs{LaTeXraggedright}.
516 % \item[\normalfont\option{originalparameters}]
517 % The parameters used by the commands implemented by
518 % \package{ragged2e} are initialized with the default settings
519 % used by \LaTeX.
520 % \item[\normalfont\option{newparameters}]
521 % The parameters used by the commands implemented by
522 % \package{ragged2e} are initialized with the default settings
523 % defined by \package{ragged2e}.\newline
524 % It is the default.
525 % \item[\normalfont\option{raggedrightboxes}]
526 % \changes{v2.00}{2003/01/04}{New option \option{raggedrightboxes}}
527 % \NEWfeature{2003/01/18}
528 % All \cs{parbox}es, \env{minipage}s, \cs{marginpar}s and
529 % |p|-columns of \env{tabular}s and \env{array}s are
530 % automatically set using \cs{RaggedRight}.
531 % \item[\normalfont\option{footnotes}]
532 % \changes{v2.00}{2003/01/18}{New option \option{footnotes}}
533 % \NEWfeature{2003/01/18}
534 % This options sets all footnotes ragged-right by loading the
535 % \package{footmisc}\,\cite{footmisc} package with the
536 % \option{ragged} option.
537 % \item[\normalfont\option{document}]
538 % \changes{v2.00}{2003/01/18}{New option \option{document}}
539 % \NEWfeature{2003/01/18}
540 % This options sets the complete document ragged-right by
541 % executing a \cs{RaggedRight} at \cs{begin\{document\}} and
542 % the \option{raggedrightboxes} and the \option{footnotes}
543 % options.
544 % \end{description}
545 % All other options are passed to the \package{footmisc} package if
546 % the \option{footnotes} option is selected.
547 %
548 %
549 % ^^A -----------------------------
550 %
551 % \section{Required packages}
552 % ^^A
553 % \changes{v2.1}{2003/10/08}{document that \option{document} needs
554 % \package{footmisc}}
555 % \changes{v3.0}{2021/02/05}{document everysel is obsolete}
556 % This package requires the following packages:
557 % \begin{description}
558 % \item[\normalfont\package{everysel}\,\cite{everysel}](only if format older than 2021/01/05)
559 % It has been used to distinguish between monospaced and proportional
560 % fonts as long as the LaTeX kernel did not provide the functionality with lthooks \cite{lthooks-doc}.
561 % Formats newer than 2021/01/05 do no longer depend on everysel.
562 % \item[\normalfont\package{footmisc}\,\cite{footmisc}]
563 % It is used by the \option{footnotes} and the
564 % \option{document} options; at least version~5.00 (2002/08/28)
565 % is needed.
566 % \end{description}
567 %
568 %
569 % ^^A -----------------------------
570 %
571 % \StopEventually{^^A
572 %
573 %
574 % ^^A -----------------------------
575 %
576 % \section{Acknowledgements}
577 % ^^A
578 % A first version of this package for \LaTeX2.09 was named
579 % \package{raggedri}\,\cite{raggedri}.
580 % Laurent Siebenmann (\url{[email protected]}) with his
581 % style \package{ragged.sty}\,\cite{ragged} provided the final impulse
582 % for this new implementation.\newline
583 % The code for \cs{justifying}, \env{justify} and the overloading of
584 % \cs{@arrayparboxrestore} is incorporated from the
585 % \package{raggedr}\,\cite{raggedr} package by James Kilfinger
586 % (\url{[email protected]}).\newline
587 % Without the constant nagging of Rainer Sieger
588 % (\url{[email protected]}) this package might not
589 % be.\newline
590 % Markus Kohm (\url{[email protected]}) provided the code for
591 % \cs{@gnewline}.\newline
592 % Frank Mittelbach (\url{[email protected]})
593 % provided the impetus for version~2.00.\newline
594 % Rolf Niepraschk (\url{[email protected]}) and Hubert Gäßlein
595 % found many bugs and provided fixes for them and code for new
596 % features.\newline
597 % Jordan Firth (\url{[email protected]}) provided the final push for
598 % version~2.2.
599 % Maurice Hansen reported and helped testing the fix for the bug adding
600 % an additional parskip fixed in version 3.2.
601 %
602 % ^^A -----------------------------
603 %
604 % \newcommand{\noopsort}[1]{} \newcommand{\printfirst}[2]{##1}
605 % \newcommand{\singleletter}[1]{##1} \newcommand{\switchargs}[2]{##2##1}
606 % \begin{thebibliography}{1}
607 %
608 % \bibitem{ltmiscen}
609 % Johannes Braams, David Carlisle, Alan Jeffrey, Leslie Lamport, Frank
610 % Mittelbach, Chris Rowley, and Rainer Schöpf.
611 % \newblock ltmiscen.dtx.
612 % \newblock Part of the {\LaTeX}-distribution.
613 %
614 % \bibitem{footmisc}
615 % Robin Fairbairns.
616 % \newblock \texttt{footmisc} --- a portmanteau package for
617 % customising footnotes in \LaTeXe.
618 % \newblock \url{https://mirror.ctan.org/macros/latex/contrib/footmisc/}.
619 %
620 % \bibitem{raggedr}
621 % James Kilfiger.
622 % \newblock \url{https://ctan.org/tex-archive/obsolete/macros/latex/contrib/misc/raggedr.sty}.
623 % \newblock \LaTeXe{} package.
624 %
625 % \bibitem{KnuthTeXa}
626 % Donald~E. Knuth.
627 % \newblock \emph{The {\TeX}Book}, volume~A of \emph{Computers \& Typesetting}.
628 % \newblock Ad{\-d}i{\-s}on-Wes{\-l}ey, Reading, MA, USA, {\noopsort{1986a}}1986.
629 %
630 % \bibitem{lamport86}
631 % Leslie Lamport.
632 % \newblock \emph{\LaTeX: A Document Preparation System}.
633 % \newblock Ad{\-d}i{\-s}on-Wes{\-l}ey, Reading, MA, USA, first edition, 1986.
634 %
635 % \bibitem{lthooks-doc}
636 % Frank Mittelbach.
637 % \newblock The \package{lthooks} package.
638 % \newblock \url{http://mirrors.ctan.org/macros/latex/base/lthooks-doc.pdf}
639 %
640 % \bibitem{cmfonts}
641 % Frank Mittelbach and Rainer Schöpf.
642 % \newblock The file {\texttt{cmfonts.fdd}} for use with {\LaTeXe}.
643 % \newblock Part of the {\LaTeX}-distribution.
644 %
645 % \bibitem{everysel}
646 % Martin Schröder.
647 % \newblock The obsolete \package{everysel}-package.
648 % \newblock \url{http://mirrors.ctan.org/macros/latex/contrib/everysel/everysel.pdf}.
649 % \newblock \LaTeXe{} package.
650 %
651 % \bibitem{raggedri}
652 % Martin Schröder.
653 % \newblock The \package{raggedri} document option.
654 % \newblock Was in \url{http://mirrors.ctan.org/tex-archive/macros/latex209/contrib/raggedright}.
655 % \newblock \LaTeX2.09 style, outdated.
656 %
657 % \bibitem{ragged}
658 % Laurent Siebenmann.
659 % \newblock \texttt{ragged.sty}.
660 % \newblock \url{CTAN: tex-archive/macros/generic/ragged.sty}.
661 % \newblock generic macro file for \texttt{plain} and \LaTeX.
662 %
663 % \end{thebibliography}
664 % }
665 %
666 % ^^A -----------------------------
667 %
668 % \section{The implementation}
669 % \changes{v2.00}{2003/01/10}{Removed spaces and unneeded braces
670 % from \cs{setlength}; replaced
671 % \texttt{plus} with \cs{@plus}}
672 % \changes{v2.02}{2003/02/24}{Removed \cs{setlength}}
673 % \changes{v2.02}{2003/02/24}{Use \cs{@flushglue}}
674 %
675 % \begin{macrocode}
676 %<*package>
677 % \end{macrocode}
678 %
679 %
680 % ^^A -----------------------------
681 %
682 % \subsection{Initial Code}
683 % ^^A
684 % \begin{macro}{\if@raggedtwoe@originalcommands}
685 % \cs{if@raggedtwoe@originalcommands} is used to flag the use of the
686 % \option{originalcommands} or \option{newcommands} option.
687 % \begin{macrocode}
688 \newif\if@raggedtwoe@originalcommands
689 % \end{macrocode}
690 % \end{macro}
691 %
692 % \begin{macro}{\if@raggedtwoe@originalparameters}
693 % \cs{if@raggedtwoe@originalparameters} is used to flag the use of the
694 % \option{originalparameters} or \option{newparameters} option.
695 % \begin{macrocode}
696 \newif\if@raggedtwoe@originalparameters
697 % \end{macrocode}
698 % \end{macro}
699 %
700 % \begin{macro}{\if@raggedtwoe@footmisc}
701 % \cs{if@raggedtwoe@footmisc} is used to flag the use of the
702 % \option{footnotes} option.
703 % \changes{v2.00}{2003/01/18}{New macro}%
704 % \begin{macrocode}
705 \newif\if@raggedtwoe@footmisc
706 % \end{macrocode}
707 % \end{macro}
708 %
709 %
710 % ^^A -----------------------------
711 %
712 % \subsection{Declaration of options}
713 %
714 %
715 % ^^A -----------------------------
716 %
717 % \subsubsection{\option{originalcommands} option}
718 % ^^A
719 % The \option{originalcommands} and \option{newcommands} options
720 % control the meaning of the \LaTeX-commands for ragged text:
721 % If \option{newcommands} is used the \LaTeX-commands are set equal
722 % to the commands defined by \package{ragged2e}.
723 % \changes{v2.00}{2003/01/04}{Allow all-lowercase versions of options}
724 % \begin{macrocode}
725 \DeclareOption{OriginalCommands}{\@raggedtwoe@originalcommandstrue}
726 \DeclareOption{originalcommands}{\@raggedtwoe@originalcommandstrue}
727 \DeclareOption{NewCommands}{\@raggedtwoe@originalcommandsfalse}
728 \DeclareOption{newcommands}{\@raggedtwoe@originalcommandsfalse}
729 % \end{macrocode}
730 %
731 %
732 % ^^A -----------------------------
733 %
734 % \subsubsection{\option{originalparameters} option}
735 % ^^A
736 % The \option{originalparameters} and \option{newparameters} options
737 % control the defaults for the parameters used by the commands
738 % implemented by \package{ragged2e}:
739 % If \option{newparameters} is used the parameters are set to the
740 % values defined by \package{ragged2e}.
741 % \changes{v2.00}{2003/01/04}{Allow all-lowercase versions of options}
742 % \begin{macrocode}
743 \DeclareOption{OriginalParameters}{\@raggedtwoe@originalparameterstrue}
744 \DeclareOption{originalparameters}{\@raggedtwoe@originalparameterstrue}
745 \DeclareOption{NewParameters}{\@raggedtwoe@originalparametersfalse}
746 \DeclareOption{newparameters}{\@raggedtwoe@originalparametersfalse}
747 % \end{macrocode}
748 %
749 %
750 % ^^A -----------------------------
751 %
752 % \subsubsection{\option{raggedrightboxes} option}
753 % ^^A
754 % \changes{v2.00}{2003/01/04}{New option \option{raggedrightboxes}}%
755 % The option \option{raggedrightboxes} sets all
756 % \cs{parbox}es, \env{minipage}s, \cs{marginpar}s and |p|-columns of
757 % \env{tabular}s and \env{array}s using \cs{RaggedRight}.
758 % This is done by redefining \cs{@arrayparboxrestore}.
759 % \begin{macro}{\@raggedtwoe@raggedrightboxes@opt}
760 % \cs{@raggedtwoe@raggedrightboxes@opt} is the code executed via
761 % \cs{DeclareOption}.
762 % \changes{v2.00}{2003/01/18}{New macro}%
763 % \changes{v2.2}{2019/03/26}{Definition of \cs{@arrayparboxrestore}
764 % has changed}%
765 % \begin{macrocode}
766 \newcommand*{\@raggedtwoe@raggedrightboxes@opt}{
767 % \end{macrocode}
768 % First we check if \cs{@arrayparboxrestore} is unchanged.
769 % \begin{macrocode}
770 \CheckCommand*{\@arrayparboxrestore}{%
771 \let\if@nobreak\iffalse
772 \let\if@noskipsec\iffalse
773 \let\par\@@par
774 \let\-\@dischyph
775 \let\'\@acci\let\`\@accii\let\=\@acciii
776 \parindent\z@ \parskip\z@skip
777 \everypar{}%
778 \linewidth\hsize
779 \@totalleftmargin\z@
780 \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
781 \parfillskip\@flushglue
782 \lineskip\normallineskip
783 \lineskiplimit\normallineskiplimit
784 \baselineskip\normalbaselineskip
785 \sloppy}%
786 % \end{macrocode}
787 % Then we redefine it by removing the setting of \cs{leftskip},
788 % \cs{rightskip}, \cs{@rightskip} and \cs{parfillskip} and instead
789 % calling \cs{RaggedRight}.
790 % \changes{v2.04}{2003/03/02}{The setting of \cs{parindent} is
791 % superfluous}%
792 % \begin{macrocode}
793 \renewcommand{\@arrayparboxrestore}{%
794 \let\if@nobreak\iffalse
795 \let\if@noskipsec\iffalse
796 \let\par\@@par
797 \let\-\@dischyph
798 \let\'\@acci\let\`\@accii\let\=\@acciii
799 \parskip\z@skip
800 \everypar{}%
801 \linewidth\hsize
802 \@totalleftmargin\z@
803 \RaggedRight
804 \lineskip\normallineskip
805 \baselineskip\normalbaselineskip
806 \lineskiplimit\normallineskiplimit
807 \sloppy}%
808 % \end{macrocode}
809 % Now we self-destroy so the command can be called more than once
810 % without causing harm (and it also frees up some space).
811 % \begin{macrocode}
812 \let\@raggedtwoe@raggedrightboxes@opt\relax
813 }
814 % \end{macrocode}
815 % \end{macro}
816 % Finally the declaration of the option.
817 % \begin{macrocode}
818 \DeclareOption{raggedrightboxes}{\@raggedtwoe@raggedrightboxes@opt}
819 % \end{macrocode}
820 %
821 %
822 % ^^A -----------------------------
823 %
824 % \subsubsection{\option{footnotes} option}
825 % ^^A
826 % \changes{v2.00}{2003/01/18}{New option \option{footnotes}}%
827 % \changes{v2.02}{2003/02/24}{Bugfix: \cs{if@raggedtwoe@footmisctrue}
828 % \ensuremath{\rightarrow} \cs{@raggedtwoe@footmisctrue}}%
829 % \changes{v2.03}{2003/02/26}{Bugfix: \option{footnotes} was actually
830 % \option{raggedrightboxes}}
831 % The option \option{footnotes} just sets a flag
832 % (\cs{if@raggedtwoe@footmisc}) to load the \option{footmisc}
833 % package and passes the option \option{ragged} to it.
834 % \begin{macrocode}
835 \DeclareOption{footnotes}{%
836 \@raggedtwoe@footmisctrue
837 \PassOptionsToPackage{ragged}{footmisc}%
838 }
839 % \end{macrocode}
840 %
841 %
842 % ^^A -----------------------------
843 %
844 % \subsubsection{\option{document} option}
845 % ^^A
846 % \changes{v2.00}{2003/01/18}{New option \option{document}}%
847 % The option \option{document} sets the complete document
848 % ragged-right by executing \cs{RaggedRight} via \cs{AtBeginDocument}
849 % and also executing the \option{raggedrightboxes} option.
850 % \begin{macro}{\@raggedtwoe@abdhook}
851 % \cs{@raggedtwoe@abdhook} is the code executed via
852 % \cs{AtBeginDocument}: Give a message on the terminal, execute
853 % \cs{RaggedRight} and self-destroy.
854 % We also make \cs{@tocrmarg} flexible; otherwise long lines in the
855 % table of contents (and similar tables) would not be broken because
856 % the spaceskip is rigid.
857 % \changes{v2.00}{2003/01/18}{New macro}%
858 % \changes{v2.04}{2003/03/02}{Set \cs{@tocrmarg} and use
859 % \cs{PackageInfo}}%
860 % \changes{v2.1}{2006/07/23}{bugfix: Use \cs{@tocrmarg} only if it's
861 % defined}%
862 % \begin{macrocode}
863 \newcommand{\@raggedtwoe@abdhook}{%
864 \PackageInfo{ragged2e}{ABD: executing \string\RaggedRight}%
865 \RaggedRight
866 \@ifundefined{@tocrmarg}{}{\edef\@tocrmarg{\@tocrmarg plus 2em}}%
867 \let\@raggedtwoe@abdhook\relax
868 }
869 % \end{macrocode}
870 % \end{macro}
871 % \begin{macro}{\@raggedtwoe@document@opt}
872 % \cs{@raggedtwoe@document@opt} is the code executed via
873 % \cs{DeclareOption}: Insert the code into \cs{AtBeginDocument},
874 % execute the \option{raggedrightboxes} and \option{footnotes} options
875 % and self-destroy.
876 % \changes{v2.00}{2003/01/18}{New macro}%
877 % \begin{macrocode}
878 \newcommand{\@raggedtwoe@document@opt}{%
879 \AtBeginDocument{\@raggedtwoe@abdhook}%
880 \@raggedtwoe@raggedrightboxes@opt
881 \@raggedtwoe@footmisctrue
882 \let\@raggedtwoe@document@opt\relax
883 }
884 % \end{macrocode}
885 % \end{macro}
886 % Finally the declaration of the option.
887 % \begin{macrocode}
888 \DeclareOption{document}{\@raggedtwoe@document@opt}
889 % \end{macrocode}
890 %
891 %
892 % ^^A -----------------------------
893 %
894 % \subsubsection{Other options}
895 % ^^A
896 % \changes{v2.00}{2003/01/18}{Pass all other options to
897 % \package{footmisc} if it's loaded}%
898 % All unused options are passed to the \package{footmisc} package if
899 % the \option{footnotes} option is selected; otherwise the usual error
900 % is raised.
901 % \begin{macrocode}
902 \DeclareOption*{%
903 \if@raggedtwoe@footmisc
904 \PassOptionsToPackage{\CurrentOption}{footmisc}%
905 \else
906 \OptionNotUsed
907 \fi
908 }
909 % \end{macrocode}
910 %
911 %
912 %% ^^A -----------------------------
913 %
914 % \subsection{Executing options}
915 % ^^A
916 % The default options are \option{originalcommands} and
917 % \option{newparameters}.
918 % \begin{macrocode}
919 \ExecuteOptions{originalcommands,newparameters}
920 \ProcessOptions\relax
921 % \end{macrocode}
922 %
923 %
924 % ^^A -----------------------------
925 %
926 % \subsection{Loading packages}
927 % ^^A
928 % \changes{v3.00}{2021/02/05}{Remove the \package{everysel} package if kernel hooks are available}
929 % We need the \package{everysel} package for older kernels.
930 % \changes{v2.00}{2003/01/18}{Load the \package{footmisc} package}%
931 % \begin{macrocode}
932 \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
933 \IfFormatAtLeastTF{2021/01/05}{}{\RequirePackage{everysel}}
934 % \end{macrocode}
935 % If the option \option{footnotes} is selected, we load the
936 % \package{footmisc} package after we are finished (\package{footmisc}
937 % detects our presence by looking for the definition of
938 % \cs{RaggedRight}, so we can not load it just now).
939 % \changes{v2.1}{2003/10/08}{bugfix: Load \package{footmisc}
940 % directly and not via \cs{AtEndOfPackage} (bug found by Axel
941 % Sommerfeldt)}
942 % \begin{macrocode}
943 \if@raggedtwoe@footmisc
944 \RequirePackage{footmisc}[2002/08/28]
945 \fi
946 % \end{macrocode}
947 %
948 %
949 % ^^A -----------------------------
950 %
951 % \subsection{Allocations}
952 % ^^A
953 % \changes{v2.00}{2003/01/25}{Removed \cs{RaggedSpaceskip} and
954 % \cs{RaggedXSpaceskip}}%
955 % \begin{macro}{\CenteringLeftskip}
956 % \begin{macro}{\RaggedLeftLeftskip}
957 % \begin{macro}{\RaggedRightLeftskip}
958 % \begin{macro}{\CenteringRightskip}
959 % \begin{macro}{\RaggedLeftRightskip}
960 % \begin{macro}{\RaggedRightRightskip}
961 % \begin{macro}{\CenteringParfillskip}
962 % \begin{macro}{\RaggedLeftParfillskip}
963 % \begin{macro}{\RaggedRightParfillskip}
964 % \begin{macro}{\JustifyingParfillskip}
965 % \changes{v2.00}{2003/01/18}{New macro}
966 % \begin{macro}{\CenteringParindent}
967 % \begin{macro}{\RaggedLeftParindent}
968 % \begin{macro}{\RaggedRightParindent}
969 % \begin{macro}{\JustifyingParindent}
970 % \changes{v2.00}{2003/01/18}{New macro}
971 % First we allocate the parameters
972 % \begin{macrocode}
973 \newlength{\CenteringLeftskip}
974 \newlength{\RaggedLeftLeftskip}
975 \newlength{\RaggedRightLeftskip}
976 \newlength{\CenteringRightskip}
977 \newlength{\RaggedLeftRightskip}
978 \newlength{\RaggedRightRightskip}
979 \newlength{\CenteringParfillskip}
980 \newlength{\RaggedLeftParfillskip}
981 \newlength{\RaggedRightParfillskip}
982 \newlength{\JustifyingParfillskip}
983 \newlength{\CenteringParindent}
984 \newlength{\RaggedLeftParindent}
985 \newlength{\RaggedRightParindent}
986 \newlength{\JustifyingParindent}
987 % \end{macrocode}
988 % \end{macro}
989 % \end{macro}
990 % \end{macro}
991 % \end{macro}
992 % \end{macro}
993 % \end{macro}
994 % \end{macro}
995 % \end{macro}
996 % \end{macro}
997 % \end{macro}
998 % \end{macro}
999 % \end{macro}
1000 % \end{macro}
1001 % \end{macro}
1002 %
1003 %
1004 % ^^A -----------------------------
1005 %
1006 % \subsection{Initializations}
1007 % ^^A
1008 % Depending on \cs{if@raggedtwoe@originalparameters} we initialize the
1009 % parameters with the values \LaTeX{} uses for its own commands or with
1010 % our new parameters.
1011 % \changes{v2.04}{2003/03/02}{Initialize \cs{JustifyingParindent}
1012 % with \cs{parindent}}
1013 % \changes{v2.04}{2003/03/02}{Insert missing \textbackslash}
1014 % \begin{macrocode}
1015 \if@raggedtwoe@originalparameters
1016 \CenteringLeftskip\@flushglue
1017 \RaggedLeftLeftskip\@flushglue
1018 \RaggedRightLeftskip\z@skip
1019 \CenteringRightskip\@flushglue
1020 \RaggedLeftRightskip\z@skip
1021 \RaggedRightRightskip\@flushglue
1022 \CenteringParfillskip\z@skip
1023 \RaggedLeftParfillskip\z@skip
1024 \RaggedRightParfillskip\@flushglue
1025 \CenteringParindent\z@
1026 \RaggedLeftParindent\z@
1027 \RaggedRightParindent\z@
1028 \else
1029 \CenteringLeftskip\z@\@plus\tw@ em
1030 \RaggedLeftLeftskip\z@\@plus\tw@ em
1031 \RaggedRightLeftskip\z@skip
1032 \CenteringRightskip\z@\@plus\tw@ em
1033 \RaggedLeftRightskip\z@skip
1034 \RaggedRightRightskip\z@\@plus\tw@ em
1035 \CenteringParfillskip\z@skip
1036 \RaggedLeftParfillskip\z@skip
1037 \RaggedRightParfillskip\@flushglue
1038 \CenteringParindent\z@
1039 \RaggedLeftParindent\z@
1040 \RaggedRightParindent\z@
1041 \fi
1042 \JustifyingParfillskip\@flushglue
1043 \JustifyingParindent\parindent
1044 % \end{macrocode}
1045 %
1046 %
1047 % ^^A -----------------------------
1048 %
1049 % \subsection{Distinguishing between monospaced and proportional fonts}
1050 % ^^A
1051 % To set ragged text with proportional fonts \emph{and} monospaced
1052 % fonts correctly, we must distinguish between these two kinds of
1053 % fonts \emph{everytime} a font is loaded.
1054 % Otherwise the settings for e.\,g.\ a proportional fonts would be
1055 % in effect if you start \cs{RaggedRight} in \cs{rmfamily} and
1056 % then switch to \cs{ttfamily}.
1057 %
1058 % The goal is to have a rigid interword space in all fonts.
1059 % \TeX's interword space is |\fontdimen2 plus \fontdimen3 minus \fontdimen4|.
1060 % This can be overwritten by setting \cs{spaceskip} (space between
1061 % words, if nonzero) and \cs{xspaceskip} (space at the end of
1062 % sentences, if nonzero).
1063 %
1064 % We do the setting with the help of \package{everysel}\,\cite{everysel},
1065 % which allows us to define code which is (hopefully) executed after
1066 % every fontchange in a \LaTeX{} document.\footnote{^^A
1067 % It \emph{is} executed after every \cs{selectfont}, so if you stay
1068 % within NFSS and don't declare your fonts with commands like
1069 % \cs{newfont} and then switch to them, it will work.}
1070 %
1071 % \begin{macro}{\if@raggedtwoe@spaceskip}
1072 % \cs{if@raggedtwoe@spaceskip} signals the use of commands defined by
1073 % \package{ragged2e} to the command inserted into \cs{selectfont}.
1074 % It is set to true by these commands and restored to false by \TeX{}
1075 % when the scope of them ends.
1076 % \begin{macrocode}
1077 \newif\if@raggedtwoe@spaceskip
1078 % \end{macrocode}
1079 % \end{macro}
1080 %
1081 % \begin{macro}{\@raggedtwoe@everyselectfont}
1082 % \cs{@raggedtwoe@everyselectfont} is our code inserted into
1083 % \cs{selectfont}.
1084 % \changes{v2.00}{2003/01/26}{Completely redesigned and removed
1085 % \cs{RaggedSpaceskip} and
1086 % \cs{RaggedXSpaceskip}}
1087 % \changes{v2.01}{2003/02/20}{Removed the setting of \cs{xspaceskip}}
1088 % \changes{v3.5}{2023/04/04}{Add mechanism to deactivate \cs{\@raggedtwoe@everyselectfont}}
1089 % \begin{macrocode}
1090 \newcommand{\@raggedtwoe@everyselectfont@active}{%
1091 \if@raggedtwoe@spaceskip
1092 % \end{macrocode}
1093 % If no command defined by \package{ragged2e} is in use, we do
1094 % nothing.
1095 % But if it is, we look at \cs{fontdimen3} to see if the current
1096 % font is monospaced or not.
1097 % \begin{macrocode}
1098 \ifdim\fontdimen\thr@@\font=\z@\relax
1099 % \end{macrocode}
1100 % If it is, we set \cs{spaceskip} to |0pt| so the interword space
1101 % will be the one specified by the font designer -- which is rigid
1102 % anyway for monospaced fonts.
1103 % \begin{macrocode}
1104 \spaceskip\z@
1105 \else
1106 % \end{macrocode}
1107 % For proportional fonts we make the interword space rigid by setting
1108 % \cs{spaceskip} to \cs{fontdimen2}.
1109 % \begin{macrocode}
1110 \spaceskip\fontdimen\tw@\font
1111 \fi
1112 % \end{macrocode}
1113 % We have to reset the interword space if we are not active.
1114 % \changes{v2.04}{2003/03/16}{Reset \cs{spaceskip} when we are not
1115 % active}
1116 % \begin{macrocode}
1117 \else
1118 \spaceskip\z@
1119 \fi
1120 }
1121 % \end{macrocode}
1122 % If our kernel is new enough we use the kernel hook directly instead of the everysel macro.
1123 % \changes{v3.00}{2021/02/05}{Use kernel hook if available}
1124 % \changes{v3.3}{2023/02/22}{Apply hook only when a ragged2e command is active.}
1125 % \begin{macrocode}
1126 \newif\if@raggedtwoe@localhook
1127 \IfFormatAtLeastTF{2021/01/05}
1128 {\@raggedtwoe@localhooktrue}
1129 {\EverySelectfont{\@raggedtwoe@everyselectfont}}
1130 % \end{macrocode}
1131 % The hook is added globally but will be inactive when none of the ragged2e comands is used.
1132 % \changes{v3.5}{2023/04/04}{Globally add inactive hook}
1133 % \begin{macrocode}
1134 \let\@raggedtwoe@everyselectfont\relax
1135 \if@raggedtwoe@localhook
1136 \AddToHook{selectfont}[ragged2e]{\@raggedtwoe@everyselectfont}%
1137 \fi
1138 % \end{macrocode}
1139 % \end{macro}
1140 %
1141 %
1142 % ^^A -----------------------------
1143 %
1144 % \subsection{The commands}
1145 % ^^A
1146 % \begin{macro}{\@raggedtwoe@savedcr}
1147 % We save the definition of \cs{\textbackslash} in
1148 % \cs{@raggedtwoe@savedcr}.
1149 % \begin{macrocode}
1150 \let\@raggedtwoe@savedcr\\
1151 % \end{macrocode}
1152 % \end{macro}
1153 %
1154 % \begin{macro}{\@raggedtwoe@saved@gnewline}
1155 % \changes{v2.00}{2003/01/04}{New macro}
1156 % We save the definition of \cs{@gnewline} in
1157 % \cs{@raggedtwoe@saved@gnewline}.
1158 % \begin{macrocode}
1159 \let\@raggedtwoe@saved@gnewline\@gnewline
1160 % \end{macrocode}
1161 % \end{macro}
1162 % \begin{macro}{\@raggedtwoe@centercrNoindent}
1163 % \changes{v3.2}{2022/11/13}{New macro}
1164 % With the bugfix in version 3.2 we also take care of the indent which
1165 % might be set when ragged2e's newline definition or \cs{@centercr} are
1166 % triggered. This can be easily archieved using the ltpara hooks.
1167 % This is not a final solution for this because on the long run one
1168 % has to replace the paragraph break within \cs{@centercr} to match
1169 % the content structure for tagging.
1170 % \begin{macrocode}
1171 \def\@raggedtwoe@centercrNoindent{%
1172 \AddToHookNext{para/begin}{%
1173 \ifx\@raggedtwoe@everyselectfont\relax\else
1174 \OmitIndent
1175 \fi
1176 }%
1177 \@centercr%
1178 }
1179 % \end{macrocode}
1180 % \changes{v3.6}{2023/06/00}{Only omit indent if inside a group where a ragged2e command is active}
1181 % \end{macro}
1182 % \begin{macro}{\@raggedtwoe@gnewline}
1183 % The following definition of a \cs{@gnewline} used by the ragged
1184 % commands was suggested by Markus Kohm:
1185 % \changes{v2.00}{2003/01/04}{New macro}
1186 % \changes{v2.02}{2003/02/24}{Bugfix: \cs{@nolerr}
1187 % \ensuremath{\rightarrow} \cs{@nolnerr}}%
1188 % \changes{v2.1}{2009/05/17}{Bugfix: handle math}
1189 % \begin{macrocode}
1190 \newcommand*{\@raggedtwoe@gnewline}[1]{%
1191 \ifvmode
1192 \@nolnerr
1193 \else
1194 \unskip
1195 \ifmmode
1196 % \end{macrocode}
1197 % In formulas we adjusted the original code of \cs{g@newline} to a negative fill to match the alignment of text.
1198 % Outside those we use \cs{@centercr} to remove the added parskip.
1199 % \changes{v3.2}{2022/11/13}{Fix bug adding parskip with newline}
1200 % \begin{macrocode}
1201 \reserved@e {\reserved@f #1}\nobreak \hskip\z@ \break
1202 \else
1203 \reserved@e {\reserved@f #1}%
1204 \@raggedtwoe@centercrNoindent
1205 \fi
1206 \fi
1207 }
1208 % \end{macrocode}
1209 % \end{macro}
1210 %
1211 % \begin{macro}{\Centering}
1212 % \cs{Centering} first lets \cs{\textbackslash} = \cs{@centercr},
1213 % but only if |\\| has its original meaning, otherwise \cs{Center}
1214 % would not work inside environments like \env{tabular} etc., in
1215 % which \cs{\textbackslash} has a different meaning.
1216 % It also sets \cs{@gnewline} to \cs{@raggedtwoe@gnewline}.
1217 % Then, the \LaTeX{} and \TeX-parameters are set.\newline
1218 % \cs{@rightskip} is \LaTeX's version of \cs{rightskip}.
1219 % \begin{Quote}
1220 % ``Every environment, like the list environments, that set
1221 % \cs{rightskip} to its 'normal' value set it to \cs{@rightskip}''
1222 % \cite{ltmiscen}
1223 % \end{Quote}
1224 % Finally we signal the code inserted into \cs{selectfont} that
1225 % we are active and call that code directly.
1226 % \changes{v3.5}{2023/04/04}{Bugfix: Only activate the global hook}
1227 % \changes{v3.4}{2023/02/25}{Bugfix: remove spurious space}
1228 % \changes{v3.3}{2023/02/22}{Apply hook only when a ragged2e command is active}
1229 % \changes{v3.1}{2021/12/15}{Robustify the user macros (Thanks to Markus Kohm for the hint)}
1230 % \changes{v2.00}{2003/01/04}{Call \cs{@raggedtwoe@everyselectfont}
1231 % and switch \cs{@gnewline}}
1232 % \begin{macrocode}
1233 \DeclareRobustCommand{\Centering}{%
1234 \if@raggedtwoe@localhook
1235 \let\@raggedtwoe@everyselectfont\@raggedtwoe@everyselectfont@active%
1236 \fi
1237 \ifx\\\@raggedtwoe@savedcr
1238 \let\\\@raggedtwoe@centercrNoindent
1239 \fi
1240 \let\@gnewline\@raggedtwoe@gnewline
1241 \leftskip\CenteringLeftskip
1242 \@rightskip\CenteringRightskip
1243 \rightskip\@rightskip
1244 \parfillskip\CenteringParfillskip
1245 \parindent\CenteringParindent
1246 \@raggedtwoe@spaceskiptrue
1247 \@raggedtwoe@everyselectfont
1248 }
1249 % \end{macrocode}
1250 % \end{macro}
1251 %
1252 % \begin{macro}{\RaggedLeft}
1253 % \cs{RaggedLeft} is like \cs{Centering}; it only uses other
1254 % parameters.
1255 % \changes{v3.5}{2023/04/04}{Bugfix: Only activate the global hook}
1256 % \changes{v3.4}{2023/02/25}{Bugfix: remove spurious space}
1257 % \changes{v3.3}{2023/02/22}{Apply hook only when a ragged2e command is active}
1258 % \changes{v3.1}{2021/12/15}{Robustify the user macros (Thanks to Markus Kohm for the hint)}
1259 % \changes{v2.00}{2003/01/04}{Call \cs{@raggedtwoe@everyselectfont}
1260 % and switch \cs{@gnewline}}
1261 % \begin{macrocode}
1262 \DeclareRobustCommand{\RaggedLeft}{%
1263 \if@raggedtwoe@localhook
1264 \let\@raggedtwoe@everyselectfont\@raggedtwoe@everyselectfont@active%
1265 \fi
1266 \ifx\\\@raggedtwoe@savedcr
1267 \let\\\@raggedtwoe@centercrNoindent
1268 \fi
1269 \let\@gnewline\@raggedtwoe@gnewline
1270 \leftskip\RaggedLeftLeftskip
1271 \@rightskip\RaggedLeftRightskip
1272 \rightskip\@rightskip
1273 \parfillskip\RaggedLeftParfillskip
1274 \parindent\RaggedLeftParindent
1275 \@raggedtwoe@spaceskiptrue
1276 \@raggedtwoe@everyselectfont
1277 }
1278 % \end{macrocode}
1279 % \end{macro}
1280 %
1281 % \begin{macro}{\RaggedRight}
1282 % \cs{RaggedRight} is like \cs{Centering}; it only uses other
1283 % parameters.
1284 % \changes{v3.5}{2023/04/04}{Bugfix: Only activate the global hook}
1285 % \changes{v3.4}{2023/02/25}{Bugfix: remove spurious space}
1286 % \changes{v3.3}{2023/02/22}{Apply hook only when a ragged2e command is active}
1287 % \changes{v3.1}{2021/12/15}{Robustify the user macros (Thanks to Markus Kohm for the hint)}
1288 % \changes{v2.00}{2003/01/04}{Call \cs{@raggedtwoe@everyselectfont}
1289 % and switch \cs{@gnewline}}
1290 % \begin{macrocode}
1291 \DeclareRobustCommand{\RaggedRight}{%
1292 \if@raggedtwoe@localhook
1293 \let\@raggedtwoe@everyselectfont\@raggedtwoe@everyselectfont@active%
1294 \fi
1295 \ifx\\\@raggedtwoe@savedcr
1296 \let\\\@raggedtwoe@centercrNoindent
1297 \fi
1298 \let\@gnewline\@raggedtwoe@gnewline
1299 \leftskip\RaggedRightLeftskip
1300 \@rightskip\RaggedRightRightskip
1301 \rightskip\@rightskip
1302 \parfillskip\RaggedRightParfillskip
1303 \parindent\RaggedRightParindent
1304 \@raggedtwoe@spaceskiptrue
1305 \@raggedtwoe@everyselectfont
1306 }
1307 % \end{macrocode}
1308 % \end{macro}
1309 %
1310 % \begin{macro}{\justifying}
1311 % \cs{justifying} switches back to the defaults used by \LaTeX{} for
1312 % typesetting justyfied text.
1313 % \changes{v3.5}{2023/04/04}{Bugfix: Only activate the global hook}
1314 % \changes{v3.4}{2023/02/25}{Bugfix: remove spurious space}
1315 % \changes{v3.3}{2023/02/22}{Apply hook only when a ragged2e command is active}
1316 % \changes{v3.1}{2021/12/15}{Robustify the user macros (Thanks to Markus Kohm for the hint)}
1317 % \changes{v2.00}{2003/01/04}{New macro}
1318 % \begin{macrocode}
1319 \DeclareRobustCommand{\justifying}{%
1320 \if@raggedtwoe@localhook
1321 \let\@raggedtwoe@everyselectfont\@raggedtwoe@everyselectfont@active%
1322 \fi
1323 \let\\\@raggedtwoe@savedcr
1324 \let\@gnewline\@raggedtwoe@saved@gnewline
1325 \leftskip\z@
1326 \@rightskip\z@
1327 \rightskip\@rightskip
1328 \parfillskip\JustifyingParfillskip
1329 \parindent\JustifyingParindent
1330 \@raggedtwoe@spaceskipfalse
1331 \@raggedtwoe@everyselectfont
1332 }
1333 % \end{macrocode}
1334 % \end{macro}
1335 %
1336 %
1337 % ^^A -----------------------------
1338 %
1339 % \subsection{The environments}
1340 % ^^A
1341 % \begin{environment}{Center}
1342 % \begin{environment}{FlushLeft}
1343 % \begin{environment}{FlushRight}
1344 % The environments \env{Center}, \env{FlushLeft}, and \cs{FlushRight}
1345 % are implemented like their counterparts in \LaTeX: Start a
1346 % \env{trivlist} and switch on the right command.
1347 % \changes{v2.02}{2003/02/24}{Use \cs{trivlist} \ldots{}
1348 % \cs{endtrivlist} instead of
1349 % \cs{begin\{trivlist\}} \ldots{}
1350 % \cs{end\{trivlist\}}}
1351 % \begin{macrocode}
1352 \newenvironment{Center}{%
1353 \trivlist
1354 \Centering\item\relax
1355 }{%
1356 \endtrivlist
1357 }
1358 \newenvironment{FlushLeft}{%
1359 \trivlist
1360 \RaggedRight\item\relax
1361 }{%
1362 \endtrivlist
1363 }
1364 \newenvironment{FlushRight}{%
1365 \trivlist
1366 \RaggedLeft\item\relax
1367 }{%
1368 \endtrivlist
1369 }
1370 % \end{macrocode}
1371 % \end{environment}
1372 % \end{environment}
1373 % \end{environment}
1374 % \begin{environment}{justify}
1375 % \env{justify} is similar to the other environments: Start a
1376 % \env{trivlist} and use \cs{justifying}.
1377 % \changes{v2.00}{2003/01/04}{New environment}
1378 % \changes{v2.02}{2003/02/24}{Use \cs{trivlist} \ldots{}
1379 % \cs{endtrivlist} instead of
1380 % \cs{begin\{trivlist\}} \ldots{}
1381 % \cs{end\{trivlist\}}}
1382 % \begin{macrocode}
1383 \newenvironment{justify}{%
1384 \trivlist
1385 \justifying\item\relax
1386 }{%
1387 \endtrivlist
1388 }
1389 % \end{macrocode}
1390 % \end{environment}
1391 %
1392 %
1393 % ^^A -----------------------------
1394 %
1395 % \subsection{Overloading the \LaTeX-commands}
1396 % ^^A
1397 % If the option \option{newcommands} is used, we save the original
1398 % \LaTeX-commands and environments for ragged text and overload them.
1399 % \changes{v2.04}{2003/03/02}{Save more commands}
1400 % \changes{v2.1}{2003/10/08}{bugfix: \cs{Flushleft} instead of
1401 % \cs{FlushLeft} (found by Berend Hasselman)}
1402 % \begin{macrocode}
1403 \if@raggedtwoe@originalcommands
1404 \else
1405 \let\LaTeXcentering\centering
1406 \let\LaTeXraggedleft\raggedleft
1407 \let\LaTeXraggedright\raggedright
1408 \let\centering\Centering
1409 \let\raggedleft\RaggedLeft
1410 \let\raggedright\RaggedRight
1411 \let\LaTeXcenter\center
1412 \let\endLaTeXcenter\endcenter
1413 \let\LaTeXflushleft\flushleft
1414 \let\endLaTeXflushleft\endflushleft
1415 \let\LaTeXflushright\flushright
1416 \let\endLaTeXflushright\endflushright
1417 \let\center\Center
1418 \let\endcenter\endCenter
1419 \let\flushleft\FlushLeft
1420 \let\endflushleft\endFlushLeft
1421 \let\flushright\FlushRight
1422 \let\endflushright\endFlushRight
1423 \fi
1424 % \end{macrocode}
1425 %
1426 % ^^A -----------------------------
1427 %
1428 % \begin{macrocode}
1429 %</package>
1430 % \end{macrocode}
1431 % \Finale
1432 % ^^A