Debian Codegraph @

texmf-dist/source/latex/base/ltmiscen.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 % \iffalse
30 %%% From File: ltmiscen.dtx
31 %
32 %<*driver>
33 % \fi
34 \ProvidesFile{ltmiscen.dtx}
35 [2025/04/28 v1.2h LaTeX Kernel (Misc. Environments)]
36 % \iffalse
37 \documentclass{ltxdoc}
38 \GetFileInfo{ltmiscen.dtx}
39 \title{\filename}
40 \date{\filedate}
41 \author{%
42 Johannes Braams\and
43 David Carlisle\and
44 Alan Jeffrey\and
45 Leslie Lamport\and
46 Frank Mittelbach\and
47 Chris Rowley\and
48 Rainer Sch\"opf}
49
50 \begin{document}
51 \MaintainedByLaTeXTeam{latex}
52 \maketitle
53 \DocInput{\filename}
54 \end{document}
55 %</driver>
56 % \fi
57 %
58 %
59 % \changes{v1.0c}{1994/03/28}{Improve Documentation}
60 % \changes{v1.0d}{1994/03/29}{Remove counter macros to ltcntlen}
61 % \changes{v1.0g}{1994/05/02}{Changed 91 to 1991 and moved some bits}
62 % \changes{v1.0i}{1994/05/05}{Removed braces from ifnextchar and
63 % ifstar arguments}
64 % \changes{v1.0m}{1994/05/20}{Use new warning commands}
65 % \changes{v1.0n}{1994/05/21}{Use new error commands}
66 % \changes{v1.0s}{1994/10/14}{Move math to other file}
67 % \changes{v1.0v}{1994/11/17}
68 % {\cs{@tempa} to \cs{reserved@a}}
69 % \changes{v1.0x}{1995/04/22}{Removed extra def of \cs{@gobble}}
70 % \changes{v1.0z}{1995/07/13}{Improve Documentation}
71 % \changes{v1.1c}{1996/04/22}{Improve Documentation}
72 % \changes{v1.1d}{1996/06/03}{Move setting of verbatim font and
73 % \cs{@noligs}.}
74 % \changes{v1.1g}{1998/08/17}{(RmS) Minor documentation fixes.}
75 % \changes{v1.1p}{2019/08/27}{Make various commands robust}
76 % \changes{v1.1v}{2020/08/21}{Integration of new hook management interface}
77 %
78 % \section{Miscellaneous Environments}
79 % This section implements the basic environment mechanism, and also
80 % a few specific environments including |document|, The math
81 % environments and related commands, the `flushing' environments,
82 % (|center|, |flushleft|, |flushright|), and |verbatim|.
83 %
84 % \MaybeStop{}
85 %
86 % \begin{macrocode}
87 %<*2ekernel>
88 \message{environments,}
89 % \end{macrocode}
90 %
91 % \subsection{Environments}
92 %
93 % |\begin{foo}| and |\end{foo}| are used to delimit environment |foo|.
94 %
95 % |\begin{foo}| starts a group and calls |\foo| if it is defined,
96 % otherwise it does nothing.
97 %
98 % |\end{foo}| checks to see that it matches the
99 % corresponding |\begin| and if so, it calls |\endfoo| and does an
100 % |\endgroup|. Otherwise, |\end{foo}| does nothing.
101 %
102 % If |\end{foo}| needs to ignore blanks after it, then |\endfoo| should
103 % globally set the |@ignore| switch true with |\@ignoretrue|
104 % (this will automatically be global).
105 %
106 %
107 % NOTE: |\@@end| is defined to be the |\end| command of \TeX82.
108 %
109 % |\enddocument| is the user's command for ending the manuscript file.
110 %
111 % |\stop| is a panic button --- to end \TeX\ in the middle.
112 %
113 % \begin{oldcomments}
114 % \enddocument ==
115 % BEGIN
116 % \@checkend{document} %% checks for unmatched \begin
117 % \clearpage
118 % \begingroup
119 % if @filesw = true
120 % then close file @mainaux
121 % if G@refundefined = true
122 % then LaTeX Warning: 'There are undefined references.' fi
123 % if @multiplelabels = true
124 % then LaTeX Warning:
125 % 'One or more label(s) multiply defined.'
126 % else
127 % \@setckpt {ARG1}{ARG2} == null
128 % \newlabel{LABEL}{VAL} ==
129 % BEGIN
130 % \reserved@a == VAL
131 % if def(\reserved@a) = def(\r@LABEL)
132 % else @tempswa := true fi
133 % END
134 % \bibcite{LABEL}{VAL} == null
135 % BEGIN
136 % \reserved@a == VAL
137 % if def(\reserved@a) = def(\g@LABEL)
138 % else @tempswa := true fi
139 % END
140 % @tempswa := false
141 % make @ a letter
142 % \input \jobname.AUX
143 % if @tempswa = true
144 % then LaTeX Warning: 'Label may have changed.
145 % Rerun to get cross-references right.'
146 % fi fi fi
147 % \endgroup
148 % finish up
149 % END
150 %
151 % \@writefile{EXT}{ENTRY} ==
152 % if tf@EXT undefined
153 % else \write\tf@EXT{ENTRY}
154 % fi
155 % \end{oldcomments}
156 %
157 % \begin{macro}{\@currenvir}
158 % The name of the current environment. Initialized to
159 % \texttt{document} to so that |\end{document}| works correctly.
160 % \begin{macrocode}
161 \def\@currenvir{document}
162 % \end{macrocode}
163 % \end{macro}
164 %
165 % \begin{macro}{\if@ignore}
166 % \begin{macro}{\@ignoretrue}
167 % \begin{macro}{\@ignorefalse}
168 % \changes{v1.1e}{1996/07/26}{put \cs{global} into definition}
169 % \begin{macrocode}
170 \def\@ignorefalse{\global\let\if@ignore\iffalse}
171 \def\@ignoretrue {\global\let\if@ignore\iftrue}
172 \@ignorefalse
173 % \end{macrocode}
174 % \end{macro}
175 % \end{macro}
176 % \end{macro}
177 %
178 %
179 % \begin{macro}{\ignorespacesafterend}
180 % \changes{v1.1e}{1996/07/26}{user level macro added}
181 % \begin{macrocode}
182 \let\ignorespacesafterend\@ignoretrue
183 % \end{macrocode}
184 % \end{macro}
185 %
186 % \begin{environment}{document}
187 % \begin{macro}{\enddocument}
188 % \changes{LaTeX2.09}{1993/08/03}
189 % {Changed redefinition of \cs{global} to redefinition
190 % of \cs{@setckpt}.}
191 % \changes{LaTeX2.09}{1993/09/08}
192 % {Added warning in case of undefined references.}%
193 % \changes{v0.9e}{1993/12/09}{Hook added}
194 % \begin{macrocode}
195 %</2ekernel>
196 %<*2ekernel|latexrelease>
197 %<latexrelease>\IncludeInRelease{2023/11/01}%
198 %<latexrelease> {\enddocument}{check property labels}%
199 \def\enddocument{%
200 % \end{macrocode}
201 % The |\end{document}| hook is executed first. If necessary it can
202 % contain a |\clearpage| to output dangling floats first. In this
203 % position it can also contain something like |\end{foo}| so that
204 % the whole document effectively starts and ends with some special
205 % environment. However, this must be used with care, eg if two
206 % applications would use this without knowledge of each other the
207 % order of the environments will be wrong after all.
208 % |\AtEndDocument| is redefined
209 % at this point so that and such commands that get into the hook do
210 % not chase their tail\ldots
211 % \changes{v1.0y}{1995/04/27}{\cs{@checkend} moved after hook}
212 % \changes{v1.0z}{1995/07/13}{Set \cs{@setckpt} to \cs{@gobbletwo}
213 % instead of defining it by hand}
214 % \changes{v1.1i}{2000/05/19}
215 % {Reset \cs{AtEndDocument} for latex/3060}
216 % \begin{macrocode}
217 \@kernel@before@enddocument
218 \UseOneTimeHook{enddocument}%
219 \@kernel@after@enddocument
220 % \end{macrocode}
221 %
222 % \begin{macrocode}
223 \@checkend{document}%
224 \clearpage
225 % \end{macrocode}
226 %
227 % \changes{v1.2g}{2025/03/05}{Added \cs{@kernel@before@enddocument@afterlastpage}}
228 % \begin{macrocode}
229 \@kernel@before@enddocument@afterlastpage
230 \UseOneTimeHook{enddocument/afterlastpage}%
231 \@kernel@after@enddocument@afterlastpage
232 \begingroup
233 \if@filesw
234 \immediate\closeout\@mainaux
235 \let\@setckpt\@gobbletwo
236 \let\@newl@bel\@testdef
237 % \end{macrocode}
238 % \changes{v1.2b}{2023/09/06}{Test changes of values in \cs{new@label@record}}
239 % \begin{macrocode}
240 \let\new@label@record\@kernel@new@label@record@testdef
241 % \end{macrocode}
242 % \changes{v1.0z}{1995/07/13}{Shorten redefinition of \cs{bibcite} and
243 % \cs{newlabel}}
244 % The previous line is equiv to setting
245 %\begin{verbatim}
246 % \def\newlabel{\@testdef r}%
247 % \def\bibcite{\@testdef b}%
248 %\end{verbatim}
249 % \changes{v1.1k}{2010/08/17}{Use braces around \cs{input} arg (pr/4124)}
250 % \changes{v1.1l}{2010/08/17}{Change of plan: use \cs{@@input} instead
251 % (pr/4124)}
252 % \changes{v1.1w}{2020/10/23}{Make \texttt{enddocument/afteraux} one-time}
253 % \changes{v1.2h}{2025/04/28}{Increment page counter gh/1717}
254 % We use |\@@input| to load the \texttt{.aux} file, so that it doesn't
255 % show up in the list of files produced by |\listfiles|.
256 % \begin{macrocode}
257 \@tempswafalse
258 \global\advance\c@page\@ne
259 \makeatletter \@@input\jobname.aux
260 \fi
261 \UseOneTimeHook{enddocument/afteraux}%
262 % \end{macrocode}
263 % Next hook is expect to contain only code for writing info
264 % messages on the terminal.
265 % \begin{macrocode}
266 \UseOneTimeHook{enddocument/info}%
267 \endgroup
268 \UseOneTimeHook{enddocument/end}%
269 \deadcycles\z@\@@end}
270 % \end{macrocode}
271 %
272 % The public hooks used in \cs{enddocument}:
273 % \begin{macrocode}
274 \NewHook{enddocument}
275 \NewHook{enddocument/afterlastpage}
276 \NewHook{enddocument/afteraux}
277 \NewHook{enddocument/info}
278 \NewHook{enddocument/end}
279 % \end{macrocode}
280 %
281 % This is one of the few places where we already add data and rules
282 % to a hook already in the kernel.
283 % \changes{v1.0w}{1994/11/30}{(DPC) Use \cs{@dofilelist}}
284 % \changes{v1.2a}{2022/11/06}{Repeat release info at the end (gh/944)}
285 % \begin{macrocode}
286 % \end{macrocode}
287 % If we roll back we have to drop stuff before adding chunks,
288 % otherwise the code will just be appended, and thus doubled.
289 % This would result in a harmless warning during the format
290 % generation, because in that case the code chunk label doesn't
291 % exist, and therefore can't be dropped.
292 % \changes{v1.2e}{2024/07/10}{Drop code chunks before adding them to
293 % avoid duplication in rollback (gh/1407)}
294 % \begin{macrocode}
295 %<latexrelease>\RemoveFromHook{enddocument/info}[kernel/filelist]
296 %<latexrelease>\RemoveFromHook{enddocument/info}[kernel/warnings]
297 %<latexrelease>\RemoveFromHook{enddocument/info}[kernel/release]
298 % \end{macrocode}
299 %
300 % \begin{macrocode}
301 \AddToHook{enddocument/info}[kernel/filelist]{\@dofilelist}
302 \AddToHook{enddocument/info}[kernel/warnings]{\@enddocument@kernel@warnings}
303 \AddToHook{enddocument/info}[kernel/release]{%
304 \let\show@release@info\wlog
305 \show@release@info{ ***********}%
306 \the\LaTeXReleaseInfo
307 \show@release@info{ ***********}}
308
309 \DeclareHookRule{enddocument/info}{kernel/release}{before}{kernel/filelist}
310 \DeclareHookRule{enddocument/info}{kernel/filelist}{before}{kernel/warnings}
311 % \end{macrocode}
312 % \end{macro}
313 % \end{environment}
314 %
315 % \begin{macro}{\@enddocument@kernel@warnings}
316 %
317 % \begin{macrocode}
318 \def\@enddocument@kernel@warnings{%
319 % \end{macrocode}
320 % First we check for font size substitution bigger than
321 % |\fontsubfuzz|. The |\relax| is necessary because this is a macro
322 % not a register.
323 % \changes{v1.0w}{1994/11/30}
324 % {(DPC) Do warnings even for \cs{nofiles}}
325 % \begin{macrocode}
326 \ifdim \font@submax >\fontsubfuzz\relax
327 % \end{macrocode}
328 % In case you wonder about the |\@gobbletwo| inside the message
329 % below, this is a horrible hack to remove the tokens |\on@line.|
330 % that are added by |\@font@warning| at the end.
331 % \changes{v1.1j}{2000/07/11}{Fix typo in warning}
332 % \begin{macrocode}
333 \@font@warning{Size substitutions with differences\MessageBreak
334 up to \font@submax\space have occurred.\@gobbletwo}%
335 \fi
336 % \end{macrocode}
337 % The macro |\@defaultsubs| is initially |\relax| but gets redefined
338 % to produce
339 % a warning if there have been some default font substitutions.
340 % \changes{v1.0z}{1995/07/13}{Use \cs{@defaultsubs} instead of switch}
341 % \begin{macrocode}
342 \@defaultsubs
343 % \end{macrocode}
344 % The macro |\@refundefined| is initially |\relax| but gets redefined
345 % to produce a warning if there are undefined refs.
346 % \changes{v1.1b}{1995/10/24}{Use \cs{@refundefined} instead of switch}
347 % \begin{macrocode}
348 \@refundefined
349 % \end{macrocode}
350 % If a label is defined more than once, |\@tempswa| will always be
351 % true and thus produce a ``Label(s) may \ldots'' warning. But
352 % since a rerun will not solve that problem (unless one uses a
353 % package like \texttt{varioref} that generates labels on the fly),
354 % we suppress this message.
355 % \changes{v1.0e}{1994/04/20}{Changed logic for producing
356 % warning messages}
357 % \changes{v1.1b}{1995/10/24}{Changed logic for producing
358 % warning messages and removed switch}
359 % \begin{macrocode}
360 \if@filesw
361 \ifx \@multiplelabels \relax
362 \if@tempswa
363 \@latex@warning@no@line{Label(s) may have changed.
364 Rerun to get cross-references right}%
365 \fi
366 \else
367 \@multiplelabels
368 \fi
369 \ifx \@extra@page@added \relax
370 \@latex@warning@no@line{Temporary extra page added at the end.
371 Rerun to get it removed}%
372 \fi
373 % \end{macrocode}
374 % We could think of adding a warning that nothing can be corrected
375 % while \cs{nofiles} is in force. In the past the warnings related
376 % to the \texttt{aux} file are simply suppressed in this case.
377 % \begin{macrocode}
378 \fi
379 }
380 % \end{macrocode}
381 % \end{macro}
382 %
383 % \begin{macrocode}
384 %</2ekernel|latexrelease>
385 %<latexrelease>\EndIncludeInRelease
386 %<latexrelease>\IncludeInRelease{2020/10/01}%
387 %<latexrelease> {\enddocument}{Use Hooks}%
388 %<latexrelease>\def\enddocument{%
389 %<latexrelease> \@kernel@before@enddocument
390 %<latexrelease> \UseOneTimeHook{enddocument}%
391 %<latexrelease> \@kernel@after@enddocument
392 %<latexrelease> \@checkend{document}%
393 %<latexrelease> \clearpage
394 %<latexrelease> \UseOneTimeHook{enddocument/afterlastpage}%
395 %<latexrelease> \@kernel@after@enddocument@afterlastpage
396 %<latexrelease> \begingroup
397 %<latexrelease> \if@filesw
398 %<latexrelease> \immediate\closeout\@mainaux
399 %<latexrelease> \let\@setckpt\@gobbletwo
400 %<latexrelease> \let\@newl@bel\@testdef
401 %<latexrelease> \@tempswafalse
402 %<latexrelease> \makeatletter \@@input\jobname.aux
403 %<latexrelease> \fi
404 %<latexrelease> \UseOneTimeHook{enddocument/afteraux}%
405 %<latexrelease> \UseOneTimeHook{enddocument/info}%
406 %<latexrelease> \endgroup
407 %<latexrelease> \UseOneTimeHook{enddocument/end}%
408 %<latexrelease> \deadcycles\z@\@@end}
409 %<latexrelease>\NewHook{enddocument}
410 %<latexrelease>\NewHook{enddocument/afterlastpage}
411 %<latexrelease>\NewHook{enddocument/afteraux}
412 %<latexrelease>\NewHook{enddocument/info}
413 %<latexrelease>\NewHook{enddocument/end}
414 % \end{macrocode}
415 % If we roll back we have to drop stuff before adding chunks,
416 % otherwise the code will just be appended, and thus doubled.
417 % \changes{v1.2e}{2024/07/10}{Drop code chunks before adding them to
418 % avoid duplication in rollback (gh/1407)}
419 % \begin{macrocode}
420 %<latexrelease>\RemoveFromHook{enddocument/info}[kernel/filelist]
421 %<latexrelease>\RemoveFromHook{enddocument/info}[kernel/warnings]
422 %<latexrelease>\RemoveFromHook{enddocument/info}[kernel/release]
423 % \end{macrocode}
424 %
425 % \begin{macrocode}
426 %<latexrelease>\AddToHook{enddocument/info}[kernel/filelist]{\@dofilelist}
427 %<latexrelease>\AddToHook{enddocument/info}[kernel/warnings]{\@enddocument@kernel@warnings}
428 %<latexrelease>\AddToHook{enddocument/info}[kernel/release]{%
429 %<latexrelease> \let\show@release@info\wlog
430 %<latexrelease> \show@release@info{ ***********}%
431 %<latexrelease> \the\LaTeXReleaseInfo
432 %<latexrelease> \show@release@info{ ***********}}
433 %<latexrelease>
434 %<latexrelease>\DeclareHookRule{enddocument/info}{kernel/release}{before}{kernel/filelist}
435 %<latexrelease>\DeclareHookRule{enddocument/info}{kernel/filelist}{before}{kernel/warnings}
436 %<latexrelease>\def\@enddocument@kernel@warnings{%
437 %<latexrelease> \ifdim \font@submax >\fontsubfuzz\relax
438 %<latexrelease> \@font@warning{Size substitutions with differences\MessageBreak
439 %<latexrelease> up to \font@submax\space have occurred.\@gobbletwo}%
440 %<latexrelease> \fi
441 %<latexrelease> \@defaultsubs
442 %<latexrelease> \@refundefined
443 %<latexrelease> \if@filesw
444 %<latexrelease> \ifx \@multiplelabels \relax
445 %<latexrelease> \if@tempswa
446 %<latexrelease> \@latex@warning@no@line{Label(s) may have changed.
447 %<latexrelease> Rerun to get cross-references right}%
448 %<latexrelease> \fi
449 %<latexrelease> \else
450 %<latexrelease> \@multiplelabels
451 %<latexrelease> \fi
452 %<latexrelease> \ifx \@extra@page@added \relax
453 %<latexrelease> \@latex@warning@no@line{Temporary extra page added at the end.
454 %<latexrelease> Rerun to get it removed}%
455 %<latexrelease> \fi
456 %<latexrelease> \fi
457 %<latexrelease>}
458 %<latexrelease>\EndIncludeInRelease
459 %<latexrelease>\IncludeInRelease{0000/00/00}%
460 %<latexrelease> {\enddocument}{Use Hooks}%
461 %<latexrelease>
462 %<latexrelease>\def\enddocument{%
463 %<latexrelease> \let\AtEndDocument\@firstofone
464 %<latexrelease> \@enddocumenthook
465 %<latexrelease> \@checkend{document}%
466 %<latexrelease> \clearpage
467 %<latexrelease> \begingroup
468 %<latexrelease> \if@filesw
469 %<latexrelease> \immediate\closeout\@mainaux
470 %<latexrelease> \let\@setckpt\@gobbletwo
471 %<latexrelease> \let\@newl@bel\@testdef
472 %<latexrelease> \@tempswafalse
473 %<latexrelease> \makeatletter \@@input\jobname.aux
474 %<latexrelease> \fi
475 %<latexrelease> \@dofilelist
476 %<latexrelease> \ifdim \font@submax >\fontsubfuzz\relax
477 %<latexrelease> \@font@warning{Size substitutions with differences\MessageBreak
478 %<latexrelease> up to \font@submax\space have occurred.\@gobbletwo}%
479 %<latexrelease> \fi
480 %<latexrelease> \@defaultsubs
481 %<latexrelease> \@refundefined
482 %<latexrelease> \if@filesw
483 %<latexrelease> \ifx \@multiplelabels \relax
484 %<latexrelease> \if@tempswa
485 %<latexrelease> \@latex@warning@no@line{Label(s) may have changed.
486 %<latexrelease> Rerun to get cross-references right}%
487 %<latexrelease> \fi
488 %<latexrelease> \else
489 %<latexrelease> \@multiplelabels
490 %<latexrelease> \fi
491 %<latexrelease> \fi
492 %<latexrelease> \endgroup
493 %<latexrelease> \deadcycles\z@\@@end}
494 %<latexrelease>
495 %<latexrelease>\let\@enddocument@kernel@warnings\@undefined
496 %<latexrelease>
497 %<latexrelease>\EndIncludeInRelease
498 %<*2ekernel>
499 % \end{macrocode}
500 %
501 % \begin{macro}{\@kernel@before@enddocument}
502 % The \cs{@kernel@before@enddocument} hook is slightly different
503 % because we initialize it with \cs{par} so that \cs{enddocument} always
504 % returns to vertical mode as its first action.
505 % \changes{v1.1x}{2020/10/26}{\cs{enddocument} should always start out in
506 % vmode (gh/385)}
507 % \begin{macrocode}
508 %</2ekernel>
509 %<*2ekernel|latexrelease>
510 %<latexrelease>\IncludeInRelease{2021/06/01}%
511 %<latexrelease> {\@kernel@before@enddocument}{kernel before hook}%
512 \def\@kernel@before@enddocument{\par}
513 %</2ekernel|latexrelease>
514 %<latexrelease>\EndIncludeInRelease
515 % \end{macrocode}
516 %
517 % The rollback code renders it harmless.
518 % \begin{macrocode}
519 %<latexrelease>\IncludeInRelease{0000/00/00}%
520 %<latexrelease> {\@kernel@before@enddocument}{kernel before hook}%
521 %<latexrelease>
522 %<latexrelease>\let\@kernel@before@enddocument\@empty
523 %<latexrelease>
524 %<latexrelease>\EndIncludeInRelease
525 %<*2ekernel>
526 % \end{macrocode}
527 % \end{macro}
528 %
529 %
530 %
531 %
532 % \begin{macro}{\@testdef}
533 % \begin{macrocode}
534 \def\@testdef #1#2#3{%
535 \def\reserved@a{#3}\expandafter \ifx \csname #1@#2\endcsname
536 \reserved@a \else \@tempswatrue \fi}
537 % \end{macrocode}
538 % \end{macro}
539 %
540 %
541 % Reading data from auxiliary files (like \texttt{.toc} normally
542 % happens in vertical mode and it therefore doesn't matter if line
543 % endings are converted to spaces by \TeX{} during that process.
544 %
545 % However, especially the \texttt{.toc} file might be read in L-R mode
546 % (in cases the \cs{tableofcontents} attempts to put, say, a list of
547 % sub-sections as a paragraph). In that case the newlines after a line
548 % like
549 % \begin{verbatim}
550 % \contentsline {subsubsection}{\numberline {1.1.1}A C-head}{2}
551 % \end{verbatim}
552 % might result in spurious spaces (e.g., when that level is not
553 % included).
554 %
555 % That could be fixed by reading in the file using
556 % \cs{endlinechar}\texttt{=-1} but that has the danger that it drops
557 % some valid endlines that should be converted to spaces (for example,
558 % when the user edited the TOC and then used \cs{nofiles} to preserve
559 % it).
560 %
561 % So the approach taken instead is this:
562 % \begin{itemize}
563 % \item \cs{addcontentsline} adds the command
564 % \cs{protected@file@percent} to the end of the second argument of
565 % \cs{@writefile} that is written to the \texttt{.aux}. As the name
566 % indicates this is a protected macro so it doesn't change if it is
567 % written out.
568 %
569 % \item When the \texttt{.aux} is read back in at the end of the run,
570 % \cs{@writefile} is executed and writes its second argument
571 % unmodified to the file with the extension given by its first
572 % argument. Or rather that was how it was in the past.
573 %
574 % \item Instead we change \cs{@writefile} slightly: basically it looks
575 % at the second argument and if the last token in there is
576 % \cs{protected@file@percent} then it is replaced by a percent
577 % character and that is then written out. If not (for example, if
578 % the data came from a user issued \cs{addtocontents}, or from some
579 % package that uses \cs{@writefile} for writing its own files) then
580 % the command behaves exactly as before.
581 % \end{itemize}
582 %
583 %
584 % \begin{macro}{\protected@file@percent}
585 % Dummy cs to be replaced by a percent sign inside
586 % \cs{@writefile}. If it survives (when used incorrectly) it will
587 % expand to nothing in a typsetting context.
588 % \changes{v1.1n}{2018/09/26}{Sometimes mask the endline char when
589 % writing to files (github/73)}
590 % \begin{macrocode}
591 %</2ekernel>
592 %<*2ekernel|latexrelease>
593 %<latexrelease>\IncludeInRelease{2018/12/01}%
594 %<latexrelease> {\protected@file@percent}{Mask line endings}%
595 \protected\def\protected@file@percent{}
596 % \end{macrocode}
597 % \end{macro}
598 %
599 % \begin{macro}{\add@percent@to@temptokena}
600 % Helper function which is used to inspect a sequence of tokens
601 % (the second argument of \cs{@writefile} and it the last token is
602 % \cs{protected@file@percent} it will replace it by a harmless
603 % percent. The result is saved in \cs{@temptokena} for later use.
604 % \changes{v1.1n}{2018/09/26}{Sometimes mask the endline char when
605 % writing to files (github/73)}
606 %
607 % \begin{macrocode}
608 \catcode`\^^A=9
609 \long\gdef\add@percent@to@temptokena
610 #1\protected@file@percent#2\add@percent@to@temptokena
611 % \end{macrocode}
612 % When we call this macro in |\@writefile| we stick in |\@empty| at
613 % the beginning, so that in case the tokenlist consists of a single brace
614 % group the braces aren't stripped. The |\expandafter| then expands
615 % this extra token away again.
616 % \changes{v1.1q}{2019/10/25}{Allow unbalanced conditionals in \texttt{\#1} (gh/202)}
617 % \changes{v1.1r}{2019/11/10}{fix to special comment catcodes (gh/202)}
618 % \begin{macrocode}
619 {\expandafter\ifx\expandafter X\detokenize{#2}X\expandafter\dont@add@percent@to@temptokena\else
620 \expandafter\do@add@percent@to@temptokena\fi{#1}}
621 % \end{macrocode}
622 %
623 % \begin{macrocode}
624 \long\def\dont@add@percent@to@temptokena#1{%
625 \@temptokena\expandafter{#1}}
626 % \end{macrocode}
627 % \texttt{latexrelease} will read this code in high-speed
628 % mode in certain situations. During that it will only look for
629 % \cs{if} tests but not actually execute the \cs{catcode} change
630 % above. As a result it will drop anything after the |%| character
631 % in the definition. Therefore the |\fi| needs to be on the next
632 % line and we need locally another comment character to avoid
633 % getting spaces into the definition---a weird problem :-)
634 %
635 % \begin{macrocode}
636 \begingroup
637 \catcode`\%=12
638 \catcode`\^^A=14
639 \long\gdef\do@add@percent@to@temptokena#1{\@temptokena\expandafter{#1%^^A
640 % \end{macrocode}
641 % Can't be on the same line as the |%| --- see above.
642 % \begin{macrocode}
643 }}
644 \endgroup
645 % \end{macrocode}
646 % \end{macro}
647 %
648 % \begin{macro}{\@writefile}
649 % \changes{v1.0l}{1994/05/20}{Added correct setting of \cs{protect}.}
650 % \changes{v1.0t}{1994/11/04}{Removed setting of \cs{protect}. ASAJ.}
651 % \changes{v1.0z}{1995/07/13}{Added missing percent and use \cs{relax}
652 % in the THEN case}
653 % \changes{v1.1n}{2018/09/26}{Sometimes mask the endline char when
654 % writing to files (github/73)}
655 % \begin{macrocode}
656 \long\def\@writefile#1#2{%
657 \@ifundefined{tf@#1}\relax
658 {%
659 % \end{macrocode}
660 % If we write to the file we first prepare |#2| using
661 % \cs{add@percent@to@temptokena} and then write the token register
662 % out.
663 % \begin{macrocode}
664 \add@percent@to@temptokena
665 \@empty#2\protected@file@percent
666 \add@percent@to@temptokena
667 \immediate\write\csname tf@#1\endcsname{\the\@temptokena}%
668 }%
669 }
670 % \end{macrocode}
671 %
672 % \begin{macrocode}
673 %</2ekernel|latexrelease>
674 %<latexrelease>\EndIncludeInRelease
675 %<latexrelease>\IncludeInRelease{0000/00/00}%
676 %<latexrelease> {\protected@file@percent}{Mask line endings}%
677 %<latexrelease>\let\protected@file@percent\@undefined
678 %<latexrelease>\let\add@percent@to@temptokena\@undefined
679 %<latexrelease>\let\do@add@percent@to@temptokena\@undefined
680 %<latexrelease>\let\dont@add@percent@to@temptokena\@undefined
681 %<latexrelease>\long\def\@writefile#1#2{%
682 %<latexrelease> \@ifundefined{tf@#1}\relax
683 %<latexrelease> {\@temptokena{#2}%
684 %<latexrelease> \immediate\write\csname tf@#1\endcsname{\the\@temptokena}%
685 %<latexrelease> }%
686 %<latexrelease>}
687 %<latexrelease>\EndIncludeInRelease
688 %<*2ekernel>
689 % \end{macrocode}
690 % \end{macro}
691 %
692 % \begin{macro}{\stop}
693 % \begin{macrocode}
694 \def\stop{\clearpage\deadcycles\z@\let\par\@@par\@@end}
695 % \end{macrocode}
696 % \end{macro}
697 %
698 %
699 % \begin{oldcomments}
700 %
701 % \begin{macrocode}
702 \everypar{\@nodocument} %% To get an error if text appears before the
703 \nullfont %% \begin{document}
704 % \end{macrocode}
705 %
706 % \begin, \end, and \@checkend changed so \end{document} will catch
707 % an unmatched \begin. Changed 24 May 89 as suggested by
708 % Frank Mittelbach and Rainer Sch\"opf.
709 %
710 % \begin{NAME} ==
711 % BEGIN
712 % IF \NAME undefined THEN \reserved@a == BEGIN report error END
713 % ELSE \reserved@a ==
714 % (\@currenvir :=L NAME) \NAME
715 % FI
716 % @ignore :=G F %% Added 30 Nov 88
717 % \begingroup
718 % \@endpe := F
719 % \@currenvir :=L NAME
720 % \NAME
721 % END
722 %
723 % \end{NAME} ==
724 % BEGIN
725 % \endNAME
726 % \@checkend{NAME}
727 % \endgroup
728 % IF @endpe = T %% @endpe set True by \@endparenv
729 % THEN \@doendpe %% \@doendpe redefines \par and \everypar
730 % %% to suppress paragraph indentation in
731 % FI %% immediately following text
732 % IF @ignore = T
733 % THEN @ignore :=G F
734 % \ignorespaces
735 % FI
736 % END
737 %
738 % \@checkend{NAME} ==
739 % BEGIN
740 % IF \@currenvir = NAME
741 % ELSE \@badend{NAME}
742 % FI
743 % END
744 %
745 % \end{oldcomments}
746 %
747 %
748 % \begin{macro}{\begin}
749 % \changes{LaTeX2.09}{1992/03/18}{Changed \cs{@ignoretrue} to
750 % \cs{@ignorefalse} (as documented)}
751 % \changes{LaTeX2.09}{1992/08/24}{Added code to \cs{begin} to
752 % remember line number. Used by \cs{@badend} to display
753 % position of non-matching \cs{begin}.}
754 % \changes{v1.1e}{1996/07/26}{remove \cs{global} before \cs{@ignore...}}
755 % \changes{v1.1p}{2019/08/27}{Make command robust}
756 % \changes{v1.2d}{2024/06/23}{Separate \cs{begin} and \cs{end} definitions
757 % for individual rollback}
758 % \changes{v1.2f}{2024/10/12}{Make \cs{begin} engine-protected}
759 % \begin{macrocode}
760 %</2ekernel>
761 %<*2ekernel|latexrelease>
762 %<latexrelease>\IncludeInRelease{2020/10/01}%
763 %<latexrelease> {\begin}{Use hook system}%
764 \protected\def\begin#1{%
765 \UseHook{env/#1/before}%
766 \@ifundefined{#1}%
767 {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
768 {\def\reserved@a{\def\@currenvir{#1}%
769 \edef\@currenvline{\on@line}%
770 \@execute@begin@hook{#1}%
771 \csname #1\endcsname}}%
772 \@ignorefalse
773 \begingroup\@endpefalse\reserved@a}
774 % \end{macrocode}
775 %
776 % Before the \cs{document} code is executed we have to first undo
777 % the \cs{endgroup} as there should be none for this environment to
778 % avoid that changes on top-level unnecessarily go to \TeX's
779 % savestack, and we have to initialize all hooks in the hook system.
780 % So we need to test for this environment name. But once it has be
781 % found all this testing is no longer needed and so we redefine
782 % \cs{@execute@begin@hook} to simply use the hook.
783 % \begin{macrocode}
784 \def\@execute@begin@hook #1{%
785 \expandafter\ifx\csname #1\endcsname\document
786 \endgroup
787 \gdef\@execute@begin@hook##1{\UseHook{env/##1/begin}}%
788 \@expl@@@initialize@all@@
789 \fi
790 % \end{macrocode}
791 % If this is an environment before \verb=\begin{document}= we just
792 % run the hook so this can be outside the test.
793 % \begin{macrocode}
794 \UseHook{env/#1/begin}%
795 }
796 % \end{macrocode}
797 %
798 % \begin{macrocode}
799 %</2ekernel|latexrelease>
800 %<latexrelease>\EndIncludeInRelease
801 % \end{macrocode}
802 %
803 % \begin{macrocode}
804 %<latexrelease>\IncludeInRelease{2019/10/01}%
805 %<latexrelease> {\begin}{Making \begin/\end robust}%
806 %<latexrelease>\DeclareRobustCommand\begin[1]{%
807 %<latexrelease> \@ifundefined{#1}%
808 %<latexrelease> {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
809 %<latexrelease> {\def\reserved@a{\def\@currenvir{#1}%
810 %<latexrelease> \edef\@currenvline{\on@line}%
811 %<latexrelease> \csname #1\endcsname}}%
812 %<latexrelease> \@ignorefalse
813 %<latexrelease> \begingroup\@endpefalse\reserved@a}
814 %<latexrelease>\EndIncludeInRelease
815 % \end{macrocode}
816 % A version that doesn't start out with \cs{relax} when in
817 % typesetting mode would be the following, but since \cs{begin}
818 % issues a \cs{begingroup} it wouldn't help much with respect to
819 % allowing things like \cs{noalign} or \cs{multicolumn} inside.
820 % \begin{macrocode}
821 %\edef\begin
822 % {\unexpanded{%
823 % \ifx\protect\@typeset@protect
824 % \expandafter\@gobble
825 % \fi
826 % \protect
827 % }%
828 % \expandafter\noexpand\csname begin \endcsname
829 % }
830 %\@namedef{begin }#1{%
831 % \@ifundefined{#1}%
832 % {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
833 % {\def\reserved@a{\def\@currenvir{#1}%
834 % \edef\@currenvline{\on@line}%
835 % \csname #1\endcsname}}%
836 % \@ignorefalse
837 % \begingroup\@endpefalse\reserved@a}
838 % \end{macrocode}
839 %
840 % \begin{macrocode}
841 %<latexrelease>\IncludeInRelease{0000/00/00}%
842 %<latexrelease> {\begin}{Making \begin/\end robust}%
843 %<latexrelease>\def\begin#1{%
844 %<latexrelease> \@ifundefined{#1}%
845 %<latexrelease> {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
846 %<latexrelease> {\def\reserved@a{\def\@currenvir{#1}%
847 %<latexrelease> \edef\@currenvline{\on@line}%
848 %<latexrelease> \csname #1\endcsname}}%
849 %<latexrelease> \@ignorefalse
850 %<latexrelease> \begingroup\@endpefalse\reserved@a}
851 %<latexrelease>
852 % \end{macrocode}
853 % Also undo the internal commands as some packages unfortunately test
854 % for their existence instead of using \cs{IfFormatAtLeastTF}.
855 % \changes{v1.1y}{2021/02/08}{Undo the internals for robust \cs{begin}
856 % and \cs{end} in rollback (gh/494)}
857 % \begin{macrocode}
858 %<latexrelease>\expandafter\let\csname begin \endcsname\@undefined
859 %<latexrelease>
860 %<latexrelease>\EndIncludeInRelease
861 %<*2ekernel>
862 % \end{macrocode}
863 % \end{macro}
864 %
865
866
867
868
869 % \begin{macro}{\end}
870 % The top level definition for \cs{end}.
871 % \changes{v1.2d}{2024/06/23}{Separate \cs{begin} and \cs{end} definitions
872 % for individual rollback}
873 % \begin{macrocode}
874 %</2ekernel>
875 %<*2ekernel|latexrelease>
876 %<latexrelease>\IncludeInRelease{2019/10/01}%
877 %<latexrelease> {\end}{Making \begin/\end robust}%
878 % \end{macrocode}
879 % While \cs{begin} was made robust simply by using
880 % \cs{DeclareRobustCommand} we need to be a bit more subtle with
881 % \cs{end} as there are packages out there that try to look into
882 % the top-level contents of \verb=\end{foo}= (that is at the expansion
883 % of \verb=\endfoo=) to see if it contains certain macros. This is
884 % done by hitting \verb=\end{foo}= with three \cs{expandafter}s,
885 % the first to get
886 %\begin{verbatim}
887 % \csname endfoo\endcsname \@checkend{foo}% etc.
888 %\end{verbatim}
889 % the second to expand the \cs{csname}, i.e., to get to
890 %\begin{verbatim}
891 % \endfoo \@checkend{foo}% etc.
892 %\end{verbatim}
893 % and the third to finally get to the top-level content of
894 % \verb=\endfoo=, i.e.
895 %\begin{verbatim}
896 % <top-level content of \endfoo> \@checkend{foo}% etc.
897 %\end{verbatim}
898 % Therefore a robust replacement should produce the same results
899 % after three expansions (there first is obviously different).
900 %
901 % Basically the definition of \cs{end} should either produce
902 % \verb*=\protect\end = (when not doing typesetting) or it should
903 % produce \verb*=\end = (without the \cs{protect}) when doing typesetting.
904 % Furthermore, it should (when in typesetting mode) show exactly the
905 % same result as
906 % \verb*=\end = (which is the original fragile definition
907 % of \cs{end}) when you expand either of them twice, i.e.,
908 %\begin{verbatim}
909 % \endfoo \@checkend{foo}% etc.
910 %\end{verbatim}
911 % That is achieved with the code below (which is worth studying
912 % carefully).
913 %
914 % There is some trickery involved here: in particular we use
915 % \cs{romannumeral} to change a single expansion into three
916 % successive expansions in one go. That primitive expands until it
917 % has scanned a number (0 in this case, so it doesn't produce any
918 % output) and so it allows us to place arbitrary many
919 % \cs{expandafter}s inside that are all going to be executed when
920 % \cs{romannumeral} is hit by a single \cs{expandafter}.
921 %
922 % \changes{v1.1e}{1996/07/26}{remove \cs{global} before \cs{@ignore...}}
923 % \changes{v1.1p}{2019/08/27}{Make command robust}
924 %
925 % \begin{macrocode}
926 \edef\end
927 {\unexpanded{%
928 \romannumeral
929 \ifx\protect\@typeset@protect
930 \expandafter %1
931 \expandafter %2
932 \expandafter %1
933 \expandafter %3 expands the \csname inside \end<space>
934 \expandafter %1
935 \expandafter %2 expands \end<space>
936 \expandafter %1 expands the \else
937 \z@
938 \else
939 \expandafter\z@\expandafter\protect
940 \fi
941 }%
942 \expandafter\noexpand\csname end \endcsname
943 }
944 %</2ekernel|latexrelease>
945 %<latexrelease>\EndIncludeInRelease
946 % \end{macrocode}
947 % And here is the original definition of \cs{end} the way it was in
948 % \LaTeX{} for several decades now hidden in \verb*=\end =.
949 % \begin{macrocode}
950 %<latexrelease>\IncludeInRelease{0000/00/00}%
951 %<latexrelease> {\end}{Making \begin/\end robust}%
952 %<latexrelease>\def\end#1{%
953 %<latexrelease> \csname end#1\endcsname\@checkend{#1}%
954 %<latexrelease> \expandafter\endgroup\if@endpe\@doendpe\fi
955 %<latexrelease> \if@ignore\@ignorefalse\ignorespaces\fi}
956 %<latexrelease>
957 %<latexrelease>\EndIncludeInRelease
958 %<*2ekernel>
959 % \end{macrocode}
960 % \end{macro}
961
962
963
964 % \begin{macro}{\end\verbvisiblespace}
965 % The internal version with a space at the end.
966 % \begin{macrocode}
967 %</2ekernel>
968 %<*2ekernel|latexrelease>
969 %<latexrelease>\IncludeInRelease{2024/11/01}%
970 %<latexrelease> {\end!space}{New @endpe handling}%
971 \@namedef{end }#1{%
972 \romannumeral
973 \IfHookEmptyTF{env/#1/end}%
974 {\expandafter\z@}%
975 {\z@\UseHook{env/#1/end}}%
976 \csname end#1\endcsname\@checkend{#1}%
977 % \end{macrocode}
978 % We can now close the environment group and due to the new
979 % \cs{if@endpe} handling we no longer need to \cs{expandafter}
980 % out of the group.
981 % \changes{v1.2d}{2024/06/23}{Adjust for new \texttt{@endpe} handling}
982 % \begin{macrocode}
983 % \expandafter\endgroup\if@endpe\@doendpe\fi
984 \endgroup
985 \UseHook{env/#1/after}%
986 \if@ignore\@ignorefalse\ignorespaces\fi
987 }
988 %</2ekernel|latexrelease>
989 %<latexrelease>\EndIncludeInRelease
990 % \end{macrocode}
991 %
992 % Version that adds hooks (so different from the 2019 version). It
993 % fixes tlb3722 but the change should perhaps be made in
994 % \texttt{tabularx} instead.
995 % \begin{macrocode}
996 % \begin{macrocode}
997 %<latexrelease>\IncludeInRelease{2020/10/01}%
998 %<latexrelease> {\end!space}{Use hook system}%
999 %<latexrelease>
1000 %<latexrelease>\@namedef{end }#1{%
1001 %<latexrelease> \romannumeral
1002 %<latexrelease> \IfHookEmptyTF{env/#1/end}%
1003 %<latexrelease> {\expandafter\z@}%
1004 %<latexrelease> {\z@\UseHook{env/#1/end}}%
1005 %<latexrelease> \csname end#1\endcsname\@checkend{#1}%
1006 %<latexrelease> \expandafter\endgroup\if@endpe\@doendpe\fi
1007 %<latexrelease> \UseHook{env/#1/after}%
1008 %<latexrelease> \if@ignore\@ignorefalse\ignorespaces\fi
1009 %<latexrelease>}
1010 %<latexrelease>\EndIncludeInRelease
1011 % \end{macrocode}
1012 %
1013 % Version without the fix for tlb3722 for the record:
1014 %\begin{verbatim}
1015 %\@namedef{end }#1{%
1016 % \UseHook{env/#1/end}%
1017 % \csname end#1\endcsname\@checkend{#1}%
1018 % \expandafter\endgroup\if@endpe\@doendpe\fi
1019 % \UseHook{env/#1/after}%
1020 % \if@ignore\@ignorefalse\ignorespaces\fi}%
1021 % \end{verbatim}
1022 %
1023 % \begin{macrocode}
1024 %<latexrelease>\IncludeInRelease{2019/10/01}%
1025 %<latexrelease> {\end!space}{Making \begin/\end robust}%
1026 %<latexrelease>
1027 %<latexrelease>\@namedef{end }#1{%
1028 %<latexrelease> \csname end#1\endcsname\@checkend{#1}%
1029 %<latexrelease> \expandafter\endgroup\if@endpe\@doendpe\fi
1030 %<latexrelease> \if@ignore\@ignorefalse\ignorespaces\fi}
1031 %<latexrelease>\EndIncludeInRelease
1032 % \end{macrocode}
1033 %
1034 % \begin{macrocode}
1035 %<latexrelease>\IncludeInRelease{0000/00/00}%
1036 %<latexrelease> {\end!space}{Making \begin/\end robust}%
1037 % \end{macrocode}
1038 % Undo the internal command as some packages unfortunately test
1039 % for their existence instead of using \cs{IfFormatAtLeastTF}.
1040 % \changes{v1.1y}{2021/02/08}{Undo the internals for robust \cs{begin}
1041 % and \cs{end} in rollback (gh/494)}
1042 % \begin{macrocode}
1043 %<latexrelease>\expandafter\let\csname end \endcsname\@undefined
1044 %<latexrelease>
1045 %<latexrelease>\EndIncludeInRelease
1046 %<*2ekernel>
1047 % \end{macrocode}
1048 % \end{macro}
1049 %
1050 %
1051 %
1052 %
1053 %
1054 % \begin{macro}{\@checkend}
1055 % \begin{macrocode}
1056 \def\@checkend#1{\def\reserved@a{#1}\ifx
1057 \reserved@a\@currenvir \else\@badend{#1}\fi}
1058 % \end{macrocode}
1059 % \end{macro}
1060 %
1061 % \begin{macro}{\@currenvline}
1062 % We do need a default value for |\@currenvline| on top-level since
1063 % the document environment cancels the brace group. This means that
1064 % a mismatch with |\begin|\allowbreak|{document}| will not produce
1065 % a line number. Thus the outer default must be |\@empty| or we
1066 % will end up with two spaces.
1067 % \changes{v1.0q}{1994/05/24}{Use \cs{@empty} as outer default}
1068 % \begin{macrocode}
1069 \let\@currenvline\@empty
1070 % \end{macrocode}
1071 % \end{macro}
1072 %
1073 %
1074 %
1075 % \begin{macro}{\AtBeginEnvironment,\AtEndEnvironment,
1076 % \BeforeBeginEnvironment,\AfterEndEnvironment}
1077 %
1078 % We provide 4 high-level hook interfaces directly, the others only when
1079 % etoolbox is loaded
1080 % \begin{macrocode}
1081 %</2ekernel>
1082 %<*2ekernel|latexrelease>
1083 %<latexrelease>\IncludeInRelease{2020/10/01}%
1084 %<latexrelease> {\AtBeginEnvironment}{Hooks for environments}%
1085 % \end{macrocode}
1086 %
1087 % \begin{macrocode}
1088 \newcommand\AtBeginEnvironment[2][.] {\AddToHook{env/#2/begin}[#1]}
1089 \newcommand\AtEndEnvironment[2][.] {\AddToHook{env/#2/end}[#1]}
1090 \newcommand\BeforeBeginEnvironment[2][.]{\AddToHook{env/#2/before}[#1]}
1091 \newcommand\AfterEndEnvironment[2][.] {\AddToHook{env/#2/after}[#1]}
1092 % \end{macrocode}
1093 %
1094 % \begin{macrocode}
1095 %</2ekernel|latexrelease>
1096 %<latexrelease>\EndIncludeInRelease
1097 % \end{macrocode}
1098 %
1099 % \begin{macrocode}
1100 %<latexrelease>\IncludeInRelease{0000/00/00}%
1101 %<latexrelease> {\AtBeginEnvironment}{Hooks for environments}%
1102 %<latexrelease>
1103 %<latexrelease>\let\AtBeginEnvironment\@undefined
1104 %<latexrelease>\let\AtEndEnvironment\@undefined
1105 %<latexrelease>\let\BeforeBeginEnvironment\@undefined
1106 %<latexrelease>\let\AfterEndEnvironment\@undefined
1107 %<latexrelease>
1108 %<latexrelease>\EndIncludeInRelease
1109 %<*2ekernel>
1110 % \end{macrocode}
1111 % \end{macro}
1112 %
1113 %
1114 %
1115 % \subsection{Center, Flushright, Flushleft}
1116 %
1117 % \begin{macrocode}
1118 \message{center,}
1119 % \end{macrocode}
1120 %
1121 % \begin{oldcomments}
1122 %
1123 % \center, \flushright and \flushleft set
1124 % \rightskip = 0pt or \@flushglue (as appropriate)
1125 % \leftskip = 0pt or \@flushglue (as appropriate)
1126 % \parindent = 0pt
1127 % \parfillskip = 0pt. (except \flushleft)
1128 % \\ == \par \vskip -\parskip
1129 % \\[LENGTH] == \\ \vskip LENGTH
1130 % \\* == \par \penalty 10000 \vskip -\parskip
1131 % \\*[LEN] == \\* \vskip LENGTH
1132 %
1133 % They invoke the trivlist environment to handle vertical spacing before
1134 % and after them.
1135 %
1136 % \centering, \raggedright and \raggedleft are the declaration analogs
1137 % of the above.
1138 %
1139 % \raggedright has a more universal effect, however. It sets
1140 % \@rightskip := flushglue. Every environment, like the list
1141 % environments,
1142 % that set \rightskip to its 'normal' value set it to \@rightskip
1143 %
1144 % \end{oldcomments}
1145 %
1146 % \begin{macro}{\@centercr}
1147 % \changes{v1.0h}{1994/05/03}{\cs{@badcrerr} replaced by \cs{@nolnerr}}
1148 % \changes{v1.0z}{1995/07/13}{Use \cs{nobreak}}
1149 % \changes{v1.1s}{2019/11/02}{Make \cs{@centercr} robust (gh/203)}
1150 % \begin{macrocode}
1151 %</2ekernel>
1152 %<*2ekernel|latexrelease>
1153 %<latexrelease>\IncludeInRelease{2020/02/02}%
1154 %<latexrelease> {\@centercr}{Make robust}%
1155 \protected\def\@centercr{\ifhmode \unskip\else \@nolnerr\fi
1156 \par\@ifstar{\nobreak\@xcentercr}\@xcentercr}
1157 %</2ekernel|latexrelease>
1158 % \end{macrocode}
1159 %
1160 % \begin{macrocode}
1161 %<latexrelease>\EndIncludeInRelease
1162 %<latexrelease>\IncludeInRelease{0000/00/00}%
1163 %<latexrelease> {\@centercr}{Make robust}%
1164 %<latexrelease>
1165 %<latexrelease>\def\@centercr{\ifhmode \unskip\else \@nolnerr\fi
1166 %<latexrelease> \par\@ifstar{\nobreak\@xcentercr}\@xcentercr}
1167 %<latexrelease>
1168 %<latexrelease>\EndIncludeInRelease
1169 %<*2ekernel>
1170 % \end{macrocode}
1171 % \end{macro}
1172 %
1173 % \begin{macro}{\@xcentercr}
1174 % \begin{macrocode}
1175 \def\@xcentercr{\addvspace{-\parskip}\@ifnextchar
1176 [\@icentercr\ignorespaces}
1177 % \end{macrocode}
1178 % \end{macro}
1179 %
1180 % \begin{macro}{\@icentercr}
1181 % \changes{v1.1t}{2020/04/21}{Support calc syntax (gh/152)}
1182 % \begin{macrocode}
1183 %</2ekernel>
1184 %<*2ekernel|latexrelease>
1185 %<latexrelease>\IncludeInRelease{2020/10/01}%
1186 %<latexrelease> {\@icentercr}{centering, etc support calc}%
1187 \def\@icentercr[#1]{\@vspace@calcify{#1}\ignorespaces}
1188 %</2ekernel|latexrelease>
1189 %<latexrelease>\EndIncludeInRelease
1190 % \end{macrocode}
1191 %
1192 % \begin{macrocode}
1193 %<latexrelease>\IncludeInRelease{0000/00/00}%
1194 %<latexrelease> {\@icentercr}{centering, etc support calc}%
1195 %<latexrelease>
1196 %<latexrelease>\def\@icentercr[#1]{\vskip #1\ignorespaces}
1197 %<latexrelease>\EndIncludeInRelease
1198 %<*2ekernel>
1199 % \end{macrocode}
1200 % \end{macro}
1201 %
1202 %
1203 % \begin{environment}{center}
1204 % \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}}
1205 % \changes{v1.0u}{1994/11/12}{Changed end macro to \cs{def}: safer and
1206 % consistent}
1207 % We use |\relax| to prevent |\item| scanning too far.
1208 % \begin{macrocode}
1209 \def\center{\trivlist \centering\item\relax}
1210 % \end{macrocode}
1211 %
1212 % \begin{macrocode}
1213 \def\endcenter{\endtrivlist}
1214 % \end{macrocode}
1215 % \end{environment}
1216 %
1217 %
1218 % \begin{macrocode}
1219 %</2ekernel>
1220 %<*2ekernel|latexrelease>
1221 %<latexrelease>\IncludeInRelease{2020/10/01}%
1222 %<latexrelease> {\centering}{Set finaldhypendemerits}%
1223 % \end{macrocode}
1224 %
1225 % \begin{macro}{\centering}
1226 % \changes{v1.1u}{2020/05/31}{Added \cs{finalhyphendemerits} setting (gh/247)}
1227 % \begin{macrocode}
1228 \DeclareRobustCommand\centering{%
1229 \let\\\@centercr
1230 \rightskip\@flushglue\leftskip\@flushglue
1231 \finalhyphendemerits=\z@
1232 \parindent\z@\parfillskip\z@skip}
1233 % \end{macrocode}
1234 % \end{macro}
1235 %
1236 % \begin{macro}{\raggedright}
1237 % \changes{v1.1u}{2020/05/31}{Added \cs{finalhyphendemerits} setting (gh/247)}
1238 % \begin{macrocode}
1239 \DeclareRobustCommand\raggedright{%
1240 \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
1241 \finalhyphendemerits=\z@
1242 \leftskip\z@skip
1243 \parindent\z@}
1244 % \end{macrocode}
1245 % \end{macro}
1246 %
1247 % \begin{macro}{\raggedleft}
1248 % \changes{v1.1u}{2020/05/31}{Added \cs{finalhyphendemerits} setting (gh/247)}
1249 % \begin{macrocode}
1250 \DeclareRobustCommand\raggedleft{%
1251 \let\\\@centercr
1252 \rightskip\z@skip\leftskip\@flushglue
1253 \finalhyphendemerits=\z@
1254 \parindent\z@\parfillskip\z@skip}
1255 % \end{macrocode}
1256 % \end{macro}
1257 %
1258 % \begin{macrocode}
1259 %</2ekernel|latexrelease>
1260 %<latexrelease>\EndIncludeInRelease
1261 %<latexrelease>\IncludeInRelease{2019/10/01}%
1262 %<latexrelease> {\centering}{Make commands robust}%
1263 %<latexrelease>
1264 %<latexrelease>\DeclareRobustCommand\centering{%
1265 %<latexrelease> \let\\\@centercr
1266 %<latexrelease> \rightskip\@flushglue\leftskip\@flushglue
1267 %<latexrelease> \parindent\z@\parfillskip\z@skip}
1268 %<latexrelease>\DeclareRobustCommand\raggedright{%
1269 %<latexrelease> \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
1270 %<latexrelease> \leftskip\z@skip
1271 %<latexrelease> \parindent\z@}
1272 %<latexrelease>\DeclareRobustCommand\raggedleft{%
1273 %<latexrelease> \let\\\@centercr
1274 %<latexrelease> \rightskip\z@skip\leftskip\@flushglue
1275 %<latexrelease> \parindent\z@\parfillskip\z@skip}
1276 %<latexrelease>\EndIncludeInRelease
1277 %<latexrelease>
1278 %<latexrelease>\IncludeInRelease{0000/00/00}%
1279 %<latexrelease> {\centering}{Make commands robust}%
1280 %<latexrelease>
1281 %<latexrelease>\kernel@make@fragile\centering
1282 %<latexrelease>\kernel@make@fragile\raggedright
1283 %<latexrelease>\kernel@make@fragile\raggedleft
1284 %<latexrelease>
1285 %<latexrelease>\EndIncludeInRelease
1286 %<*2ekernel>
1287 % \end{macrocode}
1288 %
1289 %
1290 %
1291 % \begin{macro}{\@rightskip}
1292 % \begin{macrocode}
1293 \newskip\@rightskip \@rightskip \z@skip
1294 % \end{macrocode}
1295 % \end{macro}
1296 %
1297 % \begin{environment}{flushleft}
1298 % \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}}
1299 % \changes{v1.0u}{1994/11/12}{Changed end macro to \cs{def}: safer and
1300 % consistent}
1301 % We use |\relax| to prevent |\item| scanning too far.
1302 % \begin{macrocode}
1303 \def\flushleft{\trivlist \raggedright\item\relax}
1304 % \end{macrocode}
1305 %
1306 % \begin{macrocode}
1307 \def\endflushleft{\endtrivlist}
1308 % \end{macrocode}
1309 % \end{environment}
1310 %
1311 %
1312 % \begin{environment}{flushright}
1313 % \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}}
1314 % \changes{v1.0u}{1994/11/12}{Changed end macro to \cs{def}: safer and
1315 % consistent}
1316 % We use |\relax| to prevent |\item| scanning too far.
1317 % \begin{macrocode}
1318 \def\flushright{\trivlist \raggedleft\item\relax}
1319 % \end{macrocode}
1320 %
1321 % \begin{macrocode}
1322 \def\endflushright{\endtrivlist}
1323 % \end{macrocode}
1324 % \end{environment}
1325 %
1326 %
1327 % \subsection{Verbatim}
1328 %
1329 % \begin{macrocode}
1330 \message{verbatim,}
1331 % \end{macrocode}
1332 %
1333 % The verbatim environment uses the fixed-width |\ttfamily| font, turns
1334 % blanks into spaces, starts a new line for each carriage return (or
1335 % sequence of consecutive carriage returns), and interprets
1336 % \emph{every} character literally.
1337 % I.e., all special characters |\, {, $|, etc.
1338 % are |\catcode|'d to 'other'.
1339 %
1340 % The command |\verb| produces in-line verbatim text, where the argument
1341 % is delimited by any pair of characters. E.g., |\verb #...#| takes
1342 % `|...|' as its argument, and sets it verbatim in |\ttfamily| font.
1343 %
1344 % The *-variants of these commands are the same, except that spaces
1345 % print as the \TeX{}book's space character instead of as blank spaces.
1346 %
1347 % \begin{macro}{\@vobeyspaces}
1348 % \changes{v1.2b}{2023/06/15}{Support tabs}
1349 % \begin{macro}{\@vobeytabs}
1350 % \changes{v1.2b}{2023/06/14}{Macro added}
1351 % \changes{v1.2c}{2023/09/01}{Provide global definition for active tab}
1352 % \begin{macrocode}
1353 %</2ekernel>
1354 %<latexrelease>\IncludeInRelease{2023/11/01}%
1355 %<latexrelease> {\@vobeytabs}{Obeyed tabs}%
1356 %<*2ekernel|latexrelease>
1357 {\catcode`\ =\active%
1358 \gdef\@vobeyspaces{\catcode`\ \active\let \@xobeysp\@vobeytabs}}
1359 {\catcode`\^^I=\active
1360 \gdef\@vobeytabs{\catcode`\^^I\active\let^^I\@xobeytab}%
1361 \global\let^^I=\space
1362 }
1363 %</2ekernel|latexrelease>
1364 %<latexrelease>\EndIncludeInRelease
1365 %<latexrelease>\IncludeInRelease{0000/00/00}%
1366 %<latexrelease> {\@vobeytabs}{Obeyed tabs}%
1367 %<latexrelease>{\catcode`\ =\active%
1368 %<latexrelease>\gdef\@vobeyspaces{\catcode`\ \active\let \@xobeysp}}
1369 %<latexrelease>\let\@vobeytabs\@undefined
1370 %<latexrelease>\EndIncludeInRelease
1371 %<*2ekernel>
1372 % \end{macrocode}
1373 % \end{macro}
1374 % \end{macro}
1375 %
1376 % \begin{macro}{\@xobeysp}
1377 % \changes{v1.0z}{1995/07/13}{Use \cs{nobreak}}
1378 % \changes{v1.1f}{1996/09/28}{Moved to ltspace.dtx}
1379 % \end{macro}
1380 %
1381 %
1382 % \begin{macro}{\@xverbatim}
1383 % \begin{macro}{\@sxverbatim}
1384 % \begin{macrocode}
1385 \begingroup \catcode `|=0 \catcode `[= 1
1386 \catcode`]=2 \catcode `\{=12 \catcode `\}=12
1387 \catcode`\\=12 |gdef|@xverbatim#1\end{verbatim}[#1|end[verbatim]]
1388 |gdef|@sxverbatim#1\end{verbatim*}[#1|end[verbatim*]]
1389 |endgroup
1390 % \end{macrocode}
1391 % \end{macro}
1392 % \end{macro}
1393 %
1394 % \begin{macro}{\@verbatim}
1395 % \changes{LaTeX2.09}{1991/07/24}{Added \cs{penalty}\cs{interlinepenalty}
1396 % to definition of \cs{par} so that \cs{samepage} works}
1397 % \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}}
1398 % Real start of verbatim environment
1399 % We use |\relax| to prevent |\item| scanning too far.
1400 % \changes{v0.9p}{1994/01/18}
1401 % {Add \cs{global}\cs{@inlabelfalse}}
1402 % \changes{v1.0b}{1994/03/16}
1403 % {Remove \cs{global}\cs{@inlabelfalse} again.}
1404 % \begin{macrocode}
1405 %</2ekernel>
1406 %<*2ekernel|latexrelease>
1407 %<latexrelease>\IncludeInRelease{2017-04-15}{\@verbatim}%
1408 %<latexrelease> {Disable hyphenation in verbatim}%
1409 \def\@verbatim{\trivlist \item\relax
1410 \if@minipage\else\vskip\parskip\fi
1411 \leftskip\@totalleftmargin\rightskip\z@skip
1412 \parindent\z@\parfillskip\@flushglue\parskip\z@skip
1413 % \end{macrocode}
1414 % \changes{LaTeX2.09}{1991/08/26}{\cs{@@par} added}
1415 % Added |\@@par| to clear possible |\parshape| definition
1416 % from a surrounding list (the verbatim guru says).
1417 % \changes{v0.9p}{1994/01/18}
1418 % {Only add \cs{penalty} if in hmode}
1419 % Switch language when in vertical mode.
1420 % \begin{macrocode}
1421 \@@par
1422 % \end{macrocode}
1423 % Set |\language| here to suppress hyphenation. Done this way rather
1424 % than setting |\hyphenchar| as that is a global setting.
1425 % \begin{macrocode}
1426 \language\l@nohyphenation
1427 \@tempswafalse
1428 \def\par{%
1429 \if@tempswa
1430 % \end{macrocode}
1431 % A |\leavevmode| added: needed if, for example, a blank verbatim
1432 % line is the first thing in a list item (wow!).
1433 % \changes{v1.0f}{1994/04/29}{\cs{leavevmode} added}
1434 % \begin{macrocode}
1435 \leavevmode \null \@@par\penalty\interlinepenalty
1436 \else
1437 \@tempswatrue
1438 \ifhmode\@@par\penalty\interlinepenalty\fi
1439 \fi}%
1440 % \end{macrocode}
1441 % To allow customization we hide the font used in a separate macro.
1442 % \changes{v0.9a}{1993/11/21}{use \cs{verbatim@font} instead of \cs{tt}}
1443 % \changes{v0.9h}{1993/12/13}{Readded \cs{@noligs}}
1444 % \changes{v1.1d}{1996/06/03}{Exchanged the following two code lines
1445 % so that \cs{dospecials} cannot reset the category code
1446 % of characters handled by \cs{@noligs}.}
1447 % \changes{v1.1h}{2000/01/07}{Disable hyphenation even if the font allows it.}
1448 % \changes{v1.1m}{2017-03-09}{Use \cs{language} not \cs{hyphenchar}}
1449 % \begin{macrocode}
1450 \let\do\@makeother \dospecials
1451 \obeylines \verbatim@font \@noligs
1452 % \end{macrocode}
1453 % To avoid a breakpoint after the labels box, we remove the penalty
1454 % put there by the list macros: another use of |\unpenalty|!
1455 % \changes{v1.0f}{1994/04/29}{Change to \cs{everypar} added}
1456 % \begin{macrocode}
1457 \everypar \expandafter{\the\everypar \unpenalty}%
1458 }
1459 %</2ekernel|latexrelease>
1460 %<latexrelease>\EndIncludeInRelease
1461 %<latexrelease>\IncludeInRelease{0000-00-00}{\@verbatim}%
1462 %<latexrelease> {Disable hyphenation in verbatim}%
1463 %<latexrelease>\def\@verbatim{\trivlist \item\relax
1464 %<latexrelease> \if@minipage\else\vskip\parskip\fi
1465 %<latexrelease> \leftskip\@totalleftmargin\rightskip\z@skip
1466 %<latexrelease> \parindent\z@\parfillskip\@flushglue\parskip\z@skip
1467 %<latexrelease> \@@par
1468 %<latexrelease> \@tempswafalse
1469 %<latexrelease> \def\par{%
1470 %<latexrelease> \if@tempswa
1471 %<latexrelease> \leavevmode \null \@@par\penalty\interlinepenalty
1472 %<latexrelease> \else
1473 %<latexrelease> \@tempswatrue
1474 %<latexrelease> \ifhmode\@@par\penalty\interlinepenalty\fi
1475 %<latexrelease> \fi}%
1476 %<latexrelease> \let\do\@makeother \dospecials
1477 %<latexrelease> \obeylines \verbatim@font \@noligs
1478 %<latexrelease> \hyphenchar\font\m@ne
1479 %<latexrelease> \everypar \expandafter{\the\everypar \unpenalty}%
1480 %<latexrelease>}
1481 %<latexrelease>\EndIncludeInRelease
1482 %<*2ekernel>
1483 % \end{macrocode}
1484 % \end{macro}
1485 %
1486 % \begin{environment}{verbatim}
1487 % \begin{macro}{\verbatim}
1488 % \begin{macro}{\endverbatim}
1489 % (RmS 93/09/19) Protected against `missing item' error message
1490 % triggered by empty verbatim environment.
1491 % \begin{macrocode}
1492 \def\verbatim{\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}
1493 \def\endverbatim{\if@newlist \leavevmode\fi\endtrivlist}
1494 % \end{macrocode}
1495 % \end{macro}
1496 % \end{macro}
1497 % \end{environment}
1498 %
1499 % \begin{macro}{\verbatim@font}
1500 % \changes{v0.9a}{1993/11/21}{Macro added}
1501 % Macro to select the font used for verbatim typesetting.
1502 % It also does other work if necessary for the font used.
1503 % \changes{v0.9s}{1994/01/21}{Removed unnecessary category code
1504 % hackery.}
1505 % \begin{macrocode}
1506 \def\verbatim@font{\normalfont\ttfamily}
1507 % \end{macrocode}
1508 % \end{macro}
1509 %
1510 %
1511 % \begin{macrocode}
1512 %</2ekernel>
1513 %<*2ekernel|latexrelease>
1514 %<latexrelease>\IncludeInRelease{2018/12/01}%
1515 %<latexrelease> {\verbvisiblespace}{Setup visible space for \verb}%
1516 % \end{macrocode}
1517 %
1518 %
1519 % \begin{macro}{\asciispace}
1520 % The character in slot 32, in typewriter fonts (historically) a
1521 % visible space but in other fonts a real space or something else
1522 % \changes{v1.1o}{2018/10/11}
1523 % {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
1524 % \begin{macrocode}
1525 \DeclareRobustCommand\asciispace{\char 32 }
1526 % \end{macrocode}
1527 % \end{macro}
1528 %
1529 % \begin{macro}{\verbvisiblespace}
1530 % This defines how to get a visible space in
1531 % |\verb*| and friends. In classic \TeX{} this is just the
1532 % slot 32, but in TU encoded fonts we switch fonts and take the
1533 % character from cmtt.
1534 % \changes{v1.1o}{2018/10/11}
1535 % {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
1536 % \changes{v1.1o}{2018/10/11}
1537 % {Provide \cs{verbvisiblespace} such that it is usable in normal text (github/70)}
1538 % \begin{macrocode}
1539 \ifx\Umathcode\@undefined
1540 \let\verbvisiblespace\asciispace % Pdftex version
1541 \else
1542 \DeclareRobustCommand\verbvisiblespace
1543 {\leavevmode{\usefont{OT1}{cmtt}{m}{n}\asciispace}} % xetex/luatex version
1544 \fi
1545 % \end{macrocode}
1546 % \end{macro}
1547 %
1548 %
1549 % ^^A \@setupverbvisiblespace was here
1550 %
1551 % \begin{macro}{\@verbvisiblespacebox}
1552 % The box to hold the visible space character if it isn't in slot
1553 % 32 in the current typewriter font.
1554 % \changes{v1.1o}{2018/10/11}
1555 % {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
1556 % \begin{macrocode}
1557 \newbox\@verbvisiblespacebox
1558 % \end{macrocode}
1559 % \end{macro}
1560 %
1561 %^^A \@sverb was here
1562 %
1563 % \begin{environment}{verbatim*}
1564 % For \texttt{verbatim*} we also set up the correct visible space
1565 % character definition and then run |\@vobeyspaces|. As this code
1566 % is not called as part of the normal verbatim environment (the
1567 % method is done the other way around this time) we don't have to
1568 % check if space is already active---it shouldn't be.
1569 % \changes{v1.1o}{2018/10/11}
1570 % {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
1571 % \changes{v1.2b}{2023/06/14}
1572 % {Support visible tabs in \cs{verb*}}
1573 % \begin{macrocode}
1574 \@namedef{verbatim*}{\@verbatim
1575 \@setupverbvisiblespace
1576 \frenchspacing\@vobeyspaces\@sxverbatim}
1577 \expandafter\let\csname endverbatim*\endcsname =\endverbatim
1578 % \end{macrocode}
1579 % \end{environment}
1580 %
1581 % \begin{macrocode}
1582 %</2ekernel|latexrelease>
1583 %<latexrelease>\EndIncludeInRelease
1584 %<latexrelease>\IncludeInRelease{0000/00/00}%
1585 %<latexrelease> {\verbvisiblespace}{Setup visible space for \verb}%
1586 %<latexrelease>
1587 %<latexrelease>\@namedef{verbatim*}{\@verbatim\@sxverbatim}
1588 %<latexrelease>
1589 %<latexrelease>\let\asciispace \@undefined
1590 %<latexrelease>\let\verbvisiblespace \@undefined
1591 %<latexrelease>\let\@setupverbvisiblespace\@undefined
1592 %<latexrelease>\let\@verbvisiblespacebox \@undefined
1593 %<latexrelease>\EndIncludeInRelease
1594 %<*2ekernel>
1595 % \end{macrocode}
1596 %
1597 % \begin{macro}{\@setupverbvisiblespace}
1598 %
1599 % In pdf\TeX{} a catcode 12 space will produce the character in
1600 % slot 32 which is assumed to be a visible space character (in a
1601 % typewriter font in OT1 or T1 encoding). In Xe\TeX{} or Lua\TeX{} a
1602 % font in TU encoding is normally used and that has a real space in
1603 % this slot. So what we do in this case is this: we check the
1604 % definition of
1605 % |\verbvisiblespace| and if it is |\asciispace| we assume that the
1606 % char32 can be used (e.g., in pdf\TeX{}). We then redefine
1607 % |\@xobeysp| so that after running |\@vobeyspaces| we get
1608 % characters from slot 32 for each active space.
1609 %
1610 % \changes{v1.1o}{2018/10/11}
1611 % {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
1612 % \changes{v1.2b}{2023/06/15}
1613 % {Support visible tabs}
1614 % \begin{macrocode}
1615 %</2ekernel>
1616 %<*2ekernel|latexrelease>
1617 %<latexrelease>\IncludeInRelease{2023/11/01}%
1618 %<latexrelease> {\@setupverbvisiblespace}{Setup visible tab for \verb}%
1619 \def\@setupverbvisiblespace{%
1620 \ifx\verbvisiblespace\asciispace
1621 \let\@xobeysp\asciispace
1622 \else
1623 % \end{macrocode}
1624 % Otherwise we measure the width of a character in
1625 % the mono-spaced current font and place a
1626 % |\verbvisiblespace| into a box of the right width which we are then
1627 % using as the character for a space. By default this will be the space
1628 % character from OT1 cmtt but by changing
1629 % |\verbvisiblespace| one could use, for example, the |\textvisiblespace|
1630 % of the current typewriter font.
1631 % \begin{macrocode}
1632 \setbox\z@\hbox{x}%
1633 \setbox\@verbvisiblespacebox\hbox to\wd\z@{\hss\verbvisiblespace\hss}%
1634 \def\@xobeysp{\leavevmode\copy\@verbvisiblespacebox}%
1635 \fi
1636 \@setupverbvisibletab
1637 }
1638 %</2ekernel|latexrelease>
1639 %<latexrelease>\EndIncludeInRelease
1640 %<latexrelease>\IncludeInRelease{2018/12/01}%
1641 %<latexrelease> {\@setupverbvisiblespace}{Setup visible space for \verb}%
1642 %<latexrelease>\def\@setupverbvisiblespace{%
1643 %<latexrelease> \ifx\verbvisiblespace\asciispace
1644 %<latexrelease> \let\@xobeysp\asciispace
1645 %<latexrelease> \else
1646 %<latexrelease> \setbox\z@\hbox{x}%
1647 %<latexrelease> \setbox\@verbvisiblespacebox\hbox to\wd\z@{\hss\verbvisiblespace\hss}%
1648 %<latexrelease> \def\@xobeysp{\leavevmode\copy\@verbvisiblespacebox}%
1649 %<latexrelease> \fi
1650 %<latexrelease>}
1651 %<latexrelease>\EndIncludeInRelease
1652 %<latexrelease>\IncludeInRelease{0000/00/00}%
1653 %<latexrelease> {\@setupverbvisiblespace}{Setup visible space for \verb}%
1654 %<latexrelease>\let\@setupverbvisiblespace\@undefined
1655 %<latexrelease>\EndIncludeInRelease
1656 %<*2ekernel>
1657 % \end{macrocode}
1658 % \end{macro}
1659 %
1660 % \begin{macro}{\@setupverbvisibletab}
1661 % \changes{v1.2q}{2023/06/15}
1662 % {Provide visible tab in \cs{verb*}}
1663 % A redirection: just a simple wrapper.
1664 % \begin{macrocode}
1665 %</2ekernel>
1666 %<latexrelease>\IncludeInRelease{2023/11/01}%
1667 %<latexrelease> {\@setupverbvisibletab}{Setup visible tab for \verb}%
1668 %<*2ekernel|latexrelease>
1669 \def\@setupverbvisibletab{\let\@xobeytab\@xobeysp}
1670 %</2ekernel|latexrelease>
1671 %<latexrelease>\EndIncludeInRelease
1672 %<latexrelease>\IncludeInRelease{0000/00/00}%
1673 %<latexrelease> {\@setupverbvisibletab}{Setup visible tab for \verb}%
1674 %<latexrelease>\let\@setupverbvisibletab\@undefined
1675 %<latexrelease>\EndIncludeInRelease
1676 %<*2ekernel>
1677 % \end{macrocode}
1678 % \end{macro}
1679 %
1680 % \begin{macro}{\@sverb}
1681 % \begin{macro}{\@@sverb}
1682 % \changes{v1.0j}{1994/05/10}{Slight change in error message text.}
1683 % Definitions of |\@sverb| and |\@verb| changed so |\verb+ foo+|
1684 % does not lose leading blanks when it comes at the beginning of a line.
1685 % Change made 24 May 89. Suggested by Frank Mittelbach and Rainer
1686 % Sch\"opf.
1687 % \begin{macrocode}
1688 %</2ekernel>
1689 %<*2ekernel|latexrelease>
1690 %<latexrelease>\IncludeInRelease{2023/11/01}%
1691 %<latexrelease> {\@sverb}{Support visible tabs}%
1692 % \end{macrocode}
1693 %
1694 % If the users types \verb=\verb !~! foo= then surprisingly we would
1695 % get the space as the delimiter and thus
1696 % ``\verb=!~!foo='' in the output.
1697 % To avoid this scenario we check if \verb=#1= has the character
1698 % code of a space, if so we recurse otherwise we call \cs{@@sverb}
1699 % (which is the original definition of \cs{@sverb}).
1700 % \changes{v1.1u}{2020/04/22}{Drop spaces before \cs{verb} delimiter (gh/327)}
1701 % \begin{macrocode}
1702 \def\@sverb#1{\if\noexpand#1 \expandafter\@sverb\else\@@sverb{#1}\fi}
1703 % \end{macrocode}
1704 %
1705 % \changes{v1.1z}{2021/06/05}{Normalize error message}
1706 % \begin{macrocode}
1707 \def\@@sverb#1{%
1708 \catcode`#1\active
1709 \lccode`\~`#1%
1710 \gdef\verb@balance@group{\verb@egroup
1711 \@latex@error{\noexpand\verb illegal in argument}\@ehc}%
1712 \aftergroup\verb@balance@group
1713 \lowercase{\let~\verb@egroup}%
1714 % \end{macrocode}
1715 % If |\@sverb| is called from |\@verb| then space is already active
1716 % and supposed to produce a real space. In this case we do
1717 % nothing. Otherwise we run |\@setupverbvisiblespace| to setup the
1718 % right visible space char and afterwards |\@vobeyspaces| to make
1719 % it the definition for the active space character.
1720 % \changes{v1.1o}{2018/10/11}
1721 % {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)}
1722 % \changes{v1.2b}{2023/06/15}
1723 % {Support visible tabs}
1724 % \begin{macrocode}
1725 \ifnum0%
1726 \ifnum\catcode`\ =\active\else 1\fi
1727 \ifnum\catcode`\^^I=\active\else 1\fi
1728 =0 %
1729 \else \@setupverbvisiblespace \@vobeyspaces \fi
1730 }
1731 % \end{macrocode}
1732 %
1733 % \begin{macrocode}
1734 %</2ekernel|latexrelease>
1735 %<latexrelease>\EndIncludeInRelease
1736 %<latexrelease>\IncludeInRelease{2020/10/01}%
1737 %<latexrelease> {\@sverb}{Drop spaces before \verb delimiter}%
1738 %<latexrelease>\def\@@sverb#1{%
1739 %<latexrelease> \catcode`#1\active
1740 %<latexrelease> \lccode`\~`#1%
1741 %<latexrelease> \gdef\verb@balance@group{\verb@egroup
1742 %<latexrelease> \@latex@error{\noexpand\verb illegal in argument}\@ehc}%
1743 %<latexrelease> \aftergroup\verb@balance@group
1744 %<latexrelease> \lowercase{\let~\verb@egroup}%
1745 %<latexrelease> \ifnum\catcode`\ =\active
1746 %<latexrelease> \else \@setupverbvisiblespace \@vobeyspaces \fi
1747 %<latexrelease>}
1748 %<latexrelease>\EndIncludeInRelease
1749 %<latexrelease>\IncludeInRelease{2018/12/01}%
1750 %<latexrelease> {\@sverb}{Setup visible space for \verb}%
1751 %<latexrelease>
1752 %<latexrelease>\def\@sverb#1{%
1753 %<latexrelease> \catcode`#1\active
1754 %<latexrelease> \lccode`\~`#1%
1755 %<latexrelease> \gdef\verb@balance@group{\verb@egroup
1756 %<latexrelease> \@latex@error{\noexpand\verb illegal in command argument}\@ehc}%
1757 %<latexrelease> \aftergroup\verb@balance@group
1758 %<latexrelease> \lowercase{\let~\verb@egroup}%
1759 %<latexrelease> \ifnum\catcode`\ =\active
1760 %<latexrelease> \else \@setupverbvisiblespace \@vobeyspaces \fi
1761 %<latexrelease>}
1762 %<latexrelease>\let\@@sverb\@undefined
1763 %<latexrelease>\EndIncludeInRelease
1764 %<latexrelease>
1765 %<latexrelease>\IncludeInRelease{0000/00/00}%
1766 %<latexrelease> {\@sverb}{Setup visible space for \verb}%
1767 %<latexrelease>\def\@sverb#1{%
1768 %<latexrelease> \catcode`#1\active
1769 %<latexrelease> \lccode`\~`#1%
1770 %<latexrelease> \gdef\verb@balance@group{\verb@egroup
1771 %<latexrelease> \@latex@error{\noexpand\verb illegal in command argument}\@ehc}%
1772 %<latexrelease> \aftergroup\verb@balance@group
1773 %<latexrelease> \lowercase{\let~\verb@egroup}}%
1774 %<latexrelease>
1775 %<latexrelease>\EndIncludeInRelease
1776 %<*2ekernel>
1777 % \end{macrocode}
1778 % \end{macro}
1779 % \end{macro}
1780 %
1781 %
1782 % \begin{macro}{\@makeother}
1783 % \begin{macrocode}
1784 \def\@makeother#1{\catcode`#112\relax}
1785 % \end{macrocode}
1786 % \end{macro}
1787 %
1788 % \begin{macro}{\verb@balance@group}
1789 % \changes{LaTeX2.09}{1993/09/07}
1790 % {(RmS) Changed definition of \cs{verb} so that it detects a
1791 % missing second delimiter.}
1792 % \begin{macrocode}
1793 \let\verb@balance@group\@empty
1794 % \end{macrocode}
1795 % \end{macro}
1796 %
1797 % \begin{macro}{\verb@egroup}
1798 % \begin{macrocode}
1799 \def\verb@egroup{\global\let\verb@balance@group\@empty\egroup}
1800 % \end{macrocode}
1801 % \end{macro}
1802 %
1803 % \begin{macro}{\verb@eol@error}
1804 % \begin{macrocode}
1805 \begingroup
1806 \obeylines%
1807 \gdef\verb@eol@error{\obeylines%
1808 \def^^M{\verb@egroup\@latex@error{%
1809 \noexpand\verb ended by end of line}\@ehc}}%
1810 \endgroup
1811 % \end{macrocode}
1812 % \end{macro}
1813 %
1814 % \begin{macro}{\verb}
1815 % \changes{LaTeX2.09}{1992/08/24}
1816 % {Changed \cs{verb} and \cs{@sverb} to work correctly
1817 % in math mode}
1818 % \changes{v0.9a}{1993/11/21}{Use \cs{verbatim@font} instead of
1819 % \cs{tt}.}
1820 % \changes{v1.1a}{1995/09/19}{Put \cs{@noligs} after
1821 % \cs{verbatim@font} where it belongs.}
1822 % Typesetting a small piece verbatim.
1823 % \changes{v1.1d}{1996/06/03}{Put setting of verbatim font after
1824 % \cs{dospecials}
1825 % so that \cs{dospecials} cannot reset the category code
1826 % of characters handled by \cs{@noligs}.}
1827 % \changes{v1.1m}{2017/03/09}
1828 % {Use \cs{language} to stop hyphenation}
1829 % \begin{macrocode}
1830 %</2ekernel>
1831 %<*2ekernel|latexrelease>
1832 %<latexrelease>\IncludeInRelease{2017-04-15}{\verb}%
1833 %<latexrelease> {Disable hyphenation in verb}%
1834 \def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
1835 \bgroup
1836 \verb@eol@error \let\do\@makeother \dospecials
1837 \verbatim@font\@noligs
1838 % \end{macrocode}
1839 % Set |\language| here to suppress hyphenation. Done this way rather
1840 % than setting |\hyphenchar| as that is a global setting.
1841 % \begin{macrocode}
1842 \language\l@nohyphenation
1843 \@ifstar\@sverb\@verb}
1844 %</2ekernel|latexrelease>
1845 %<latexrelease>\EndIncludeInRelease
1846 %<latexrelease>\IncludeInRelease{0000-00-00}{\verb}%
1847 %<latexrelease> {Disable hyphenation in verb}%
1848 %<latexrelease>\def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
1849 %<latexrelease> \bgroup
1850 %<latexrelease> \verb@eol@error \let\do\@makeother \dospecials
1851 %<latexrelease> \verbatim@font\@noligs
1852 %<latexrelease> \@ifstar\@sverb\@verb}
1853 %<latexrelease>\EndIncludeInRelease
1854 %<*2ekernel>
1855 % \end{macrocode}
1856 % \end{macro}
1857 %
1858 %
1859 %
1860 % \begin{macro}{\@verb}
1861 % \begin{macrocode}
1862 \def\@verb{\@vobeyspaces \frenchspacing \@sverb}
1863 % \end{macrocode}
1864 % \end{macro}
1865 %
1866 % \begin{macro}{\verbatim@nolig@list}
1867 % \changes{LaTeX2.09}{1993/09/03}
1868 % {Replaced \cs{@noligs} by extensible list}
1869 % \begin{macrocode}
1870 \def\verbatim@nolig@list{\do\`\do\<\do\>\do\,\do\'\do\-}
1871 % \end{macrocode}
1872 % \end{macro}
1873 %
1874 % \begin{macro}{\do@noligs}
1875 % \begin{macrocode}
1876 \def\do@noligs#1{%
1877 \catcode`#1\active
1878 \begingroup
1879 \lccode`\~`#1\relax
1880 \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1}}}
1881 % \end{macrocode}
1882 % \end{macro}
1883 %
1884 % \begin{macro}{\@noligs}
1885 % To stay compatible with packages that use |\@noligs| we keep it.
1886 % \changes{v0.9h}{1993/12/13}{Readded \cs{@noligs}}
1887 % \begin{macrocode}
1888 \def\@noligs{\let\do\do@noligs \verbatim@nolig@list}
1889 % \end{macrocode}
1890 % \end{macro}
1891 %
1892 % \changes{v0.9i}{1993/12/16}{\cs{literal} added}
1893 % \changes{v1.0r}{1994/05/26/16}{\cs{literal} removed}
1894 % \begin{macrocode}
1895 %</2ekernel>
1896 % \end{macrocode}
1897 %
1898 % \Finale
1899 %