diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/base/ltmiscen.dtx |
Initial commit
Diffstat (limited to 'macros/latex/base/ltmiscen.dtx')
-rw-r--r-- | macros/latex/base/ltmiscen.dtx | 1119 |
1 files changed, 1119 insertions, 0 deletions
diff --git a/macros/latex/base/ltmiscen.dtx b/macros/latex/base/ltmiscen.dtx new file mode 100644 index 0000000000..122ef3b39b --- /dev/null +++ b/macros/latex/base/ltmiscen.dtx @@ -0,0 +1,1119 @@ +% \iffalse meta-comment +% +% Copyright 1993-2018 +% The LaTeX3 Project and any individual authors listed elsewhere +% in this file. +% +% This file is part of the LaTeX base system. +% ------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3c +% of this license or (at your option) any later version. +% The latest version of this license is in +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This file has the LPPL maintenance status "maintained". +% +% The list of all files belonging to the LaTeX base distribution is +% given in the file `manifest.txt'. See also `legal.txt' for additional +% information. +% +% The list of derived (unpacked) files belonging to the distribution +% and covered by LPPL is defined by the unpacking scripts (with +% extension .ins) which are part of the distribution. +% +% \fi +% \iffalse +%%% From File: ltmiscen.dtx +% +%<*driver> +% \fi +\ProvidesFile{ltmiscen.dtx} + [2018/10/11 v1.1o LaTeX Kernel (Misc. Environments)] +% \iffalse +\documentclass{ltxdoc} +\GetFileInfo{ltmiscen.dtx} +\title{\filename} +\date{\filedate} + \author{% + Johannes Braams\and + David Carlisle\and + Alan Jeffrey\and + Leslie Lamport\and + Frank Mittelbach\and + Chris Rowley\and + Rainer Sch\"opf} + +\begin{document} + \MaintainedByLaTeXTeam{latex} + \maketitle + \DocInput{\filename} +\end{document} +%</driver> +% \fi +% +% +% \changes{v1.0c}{1994/03/28}{Improve Documentation} +% \changes{v1.0d}{1994/03/29}{Remove counter macros to ltcntlen} +% \changes{v1.0g}{1994/05/02}{Changed 91 to 1991 and moved some bits} +% \changes{v1.0i}{1994/05/05}{Removed braces from ifnextchar and +% ifstar arguments} +% \changes{v1.0m}{1994/05/20}{Use new warning commands} +% \changes{v1.0n}{1994/05/21}{Use new error commands} +% \changes{v1.0s}{1994/10/14}{Move math to other file} +% \changes{v1.0v}{1994/11/17} +% {\cs{@tempa} to \cs{reserved@a}} +% \changes{v1.0x}{1995/04/22}{Removed extra def of \cs{@gobble}} +% \changes{v1.0z}{1995/07/13}{Improve Documentation} +% \changes{v1.1c}{1996/04/22}{Improve Documentation} +% \changes{v1.1d}{1996/06/03}{Move setting of verbatim font and +% \cs{@noligs}.} +% \changes{v1.1g}{1998/08/17}{(RmS) Minor documentation fixes.} +% +% \section{Miscellaneous Environments} +% This section implements the basic environment mechanism, and also +% a few specific environments including |document|, The math +% environments and related commands, the `flushing' environments, +% (|center|, |flushleft|, |flushright|), and |verbatim|. +% +% \StopEventually{} +% +% \begin{macrocode} +%<*2ekernel> +\message{environments,} +% \end{macrocode} +% +% \subsection{Environments} +% +% |\begin{foo}| and |\end{foo}| are used to delimit environment |foo|. +% +% |\begin{foo}| starts a group and calls |\foo| if it is defined, +% otherwise it does nothing. +% +% |\end{foo}| checks to see that it matches the +% corresponding |\begin| and if so, it calls |\endfoo| and does an +% |\endgroup|. Otherwise, |\end{foo}| does nothing. +% +% If |\end{foo}| needs to ignore blanks after it, then |\endfoo| should +% globally set the |@ignore| switch true with |\@ignoretrue| +% (this will automatically be global). +% +% +% NOTE: |\@@end| is defined to be the |\end| command of \TeX82. +% +% |\enddocument| is the user's command for ending the manuscript file. +% +% |\stop| is a panic button --- to end \TeX\ in the middle. +% +% \begin{oldcomments} +% \enddocument == +% BEGIN +% \@checkend{document} %% checks for unmatched \begin +% \clearpage +% \begingroup +% if @filesw = true +% then close file @mainaux +% if G@refundefined = true +% then LaTeX Warning: 'There are undefined references.' fi +% if @multiplelabels = true +% then LaTeX Warning: +% 'One or more label(s) multiply defined.' +% else +% \@setckpt {ARG1}{ARG2} == null +% \newlabel{LABEL}{VAL} == +% BEGIN +% \reserved@a == VAL +% if def(\reserved@a) = def(\r@LABEL) +% else @tempswa := true fi +% END +% \bibcite{LABEL}{VAL} == null +% BEGIN +% \reserved@a == VAL +% if def(\reserved@a) = def(\g@LABEL) +% else @tempswa := true fi +% END +% @tempswa := false +% make @ a letter +% \input \jobname.AUX +% if @tempswa = true +% then LaTeX Warning: 'Label may have changed. +% Rerun to get cross-references right.' +% fi fi fi +% \endgroup +% finish up +% END +% +% \@writefile{EXT}{ENTRY} == +% if tf@EXT undefined +% else \write\tf@EXT{ENTRY} +% fi +% \end{oldcomments} +% +% \begin{macro}{\@currenvir} +% The name of the current environment. Initialized to +% \texttt{document} to so that |\end{document}| works correctly. +% \begin{macrocode} +\def\@currenvir{document} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\if@ignore} +% \begin{macro}{\@ignoretrue} +% \begin{macro}{\@ignorefalse} +% \changes{v1.1e}{1996/07/26}{put \cs{global} into definition} +% \begin{macrocode} +\def\@ignorefalse{\global\let\if@ignore\iffalse} +\def\@ignoretrue {\global\let\if@ignore\iftrue} +\@ignorefalse +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\ignorespacesafterend} +% \changes{v1.1e}{1996/07/26}{user level macro added} +% \begin{macrocode} +\let\ignorespacesafterend\@ignoretrue +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\enddocument} +% \changes{LaTeX2.09}{1993/08/03} +% {Changed redefinition of \cs{global} to redefinition +% of \cs{@setckpt}.} +% \changes{LaTeX2.09}{1993/09/08} +% {Added warning in case of undefined references.}% +% \changes{v0.9e}{1993/12/09}{Hook added} +% \begin{macrocode} +\def\enddocument{% +% \end{macrocode} +% The |\end{document}| hook is executed first. If necessary it can +% contain a |\clearpage| to output dangling floats first. In this +% position it can also contain something like |\end{foo}| so that +% the whole document effectively starts and ends with some special +% environment. However, this must be used with care, eg if two +% applications would use this without knowledge of each other the +% order of the environments will be wrong after all. +% |\AtEndDocument| is redefined +% at this point so that and such commands that get into the hook do +% not chase their tail\ldots +% \changes{v1.0y}{1995/04/27}{\cs{@checkend} moved after hook} +% \changes{v1.0z}{1995/07/13}{Set \cs{@setckpt} to \cs{@gobbletwo} +% instead of defining it by hand} +% \changes{v1.1i}{2000/05/19} +% {Reset \cs{AtEndDocument} for latex/3060} +% \begin{macrocode} + \let\AtEndDocument\@firstofone + \@enddocumenthook + \@checkend{document}% + \clearpage + \begingroup + \if@filesw + \immediate\closeout\@mainaux + \let\@setckpt\@gobbletwo + \let\@newl@bel\@testdef +% \end{macrocode} +% \changes{v1.0z}{1995/07/13}{Shorten redefinition of \cs{bibcite} and +% \cs{newlabel}} +% The previous line is equiv to setting +%\begin{verbatim} +% \def\newlabel{\@testdef r}% +% \def\bibcite{\@testdef b}% +%\end{verbatim} +% \changes{v1.1k}{2010/08/17}{Use braces around \cs{input} arg (pr/4124)} +% \changes{v1.1l}{2010/08/17}{Change of plan: use \cs{@@input} instead +% (pr/4124)} +% We use |\@@input| to load the \texttt{.aux} file, so that it doesn't +% show up in the list of files produced by |\listfiles|. +% \begin{macrocode} + \@tempswafalse + \makeatletter \@@input\jobname.aux + \fi +% \end{macrocode} +% \changes{v1.0w}{1994/11/30} +% {(DPC) Use \cs{@dofilelist}} +% \begin{macrocode} + \@dofilelist +% \end{macrocode} +% First we check for font size substitution bigger than +% |\fontsubfuzz|. The |\relax| is necessary because this is a macro +% not a register. +% \changes{v1.0w}{1994/11/30} +% {(DPC) Do warnings even for \cs{nofiles}} +% \begin{macrocode} + \ifdim \font@submax >\fontsubfuzz\relax +% \end{macrocode} +% In case you wonder about the |\@gobbletwo| inside the message +% below, this is a horrible hack to remove the tokens |\on@line.| +% that are added by |\@font@warning| at the end. +% \changes{v1.1j}{2000/07/11}{Fix typo in warning} +% \begin{macrocode} + \@font@warning{Size substitutions with differences\MessageBreak + up to \font@submax\space have occurred.\@gobbletwo}% + \fi +% \end{macrocode} +% The macro |\@defaultsubs| is initially |\relax| but gets redefined +% to produce +% a warning if there have been some default font substitutions. +% \changes{v1.0z}{1995/07/13}{Use \cs{@defaultsubs} instead of switch} +% \begin{macrocode} + \@defaultsubs +% \end{macrocode} +% The macro |\@refundefined| is initially |\relax| but gets redefined +% to produce a warning if there are undefined refs. +% \changes{v1.1b}{1995/10/24}{Use \cs{@refundefined} instead of switch} +% \begin{macrocode} + \@refundefined +% \end{macrocode} +% If a label is defined more than once, |\@tempswa| will always be +% true and thus produce a ``Label(s) may \ldots'' warning. But +% since a rerun will not solve that problem (unless one uses a +% package like \texttt{varioref} that generates labels on the fly), +% we suppress this message. +% \changes{v1.0e}{1994/04/20}{Changed logic for producing +% warning messages} +% \changes{v1.1b}{1995/10/24}{Changed logic for producing +% warning messages and removed switch} +% \begin{macrocode} + \if@filesw + \ifx \@multiplelabels \relax + \if@tempswa + \@latex@warning@no@line{Label(s) may have changed. + Rerun to get cross-references right}% + \fi + \else + \@multiplelabels + \fi + \fi + \endgroup + \deadcycles\z@\@@end} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@testdef} +% \begin{macrocode} +\def\@testdef #1#2#3{% + \def\reserved@a{#3}\expandafter \ifx \csname #1@#2\endcsname + \reserved@a \else \@tempswatrue \fi} +% \end{macrocode} +% \end{macro} +% +% +% Reading data from auxiliary files (like \texttt{.toc} normally +% happens in vertical mode and it therefore doesn't matter if line +% endings are converted to spaces by \TeX{} during that process. +% +% However, especially the \texttt{.toc} file might be read in L-R mode +% (in cases the \cs{tableofcontents} attempts to put, say a list of +% sub-sections as a paragraph. In that case the newlines after a line +% like +% \begin{verbatim} +% \contentsline {subsubsection}{\numberline {1.1.1}A C-head}{2} +% \end{verbatim} +% might result in spurious spaces (e.g., when that level is not +% included). +% +% That could be fixed by reading in the file using +% \cs{endlinechar}\texttt{=-1} but that has the danger that it drops +% some valid endlines that should be converted to spaces (for example +% when the user edited the TOC and then used \cs{nofiles} to preserve +% it. +% +% So the approach taken instead is this: +% \begin{itemize} +% \item \cs{addcontentsline} adds the command +% \cs{protected@file@percent} to the end of the second argument of +% \cs{@writefile} that is written to the \texttt{.aux}. As the name +% indicates this is a protected macro so it doesn't change if it is +% written out. +% +% \item When the \texttt{.aux} is read back in at the end of the run, +% \cs{@writefile} is executed and writes its second argument +% unmodified to the file with the extension given by its first +% argument. Or rather that was how it was in the past. +% +% \item Instead we change \cs{@writefile} slightly: basically it looks +% at the second argument and if the last token in there is +% \cs{protected@file@percent} then it is replaced by a percent +% character and that is then written out. If not (for example, if +% the data came from a user issued \cs{addtocontents}, or from some +% package that uses \cs{@writefile} for writing its own files) then +% the command behaves exactly as before. +% \end{itemize} +% +% +% \begin{macro}{\protected@file@percent} +% Dummy cs to be replaced by a percent sign inside +% \cs{@writefile}. If it survives (when used incorrectly) it will +% expand to nothing in a typsetting context. +% \changes{v1.1n}{2018/09/26}{Sometimes mask the endline char when +% writing to files (github/73)} +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2018/12/01}% +%<latexrelease> {\protected@file@percent}{Mask line endings}% +\protected\def\protected@file@percent{} +% \end{macrocode} +% \end{macro} + + +% \begin{macro}{\add@percent@to@temptokena} +% Helper function which is used to inspect a sequence of tokens +% (the second argument of \cs{@writefile} and it the last token is +% \cs{protected@file@percent} it will replace it by a harmless +% percent. The result is saved in \cs{@temptokena} for later use. +% \changes{v1.1n}{2018/09/26}{Sometimes mask the endline char when +% writing to files (github/73)} +% \begin{macrocode} +\begingroup +\catcode`\%=12 +% \end{macrocode} +% \texttt{latexrelease} will read this code in high-speed +% mode in certain situations. During that it will only look for +% \cs{if} tests but not actually execute the \cs{catcode} change +% above. As a result it will drop anything after the |%| character +% in the definition. Therefore the |\fi| needs to be on the next +% line and we need locally another comment character to avoid +% getting spaces into the definition---a weird problem :-) +% \begin{macrocode} +\catcode`\^^A=9 +\long\gdef\add@percent@to@temptokena + #1\protected@file@percent#2\add@percent@to@temptokena +% \end{macrocode} +% When we call this macro in |\@writefile| we stick in |\@empty| at +% the beginning, so that in case the tokenlist consists of a single brace +% group the braces aren't stripped. The |\expandafter| then expands +% this extra token away again. +% \begin{macrocode} + {\ifx!#2!\@temptokena\expandafter{#1}\else + \@temptokena\expandafter{#1%^^A +% \end{macrocode} +% Can't be on the same line as the |%| --- see above. +% \begin{macrocode} + }\fi} +\endgroup +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@writefile} +% \changes{v1.0l}{1994/05/20}{Added correct setting of \cs{protect}.} +% \changes{v1.0t}{1994/11/04}{Removed setting of \cs{protect}. ASAJ.} +% \changes{v1.0z}{1995/07/13}{Added missing percent and use \cs{relax} +% in the THEN case} +% \changes{v1.1n}{2018/09/26}{Sometimes mask the endline char when +% writing to files (github/73)} +% \begin{macrocode} +\long\def\@writefile#1#2{% + \@ifundefined{tf@#1}\relax + {% +% \end{macrocode} +% If we write to the file we first prepare |#2| using +% \cs{add@percent@to@temptokena} and then write the token register +% out. +% \begin{macrocode} + \add@percent@to@temptokena + \@empty#2\protected@file@percent + \add@percent@to@temptokena + \immediate\write\csname tf@#1\endcsname{\the\@temptokena}% + }% +} +% \end{macrocode} +% +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\protected@file@percent}{Mask line endings}% +%<latexrelease>\let\protected@file@percent\@undefined +%<latexrelease>\let\add@percent@to@temptokena\@undefined +%<latexrelease>\long\def\@writefile#1#2{% +%<latexrelease> \@ifundefined{tf@#1}\relax +%<latexrelease> {\@temptokena{#2}% +%<latexrelease> \immediate\write\csname tf@#1\endcsname{\the\@temptokena}% +%<latexrelease> }% +%<latexrelease>} +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stop} +% \begin{macrocode} +\def\stop{\clearpage\deadcycles\z@\let\par\@@par\@@end} +% \end{macrocode} +% \end{macro} +% +% +% \begin{oldcomments} +% +% \begin{macrocode} +\everypar{\@nodocument} %% To get an error if text appears before the +\nullfont %% \begin{document} +% \end{macrocode} +% +% \begin, \end, and \@checkend changed so \end{document} will catch +% an unmatched \begin. Changed 24 May 89 as suggested by +% Frank Mittelbach and Rainer Sch\"opf. +% +% \begin{NAME} == +% BEGIN +% IF \NAME undefined THEN \reserved@a == BEGIN report error END +% ELSE \reserved@a == +% (\@currenvir :=L NAME) \NAME +% FI +% @ignore :=G F %% Added 30 Nov 88 +% \begingroup +% \@endpe := F +% \@currenvir :=L NAME +% \NAME +% END +% +% \end{NAME} == +% BEGIN +% \endNAME +% \@checkend{NAME} +% \endgroup +% IF @endpe = T %% @endpe set True by \@endparenv +% THEN \@doendpe %% \@doendpe redefines \par and \everypar +% %% to suppress paragraph indentation in +% FI %% immediately following text +% IF @ignore = T +% THEN @ignore :=G F +% \ignorespaces +% FI +% END +% +% \@checkend{NAME} == +% BEGIN +% IF \@currenvir = NAME +% ELSE \@badend{NAME} +% FI +% END +% +% \end{oldcomments} +% +% +% \begin{macro}{\begin} +% \changes{LaTeX2.09}{1992/03/18}{Changed \cs{@ignoretrue} to +% \cs{@ignorefalse} (as documented)} +% \changes{LaTeX2.09}{1992/08/24}{Added code to \cs{begin} to +% remember line number. Used by \cs{@badend} to display +% position of non-matching \cs{begin}.} +% \changes{v1.1e}{1996/07/26}{remove \cs{global} before \cs{@ignore...}} +% \begin{macrocode} +\def\begin#1{% + \@ifundefined{#1}% + {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}% + {\def\reserved@a{\def\@currenvir{#1}% + \edef\@currenvline{\on@line}% + \csname #1\endcsname}}% + \@ignorefalse + \begingroup\@endpefalse\reserved@a} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\end} +% \changes{v1.1e}{1996/07/26}{remove \cs{global} before \cs{@ignore...}} +% \begin{macrocode} +\def\end#1{% + \csname end#1\endcsname\@checkend{#1}% + \expandafter\endgroup\if@endpe\@doendpe\fi + \if@ignore\@ignorefalse\ignorespaces\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@checkend} +% \begin{macrocode} +\def\@checkend#1{\def\reserved@a{#1}\ifx + \reserved@a\@currenvir \else\@badend{#1}\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@currenvline} +% We do need a default value for |\@currenvline| on top-level since +% the document environment cancels the brace group. This means that +% a mismatch with |\begin|\allowbreak|{document}| will not produce +% a line number. Thus the outer default must be |\@empty| or we +% will end up with two spaces. +% \changes{v1.0q}{1994/05/24}{Use \cs{@empty} as outer default} +% \begin{macrocode} +\let\@currenvline\@empty +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Center, Flushright, Flushleft} +% +% \begin{macrocode} +\message{center,} +% \end{macrocode} +% +% \begin{oldcomments} +% +% \center, \flushright and \flushleft set +% \rightskip = 0pt or \@flushglue (as appropriate) +% \leftskip = 0pt or \@flushglue (as appropriate) +% \parindent = 0pt +% \parfillskip = 0pt. (except \flushleft) +% \\ == \par \vskip -\parskip +% \\[LENGTH] == \\ \vskip LENGTH +% \\* == \par \penalty 10000 \vskip -\parskip +% \\*[LEN] == \\* \vskip LENGTH +% +% They invoke the trivlist environment to handle vertical spacing before +% and after them. +% +% \centering, \raggedright and \raggedleft are the declaration analogs +% of the above. +% +% \raggedright has a more universal effect, however. It sets +% \@rightskip := flushglue. Every environment, like the list +% environments, +% that set \rightskip to its 'normal' value set it to \@rightskip +% +% \end{oldcomments} +% +% \begin{macro}{\@centercr} +% \changes{v1.0h}{1994/05/03}{\cs{@badcrerr} replaced by \cs{@nolnerr}} +% \changes{v1.0z}{1995/07/13}{Use \cs{nobreak}} +% \begin{macrocode} +\def\@centercr{\ifhmode \unskip\else \@nolnerr\fi + \par\@ifstar{\nobreak\@xcentercr}\@xcentercr} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xcentercr} +% \begin{macrocode} +\def\@xcentercr{\addvspace{-\parskip}\@ifnextchar + [\@icentercr\ignorespaces} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@icentercr} +% \begin{macrocode} +\def\@icentercr[#1]{\vskip #1\ignorespaces} +% \end{macrocode} +% \end{macro} +% +% +% \begin{environment}{center} +% \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}} +% \changes{v1.0u}{1994/11/12}{Changed end macro to \cs{def}: safer and +% consistent} +% We use |\relax| to prevent |\item| scanning too far. +% \begin{macrocode} +\def\center{\trivlist \centering\item\relax} +% \end{macrocode} +% +% \begin{macrocode} +\def\endcenter{\endtrivlist} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\centering} +% \begin{macrocode} +\def\centering{% + \let\\\@centercr + \rightskip\@flushglue\leftskip\@flushglue + \parindent\z@\parfillskip\z@skip} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@rightskip} +% \begin{macrocode} +\newskip\@rightskip \@rightskip \z@skip +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{flushleft} +% \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}} +% \changes{v1.0u}{1994/11/12}{Changed end macro to \cs{def}: safer and +% consistent} +% We use |\relax| to prevent |\item| scanning too far. +% \begin{macrocode} +\def\flushleft{\trivlist \raggedright\item\relax} +% \end{macrocode} +% +% \begin{macrocode} +\def\endflushleft{\endtrivlist} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\raggedright} +% \begin{macrocode} +\def\raggedright{% + \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip + \leftskip\z@skip + \parindent\z@} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{flushright} +% \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}} +% \changes{v1.0u}{1994/11/12}{Changed end macro to \cs{def}: safer and +% consistent} +% We use |\relax| to prevent |\item| scanning too far. +% \begin{macrocode} +\def\flushright{\trivlist \raggedleft\item\relax} +% \end{macrocode} +% +% \begin{macrocode} +\def\endflushright{\endtrivlist} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\raggedleft} +% \begin{macrocode} +\def\raggedleft{% + \let\\\@centercr + \rightskip\z@skip\leftskip\@flushglue + \parindent\z@\parfillskip\z@skip} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Verbatim} +% +% \begin{macrocode} +\message{verbatim,} +% \end{macrocode} +% +% The verbatim environment uses the fixed-width |\ttfamily| font, turns +% blanks into spaces, starts a new line for each carriage return (or +% sequence of consecutive carriage returns), and interprets +% \emph{every} character literally. +% I.e., all special characters |\, {, $|, etc. +% are |\catcode|'d to 'other'. +% +% The command |\verb| produces in-line verbatim text, where the argument +% is delimited by any pair of characters. E.g., |\verb #...#| takes +% `|...|' as its argument, and sets it verbatim in |\ttfamily| font. +% +% The *-variants of these commands are the same, except that spaces +% print as the \TeX{}book's space character instead of as blank spaces. +% +% \begin{macro}{\@vobeyspaces} +% \begin{macrocode} +{\catcode`\ =\active% +\gdef\@vobeyspaces{\catcode`\ \active\let \@xobeysp}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@xobeysp} +% \changes{v1.0z}{1995/07/13}{Use \cs{nobreak}} +% \changes{v1.1f}{1996/09/28}{Moved to ltspace.dtx} +% \end{macro} +% +% +% \begin{macro}{\@xverbatim} +% \begin{macro}{\@sxverbatim} +% \begin{macrocode} +\begingroup \catcode `|=0 \catcode `[= 1 +\catcode`]=2 \catcode `\{=12 \catcode `\}=12 +\catcode`\\=12 |gdef|@xverbatim#1\end{verbatim}[#1|end[verbatim]] +|gdef|@sxverbatim#1\end{verbatim*}[#1|end[verbatim*]] +|endgroup +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@verbatim} +% \changes{LaTeX2.09}{1991/07/24}{Added \cs{penalty}\cs{interlinepenalty} +% to definition of \cs{par} so that \cs{samepage} works} +% \changes{v0.9h}{1993/12/13}{Removed optional argument of \cs{item}} +% Real start of verbatim environment +% We use |\relax| to prevent |\item| scanning too far. +% \changes{v0.9p}{1994/01/18} +% {Add \cs{global}\cs{@inlabelfalse}} +% \changes{v1.0b}{1994/03/16} +% {Remove \cs{global}\cs{@inlabelfalse} again.} +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2017-04-15}{\@verbatim}% +%<latexrelease> {Disable hyphenation in verbatim}% +\def\@verbatim{\trivlist \item\relax + \if@minipage\else\vskip\parskip\fi + \leftskip\@totalleftmargin\rightskip\z@skip + \parindent\z@\parfillskip\@flushglue\parskip\z@skip +% \end{macrocode} +% \changes{LaTeX2.09}{1991/08/26}{\cs{@@par} added} +% Added |\@@par| to clear possible |\parshape| definition +% from a surrounding list (the verbatim guru says). +% \changes{v0.9p}{1994/01/18} +% {Only add \cs{penalty} if in hmode} +% Switch language when in vertical mode. +% \begin{macrocode} + \@@par +% \end{macrocode} +% Set |\language| here to suppress hyphenation. Done this way rather +% than setting |\hyphenchar| as that is a global setting. +% \begin{macrocode} + \language\l@nohyphenation + \@tempswafalse + \def\par{% + \if@tempswa +% \end{macrocode} +% A |\leavevmode| added: needed if, for example, a blank verbatim +% line is the first thing in a list item (wow!). +% \changes{v1.0f}{1994/04/29}{\cs{leavevmode} added} +% \begin{macrocode} + \leavevmode \null \@@par\penalty\interlinepenalty + \else + \@tempswatrue + \ifhmode\@@par\penalty\interlinepenalty\fi + \fi}% +% \end{macrocode} +% To allow customization we hide the font used in a separate macro. +% \changes{v0.9a}{1993/11/21}{use \cs{verbatim@font} instead of \cs{tt}} +% \changes{v0.9h}{1993/12/13}{Readded \cs{@noligs}} +% \changes{v1.1d}{1996/06/03}{Exchanged the following two code lines +% so that \cs{dospecials} cannot reset the category code +% of characters handled by \cs{@noligs}.} +% \changes{v1.1h}{2000/01/07}{Disable hyphenation even if the font allows it.} +% \changes{v1.1m}{2017-03-09}{Use \cs{language} not \cs{hyphenchar}} +% \begin{macrocode} + \let\do\@makeother \dospecials + \obeylines \verbatim@font \@noligs +% \end{macrocode} +% To avoid a breakpoint after the labels box, we remove the penalty +% put there by the list macros: another use of |\unpenalty|! +% \changes{v1.0f}{1994/04/29}{Change to \cs{everypar} added} +% \begin{macrocode} + \everypar \expandafter{\the\everypar \unpenalty}% +} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000-00-00}{\@verbatim}% +%<latexrelease> {Disable hyphenation in verbatim}% +%<latexrelease>\def\@verbatim{\trivlist \item\relax +%<latexrelease> \if@minipage\else\vskip\parskip\fi +%<latexrelease> \leftskip\@totalleftmargin\rightskip\z@skip +%<latexrelease> \parindent\z@\parfillskip\@flushglue\parskip\z@skip +%<latexrelease> \@@par +%<latexrelease> \@tempswafalse +%<latexrelease> \def\par{% +%<latexrelease> \if@tempswa +%<latexrelease> \leavevmode \null \@@par\penalty\interlinepenalty +%<latexrelease> \else +%<latexrelease> \@tempswatrue +%<latexrelease> \ifhmode\@@par\penalty\interlinepenalty\fi +%<latexrelease> \fi}% +%<latexrelease> \let\do\@makeother \dospecials +%<latexrelease> \obeylines \verbatim@font \@noligs +%<latexrelease> \hyphenchar\font\m@ne +%<latexrelease> \everypar \expandafter{\the\everypar \unpenalty}% +%<latexrelease>} +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim} +% \begin{macro}{\endverbatim} +% (RmS 93/09/19) Protected against `missing item' error message +% triggered by empty verbatim environment. +% \begin{macrocode} +\def\verbatim{\@verbatim \frenchspacing\@vobeyspaces \@xverbatim} +\def\endverbatim{\if@newlist \leavevmode\fi\endtrivlist} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\verbatim@font} +% \changes{v0.9a}{1993/11/21}{Macro added} +% Macro to select the font used for verbatim typesetting. +% It also does other work if necessary for the font used. +% \changes{v0.9s}{1994/01/21}{Removed unnecessary category code +% hackery.} +% \begin{macrocode} +\def\verbatim@font{\normalfont\ttfamily} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2018/12/01}% +%<latexrelease> {\verbvisiblespace}{Setup visible space for verb}% +% \end{macrocode} +% +% +% \begin{macro}{\asciispace} +% The character in slot 32, in typewriter fonts (historically) a +% visible space but in other fonts a real space or something else +% \changes{v1.1o}{2018/10/11} +% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)} +% \begin{macrocode} +\DeclareRobustCommand\asciispace{\char 32 } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbvisiblespace} +% This defines how to get a visible space in +% |\verb*| and friends. In classic \TeX{} this is just the +% slot 32, but in TU encoded fonts we switch fonts and take the +% character from cmtt. +% \changes{v1.1o}{2018/10/11} +% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)} +% \changes{v1.1o}{2018/10/11} +% {Provide \cs{verbvisiblespace} such that it is usable in normal text (github/70)} +% \begin{macrocode} +\ifx\Umathcode\@undefined + \let\verbvisiblespace\asciispace % Pdftex version +\else + \DeclareRobustCommand\verbvisiblespace + {\leavevmode{\usefont{OT1}{cmtt}{m}{n}\asciispace}} % xetex/luatex version +\fi +% \end{macrocode} +% \end{macro} +% +% + +% \begin{macro}{\@setupverbvisiblespace} +% +% In pdf\TeX{} a catcode 12 space will produce the character in +% slot 32 which is assumed to be a visible space character (in a +% typewriter font in OT1 or T1 encoding). In Xe\TeX{} or Lua\TeX{} a +% font in TU encoding is normally used and that has a real space in +% this slot. So what we do in this case is this: we check the +% definition of +% |\verbvisiblespace| and if it is |\asciispace| we assume that the +% char32 can be used (e.g., in pdf\TeX{}). We then redefine +% |\@xobeysp| so that after running |\@vobeyspaces| we get +% characters from slot 32 for each active space. +% +% \changes{v1.1o}{2018/10/11} +% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)} +% \begin{macrocode} +\def\@setupverbvisiblespace{% + \ifx\verbvisiblespace\asciispace + \let\@xobeysp\asciispace + \else +% \end{macrocode} Otherwise we measure the width of a character in +% the mon-spaced current font and place a +% |\verbvisiblespace| into a box of the right width which we are then +% using as the character for a space. By default this will be the space +% character from OT1 cmtt but by changing +% |\verbvisiblespace| one could use, for example, the |\textvisiblespace| +% of the current typewriter font. +% \begin{macrocode} + \setbox\z@\hbox{x}% + \setbox\@verbvisiblespacebox\hbox to\wd\z@{\hss\verbvisiblespace\hss}% + \def\@xobeysp{\leavevmode\copy\@verbvisiblespacebox}% + \fi +} +% \end{macrocode} +% \end{macro} +% + +% \begin{macro}{\@verbvisiblespacebox} +% The box to hold the visible space character if it isn't in slot +% 32 in the current typewriter font. +% \changes{v1.1o}{2018/10/11} +% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)} +% \begin{macrocode} +\newbox\@verbvisiblespacebox +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@sverb} +% \changes{v1.0j}{1994/05/10}{Slight change in error message text.} +% Definitions of |\@sverb| and |\@verb| changed so |\verb+ foo+| +% does not lose leading blanks when it comes at the beginning of a line. +% Change made 24 May 89. Suggested by Frank Mittelbach and Rainer +% Sch\"opf. +% \begin{macrocode} +\def\@sverb#1{% + \catcode`#1\active + \lccode`\~`#1% + \gdef\verb@balance@group{\verb@egroup + \@latex@error{\noexpand\verb illegal in command argument}\@ehc}% + \aftergroup\verb@balance@group + \lowercase{\let~\verb@egroup}% +% \end{macrocode} +% If |\@sverb| is called from |\@verb| then space is already active +% and supposed to produce a real space. In this case we do +% nothing. Otherwise we run |\@setupverbvisiblespace| to setup the +% right visible space char and afterwards |\@vobeyspaces| to make +% it the definition for the active space character. +% \changes{v1.1o}{2018/10/11} +% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)} +% \begin{macrocode} + \ifnum\catcode`\ =\active + \else \@setupverbvisiblespace \@vobeyspaces \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{verbatim*} +% For \texttt{verbatim*} we also set up the correct visible space +% character definition and then run |\@vobeyspaces|. As this code +% is not called as part of the normal verbatim environment (the +% method is done the other way around this time) we don't have to +% check if space is already active---it shouldn't be. +% \changes{v1.1o}{2018/10/11} +% {Provide visible space in \cs{verb*} also for XeTeX and LuaTeX (github/69)} +% \begin{macrocode} +\@namedef{verbatim*}{\@verbatim + \@setupverbvisiblespace + \frenchspacing\@vobeyspaces\@sxverbatim} +\expandafter\let\csname endverbatim*\endcsname =\endverbatim +% \end{macrocode} +% \end{environment} +% +% +% +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\verbvisiblespace}{Setup visible space for verb}% +%<latexrelease> +%<latexrelease>\@namedef{verbatim*}{\@verbatim\@sxverbatim} +%<latexrelease> +%<latexrelease>\let\asciispace \@undefined +%<latexrelease>\let\verbvisiblespace \@undefined +%<latexrelease>\let\@setupverbvisiblespace\@undefined +%<latexrelease>\let\@verbvisiblespacebox \@undefined +%<latexrelease> +%<latexrelease>\def\@sverb#1{% +%<latexrelease> \catcode`#1\active +%<latexrelease> \lccode`\~`#1% +%<latexrelease> \gdef\verb@balance@group{\verb@egroup +%<latexrelease> \@latex@error{\noexpand\verb illegal in command argument}\@ehc}% +%<latexrelease> \aftergroup\verb@balance@group +%<latexrelease> \lowercase{\let~\verb@egroup}}% +%<latexrelease> +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% +% +% +% +% \begin{macro}{\@makeother} +% \begin{macrocode} +\def\@makeother#1{\catcode`#112\relax} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verb@balance@group} +% \changes{LaTeX2.09}{1993/09/07} +% {(RmS) Changed definition of \cs{verb} so that it detects a +% missing second delimiter.} +% \begin{macrocode} +\let\verb@balance@group\@empty +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verb@egroup} +% \begin{macrocode} +\def\verb@egroup{\global\let\verb@balance@group\@empty\egroup} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verb@eol@error} +% \begin{macrocode} +\begingroup + \obeylines% + \gdef\verb@eol@error{\obeylines% + \def^^M{\verb@egroup\@latex@error{% + \noexpand\verb ended by end of line}\@ehc}}% +\endgroup +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verb} +% \changes{LaTeX2.09}{1992/08/24} +% {Changed \cs{verb} and \cs{@sverb} to work correctly +% in math mode} +% \changes{v0.9a}{1993/11/21}{Use \cs{verbatim@font} instead of +% \cs{tt}.} +% \changes{v1.1a}{1995/09/19}{Put \cs{@noligs} after +% \cs{verbatim@font} where it belongs.} +% Typesetting a small piece verbatim. +% \changes{v1.1d}{1996/06/03}{Put setting of verbatim font after +% \cs{dospecials} +% so that \cs{dospecials} cannot reset the category code +% of characters handled by \cs{@noligs}.} +% \changes{v1.1m}{2017/03/09} +% {Use \cs{language} to stop hyphenation} +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2017-04-15}{\verb}% +%<latexrelease> {Disable hyphenation in verb}% +\def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi + \bgroup + \verb@eol@error \let\do\@makeother \dospecials + \verbatim@font\@noligs +% \end{macrocode} +% Set |\language| here to suppress hyphenation. Done this way rather +% than setting |\hyphenchar| as that is a global setting. +% \begin{macrocode} + \language\l@nohyphenation + \@ifstar\@sverb\@verb} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000-00-00}{\verb}% +%<latexrelease> {Disable hyphenation in verb}% +%<latexrelease>\def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi +%<latexrelease> \bgroup +%<latexrelease> \verb@eol@error \let\do\@makeother \dospecials +%<latexrelease> \verbatim@font\@noligs +%<latexrelease> \@ifstar\@sverb\@verb} +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\@verb} +% \begin{macrocode} +\def\@verb{\@vobeyspaces \frenchspacing \@sverb} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbatim@nolig@list} +% \changes{LaTeX2.09}{1993/09/03} +% {Replaced \cs{@noligs} by extensible list} +% \begin{macrocode} +\def\verbatim@nolig@list{\do\`\do\<\do\>\do\,\do\'\do\-} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\do@noligs} +% \begin{macrocode} +\def\do@noligs#1{% + \catcode`#1\active + \begingroup + \lccode`\~`#1\relax + \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@noligs} +% To stay compatible with packages that use |\@noligs| we keep it. +% \changes{v0.9h}{1993/12/13}{Readded \cs{@noligs}} +% \begin{macrocode} +\def\@noligs{\let\do\do@noligs \verbatim@nolig@list} +% \end{macrocode} +% \end{macro} +% +% \changes{v0.9i}{1993/12/16}{\cs{literal} added} +% \changes{v1.0r}{1994/05/26/16}{\cs{literal} removed} +% \begin{macrocode} +%</2ekernel> +% \end{macrocode} +% +% \Finale +% |