% \iffalse meta-comment
%
% Copyright 2024
% The LaTeX 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 2008 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
% Filename: ltnews40.tex
%
% This is issue 40 of LaTeX News.

\NeedsTeXFormat{LaTeX2e}[2020-02-02]

\documentclass{ltnews}

%% Maybe needed only for Chris' inadequate system:
\providecommand\Dash {\unskip \textemdash}

%% NOTE: Chris' preferred hyphens!
%% \showhyphens{parameters}
%% \hyphenation{because}

\usepackage[T1]{fontenc}

\usepackage{lmodern,url,hologo}

\usepackage{csquotes}
\usepackage{multicol}
\usepackage{color}

\providecommand\hook[1]{\texttt{#1}}

\providecommand\meta[1]{$\langle$\textrm{\itshape#1}$\rangle$}
\providecommand\option[1]{\texttt{#1}}
\providecommand\env[1]{\texttt{#1}}
\providecommand\Arg[1]{\texttt\{\meta{#1}\texttt\}}


\providecommand\eTeX{\hologo{eTeX}}
\providecommand\XeTeX{\hologo{XeTeX}}
\providecommand\LuaTeX{\hologo{LuaTeX}}
\providecommand\pdfTeX{\hologo{pdfTeX}}
\providecommand\MiKTeX{\hologo{MiKTeX}}
\providecommand\CTAN{\textsc{ctan}}
\providecommand\TL{\TeX\,Live}


\providecommand\githubissue[2][]{\ifhmode\unskip\fi
     \quad\penalty500\strut\nobreak\hfill
     \mbox{\small\slshape(%
       \href{https://github.com/latex3/latex2e/issues/\getfirstgithubissue#2 \relax}%
          	    {github issue#1 #2}%
           )}%
     \par\smallskip}


% same for issues in the tagging repository:

\providecommand\taggingissue[2][]{\ifhmode\unskip\fi
     \quad\penalty500\strut\nobreak\hfill
     \mbox{\small\slshape(%
       \href{https://github.com/latex3/tagging-project/issues/\getfirstgithubissue#2 \relax}%
          	    {github tagging issue#1 #2}%
           )}%
     \par\smallskip}

%% But Chris has to mostly disable \href for his TEXPAD app:
%% \def\href #1#2{#2} % Only For Chris' deficient TeX engine

% simple solution right now (just link to the first issue if there are several)
\def\getfirstgithubissue#1 #2\relax{#1}

\providecommand\sxissue[1]{\ifhmode\unskip
     \else
       % githubissue preceding
       \vskip-\smallskipamount
       \vskip-\parskip
     \fi
     \quad\penalty500\strut\nobreak\hfill
     \mbox{\small\slshape(\url{https://tex.stackexchange.com/#1})}\par}

\providecommand\gnatsissue[2]{\ifhmode\unskip\fi
     \quad\penalty500\strut\nobreak\hfill
     \mbox{\small\slshape(%
       \href{https://www.latex-project.org/cgi-bin/ltxbugs2html?pr=#1\%2F\getfirstgithubissue#2 \relax}%
          	    {gnats issue #1/#2}%
           )}%
     \par}



\let\cls\pkg
\providecommand\env[1]{\texttt{#1}}
\providecommand\acro[1]{\textsc{#1}}

\vbadness=1400  % accept slightly empty columns


\let\finalpagebreak\pagebreak % for TUB (if they use it)
\let\finalvspace\vspace       % for document layout fixes

\makeatletter
% maybe not the greatest design but normally we wouldn't have subsubsections
\renewcommand{\subsubsection}{%
   \@startsection {subsubsection}{2}{0pt}{1.5ex \@plus 1ex \@minus .2ex}%
                  {-1em}{\@subheadingfont\colonize}%
}
\providecommand\colonize[1]{#1:}
\makeatother


% Undo ltnews's \verbatim@font with active < and >
\makeatletter
\def\verbatim@font{\normalsize\ttfamily}
\makeatother


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\providecommand\tubcommand[1]{}
\tubcommand{\input{tubltmac}}

\publicationmonth{November}
\publicationyear{2024  --- DRAFT version for upcoming release}

\publicationissue{40}

\begin{document}

\maketitle
{\hyphenpenalty=10000 \exhyphenpenalty=10000 \spaceskip=3.33pt \hbadness=10000
\tableofcontents}

\setlength\rightskip{0pt plus 3em}

\medskip

\section{Introduction}

\emph{to write \ldots\ 30th aniversary of \LaTeXe{} this year btw}

\section{Switch to T1 as default encoding in documents using \cs{DocumentMetadata}}

As it is well known the font encoding \texttt{OT1} supports only 128 characters and 
has various problems and quirks notably for languages different to English. 
Nevertheless \texttt{OT1} is the default encoding in \LaTeX{} and this can not be easily 
changed without affecting many documents as the \texttt{T1} version of the fonts have slightly different metrics. 

The introduction of the \cs{DocumentMetadata} command, which announces 
\emph{new} code and changes that can also affect the layout gives us now the 
opportunity to make this step. So with this version a use of 
\cs{DocumentMetadata} with (pdf)\LaTeX{} will setup  \texttt{T1} as default 
font encoding\footnote{The Unicode engines will continue to use \texttt{TU} 
as encoding.}. To ensure that scalable fonts are used, the package 
\pkg{cm-super} has to be installed. Users who want to revert to the 
\texttt{OT1} encoding in their document can do so with
\verb+\usepackage[OT1]{fontenc}+. 



\section{News from the \enquote{\LaTeX{} Tagged PDF} project}

The tagging of tabulars has been extended: it is now possible to tag
also row headers and to create cells that span more than one row. 

\emph{write more details ...}


The math module will automatically generate a MathML file and use it to 
attach MathML associated files to the structure if lua\LaTeX{} and 
the \pkg{unicode-math} package are used and the \pkg{luamml} is found.
This new feature can be disabled with \verb+\tagpdfsetup{math/mathml/luamml=false}+ 
More details can be found in the documentation of \pkg{latex-lab-math}. 

At \url{https://latex3.github.io/tagging-project/tagging-status/} we show the status of many \LaTeX{} Packages and Classes with respect to PDF tagging. 
We also started to improve tagging support in external packages. If the 
\texttt{firstaid} key is used in addition to the \texttt{phase-III} key
basic commands of packages like \pkg{amsthm} and \pkg{fancyvrb} can now be used. 

\section{Handling paragraph continuation}

Already \LaTeX~2.09 offered some automatism to detect whether or not
text after a list or some other display environment is meant to be a
continuation of the current paragraph or should start a new one.  The
document-level syntax for this is that a blank line after such an
environment signals to \LaTeX{} that it should start a new paragraph; whilst
no blank line signals that there should be no new paragraph and the
text should be considered a continuation.

Unfortunately, there are a number of cases where the original 2.09
approach failed, e.g., with
\begin{flushleft}
  \ttfamily
\{\meta{local customizations}\\
\cs{begin}\{equation\} a<b \cs{end}\{equation\}\} \\
\meta{some text}
\end{flushleft}
the \meta{some text} incorrectly started a new paragraph.  Bug reports
about this behavior can be traced back to the time \LaTeXe{} was
developed, e.g., one test file from 1992 has a note that the above
case was unfortunately not resolvable despite some improvements made back
then.  The main cause of the issue (as you probably guessed) is that
the mechanism failed whenever the environment was executed within a
group (\texttt{\{...\}}, \cs{begingroup}/\cs{endgroup}, or
\cs{bgroup}/\cs{egroup} pair) that was closed before the next blank
line was reached.

While most of the time  this could be visually corrected by adding some
explicit \cs{noindent}, the situation got worse when we tried to
implement tagged PDFs resulting in incorrect structures or worse.

We therefore made a new attempt to resolve this problem in every
situation and this new solution is rolled out in the current
release.


\section{New or improved commands}

\subsection{Avoid bogus \enquote{no item} error}

The commands \cs{addvspace} and \cs{addpenalty} generated the famous
error message \enquote{Something's wrong--perhaps a missing \cs{item}}
when they were encountered outside vertical mode. Most of the time this
error was bogus and if not, then it was generated several times rather
than once.

Once upon a time (in \LaTeX{}~2.09) it was necessary that these
commands were used only in vertical mode, but with \LaTeXe{} in 1994,
we changed the internals but simply overlooked that this error message
then had become useless. In this release, i.e.,~30 years too late, we have
finally lifted the ban and from now on this error should only show
up if there is indeed a missing \cs{item}.
%
\githubissue{1460}


\section{Code improvements}

\subsection{Avoiding keyval option clashes between classes and packages}

In \LaTeX{} News~35~\cite{40:ltnews35} we introduced keyval option processing
to the kernel. Following the standard for \LaTeXe{} options, keyval options
given to the \cs{documentclass} line were treated as global and so parsed by
every package. However, with keyvals, the likelihood of a name clash between a
class-specific option and one used by a package is much higher than it is with
simple strings. We have therefore refined the mechanism in the current release.

When a class uses the kernel keyval processor, any options it recognises are
recorded and any packages using the keyval processor will then \emph{skip}
these \enquote{global} options. To allow for the case where a class directly
uses an option which should be global (for example \texttt{draft}), a new key
property \texttt{.pass-to-packages} has been added. This can then be set to
indicate that this key is not to be skipped. For example
\begin{verbatim}
\DeclareKeys{
  draft .if = {ifl@cls@draft},
  draft .pass-to-packages = true,
  mode  .store = \cls@mode
}
\end{verbatim}
in a class would create two options, \texttt{draft} and \texttt{mode}. The
\texttt{draft} option will be treated in the normal way by packages using
keyvals, but they will ignore the \texttt{mode} option: it is effectively
marked as \enquote{private} to the class.
%
\githubissue{1279}


\subsection{Improved error raised by empty hook}

When using the hook management, both hook and label names (if specified) 
should be non-empty. Before empty hook and empty label both raised the
same label-specific error.
\begin{verbatim}
! LaTeX hooks Error: Empty code label on line ....
  Using 'top-level' instead.
\end{verbatim}
This has now been improved. Now empty hook raises
\begin{verbatim}
! LaTeX hooks Error: Empty hook on line ....
\end{verbatim}
%
\githubissue{1423}

\subsection{Provide counter representations for link targets}

To create unique target names for links the package 
\pkg{hyperref} uses a special counter representation
\verb+\theH+\meta{counter}. To ensure that this 
counter representation exists, \pkg{hyperref} redefined the 
commands \verb+\@definecounter+, \verb+\@addtoreset+ 
and \verb+\refstepcounter+. This counter representation is also
needed for the Tagged PDF project and and so these augmented command definitions 
have now been incorporated
into the kernel. 
Thus from now on every \verb+\newcounter{+\meta{counter}\verb+}+ will not
only define \verb+\the+\meta{counter} but also \verb+\theH+\meta{counter}.

\subsection{Extending \cs{refstepcounter}}

The package \pkg{hyperref} redefines since many years \verb+\refstepcounter+ and
adds code that creates link targets. The kernel definition has now been extended
with socket interfaces that will allow \pkg{hyperref} to avoid the redefinitions. The new interfaces are also used by the Tagged PDF code that needs target names to resolve
references between structures.

\section{Bug fixes}

\subsection{Fix wrong file type in a rollback warning}

When \LaTeX{} is rolled back to date \meta{date1} and a class or
package with minimum date requirement \meta{date2} is to be loaded, a
rollback warning is raised if \meta{date2} is later than \meta{date1}:
\begin{verbatim}
LaTeX Warning: Suspicious rollback/min-date
               date given.
  A minimal date of YYYY-MM-DD has been
  specified for package '<pkgname>'.
  But this is in conflict with a rollback
  request to YYYY-MM-DD.
\end{verbatim}

In some cases this message showed a wrong file type, i.e.,
\verb|document class '<pkgname>'| or \verb|package '<clsname>'|.
This has now been corrected.
%
\githubissue{870}

\subsection*{Fix existence check of document environments}
\cs{NewDocumentEnvironment} and friends define (or redefine) a document
environment using the space-trimmed \meta{envname}, but the existence
check for \meta{envname} was done without space trimming. Thus when the
user-specified \meta{envname} consists of leading and/or trailing
space(s), it may lead to erroneously silent environment declaration.
For example, in
\begin{verbatim}
  \NewDocumentEnvironment{myenv}{}{begin}{end}
  \NewDocumentEnvironment{ myenv }{}{begin}{end}
\end{verbatim}
the first line defines a new environment \env{myenv} but the second
line would check existence for \env{ myenv } (which is not yet defined),
then redefine \env{myenv} environment without raising any errors.
This has now been corrected.
%
\githubissue{1399}

\subsection{Handling of global keys with spaces}

If the global (class) options contained spaces around key names,
\cs{ProcessKeyOptions} would fail to remove known keys from the
list of unused global options and \cs{OptionNotUsed} would mistakenly
add space-surrounded key names to that list.
These has been corrected as a hotfix in patch level 1 of the November 2023
release (but unfortunately not mentioned in~\cite{40:ltnews38}) and
the current release, respectively.
%
\githubissue{1238}

\subsection{File list entries for rolled back packages/classes}
When the rollback mechanism for packages and classes was introduced
in 2018~\cite{40:ltnews28}, loading of the selected historic release
was not recorded in the file list used by \cs{listfiles}.
This has now been corrected so that the extended usage~\cite{40:ltnews39}
\begin{verbatim}
\listfiles[hashes,sizes]
\end{verbatim}
now gives more complete and less confusing info.
%
\githubissue{1413}

\subsection{\pkg{doc}:\ \cs{PrintDescribeMacro} in preamble}

In \pkg{doc} version 2 it was possible alter the definition of
\cs{PrintDescribeMacro} and similar commands in preamble. In version 3
this stopped working because they go reset at the end of the
preamble. This has now been implemented differently and changes in the
preamble are possible again.
%
\githubissue{1000}


\section{Improvement to \XeTeX\ \cs{showhyphens}}
When using \cs{showhyphens} with \XeTeX, missing character warnings
would be generated for any character not in Latin Modern. This has been
corrected and the warnings are suppressed.
%
\githubissue{1380}


\section{Avoid code duplication in rollback}

When the kernel uses \cs{AddToHook} in a region that might be 
rolled back (which happens in a few places) and a document requests a
rollback, then we have the situation that the hook already contains code to which we added the same
(or slightly different) code during the
rollback; this results in code duplication or, worse, in errors. This has
now been corrected by dropping any such code chunk (if there is one) prior to
adding the rollback code.
%
\githubissue{1407}

\section{Passing template keys using \cs{KeyValue}}

With the move of the template code to the kernel, some internal efficiencies
were also made. However, there was an oversight in how passing key values from
one setting to another was implemented, meaning that using \cs{KeyValue} could
result in an infinite loop. This has now been fixed.
%
\githubissue{1486}

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

\section{Extend support for \cs{dots}}

The implementation of \cs{dots} in \pkg{amsmath} has the feature that
it selects different dots depending on the symbol that follows: e.g.,
dots between commas would normally be on the baseline, while dots
between binary or relational symols would be raised. However, when symbols such
as \cs{cong} were protected from expansion in moving arguments (so
that they worked in places such as headings) it had the unfortunate
side-effect that the \cs{dots} magic stopped working for them. This
has now been corrected.
%
\githubissue{1265}



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

\section{Changes to packages in the \pkg{tools} category}

\subsection{Modification to generation of the \file{.tex} from \pkg{fileerr}}

The \pkg{fileerr} extraction has been modified to write \texttt{rename-to-empty-base.tex}
rather than \texttt{.tex} to comply with an expected security change in texlive 2025.
\texttt{build.lua} has been  modified to rename \texttt{rename-to-empty-base.tex} to \texttt{.tex}
after unpacking. However if using \textsf{docstrip} directly rather than using \textsf{l3build}
or the unpacked zip file from \CTAN{}, the user must now rename the file and  install as \texttt{.tex}.
%
\githubissue{1412}

\subsection{\pkg{array}: Tagging support for \cs{cline}}

In the last release we added tagging support for \pkg{array},
\pkg{longtable} and other tabular packages, but we overlooked that the
kernel definition for \cs{cline} also needs modification because the
rule generated by the command needs to be tagged as an
artifact. Furthermore, the processing of a \cs{cline} looks to the
algorithm as if another row is added (which is technically what
happens), thus it was also necessary to decrement the internal row
counter to get a correct row count. This has now been corrected in
\pkg{array} which is automatically loaded for tagging, so that all
these packages are now fully compatible with the tagging code if it is
turned on.
%
\taggingissue{134}


\subsection{\pkg{longtable}: Extend caption type}

The \pkg{longtable} has been extended and now provides the command \cs{LTcaptype}
(stemming from the \pkg{ltcaption} package) to change
the counter and caption type used by the \cs{caption} command from longtable.
So with \verb+\renewcommand\LTcaptype{figure}+, a longtable will step the
figure counter instead of the table counter and produce an
entry in the list of figures. An empty definition, \verb+\renewcommand\LTcaptype{}+,
will suppress increasing of the counter. This makes it easy to define an
unnumbered variant of longtable:
\begin{verbatim}
\newenvironment{longtable*}
  {\renewcommand\LTcaptype{}\longtable}
  {\endlongtable}
\end{verbatim}


\subsection{\pkg{array}: Improve \texttt{>\{...\}} specifier}

If the argument of \texttt{>\{...\}} ended with a command accepting a
trailing optional argument, e.g., defined for example with
\verb=\NewDocumentCommand\foo{o}{...}=, one could get low-level
parsing errors. This has now been corrected.
%
\githubissue{1468}



%\section{Changes to files in the \pkg{cyrillic} category}

\begin{thebibliography}{9}\frenchspacing

%\fontsize{9.3}{11.3}\selectfont

\bibitem{40:Lamport}
Leslie Lamport.
\newblock \emph{{\LaTeX}: {A} Document Preparation System: User's Guide and Reference
  Manual}.
\newblock \mbox{Addison}-Wesley, Reading, MA, USA, 2nd edition, 1994.
\newblock ISBN 0-201-52983-1.
\newblock Reprinted with corrections in 1996.

\bibitem{40:ltnews} \LaTeX{} Project Team.
  \emph{\LaTeXe{} news 1--39}. June, 2024.
  \url{https://latex-project.org/news/latex2e-news/ltnews.pdf}

\bibitem{40:ltnews28} \LaTeX{} Project Team.
  \emph{\LaTeXe{} news 28}. April 2018.
  \url{https://latex-project.org/news/latex2e-news/ltnews28.pdf}

\bibitem{40:ltnews35} \LaTeX{} Project Team.
  \emph{\LaTeXe{} news 35}. June 2022.
  \url{https://latex-project.org/news/latex2e-news/ltnews35.pdf}

\bibitem{40:ltnews38} \LaTeX{} Project Team.
  \emph{\LaTeXe{} news 38}. November 2023.
  \url{https://latex-project.org/news/latex2e-news/ltnews38.pdf}

\bibitem{40:ltnews39} \LaTeX{} Project Team.
  \emph{\LaTeXe{} news 39}. June 2024.
  \url{https://latex-project.org/news/latex2e-news/ltnews39.pdf}

\end{thebibliography}

\end{document}
