diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/base/ltmiscen.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/base/ltmiscen.dtx | 304 |
1 files changed, 283 insertions, 21 deletions
diff --git a/Master/texmf-dist/source/latex/base/ltmiscen.dtx b/Master/texmf-dist/source/latex/base/ltmiscen.dtx index 081ae04317b..122ef3b39bf 100644 --- a/Master/texmf-dist/source/latex/base/ltmiscen.dtx +++ b/Master/texmf-dist/source/latex/base/ltmiscen.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright 1993-2017 +% Copyright 1993-2018 % The LaTeX3 Project and any individual authors listed elsewhere % in this file. % @@ -32,7 +32,7 @@ %<*driver> % \fi \ProvidesFile{ltmiscen.dtx} - [2017/09/13 v1.1m LaTeX Kernel (Misc. Environments)] + [2018/10/11 v1.1o LaTeX Kernel (Misc. Environments)] % \iffalse \documentclass{ltxdoc} \GetFileInfo{ltmiscen.dtx} @@ -303,19 +303,143 @@ % \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 - {\@temptokena{#2}% + {% +% \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} @@ -712,14 +836,169 @@ % \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\@sxverbatim} +\@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} @@ -797,23 +1076,6 @@ % \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} -% \end{macro} % % \begin{macro}{\@verb} % \begin{macrocode} |