Skip to content

Commit

Permalink
Gh1638 (#1639)
Browse files Browse the repository at this point in the history
* fix for #1638

* update rollback code

* extend the test to also cover extended syntax

* updates after review

* new text suggestion

* add a comment about commands defined elsewhere
  • Loading branch information
FrankMittelbach authored Jan 24, 2025
1 parent 19d68da commit c70b82b
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 17 deletions.
9 changes: 7 additions & 2 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================

2025-01-23 Frank Mittelbach <[email protected]>

* ltoutput.dtx (subsection{Floats}):
* ltsect.dtx (subsection{Table of Contents etc.}):
Make \label, \index, and \glossary truely invisible
when typesetting (gh/1638)

2025-01-23 Joseph Wright <[email protected]>
* ltcmd.dtx, usrguide.tex
New "c"-type argument

2025-01-21 Frank Mittelbach <[email protected]>

* ltoutput.dtx (subsection{Floats}):
Support extended syntax for \label, \index, and \glossary (gh/311)

* ltsect.dtx (subsection{Table of Contents etc.}):
Support extended syntax for \label, \index, and \glossary (gh/311)

Expand Down
26 changes: 23 additions & 3 deletions base/doc/ltnews41.tex
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,35 @@ \subsection{Process global options once per package}
%
\githubissue{1619}


\subsection{Make \cs{label}, \cs{index}, and \cs{glossary} truely invisible in running headers}

\LaTeX{} has had a bug since its initial implementation, in that it
correctly ignored any \cs{label}, \cs{index}, or \cs{glossary}
appearing in a mark, but neglected to handle the spaces around the
command. As a result one could end up with two spaces in the running
header when only one should be present. This was detected as part of
working on issue~311 and has now been corrected.
%
\githubissue{1638}



\section{Documentation}

\subsection{Clarifying space handling of \cs{textcolor}}

In contrast to other \cs{text}-commands like \cs{textbf} or \cs{textrm},
the command \cs{textcolor} gobbles spaces at the start of its argument, so \verb=Hello\textcolor{red}{ World}= will output Hello\textcolor{red}{ World}.
There are technical as well as compatibility reasons for this, so the behavior will not change. This has now been clarified in the documentation.
In contrast to other \cs{text}-commands like \cs{textbf} or
\cs{textrm}, the command \cs{textcolor} gobbles spaces at the start of
its argument, so \verb*=Hello\textcolor{red}{ World}= will output
Hello\textcolor{red}{ World}. There are technical as well as
compatibility reasons for this, so the behavior will not change. This
has now been clarified in the documentation.
%
\githubissue{1474}



%\section{Changes to packages in the \pkg{amsmath} category}

\section{Changes to packages in the \pkg{graphics} category}
Expand Down
11 changes: 10 additions & 1 deletion base/ltdefns.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltdefns.dtx}
[2024/09/06 v1.5t LaTeX Kernel (definition commands)]
[2025/01/24 v1.5t LaTeX Kernel (definition commands)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltdefns.dtx}
Expand Down Expand Up @@ -943,6 +943,15 @@
% \end{macro}
% \end{macro}
%
% There are also \cs{@gobble@om}, \cs{@gobble@som},
% \cs{@gobble@with@sphack@om}, and \cs{@gobble@with@sphack@som}. They
% accept an optional and a mandatory argument, possibly preceeded by a
% star. In all cases the expansion is empty or just manipulates the
% spaces around the command. Used to disable commands such as
% \cs{index} or \cs{label} in certain situations. Since they are
% defined with \cs{DeclareDocumentCommand}, which is not yet available
% at this point, the actual definition happens in \texttt{ltsect.dtx}.
%
% \begin{macro}{\@firstofone}
% \begin{macro}{\@firstoftwo}
% \begin{macro}{\@secondoftwo}
Expand Down
11 changes: 7 additions & 4 deletions base/ltoutput.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
%%% From File: ltoutput.dtx
%<flafter>\ProvidesPackage{flafter}
%<fltrace>\ProvidesPackage{fltrace}
%<flafter,fltrace> [2025/01/21 v1.4l
%<flafter,fltrace> [2025/01/23 v1.4m
%<flafter> Standard LaTeX floats after reference (FMi)]
%<fltrace> Tracing LaTeX floats algorithm (FMi)]
%
Expand Down Expand Up @@ -2201,10 +2201,13 @@
% {Move \cs{label} and \cs{index} (from patch file)}
% \changes{v1.4l}{2025/01/21}{Support extended syntax
% for \cs{label}, \cs{index}, and \cs{glossary} (gh/311)}
% \changes{v1.4m}{2025/01/23}
% {Make \cs{label}, \cs{index} and \cs{glossary} truely invisible
% when typesetting (gh/1638)}
% \begin{macrocode}
\let\label\@gobble@om
\let\index\@gobble@som
\let\glossary\@gobble@om
\let\label\@gobble@with@sphack@om
\let\index\@gobble@with@sphack@som
\let\glossary\@gobble@with@sphack@om
% \end{macrocode}
%
% \begin{macrocode}
Expand Down
31 changes: 24 additions & 7 deletions base/ltsect.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
%%% From File: ltsect.dtx
%<*driver>
% \fi
\ProvidesFile{ltsect.dtx}[2025/01/21 v1.1g LaTeX Kernel (Sectioning)]
\ProvidesFile{ltsect.dtx}[2025/01/23 v1.1h LaTeX Kernel (Sectioning)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltsect.dtx}
Expand Down Expand Up @@ -819,23 +819,38 @@
%
%
%
% \begin{macro}{\@gobble@om,\@gobble@som}
% Two commands that accept an optional and a mandatory argument or
% a star, optional and mandatory argument and then do nothing. Used
% to disable commands such as \cs{index} in certain situations.
% \changes{v1.1g}{2025/01/21}
% {Support extended syntax for \cs{label}, \cs{index} and \cs{glossary} (gh/311)}
% \begin{macro}{\@gobble@om,\@gobble@som,\@gobble@with@sphack@om,\@gobble@with@sphack@som}
%
% Each of these four commands accepts an optional and a mandatory
% argument, possibly preceeded by a star. In all cases the
% expansion is empty or just manipulates the spaces around the command.
% Used to disable commands such as \cs{index}
% or \cs{label} in certain situations.
% \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2025/06/01}%
%<latexrelease> {\@gobble@som}{Extended index/label}%
% \end{macrocode}
%
% Just getting rid of the input in an expandable way is done by these two.
% \changes{v1.1g}{2025/01/21}
% {Support extended syntax for \cs{label}, \cs{index} and \cs{glossary} (gh/311)}
% \begin{macrocode}
\DeclareExpandableDocumentCommand\@gobble@om{+o+m}{}
\DeclareExpandableDocumentCommand\@gobble@som{s+o+m}{}
% \end{macrocode}
%
% When something needs to be suppressed during typesetting, one often
% also wants to ensure that this doesn't end up with two spaces (in
% case there is one before and one after). This can't be done expandably.
% \changes{v1.1h}{2025/01/23}
% {Make \cs{label}, \cs{index} and \cs{glossary} truely invisible
% when typesetting (gh/1638)}
% \begin{macrocode}
\DeclareDocumentCommand\@gobble@with@sphack@om{+o+m}{\@bsphack\@esphack}
\DeclareDocumentCommand\@gobble@with@sphack@som{s+o+m}{\@bsphack\@esphack}
% \end{macrocode}
% \end{macro}
%
%
Expand Down Expand Up @@ -874,6 +889,8 @@
%<latexrelease>
%<latexrelease>\let\@gobble@om\@undefined
%<latexrelease>\let\@gobble@som\@undefined
%<latexrelease>\let\@gobble@with@sphack@om\@undefined
%<latexrelease>\let\@gobble@with@sphack@som\@undefined
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
% \end{macrocode}
Expand Down
27 changes: 27 additions & 0 deletions base/testfiles/github-1638.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
% Showed 2 spaces in running header, but one (correct) in TOC.
%
% Also test extended syntax (which has no separate test).
%
% As neither \label nor \index has an extended syntax so far you get strange
% output in the heading, but the TOC and the running header is ok.

\documentclass{book}

\input{regression-test}

\makeindex
\pagestyle{headings}

\showoutput

\begin{document}

\START

\tableofcontents

\chapter{X \index{blub} X \index*{abc} X \index[foo]{xyz} X X}
\section{Y \label{bla} Y \label[foo]{bar} Y Y}
x \newpage x \newpage x \newpage
\OMIT
\end{document}
Loading

0 comments on commit c70b82b

Please sign in to comment.