diff options
Diffstat (limited to 'macros/latex/required')
220 files changed, 11106 insertions, 7616 deletions
diff --git a/macros/latex/required/amsmath/README.md b/macros/latex/required/amsmath/README.md index 38e4da1427..e69baaaecd 100644 --- a/macros/latex/required/amsmath/README.md +++ b/macros/latex/required/amsmath/README.md @@ -1,7 +1,7 @@ The amsmath bundle for LaTeX ============================ -Release 2024-06-01 patch level 0 +Release 2024-11-01a Overview -------- diff --git a/macros/latex/required/amsmath/amsbsy.pdf b/macros/latex/required/amsmath/amsbsy.pdf Binary files differindex 28e261f75d..e2c08c4edb 100644 --- a/macros/latex/required/amsmath/amsbsy.pdf +++ b/macros/latex/required/amsmath/amsbsy.pdf diff --git a/macros/latex/required/amsmath/amscd.pdf b/macros/latex/required/amsmath/amscd.pdf Binary files differindex 7f052e0bda..2e9324d250 100644 --- a/macros/latex/required/amsmath/amscd.pdf +++ b/macros/latex/required/amsmath/amscd.pdf diff --git a/macros/latex/required/amsmath/amsgen.pdf b/macros/latex/required/amsmath/amsgen.pdf Binary files differindex 230bbd5e06..fb58bb4076 100644 --- a/macros/latex/required/amsmath/amsgen.pdf +++ b/macros/latex/required/amsmath/amsgen.pdf diff --git a/macros/latex/required/amsmath/amsldoc.pdf b/macros/latex/required/amsmath/amsldoc.pdf Binary files differindex 87aff77bd5..c65772883e 100644 --- a/macros/latex/required/amsmath/amsldoc.pdf +++ b/macros/latex/required/amsmath/amsldoc.pdf diff --git a/macros/latex/required/amsmath/amsmath.dtx b/macros/latex/required/amsmath/amsmath.dtx index ec44957a89..591d175642 100644 --- a/macros/latex/required/amsmath/amsmath.dtx +++ b/macros/latex/required/amsmath/amsmath.dtx @@ -85,7 +85,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \end{macrocode} % % \begin{macrocode} -\ProvidesPackage{amsmath}[2024/05/23 v2.17q AMS math features] +\ProvidesPackage{amsmath}[2024/11/05 v2.17t AMS math features] % \end{macrocode} % % \section{Catcode defenses} @@ -166,7 +166,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \section{Flush-left equations [DMJ]} % -% The left margin of math enviroments is controlled by +% The left margin of math environments is controlled by % \cs{@mathmargin}. This can be set to \cs{@centering} to % implement the default behaviour, i.e., centered equations, and to % something else to implement the flushleft style. @@ -208,7 +208,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % % The next question is what happens when amsmath is used with % one of the standard classes. Unfortunately, \latex/ implements -% \opt{fleqn} somewhat clumsily; instead of paramaterizing the +% \opt{fleqn} somewhat clumsily; instead of parameterizing the % definitions of the math structures (as I've attempted to do % here), \fn{fleqn.clo} declares a dimen \cn{mathindent} that is % much like my \cs{@mathmargin} and then redefines \cn\[, \cn\], @@ -653,7 +653,7 @@ Foreign command \@backslashchar#1;\MessageBreak % % the |withdelims| primitives do not work in xetex with OpenType % fonts, and the relevant font dimen parameters are often not set -% in luatex as theer are no matching values in the OpenType Math +% in luatex as there are no matching values in the OpenType Math % table, so here we use variants that use the font parameters if % they are set, but scale using |\left\right| rather than the % |withdelims| primitives. @@ -3363,7 +3363,7 @@ ill-advised in LaTeX.% % \end{macro} % % \begin{macro}{\column@plus} -% \cs{\column@plus} is a useful abbreviation. +% \cs{column@plus} is a useful abbreviation. % \begin{macrocode} \def\column@plus{% \global\advance\column@\@ne @@ -3786,7 +3786,7 @@ and fix things up.} % (In earlier versions of the code anything other than \texttt{b} % or \texttt{t} was interpreted as \texttt{c} and the data was % otherwise dropped.) -% \changes{v2.17g}{2020/03/10}{Explicity test for b/t/c and return +% \changes{v2.17g}{2020/03/10}{Explicitly test for b/t/c and return % optional argument is different (gh/5)} % \begin{macrocode} \def\ams@start@box#1{% @@ -3919,7 +3919,7 @@ and fix things up.} % \end{macrocode} % If we picked up a bracket group by mistake here is the place to % return it for processing. -% \changes{v2.17g}{2020/03/10}{Explicity test for b/t/c and return +% \changes{v2.17g}{2020/03/10}{Explicitly test for b/t/c and return % optional argument is different (gh/5)} % \begin{macrocode} \ams@return@opt@arg @@ -4018,7 +4018,7 @@ and fix things up.} \crcr % \end{macrocode} % And put a mistaking picked up bracket group back: -% \changes{v2.17g}{2020/03/10}{Explicity test for b/t/c and return +% \changes{v2.17g}{2020/03/10}{Explicitly test for b/t/c and return % optional argument is different (gh/5)} % \begin{macrocode} \ams@return@opt@arg @@ -4592,7 +4592,7 @@ trying to recover with `aligned'% % \env{alignat} (i.e., the $n$th field of \cs{maxcolumn@widths}.) % It expands to a \<dimen>, so it can be used as the right-hand % side of a \<variable assignment> or \<arithmetic> statement. -% It's argument can be any \<number>, \<integer variable> or macro +% Its argument can be any \<number>, \<integer variable> or macro % that expands to one of these. [Check to make sure this is true.] % % This is subtler than it looks. @@ -5041,7 +5041,7 @@ trying to recover with `aligned'% % Next we consider the case when equations are flush-left, but tags % are on the right. This case is somewhat more complicated than % the previous one, since we can adjust the right margin by varying -% the inter-align separatin. Thus, when a tag is found to be too +% the inter-align separation. Thus, when a tag is found to be too % close to its equation, we first attempt to decrease % \cs{alignsep@} enough to move the equation off to an acceptable % distance. Only if that would require a value of \cs{alignsep@} @@ -5078,7 +5078,7 @@ trying to recover with `aligned'% % \cs{alignsep@} are both~0. To get the number of align % structures, we first count the number of columns by counting the % number of entries in the \cs{fieldlengths@} for the current row. -% The effective length is calcuated by \cs{x@rcalc@width} and put +% The effective length is calculated by \cs{x@rcalc@width} and put % in the temporary register \cs{@tempdimc}, using \cs{@tempdimb} as % an auxiliary variable. % \begin{macrocode} @@ -5500,7 +5500,7 @@ trying to recover with `aligned'% % might occur at the beginning of the current line. More % specifically, we first set \cs{count@} equal to the number of % interalign spaces preceding the current field (namely, $\lfloor -% (\cs{\column@}-1)/2 \rfloor$), and then subtract \cs{count@} from +% (\cs{column@}-1)/2 \rfloor$), and then subtract \cs{count@} from % both \cs{@tempcnta} and \cs{@tempcntb}. The rationale is that % for the purposes of adjusting the spacing between the tag and the % equation, the only flexible interalign spaces are those after @@ -5523,7 +5523,7 @@ trying to recover with `aligned'% % \end{macro} % % \begin{macro}{\place@tag} -% \cs{place@tag} takes care of the placment of tags in the +% \cs{place@tag} takes care of the placement of tags in the % \env{align} environments. % \begin{macrocode} \def\place@tag{% @@ -6187,7 +6187,7 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}% % in his \fn{amstex.doc} Spivak indicates those commands should never % be used on a first or last line. Perhaps better to leave the % question open unless/until real-life examples turn up. -% \changes{v2.17m}{2022/02/03}{Make \cs{shoveright} robust (if def is not trival)} +% \changes{v2.17m}{2022/02/03}{Make \cs{shoveright} robust (if def is not trivial)} % \begin{macrocode} \iftagsleft@ \protected\def\shoveright#1{% @@ -6212,7 +6212,7 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}% } \fi % \end{macrocode} -% \changes{v2.17m}{2022/02/03}{Make \cs{shoveleft} robust (if def is not trival)} +% \changes{v2.17m}{2022/02/03}{Make \cs{shoveleft} robust (if def is not trivial)} % \begin{macrocode} \if@fleqn \def\shoveleft#1{#1}% @@ -6576,14 +6576,14 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}% \def\mathdisplay@@pop{\the\mathdisplay@stack} % \end{macrocode} %\changes{v2.17k}{2021/08/24}{Move the counter inside the equation and guard -% with a mathopen for better compability with hyperref, issue gh/652} +% with a mathopen for better compatibility with hyperref, issue gh/652} % As with hyperref incrementing the counter creates a box to raise the anchor % it should be in a place where is doesn't affect spacing. % Currently the code from hyperref is used to avoid this problem: % If fleqn isn't active the counter is set inside the equation and the potential % box guarded by a mathopen to avoid side effects on following unary symbols. % If fleqn is activated it has to be outside to avoid problems with labels. -% This solution is temporary and not necessarly the best. +% This solution is temporary and not necessarily the best. % \begin{macrocode} \if@fleqn \renewenvironment{equation}{% @@ -6637,7 +6637,7 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}% % % \section{Credits} % -% Much of the code for the \pkg{amsmath} package had its orgin in +% Much of the code for the \pkg{amsmath} package had its origin in % \fn{amstex.tex}, written by Michael Spivak. The initial work of % porting \fn{amstex.tex} to \fn{amstex.sty} was done in 1988--1989 % by Frank Mittelbach and Rainer Sch\"opf. In 1994 David M. Jones diff --git a/macros/latex/required/amsmath/amsmath.pdf b/macros/latex/required/amsmath/amsmath.pdf Binary files differindex 185206a8b2..38eac89a60 100644 --- a/macros/latex/required/amsmath/amsmath.pdf +++ b/macros/latex/required/amsmath/amsmath.pdf diff --git a/macros/latex/required/amsmath/amsopn.pdf b/macros/latex/required/amsmath/amsopn.pdf Binary files differindex a6901ac7c4..b06e491ed4 100644 --- a/macros/latex/required/amsmath/amsopn.pdf +++ b/macros/latex/required/amsmath/amsopn.pdf diff --git a/macros/latex/required/amsmath/amstext.pdf b/macros/latex/required/amsmath/amstext.pdf Binary files differindex 6735db64f6..3a2f7233bf 100644 --- a/macros/latex/required/amsmath/amstext.pdf +++ b/macros/latex/required/amsmath/amstext.pdf diff --git a/macros/latex/required/amsmath/amsxtra.pdf b/macros/latex/required/amsmath/amsxtra.pdf Binary files differindex 7df65cd7f9..8164d4609b 100644 --- a/macros/latex/required/amsmath/amsxtra.pdf +++ b/macros/latex/required/amsmath/amsxtra.pdf diff --git a/macros/latex/required/amsmath/changes.txt b/macros/latex/required/amsmath/changes.txt index 588e7d36d0..3a4e6fd46c 100644 --- a/macros/latex/required/amsmath/changes.txt +++ b/macros/latex/required/amsmath/changes.txt @@ -3,7 +3,26 @@ All changes above are only part of the development branch for the next release. ================================================================================ ######################### -# 2023-11-01 Release +# 2024-11-01a Release +######################### + +2024-11-05 David Carlisle <David.Carlisle@latex-project.org> + + * amsmath.dtx + Revert last \dots change (gh/1448) + +######################### +# 2024-11-01 Release +######################### + +2024-08-02 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * amsmath.dtx (section{Ellipsis dots}): + Support special \dots magic in case of robust symbols protected with + \protected or via \DeclareRobustCommand (gh/1265) + +######################### +# 2024-06-01 Release ######################### 2024-05-23 Frank Mittelbach <Frank.Mittelbach@latex-project.org> diff --git a/macros/latex/required/amsmath/subeqn.pdf b/macros/latex/required/amsmath/subeqn.pdf Binary files differindex 18be7c3be5..10f73e1448 100644 --- a/macros/latex/required/amsmath/subeqn.pdf +++ b/macros/latex/required/amsmath/subeqn.pdf diff --git a/macros/latex/required/amsmath/technote.pdf b/macros/latex/required/amsmath/technote.pdf Binary files differindex a563ee67d6..f36424ece9 100644 --- a/macros/latex/required/amsmath/technote.pdf +++ b/macros/latex/required/amsmath/technote.pdf diff --git a/macros/latex/required/amsmath/testmath.pdf b/macros/latex/required/amsmath/testmath.pdf Binary files differindex 1c4a265eb3..59806dcb51 100644 --- a/macros/latex/required/amsmath/testmath.pdf +++ b/macros/latex/required/amsmath/testmath.pdf diff --git a/macros/latex/required/babel/base/README.md b/macros/latex/required/babel/base/README.md index c84cd4389b..48946f7e79 100644 --- a/macros/latex/required/babel/base/README.md +++ b/macros/latex/required/babel/base/README.md @@ -1,20 +1,31 @@ -## Babel 24.7 +## Babel 25.4 -2024-06-26 +2025-02-14 -`babel` is the multilingual framework for localizing documents in -LaTeX, LuaLaTeX, XeLaTeX. It manages culturally-determined -typographical (and other) rules for about 170 to 300 languages, -depending on the engine, with several levels of coverage. A few +`Babel` is the multilingual framework to localize documents. It fully +supports pdfLaTeX and the Unicode engines LuaLaTeX and XeLaTeX. A few languages even work with Plain formats. +Its aim is to provide a localization framework for different languages, +scripts, and cultures based on the latest advances in Unicode +(including the CLDR, Common Language Repository Data), the W3C (where +applicable) and other technologies, as well as on international +standards. + +Babel supports approximately from 170 to 300 languages, depending on +the engine (with various levels of coverage), across about 45 scripts, +including complex and RTL ones. Its high-level interface with +`fontscpec` allows for seamless integration with OpenType technologies +in LuaLaTeX and XeLaTeX, enabling the use of advanced typographic +features. + The latest stable version is available on <https://ctan.org/pkg/babel>. -Changes in version 24.7 are described in: +Changes in version 25.4 are described in: -https://latex3.github.io/babel/news/whats-new-in-babel-24.7.html +https://latex3.github.io/babel/news/whats-new-in-babel-25.4.html -Apart from the manual, you can find information on some aspects of babel at: +Apart from the manual, you can find information and examples in: https://latex3.github.io/babel/ @@ -48,10 +59,9 @@ respective authors. ### Summary of latest changes ``` -24.7 2024-06-26 - * Improvements in some locales: - - Filipino (thanks to Leothelion, @ponte-vecchio) - - Line breaking in Blin, Geez, Tigre, Tigrinya, Wolaytta. +25.4 2025-02-14 + New locales for ancient languages: Etruscan, Old Persian, + Old Irish, Ugaritic, Carian, Lycian, Lydian, Sabaean. ``` ### Previous changes diff --git a/macros/latex/required/babel/base/babel-code.pdf b/macros/latex/required/babel/base/babel-code.pdf Binary files differindex 8be7825803..dabd4d201c 100644 --- a/macros/latex/required/babel/base/babel-code.pdf +++ b/macros/latex/required/babel/base/babel-code.pdf diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx index 19db345759..80cef9d06a 100644 --- a/macros/latex/required/babel/base/babel.dtx +++ b/macros/latex/required/babel/base/babel.dtx @@ -1,7 +1,7 @@ % \iffalse % This document requires lualatex %% -%% Copyright (C) 2012-2024 Javier Bezos and Johannes L. Braams. +%% Copyright (C) 2012-2025 Javier Bezos and Johannes L. Braams. %% Copyright (C) 1989-2012 Johannes L. Braams and %% any individual authors listed elsewhere in this file. %% All rights reserved. @@ -32,7 +32,13 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2024/06/26 v24.7 The Babel package] +\DocumentMetadata{ + % testphase = {sec,toc,text}, + lang = en-001, +} +\ProvidesFile{babel.dtx}% + [2025/02/14 v25.4 + The multilingual framework for pdfLaTeX, LuaLaTeX and XeLaTeX] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -50,7 +56,10 @@ {NotoSans-Regular.ttf} \setmonofont[Scale=.86, FakeStretch=.97]{DejaVu Sans Mono} \raggedright -\addtolength{\textwidth}{25pt} +\setlength{\parindent}{.8em} +\frenchspacing +\addtolength{\oddsidemargin}{-2em} +\addtolength{\textwidth}{25.5pt} \addtolength{\textheight}{3.5cm} \addtolength{\topmargin}{-2cm} \font\manual=logo10 % font used for the METAFONT logo, etc. @@ -65,17 +74,16 @@ \newcommand*\m[1]{\mbox{$\langle$\normalfont\itshape#1\/$\rangle$}} \newcommand*\langlist{% \meta{language}\texttt{,}\meta{language}\texttt{,}...} -\newcommand*\langvar{\m{lang}} +\newcommand*\langvar{\m{language}} \newcommand*\Lopt[1]{\textsf{#1}} \newcommand*\Lenv[1]{\texttt{#1}} \newcommand*\menv[1]{\char`\{#1\char`\}} \newcommand*\Eenv[1]{% - \quad\ldots\quad + \quad...\quad \texttt{\color{thered}\string\end\menv{#1}}} \newcommand*\file[1]{\texttt{#1}} \newcommand*\cls[1]{\texttt{#1}} \newcommand*\pkg[1]{\texttt{#1}} -\addtolength{\oddsidemargin}{1em} \setlength{\leftmargini}{1.5em} \usepackage{framed} \usepackage{multicol} @@ -89,78 +97,111 @@ pdfkeywords={TeX, LaTeX, pdfTeX, LuaTeX, XeTeX, internationalization, localization}} \ExplSyntaxOn +\normalmarginpar \newcommand\New[1]{% \regex_extract_once:nnN{(\d\d?)\.(\d\d?)}{#1}\bbltempa \seq_pop_right:NN\bbltempa\bbltempb \seq_pop_right:NN\bbltempa\bbltempa + \leavevmode%\marginpar + {\scriptsize + % \enspace \colorbox[rgb]{.92, .86, .73}% - {New~#1% + {%New~ + #1% \quark_if_no_value:NTF\bbltempb{}% {~ \ifnum\bbltempa>2 \ifnum\bbltempb>34 \href{https://latex3.github.io/babel/news/% whats-new-in-babel-\bbltempa.\bbltempb.html}% - {\raisebox{.15ex}{$\oplus$}}% + {\scriptsize ※}% \fi\fi \ifnum\bbltempa>23 \href{https://latex3.github.io/babel/news/% whats-new-in-babel-\bbltempa.\bbltempb.html}% - {\raisebox{.15ex}{$\oplus$}}% - \fi}}\enspace\ignorespaces} + {\scriptsize ※}% + \fi}}}\enspace\ignorespaces} \ExplSyntaxOff \definecolor{thered}{rgb}{0.65,0.04,0.07} \definecolor{thegrey}{gray}{0.8} +\definecolor{thegreyed}{gray}{0.6} \definecolor{shadecolor}{rgb}{1,1,0.97} \definecolor{messages}{rgb}{.66,.13,.27} \makeatletter +\def\@seccntformat#1{% + \llap{\makebox[1.7cm][l]{\csname the#1\endcsname.}}% + \hspace{-.7cm}} \def\@begintheorem#1#2{% \list{}{}% \global\advance\@listdepth\m@ne - \item[{\sffamily\bfseries\color{messages}\hspace*{1.3em}% + \item[{\sffamily\bfseries\color{messages}\hspace*{1.4em}%\hspace*{2.8em}% \MakeUppercase{#1}}]}% \makeatother \newtheorem{warning}{Warning} \newtheorem{note}{Note} \newtheorem{example}{Example} \newtheorem{troubleshooting}{Troubleshooting} -\newtheorem{more}{More} \let\bblxv\verbatim \let\bblexv\endverbatim \newcommand\setengine{\def\engine} \let\engine\relax +\begingroup + \catcode`\<=13 + \catcode`\>=13 + \catcode`\|=13 + \AtBeginDocument{% + \gdef|{\verb|\def<##1>{$\langle${\rmfamily\itshape##1}$\rangle$}}} +\endgroup \def\verbatim{% - \begin{shaded*}% + \fboxsep=.8em + \begin{snugshade*}% \ifx\engine\relax\else - \vskip-1.08\baselineskip - \leavevmode\llap{\fbox{\footnotesize\textsc{\engine}}\hskip2.8em}% - \vskip-1.5\baselineskip + \vskip-.75\baselineskip + \leavevmode\llap{% + \fboxsep=2pt\fbox{\scriptsize\textsc{\engine}}\hskip2.8em}% + \vskip-1.6\baselineskip \vskip0pt \global\let\engine\relax \fi - \bblxv\vskip-\baselineskip\vskip2.5\parsep} -\def\endverbatim{\bblexv\vskip-2\baselineskip\end{shaded*}} + \bblxv\vskip0pt } +\def\endverbatim{% + \bblexv\vskip-7.5ex \end{snugshade*}} \catcode`\_=\active \def_{\bgroup\let_\egroup\leavevmode\color{thered}} \def\MacroFont{\fontencoding \encodingdefault \fontfamily\ttdefault \fontseries\mddefault \fontshape\updefault \small \catcode`\_=\active} \definecolor{shadecolor}{rgb}{0.96,0.96,0.93} -\AtBeginDocument{% - \def\PrintDescribeMacro#1{% - \strut\MacroFont\color{thered}\normalsize\string#1}} -\def\Describe#1{% - \par\penalty-500\vskip3ex\noindent - \DescribeMacro{#1}\args} -\def\DescribeOther{\vskip-4ex\Describe} -\makeatletter +% +\makeatletter +\def\Describe#1#2{% + \@startsection{subsubsection}{100}{\z@}% + {2.5ex\@plus .7ex \@minus .2ex}% + {1.5ex \@plus .2ex}% + {\hspace{-2cm}\color{thegreyed}\normalsize\ttfamily}*% + {\underline{\strut{\color{thered}\string#1}\color{black}#2}}} +\def\DescribeOther{\addvspace{-1.5ex}\Describe} +\AtBeginDocument{\def\DescribeMacro#1{{\ttfamily\color{thered}\string#1}}} +\def\macro#1{% WIP + \if@noskipsec\leavevmode\vskip-1.2\baselineskip\vskip0pt\fi + \@startsection{paragraph}{101}{\z@}% + {3.25ex \@plus1ex \@minus.2ex}% + {-1em}% + {\sffamily\bfseries\color{thered}}*{\hspace*{-1em}\string#1}} +\let\environment\macro +\def\optstar{% + \kern1pt\relax + \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}% + \kern1pt} \def\trouble#1{\addcontentsline{tsh}{trouble}{#1}} +\def\toclevel@trouble{0} \def\listoftroubles{\section*{Troubleshoooting}\@starttoc{tsh}} \let\l@trouble\l@figure +\def\@tocrmarg{3.5em plus 1000em} \let\saved@check@percent\check@percent \let\check@percent\relax -\def\args#1{% - \def\bbl@tempa{#1}% - \ifx\bbl@tempa\@empty\else#1\vskip1ex\fi\ignorespaces} -\begingroup % Changes to ltxdoc +% Changes to doc.sty (add <<...>> syntax) +\def\Module#1{% + \mod@math@codes$\langle${\color{thered}$\mathsf{#1}$}$\rangle$} +\begingroup \catcode`\<\active \catcode`\>\active \gdef\check@plus@etc{% @@ -174,21 +215,34 @@ \fi\fi\fi \bbl@next} \gdef\var@module#1#2#3>>{% - $\langle$\pm@module#2#3>$\rangle$% - \ifx*#2\ $\equiv$\fi} + $\langle$\pm@module#2#3>$\rangle$% + \ifx*#2\ $\equiv$\fi} \endgroup +\def\toc@usehook#1#2#3{% + \UseHookWithArguments{contentsline/#1}{4}% + {\toclevel@section}% + {#2}{#3}{\@contentsline@destination}} \renewcommand*\l@section[2]{% - \ifnum \c@tocdepth >\z@ + \ifnum\c@tocdepth>\z@ \addpenalty\@secpenalty - \addvspace{1.0em \@plus\p@}% + \addvspace{1.0em\@plus\p@}% \setlength\@tempdima{2em}% \begingroup - \parindent \z@ \rightskip \@pnumwidth - \parfillskip -\@pnumwidth - \leavevmode \bfseries + \parindent\z@ \rightskip\@pnumwidth + \parfillskip-\@pnumwidth + \leavevmode\bfseries \advance\leftskip\@tempdima - \hskip -\leftskip - #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par + \hskip-\leftskip + \toc@usehook{text/before}{#1}{#2}% + \csname contentsline@text@1@format\endcsname{#1} + \toc@usehook{text/after}{#1}{#2}% + \nobreak\hfil\nobreak \hb@xt@\@pnumwidth + {\hss + \toc@usehook{page/before}{#1}{#2}% + #2% + \toc@usehook{page/after}{#1}{#2}% + \kern-\p@\kern\p@}% + \par \endgroup \fi} \renewcommand*\l@subsection{\@dottedtocline{2}{2em}{3em}} @@ -199,16 +253,14 @@ \makeatother \begin{document} \title{Babel, a multilingual package for use with \LaTeX's standard - document classes\thanks{During the development ideas from Nico - Poppelier, Piet van Oostrum and many others have been used. - Bernd Raichle has provided many helpful suggestions.}} + document classes.} \author{Johannes Braams\\ Javier Bezos} \date{Typeset \today} \begin{titlepage} \begin{minipage}[t][0pt]{30cm} -\vspace{-3cm}\hspace{-7cm} +\vspace{-3cm}\hspace{-6cm} \sffamily \begin{tabular}{p{8cm}p{15cm}} \cellcolor[rgb]{.86,.73,.67} @@ -252,8 +304,8 @@ Johannes L. Braams\\[-.5ex] Localization and internationalization\\[1cm] Unicode\\ \largetex\\ -pdf\largetex\\ Lua\largetex\\ +pdf\largetex\\ Xe\largetex \vspace{20cm} \end{minipage} @@ -272,26 +324,35 @@ Xe\largetex \begin{description} \item[\sffamily\color{messages}What is this document about?] This user guide focuses on internationalization and localization with \LaTeX{} -and \pdftex, \xetex{} and \luatex{} with the \babel{} package. There +and \pdftex, \luatex{} and \xetex{} with the \babel{} package. There are also some notes on its use with e-Plain and pdf-Plain \TeX. +\item[\sffamily\color{messages}I only need learn the most basic +features.] The first subsections (1.1-1.6) describe the ways +of loading a language, which is usually all you need. + +\item[\sffamily\color{messages}I don’t like manuals. I prefer sample + files.] This manual contains lots of examples and tips, but in GitHub + there are many + \href{https://github.com/latex3/babel/tree/master/samples}{sample + files}. + \item[\sffamily\color{messages}What if I’m interested only in the latest changes?] Changes and new features with relation to version 3.8 are highlighted with \New{X.XX}\hspace{-.5em} -(\raisebox{.15ex}{$\oplus$} is a link to the \babel{} site), and there +({\scriptsize ※} is a link to the \babel{} site), and there are some notes for the latest versions in \href{https://latex3.github.io/babel/}{the \babel{} site}. The most -recent features can be still unstable. Remember version 24.1 follows +recent features can still be unstable. Remember version 24.1 follows 3.99, because of a new numbering scheme. -\item[\sffamily\color{messages}Can I help?] Sure! If you are interested -in the \TeX{} multilingual support, please join the -\href{http://tug.org/mailman/listinfo/kadingira}{kadingira mail list}. -You can follow the development of \babel{} in -\href{https://github.com/latex3/babel}{GitHub} and make suggestions; feel -free to fork it and make pull requests. If you are the author of a -package, send to me a few test files which I'll add to mine, so that -possible issues can be caught in the development phase. +\item[\sffamily\color{messages}Can I help?] Sure! You can follow the +development of \babel{} in +\href{https://github.com/latex3/babel}{GitHub} and make suggestions, +including requirements for some language or script. Feel free to fork +it and make pull requests. If you are the author of a package, send +me a few test files which I'll add to mine, so that possible issues can +be caught in the development phase. \item[\sffamily\color{messages}It doesn't work for me!] You can ask for help in some forums like \textsf{tex.stackexchange}, but if you have @@ -306,26 +367,46 @@ maintained separately \item[\sffamily\color{messages}How can I contribute a new language?] See section \ref{contribute} for contributing a language. -\item[\sffamily\color{messages}I only need learn the most basic -features.] The first subsections (1.1-1.3) describe the traditional way -of loading a language (with |ldf| files), which is usually all you need. -The alternative way based on |ini| files, which complements the -previous one (it does \textit{not} replace it, although it is still -necessary in some languages), is described below; go to \ref{inifiles}. - -\item[\sffamily\color{messages}I don’t like manuals. I prefer sample - files.] This manual contains lots of examples and tips, but in GitHub - there are many - \href{https://github.com/latex3/babel/tree/master/samples}{sample - files}. - \item[\sffamily\color{messages}Where is the code?] Run |lualatex --jobname=babel-code \let\babelcode\relax\input{babel.dtx}|. \end{description} -\section{The user interface}\label{U-I} +\begin{note} + Now that the recommend engine for \LaTeX\ is \luatex, you can read + \href{https://latex3.github.io/babel/guides/migrating-pdftex-luatex.html}{Migrating + from pdfTeX to LuaTeX}. +\end{note} + +\section{The basic user interface}\label{U-I} + +There are two ways to load a language with babel, namely, the old good +‘classical’ one, based on mostly self-contained declarations in a file +with |ldf| extension, and the ‘modern’ one, based on a brand new +mechanism based on descriptive |ini| files. -\subsection{Monolingual documents} +‘Classical’ doesn’t mean outdated or obsolete. In fact, this is the +recommended method in most languages where an |ldf| file exists. Below +is a list of the supported languages. See also +\href{https://latex3.github.io/% +babel/guides/which-method-for-which-language.html}{Which +method for which language} in the \babel{} site. + +Basically, what you need is typically: +\begin{itemize} +\bfseries +\item Tell \babel{} which language or languages are required. +\item With non-Latin scripts and Unicode engines (\luatex\ is the +preferred one), select a suitable font (sec.~\ref{fonts}) +\item In multilingual documents, switch the language in the text body +(sec.~\ref{selectors}). +\end{itemize} + +You can find basic info and minimal \luatex{} example files for about +300 locales in the +\href{https://latex3.github.io/babel/guides/index-locale.html}{GitHub +repository}. There are also some videos on \href{https://www.youtube.com/playlist?list=PLVc2cHCI6zpJcaa1x-yK9iRjqtE3Ct2Ja}{Youtube}. + +\subsection{Monolingual documents: the ‘classical’ way} In most cases, a single language is required, and then all you need in \LaTeX{} is to load the package using its standard mechanism for this @@ -335,23 +416,22 @@ addition, you may want to set the font and input encodings. Another approach is making the language a global option in order to let other packages detect and use it. This is the standard way in \LaTeX{} for an option – in this case a language – to be recognized by several -packages. +packages (in other words, \babel{} doesn’t set the languages, it just +recognizes the options passed to the class or the package). -Many languages are compatible with \textsf{xetex} and \textsf{luatex}. -With them you can use \babel{} to localize the documents. When these -engines are used, the Latin script is covered by default in current -\LaTeX{} (provided the document encoding is UTF-8), because the font -loader is preloaded and the font is switched to |lmroman|. Other -scripts require loading \textsf{fontspec}. You may want to set the font -attributes with \textsf{fontspec}, too. +Many languages are compatible with \textsf{luatex} and \textsf{xetex}, +but a few only work with \pdftex. When these engines are used, the +Latin script is covered by default in current \LaTeX{} (provided the +document encoding is UTF-8). Other scripts require loading +\textsf{fontspec}, although \babel{} provides a higher level interface +(see |\babelfont| below). \begin{example} - Here is a simple full example for “traditional” \TeX{} engines - (see below for \xetex{} and \luatex{}). The packages |fontenc| and - |inputenc| do not belong to \babel, but they are included in the - example because typically you will need them. It assumes UTF-8, the - default encoding: -\setengine{pdftex} + Here is a simple full example for “traditional” \TeX{} engines (see + below for \luatex{} and \xetex{}). The package |fontenc| does not + belong to \babel, but it is included in the example because typically + you will need it. It assumes UTF-8, the default encoding: + \setengine{pdftex} \begin{verbatim} \documentclass{article} @@ -377,11 +457,10 @@ the option |french| and will be able to use it. \end{example} \begin{example} -And now a simple monolingual document in Russian (text from the -Wikipedia) with \xetex{} or \luatex{}. Note neither \textsf{fontenc} -nor \textsf{inputenc} are necessary, but the document should be encoded -in UTF-8 and a so-called Unicode font must be loaded (in this example -|\babelfont| is used, described below). +Now a simple monolingual document in Russian (text from the Wikipedia) +with \luatex{} or \xetex{}. Note neither \textsf{fontenc} nor +\textsf{inputenc} is necessary, and a so-called Unicode font must be +loaded (in this example with the help of |\babelfont|, described below). \setengine{luatex/xetex} \begin{verbatim} @@ -402,65 +481,20 @@ _\babelfont{rm}{DejaVu Serif}_ \end{verbatim} \end{example} -\begin{troubleshooting} -\trouble{Paragraph ended before \textbackslash UTFviii@three@octets -was complete} -A common source of trouble is a wrong setting of the input encoding. -Depending on the \LaTeX{} version you can get the following somewhat -cryptic error: -\begin{verbatim} -! Paragraph ended before \UTFviii@three@octets was complete. -\end{verbatim} -Or the more explanatory: -\begin{verbatim} -! Package inputenc Error: Invalid UTF-8 byte ... -\end{verbatim} -Make sure you set the encoding actually used by your editor. -\end{troubleshooting} - \begin{note} Because of the way \babel{} has evolved, ``language'' can refer to - (1) a set of hyphenation patterns as preloaded into the format, (2) - a package option, (3) an |ldf| file, and (4) a name used in the - document to select a language or dialect. So, a package option - refers to a language in a generic way -- sometimes it is the actual - language name used to select it, sometimes it is a file name loading - a language with a different name, sometimes it is a file name - loading several languages. Please, read the documentation for + (1) a set of hyphenation patterns as preloaded into the format, (2) a + package option, (3) an |ldf| file, and (4) a name used in the + document to select a language. Please, read the documentation for specific languages for further info. \end{note} -\begin{troubleshooting} - The following warning is about hyphenation patterns, which are - not under the direct control of \babel: -\trouble{No hyphenation patterns were preloaded for (babel) the - language `LANG' into the format} -\begin{verbatim} -Package babel Warning: No hyphenation patterns were preloaded for -(babel) the language `LANG' into the format. -(babel) Please, configure your TeX system to add them and -(babel) rebuild the format. Now I will use the patterns -(babel) preloaded for \language=0 instead on input line 57. -\end{verbatim} - The document will be typeset, but very likely the text will not be - correctly hyphenated. Some languages in some system may be raising - this warning wrongly (because they are not hyphenated) -- just ignore - it. See the manual of your distribution (Mac\TeX, Mik\TeX, \TeX Live, - etc.) for further info about how to configure it. -\end{troubleshooting} - \begin{note} - With \textsf{hyperref} you may want to set the document language with - something like: -\begin{verbatim} -\usepackage[_pdflang=es-MX_]{hyperref} -\end{verbatim} -This is not currently done by \babel{} and you must set it by hand. The -document language can be also set with |\DocumentMetadata|, before -|\documentclass|; for example: -\begin{verbatim} -\DocumentMetadata{_lang=es-MX_} -\end{verbatim} + \Babel{} does not make any readjustments by default in font size, + vertical positioning or line height. This is on purpose + because the optimal solution depends on the document layout and the + font, and very likely the most appropriate one is a combination of + these settings. \end{note} \begin{note} @@ -472,157 +506,178 @@ document language can be also set with |\DocumentMetadata|, before \end{note} \begin{note} - \Babel{} does not make any readjustments by default in font size, - vertical positioning or line height by default. This is on purpose - because the optimal solution depends on the document layout and the - font, and very likely the most appropriate one is a combination of - these settings. + With \textsf{hyperref} you may want to set the PDF document language + with something like: +\begin{verbatim} +\usepackage[_pdflang=es-MX_]{hyperref} +\end{verbatim} +This is not currently done by \babel{} and you must set it by hand. The +PDF document language can also be set with |\DocumentMetadata|, before +|\documentclass|; for example: +\begin{verbatim} +\DocumentMetadata{_lang=es-MX_} +\end{verbatim} \end{note} -\subsection{Multilingual documents} +\begin{warning} + In the preamble, \textit{no} language has been selected, except + hyphenation patterns and the name assigned to |\localename| (and + |\languagename|) (in particular, shorthands, captions and date are not + activated). If you need to define boxes and the like in the preamble, + you might want to use some of the language selectors described below. +\end{warning} -In multilingual documents, just use a list of the required languages as -package or class options. The last language is considered the main one, -activated by default. Sometimes, the main language changes the document -layout (eg, |spanish| and |french|). +\begin{troubleshooting} +\trouble{Package inputenc Error: Invalid UTF-8 byte ...} +\textit{Package inputenc Error: Invalid UTF-8 byte ...} +A common source of trouble is a wrong setting of the input encoding. +Make sure you set the encoding actually used by your editor, or +even better, make sure the encoding in your editor is set to UTF-8. +\end{troubleshooting} -\begin{example} - In \LaTeX, the preamble of the document: +\begin{troubleshooting} +Another typical error when using \babel{} is the following: +\trouble{Unknown language 'LANG'} \begin{verbatim} -\documentclass{article} -\usepackage[dutch,english]{babel} +! Package babel Error: Unknown language 'LANG'. Either you have +(babel) misspelled its name, it has not been installed, +(babel) or you requested it in a previous run. Fix its name, +(babel) install it or just rerun the file, respectively. In +(babel) some cases, you may need to remove the aux file \end{verbatim} - would tell \LaTeX\ that the document would be written in two - languages, Dutch and English, and that English would be the first - language in use, and the main one. -\end{example} + The most frequent reason is, by far, the latest (for example, you + included |spanish|, but you realized this language is not used after + all, and therefore you removed it from the option list). In most + cases, the error vanishes when the document is typeset again, but in + more severe ones you will need to remove the |aux| file. +\end{troubleshooting} -You can also set the main language explicitly, but it is discouraged -except if there is a real reason to do so: +\begin{troubleshooting} +\textit{No hyphenation patterns were preloaded...} + The following warning is about hyphenation patterns, which are + not under the direct control of \babel: +\trouble{No hyphenation patterns were preloaded for (babel) the + language 'LANG' into the format} \begin{verbatim} -\documentclass{article} -\usepackage[_main=english_,dutch]{babel} +Package babel Warning: No hyphenation patterns were preloaded for +(babel) the language `LANG' into the format. +(babel) Please, configure your TeX system to add them and +(babel) rebuild the format. Now I will use the patterns +(babel) preloaded for \language=0 instead on input line 57. \end{verbatim} + The document will be typeset, but very likely the text will not be + correctly hyphenated. Some languages in some system may be raising + this warning wrongly (because they are not hyphenated) -- just ignore + it. See the manual of your distribution (Mac\TeX, Mik\TeX, \TeX Live, + etc.)\ for further info about how to configure it. +\end{troubleshooting} -Examples of cases where |main| is useful are the following. - -\begin{example} -Some classes load \babel{} with a hardcoded language option. Sometimes, -the main language can be overridden with something like that before -|\documentclass|: +\begin{troubleshooting} +\textit{You are loading directly a language style.} +Loading directly +|sty| files in \LaTeX{} (i.e., |\usepackage{<language>}|) was deprecated +many years ago and you will get the error: \trouble{You are loading +directly a language style} \begin{verbatim} -\PassOptionsToPackage{main=english}{babel} +! Package babel Error: You are loading directly a language style. +(babel) This syntax is deprecated and you must use +(babel) \usepackage[language]{babel}. \end{verbatim} -\end{example} +\end{troubleshooting} \begin{note} - Languages may be set as global and as package option at the same - time, but in such a case you should set explicitly the main language - with the package option |main|: -\begin{verbatim} -\documentclass[_italian_]{book} -\usepackage[ngerman,_main=italian_]{babel} -\end{verbatim} + You will see an ‘info’ in the log file stating some data is being + loaded from an |ini| file. It includes standardized names for + language and script used by |\babelfont|, and the BCP 47 tag, required in + some cases by |\Make<Xxxxx>case|. \end{note} -\begin{warning} - In the preamble the main language has \textit{not} been selected, - except hyphenation patterns and the name assigned to |\languagename| - (in particular, shorthands, captions and date are not activated). If - you need to define boxes and the like in the preamble, you might - want to use some of the language selectors described below. -\end{warning} +\subsection{Monolingual documents: the ‘modern’ way} -To switch the language there are two basic macros, described below in -detail: |\selectlanguage| is used for blocks of text, while -|\foreignlanguage| is for chunks of text inside paragraphs. +When, for whatever reason, the ‘classical’ way with the |ldf| is not +suitable for the needs of a document or a document system, you have to +resort to a different mechanism, which is activated with the package +option |provide=*| (in monolingual documents). \begin{example} -A full bilingual document with \pdftex{} follows. The main language is -|french|, which is activated when the document begins. It assumes UTF-8: -\setengine{pdftex} + Although Georgian has its own \texttt{ldf} file, here is how to + declare this language in Unicode engines. Here, as in a previous + example, we resort to |\babelfont| to set the font for this language + (with the |Harfbuzz| renderer, just to show how to set it, because + here the |Node| renderer should be fine). +\setengine{luatex/xetex} \begin{verbatim} -\documentclass{article} +\documentclass{book} -\usepackage[T1]{fontenc} +\usepackage[_georgian, provide=*_]{babel} -_\usepackage[english,french]{babel}_ +_\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans}_ \begin{document} -Plus ça change, plus c'est la même chose! +\tableofcontents -_\selectlanguage{english}_ +\chapter{სამზარეულო და სუფრის ტრადიციები} -And an English paragraph, with a short text in -_\foreignlanguage{french}{français}_. +ქართული ტრადიციული სამზარეულო ერთ-ერთი უმდიდრესია მთელ მსოფლიოში. \end{document} \end{verbatim} -\end{example} - -\begin{example} - With \xetex{} and \luatex, the following bilingual, single script - document in UTF-8 encoding just prints a couple of ‘captions’ and - |\today| in Danish and Vietnamese. No additional packages are - required, because the default font supports both languages. -\setengine{luatex/xetex} +And with a global option: \begin{verbatim} -\documentclass{article} - -_\usepackage[vietnamese,danish]{babel}_ - -\begin{document} - -\prefacename, \alsoname, \today. - -\selectlanguage{vietnamese} - -\prefacename, \alsoname, \today. - -\end{document} +\documentclass[_georgian_]{book} +\usepackage[_provide=*_]{babel} +\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans} \end{verbatim} \end{example} \begin{note} - Once loaded a language, you can select it with the corresponding - BCP47 tag. See section \ref{bcp47} for further details. + This option actually loads the language with |\babelprovide| and the + |import| option, described below. Instead of an asterisk, you may + provide a list of options for |\babelprovide| enclosed in braces + (|import| is included by default). \end{note} -\begin{note} - Documents with several input encodings are not frequent, but - sometimes are useful. You can set different encodings for different - languages as the following example shows: +\begin{example} +For a text in Chinese, you can write in the preamble: +\setengine{luatex/xetex} \begin{verbatim} -\addto\extrasfrench{\inputencoding{latin1}} -\addto\extrasrussian{\inputencoding{koi8-r}} +\usepackage[_chinese, provide=*_]{babel} +_\babelfont{rm}{FandolSong}_ \end{verbatim} -\end{note} +The skip between characters is 0 pt plus .1 pt, which can be modified +with an option (explained below) in |provide|. For example: +\setengine{luatex/xetex} +\begin{verbatim} +\usepackage[chinese, provide=_{ intraspace=0 .2 0 }_]{babel} +\end{verbatim} +\end{example} -\subsection{Mostly monolingual documents} +\subsection{Mostly monolingual documents: lazy loading} \label{mostlymono} \New{3.39} Very often, multilingual documents consist of a main language with small pieces of text in another languages (words, idioms, short sentences). Typically, all you need is to set the line breaking -rules and, perhaps, the font. In such a case, \babel{} now does not -require declaring these secondary languages explicitly, because the -basic settings are loaded on the fly when the language is selected (and -also when provided in the optional argument of |\babelfont|, if used). - -This is particularly useful, too, when there are short texts of this -kind coming from an external source whose contents are not known on -beforehand (for example, titles in a bibliography). At this regard, it -is worth remembering that |\babelfont| does \textit{not} load any font -until required, so that it can be used just in case. +rules and, perhaps, the font. In such a case, there is no need to +clutter the preamble (particularly the class and package options) +because \babel{} does not require declaring these secondary languages +explicitly — the basic settings are loaded on the fly when the language +is first selected. + +This is particularly useful in documents with many languages, and also +when there are short texts of this kind coming from an external source +whose contents are not known beforehand (for example, titles in a +bibliography). In this regard, it is worth remembering that +|\babelfont| does \textit{not} load any font until required, so that it +can be used just in case. \New{3.84} With \pdftex, when a language is loaded on the fly -(actually, with |\babelprovide|, because this is the macro used -internally to load it) selectors now set the font encoding based on the -list provided when loading |fontenc|. Not all scripts have an -associated encoding, so this feature works only with Latin, Cyrillic, -Greek, Arabic, Hebrew, Cherokee, Armenian, and Georgian, provided a -suitable font is found. +(internally it's loaded with |\babelprovide|) selectors now set the +font encoding based on the list provided when loading |fontenc|. Not +all scripts have an associated encoding, so this feature works only +with Latin, Cyrillic, Greek, Arabic, Hebrew, Cherokee, Armenian, and +Georgian, provided a suitable font is found. \begin{example} A trivial document with the default font in English and Spanish, and @@ -641,956 +696,341 @@ _\foreignlanguage{spanish}{Español}_. \end{document} \end{verbatim} +If you need the ‘modern’ way to load the main language set as global +option, just write: +\begin{verbatim} +\usepackage[provide=*]{babel} +\end{verbatim} \end{example} \begin{note} Instead of its name, you may prefer to select the language with the - corresponding BCP47 tag. This alternative, however, must be activated - explicitly, because a two- or tree-letter word is a valid name for a - language (eg, |lu| can be the locale name with tag |khb| or the tag + corresponding BCP 47 tag. This alternative, however, must be activated + explicitly, because a two- or three-letter word is a valid name for a + language (e.g., |lu| can be the locale name with tag |khb| or the tag for |lubakatanga|). See section \ref{bcp47} for further details. \end{note} -\subsection{Modifiers} - -\New{3.9c} The basic behavior of some languages can be modified when -loading \babel{} by means of \textit{modifiers}. They are set after -the language name, and are prefixed with a dot (only when the language -is set as package option -- neither global options nor the |main| key -accepts them). An example is (spaces are not significant and they can -be added or removed):\footnote{No predefined ``axis'' for modifiers -are provided because languages and their scripts have quite different -needs.} -\begin{verbatim} -\usepackage[latin_.medieval_, spanish_.notilde.lcroman_, danish]{babel} -\end{verbatim} - -Attributes (described below) are considered modifiers, ie, you can -set an attribute by including it in the list of modifiers. - -\New{3.89} Alternatively, modifiers can be set with a separate option, -with the keyword |modifiers| followed by a dot and the language name -(note the language is not selected or loaded with this option). It is -useful to activate some feature when the language is declared as a -class option: -\begin{verbatim} -\documentclass[spanish]{report} -\usepackage[_modifiers.spanish = notilde.lcroman_]{babel} -\end{verbatim} - -\subsection{Troubleshooting} +\subsection{Multilingual documents: the ‘classical’ way} -\begin{itemize} -\item Loading directly |sty| files in \LaTeX{} (ie, - |\usepackage|\marg{language}) is deprecated and you will get the - error:\footnote{In old versions the error read ``You have used an - old interface to call babel'', not very helpful.} -\trouble{You are loading directly a language style} -\begin{verbatim} -! Package babel Error: You are loading directly a language style. -(babel) This syntax is deprecated and you must use -(babel) \usepackage[language]{babel}. -\end{verbatim} +In multilingual documents, just use a list of the required languages +either as package or as class options. The last language is considered the +main one, activated by default. Sometimes, the main language changes +the document layout (e.g., |spanish| and |french|). -\item Another typical error when using \babel{} is the - following:\footnote{In old versions the error read ``You haven't - loaded the language LANG yet''.} -\trouble{Unknown language `LANG'} -\begin{verbatim} -! Package babel Error: Unknown language `#1'. Either you have -(babel) misspelled its name, it has not been installed, -(babel) or you requested it in a previous run. Fix its name, -(babel) install it or just rerun the file, respectively. In -(babel) some cases, you may need to remove the aux file -\end{verbatim} - The most frequent reason is, by far, the latest (for example, you - included |spanish|, but you realized this language is not used after - all, and therefore you removed it from the option list). In most - cases, the error vanishes when the document is typeset again, but in - more severe ones you will need to remove the |aux| file. -\end{itemize} - -\subsection{Plain} +To switch the language there are two basic macros, described below in +detail: |\selectlanguage| is used for blocks of text, while +|\foreignlanguage| is for chunks of text inside paragraphs. -In e-Plain and pdf-Plain, load languages styles with |\input| and then use -|\begindocument| (the latter is defined by \babel): +\begin{example} + In \LaTeX, the preamble of the document: \begin{verbatim} -\input estonian.sty -\begindocument +\documentclass{article} +\usepackage[dutch,english]{babel} \end{verbatim} + would tell \LaTeX{} that the document would be written in two + languages, Dutch and English, and that English would be the first + language in use, and the main one. +\end{example} -\begin{warning} - Not all languages provide a |sty| file and some of them are not - compatible with those formats. Please, refer to - \href{https://latex3.github.io/babel/guides/using-babel-with-plain.html}% - {Using babel with Plain} for further details. -\end{warning} - -\subsection{Basic language selectors} - -This section describes the commands to be used in the document to -switch the language in multilingual documents. In most cases, only the -two basic macros |\selectlanguage| and |\foreignlanguage| are -necessary. The environments |otherlanguage|, |otherlanguage*| and -|hyphenrules| are auxiliary, and described in the next section. - -The main language is selected automatically when the |document| -environment begins. - -\Describe{\selectlanguage}{\marg{language}} -When a user wants to switch from one language to another he can -do so using the macro |\selectlanguage|. This macro takes the -language, defined previously by a language definition file, as -its argument. It calls several macros that should be defined in -the language definition files to activate the special definitions -for the language chosen: +\begin{example} +A full bilingual document with \pdftex{} follows. The main language is +|french|, which is activated when the document begins. It assumes UTF-8: +\setengine{pdftex} \begin{verbatim} -\selectlanguage{german} -\end{verbatim} - -This command can be used as environment, too, in case there are -relatively short texts and you do not want to reset the language with a -hardcode value. - -\begin{note} - For ``historical reasons'', a macro name is converted to a language - name without the leading |\|; in other words, - |\selectlanguage{\german}| is equivalent to - |\selectlanguage{german}|. Using a macro instead of a ``real'' name - is deprecated. \New{3.43} However, if the macro name does not match - any language, it will get expanded as expected. -\end{note} +\documentclass{article} -\begin{note} - Bear in mind |\selectlanguage| can be automatically executed, in some - cases, in the auxiliary files, at heads and foots, and after the - environment |otherlanguage*|. -\end{note} +\usepackage[T1]{fontenc} -\begin{warning} - If used inside braces there might be some non-local changes, as this - would be roughly equivalent to: -\begin{verbatim} -{\selectlanguage{<inner-language>} ...}\selectlanguage{<outer-language>} -\end{verbatim} - If you want a change which is really local, you must enclose this - code with an additional grouping level. -\end{warning} +_\usepackage[english,french]{babel}_ -\begin{warning} - There are a couple of issues related to the way the language - information is written to the auxiliary files: -\begin{itemize} - \item |\selectlanguage| should not be used inside some boxed environments - (like floats or |minipage|) to switch the language if you need the - information written to the |aux| be correctly synchronized. This - rarely happens, but if it were the case, you must use - |otherlanguage| instead. - \item In addition, this macro inserts a |\write| in vertical mode, - which may break the vertical spacing in some cases (for example, - between lists or at the beginning of a table cell). \New{3.64} The - behavior can be adjusted with - |\babeladjust{select.write=|\m{mode}|}|, where \m{mode} is |shift| - (which shifts the skips down and adds a |\penalty|); |keep| (the - default -- with it the |\write| and the skips are kept in the order - they are written), and |omit| (which may seem a too drastic - solution, because nothing is written, but more often than not this - command is applied to more or less shorts texts with no sectioning - or similar commands, and therefore no language synchronization is - necessary). In a table cell, a |\leavevmode| just before the - selector may be enough. -\end{itemize} -\end{warning} +\begin{document} -\Describe{\foreignlanguage}{\oarg{option-list}\marg{language}\marg{text}} +Plus ça change, plus c'est la même chose! -The command |\foreignlanguage| takes two arguments; the second argument -is a phrase to be typeset according to the rules of the language named -in its first one. +_\selectlanguage{english}_ -This command (1) only switches the extra definitions and the -hyphenation rules for the language, \emph{not} the names and dates, (2) -does not send information about the language to auxiliary files (i.e., -the surrounding language is still in force), and (3) it works even if -the language has not been set as package option (but in such a case it -only sets the hyphenation patterns and a warning is shown). With the -|bidi| option, it also enters in horizontal mode (this is not done -always for backwards compatibility), and since it is meant for phrases -only the text direction (and not the paragraph one) is set. +And an English paragraph, with a short text in +_\foreignlanguage{french}{français}_. -\New{3.44} As already said, captions and dates are not switched. -However, with the optional argument you can switch them, too. So, you -can write: -\begin{verbatim} -\foreignlanguage[date]{polish}{\today} +\end{document} \end{verbatim} -In addition, captions can be switched with |captions| (or both, of -course, with |date,| |captions|). Until 3.43 you had to write something -like |{\selectlanguage{..} ..}|, which was not always the most -convenient way. - -\begin{note} - |\bibitem| is out of sync with |\selectlanguage| in the \file{.aux} - file. The reason is |\bibitem| uses |\immediate| (and others, in - fact), while |\selectlanguage| doesn't. There is a similar issue with - floats, too. There is no known workaround. -\end{note} - -\subsection{Auxiliary language selectors} - -\Describe{\begin\menv{otherlanguage}}{\marg{language}\Eenv{otherlanguage}} - -The environment \Lenv{otherlanguage} does basically the same as -|\selectlanguage|, except that language change is (mostly) local to -the environment. +\end{example} -Actually, there might be some non-local changes, as this environment -is roughly equivalent to: +\begin{example} + With \luatex{} and \xetex, the following bilingual, single script + document in UTF-8 encoding just prints a couple of ‘captions’ and + |\today| in Danish and Vietnamese. No additional packages are + required, because the default font supports both languages. +\setengine{luatex/xetex} \begin{verbatim} -\begingroup -\selectlanguage{<inner-language>} -... -\endgroup -\selectlanguage{<outer-language>} -\end{verbatim} -If you want a change which is really local, you must enclose this -environment with an additional grouping, like braces |{}|. - -Spaces after the environment are ignored.\footnote{Very likely, and -because of the limitations of many old editors with bidi text, the idea -was \cs{end}\texttt{\{otherlanguage\}} had to be a line by itself.} If this -behavior is not desired, you may use the environment -\texttt{selectlanguage}. - -\begin{warning} - Being similar to |\selectlanguage|, the warning above about the - internal |\write| also applies here. The current mode (vertical or - horizontal) is also not changed. -\end{warning} - -\Describe{\begin\menv{otherlanguage*}}% -{\oarg{option-list}\marg{language}\Eenv{otherlanguage*}} - -Same as |\foreignlanguage| but as environment. Spaces after the -environment are \textit{not} ignored. - -This environment was originally intended for intermixing left-to-right -typesetting with right-to-left typesetting in engines not supporting a -change in the writing direction inside a line. However, by default it -never complied with the documented behavior and it is just a version as -environment of |\foreignlanguage|, except when the option |bidi| is -set -- in this case, |\foreignlanguage| emits a |\leavevmode|, while -|otherlanguage*| does not. +\documentclass{article} -\subsection{More on selection} +_\usepackage[vietnamese,danish]{babel}_ -\Describe{\babeltags}{\char`\{\m{tag1} \texttt{=} \m{language1}, \m{tag2} -\texttt{=} \m{language2}, \dots\char`\}} +\begin{document} -\New{3.9i} In multilingual documents with many language-switches the -commands above can be cumbersome. With this tool shorter names can be -defined. It adds nothing really new -- it is just syntactical sugar. +Danish: \prefacename, \alsoname, \today. -It defines |\text|\m{tag1}\marg{text} to be -|\foreignlanguage|\marg{language1}\marg{text}, and |\begin|\marg{tag1} -to be |\begin{otherlanguage*}|\marg{language1}, and so on. Note -|\|\m{tag1} is also allowed, but remember to set it locally inside a -group. +\selectlanguage{vietnamese} -\begin{warning} - There is a clear drawback to this feature, namely, the ‘prefix’ - |\text...| is heavily overloaded in \LaTeX{} and conflicts with - existing macros may arise (|\textlatin|, |\textbar|, |\textit|, - |\textcolor| and many others). The same applies to environments, - because |arabic| conflicts with |\arabic|. Furthermore, and because of - this overloading, detecting the language of a chunk of text by - external tools can become unfeasible (is |\textga| the locale for the - African language Gã or something else?). Except if there is a reason for - this ‘syntactical sugar’, the best option is to stick to the default - selectors or even to define your own alternatives. -\end{warning} +Vietnamese: \prefacename, \alsoname, \today. -\begin{example} -With -\begin{verbatim} -\babeltags{de = german} -\end{verbatim} -you can write -\begin{verbatim} -text \textde{German text} text -\end{verbatim} -and -\begin{verbatim} -text -\begin{de} - German text -\end{de} -text +\end{document} \end{verbatim} \end{example} \begin{note} - Something like \verb|\babeltags{finnish = finnish}| is legitimate -- - it defines |\textfinnish| and |\finnish| (and, of course, - |\begin{finnish}|). -\end{note} - -\Describe{\babelensure}{|[include=|\m{commands}|,exclude=|\m{commands}% - |,fontenc=|\m{encoding}|]|\marg{language}} - -\New{3.9i} Except in a few languages, like \textsf{russian}, -captions and dates are just strings, and do not switch the -language. That means you should set it explicitly if you want to use -them, or hyphenation (and in some cases the text itself) will be -wrong. For example: + Although strongly discouraged, languages can be set as global and as + package option at the same time, but in such a case you should set + explicitly the main language with the package option |main|, + described below: \begin{verbatim} -\foreignlanguage{russian}{text \foreignlanguage{polish}{\seename} text} -\end{verbatim} - -Of course, \TeX{} can do it for you. To avoid switching the language -all the while, |\babelensure| redefines the captions for a given -language to wrap them with a selector: -\begin{verbatim} -\babelensure{polish} -\end{verbatim} -By default only the basic captions and |\today| are redefined, but you -can add further macros with the key |include| in the optional argument -(without commas). Macros not to be modified are listed in -|exclude|. You can also enforce a font encoding with the option -|fontenc|.\footnote{With it, encoded strings may not work as expected.} -A couple of examples: -\begin{verbatim} -\babelensure[include=\Today]{spanish} -\babelensure[fontenc=T5]{vietnamese} +\documentclass[_italian_]{book} +\usepackage[ngerman,_main=italian_]{babel} \end{verbatim} - -They are activated when the language is selected (at the |afterextras| -event), and it makes some assumptions which could not be fulfilled in -some languages. Note also you should include only macros defined by -the language, not global macros (eg, |\TeX| of |\dag|). - -With |ini| files (see below), captions are ensured by default. - -\subsection{Shorthands} - -A \textit{shorthand} is a sequence of one or two characters that -expands to arbitrary \TeX{} code. - -Shorthands can be used for different kinds of things; for example: -(1) in some languages shorthands such as |"a| are defined to be able -to hyphenate the word if the encoding is |OT1|; (2) in some languages -shorthands such as |!| are used to insert the right amount of white -space; (3) several kinds of discretionaries and breaks can be inserted -easily with |"-|, |"=|, etc. - -The package \textsf{inputenc} as well as \xetex{} and \luatex{} have -alleviated entering non-ASCII characters, but minority languages and -some kinds of text can still require characters not directly available -on the keyboards (and sometimes not even as separated or precomposed -Unicode characters). As to the point 2, now \textsf{pdfTeX} provides -|\knbccode|, and \luatex{} can manipulate the glyph list. Tools for -point 3 can be still very useful in general. - -There are four levels of shorthands: \textit{user}, \textit{language}, -\textit{system}, and \textit{language user} (by order of precedence). -In most cases, you will use only shorthands provided by languages. - -\begin{note} Keep in mind the following: -\begin{enumerate} -\item Activated chars used for two-char shorthands cannot be followed - by a closing brace |}| and the spaces following are gobbled. With - one-char shorthands (eg,~|:|), they are preserved. -\item If on a certain level (system, language, user, language user) - there is a one-char shorthand, two-char ones starting with that char - and on the same level are ignored. -\item Since they are active, a shorthand cannot contain the same - character in its definition (except if deactivated with, eg, - |\string|). -\end{enumerate} \end{note} -\begin{troubleshooting} -\trouble{Argument of \textbackslash language@active@arg" -has an extra \textbraceright} -A typical error when using shorthands is the following: -\begin{verbatim} -! Argument of \language@active@arg" has an extra }. -\end{verbatim} -It means there is a closing brace just after a shorthand, which is not -allowed (eg,~|"}|). Just add |{}| after (eg,~|"{}}|). -\end{troubleshooting} - -\Describe{\shorthandon}{\marg{shorthands-list}} -\DescribeOther{\shorthandoff}{% -\colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}% -\marg{shorthands-list}} -It is sometimes necessary to switch a shorthand -character off temporarily, because it must be used in an -entirely different way. For this purpose, the user commands -|\shorthandoff| and |\shorthandon| are provided. They each take a -list of characters as their arguments. - -The command |\shorthandoff| sets the |\catcode| for each of the -characters in its argument to other (12); the command |\shorthandon| -sets the |\catcode| to active (13). Both commands only work on `known' -shorthand characters, and an error will be raised otherwise. You can -check if a character is a shorthand with |\ifbabelshorthand| (see -below). +\begin{note} + Once a language is loaded, you can select it with the corresponding + BCP 47 tag. See section \ref{bcp47} for further details. +\end{note} -\New{3.9a} However, |\shorthandoff| does not behave as -you would expect with characters like |~| or |^|, because they -usually are not ``other''. For them |\shorthandoff*| is provided, -so that with +\begin{note} + Documents with several input encodings are not frequent, but + sometimes are useful. You can set different encodings for different + languages as the following example shows: \begin{verbatim} -\shorthandoff*{~^} +\addto\extrasfrench{\inputencoding{latin1}} +\addto\extrasrussian{\inputencoding{koi8-r}} \end{verbatim} -|~| is still active, very likely with the meaning of a non-breaking -space, and |^| is the superscript character. The catcodes used are -those when the shorthands are defined, usually when language files are -loaded. - -If you do not need shorthands, or prefer an alternative approach of -your own, you may want to switch them off with the package option -|shorthands=off|, as described below. - -\begin{warning} - It is worth emphasizing these macros are meant for temporary changes. - Whenever possible and if there are not conflicts with other packages, - shorthands must be always enabled (or disabled). -\end{warning} - -\Describe{\useshorthands}{% -\colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}% -\marg{char}} - -The command |\useshorthands| initiates the definition of user-defined -shorthand sequences. It has one argument, the character that starts -these personal shorthands. - -\New{3.9a} User shorthands are not always alive, as they may -be deactivated by languages (for example, if you use |"| for your user -shorthands and switch from \textsf{german} to \textsf{french}, they -stop working). Therefore, a starred version -|\useshorthands*|\marg{char} is provided, which makes sure shorthands -are always activated. - -Currently, if the package option |shorthands| is used, you must include any -character to be activated with |\useshorthands|. This restriction will -be lifted in a future release. % <- TODO - -\Describe\defineshorthand{\texttt{[}\langlist\texttt{]}% - \marg{shorthand}\marg{code}} +\end{note} -The command |\defineshorthand| takes two arguments: the first is -a one- or two-character shorthand sequence, and the second is the -code the shorthand should expand to. +\subsection{Multilingual documents: the ‘modern’ way} -\New{3.9a} An optional argument allows to (re)define language and -system shorthands (some languages do not activate shorthands, so you -may want to add |\languageshorthands|\marg{lang} to the corresponding -|\extras|\m{lang}, as explained below). By default, user shorthands -are (re)defined. - -User shorthands override language ones, which in turn override -system shorthands. Language-dependent user shorthands (new in -3.9) take precedence over ``normal'' user shorthands. +If lazy loading is not enough for your purposes, you can still tell +which languages should be loaded as either class or package options. +You can combine the ‘classical’ and the ‘modern’ ways with three +options to set which method you want, which cover the most typical +cases: +\begin{itemize} +\item |provide=*| is the option explained above for monolingual + documents. If there are more languages, it applies only to the main + language, while the rest will be loaded in the ‘classical’ way. +\item |provide+=*| loads the main language in the ‘classical’ way, + and the rest in the ‘modern’ one. +\item |provide*=*| is the same for all languages, i.e., main and + secondary ones are loaded in the ‘modern’ way. +\end{itemize} +More complex combinations can be handled with |\babelprovide|, +explained below. \begin{example} - Let's assume you want a unified set of shorthand for discretionaries - (languages do not define shorthands consistently, and |"-|, |\-|, - |"=| have different meanings). You can start with, say: -\begin{verbatim} -\useshorthands*{"} -\defineshorthand{"*}{\babelhyphen{soft}} -\defineshorthand{"-}{\babelhyphen{hard}} -\end{verbatim} - However, the behavior of hyphens is language-dependent. For example, in - languages like Polish and Portuguese, a hard hyphen inside compound - words are repeated at the beginning of the next line. You can then - set: +Your document is written in Thai with large chunks in Dutch and German, +and you want the |ldf| files in the latter because, for example, you +need their shorthands. The font is Norasi, which covers the three +languages: +\setengine{luatex/xetex} \begin{verbatim} -\defineshorthand[*polish,*portuguese]{"-}{\babelhyphen{repeat}} +\usepackage[dutch,ngerman,thai,_provide=*_]{babel} +\babelfont{rm}{Norasi} \end{verbatim} - Here, options with |*| set a language-dependent user shorthand, - which means the generic one above only applies for the rest of - languages; without |*| they would (re)define the language shorthands - instead, which are overridden by user ones. - - Now, you have a single unified shorthand (|"-|), with a - content-based meaning (`compound word hyphen') whose visual behavior - is that expected in each context. -\end{example} - -\Describe{\languageshorthands}{\marg{language}} The command -|\languageshorthands| can be used to switch the shorthands on the -language level. It takes one argument, the name of a language or -|none| (the latter does what its name suggests).\footnote{Actually, -any name not corresponding to a language group does the same as -\texttt{none}. However, follow this convention because it might be -enforced in future releases of \babel{} to catch possible errors.} -Note that for this to work the language should have been specified as -an option when loading the \babel\ package. For example, you can use -in \textsf{english} the shorthands defined by \textsf{ngerman} with +This will load |dutch| and |ngerman| in the classical |ldf| mode, but +|thai| in the modern |ini| mode. Other options are: \begin{verbatim} -\addto\extrasenglish{\languageshorthands{ngerman}} + \usepackage[dutch,ngerman,thai]{babel} \end{verbatim} -(You may also need to activate them as user shorthands in the preamble -with, for example, |\useshorthands| or |\useshorthands*|.) - -\begin{example} - Very often, this is a more convenient way to deactivate shorthands - than |\shorthandoff|, for example if you want to define a macro - to easy typing phonetic characters with \textsf{tipa}: +which will use the classical mode for in languages (as decribed in the +previous section, but note |thai.ldf| is not supported in Unicode +engines), and: \begin{verbatim} -\newcommand{\myipa}[1]{{_\languageshorthands{none}_\tipaencoding#1}} + \usepackage[dutch,german,thai,_provide*=*_]{babel} \end{verbatim} +which will use the modern mode in all languages (note the correct name +here is |german|. (The option +|\usepackage||[dutch,ngerman,thai,provide+=*]||{babel}| doesn’t make +much sense in this case.) \end{example} -\Describe{\babelshorthand}{\marg{shorthand}} -With this command you can use a shorthand even if (1) not activated in -\texttt{shorthands} (in this case only shorthands for the current -language are taken into account, ie, not user shorthands), (2) turned -off with |\shorthandoff| or (3) deactivated with the internal -|\bbl@deactivate|; for example, \verb|\babelshorthand{"u}| or -\verb|\babelshorthand{:}|. (You can conveniently define your own -macros, or even your own user shorthands provided they do not overlap.) +\subsection{Languages supported by \babel{} in the ‘classical’ mode} -\begin{example} - Since by default shorthands are not activated until - |\begin{document}|, you may use this macro when defining the |\title| - in the preamble: -\begin{verbatim} -\title{Documento científico_\babelshorthand{"-}_técnico} -\end{verbatim} -\end{example} +(To be updated.) In the following table most of the languages supported +by \babel{} with an |ldf| file are listed, together with the names of +the options which you can load \babel\ with for each language. Note this +list is open and the current options may be different. It does not +include |ini| files (see below). -\bigskip +Except in a few cases (e.g., |ngerman|, |serbianc|, |acadian|) names are +those of the Unicode CLDR (or based on them). -For your records, here is a list of shorthands, but you must double -check them, as they may change:\footnote{Thanks to Enrico Gregorio} - -\begin{description} -\itemsep=-\parskip -\item[Languages with no shorthands] Croatian, English (any variety), - Indonesian, Hebrew, Interlingua, Irish, Lower Sorbian, Malaysian, - North Sami, Romanian, Scottish, Welsh -\item[Languages with only \texttt{"} as defined shorthand character] - Albanian, Bulgarian, Danish, Dutch, Finnish, German (old and new - orthography, also Austrian), Icelandic, Italian, Norwegian, Polish, - Portuguese (also Brazilian), Russian, Serbian (with Latin script), - Slovene, Swedish, Ukrainian, Upper Sorbian -\item[Basque] |" ' ~| -\item[Breton] |: ; ? !| -\item[Catalan] |" ' `| -\item[Czech] |" -| -\item[Esperanto] |^| -\item[Estonian] |" ~| -\item[French] (all varieties) |: ; ? !| -\item[Galician] |" . ' ~ < >| -\item[Greek] (ancient, polutoniko, only 8-bit \TeX) |~|, (optional, see -the manual for Greek) |;| -\item[Hungarian] |`| -\item[Kurmanji] |^| -\item[Latin] |" ^ =| -\item[Slovak] |" ^ ' -| -\item[Spanish] |" . < > ' ~| -\item[Turkish] |: ! =| -\end{description} -In addition, the \babel{} core declares |~| as a one-char shorthand -which is let, like the standard |~|, to a non breaking -space.\footnote{This declaration serves to nothing, but it is -preserved for backward compatibility.} - -\Describe\ifbabelshorthand{\marg{character}\marg{true}\marg{false}} - -\New{3.23} Tests if a character has been made a shorthand. - -\begin{note} - \catcode`\|=12\relax Both \textsf{ltxdoc} and \textsf{babel} use - \verb|\AtBeginDocument| to change some catcodes, and babel reloads - \textsf{hhline} to make sure \verb|:| has the right one, so if you - want to change the catcode of \verb/|/ it has to be done using the - same method at the proper place, with -\begin{verbatim} -\AtBeginDocument{\DeleteShortVerb{\|}} -\end{verbatim} - \textit{before} loading babel. This way, when the document begins - the sequence is (1) make \verb/|/ active (\textsf{ltxdoc}); (2) make - it inactive (your settings); (3) make babel shorthands active - (\textsf{babel)}; (4) reload \textsf{hhline} (\textsf{babel}, now - with the correct catcodes for \verb/|/ and - \verb|:|).\catcode`\|=\active -\end{note} - -\subsection{Package options} - -\New{3.9a} -These package options are processed before language options, so -that they are taken into account irrespective of its order. The first -three options have been available in previous versions. - -\Describe{KeepShorthandsActive}{} -Tells babel not to deactivate shorthands after loading a language -file, so that they are also available in the preamble. - -\Describe{activeacute}{} For some languages \babel\ supports this -options to set |'| as a shorthand in case it is not done by default. - -\Describe{activegrave}{} -Same for |`|. - -\Describe{shorthands=}{\meta{char}\meta{char}... -$\string|$ \texttt{off}} -The only language shorthands activated -are those given, like, eg: -\begin{verbatim} -\usepackage[esperanto,french,_shorthands=:;!?_]{babel} -\end{verbatim} -If \verb|'| is included, \texttt{activeacute} is set; if \verb|`| is -included, \texttt{activegrave} is set. Active characters (like -\verb|~|) should be preceded by \verb|\string| (otherwise they will be -expanded by \LaTeX{} before they are passed to the package and -therefore they will not be recognized); however, |t| is provided for -the common case of |~| (as well as |c| for not so common case of the -comma). - -With |shorthands=off| no language shorthands are defined, -As some languages use this mechanism for tools not available -otherwise, a macro \verb|\babelshorthand| is defined, which allows -using them; see above. - -\Describe{safe=}{\texttt{none} $\string|$ \texttt{ref} $\string|$ -\texttt{bib}} Some \LaTeX{} macros are redefined so that using -shorthands is safe. With \texttt{safe=bib} only |\nocite|, |\bibcite| -and |\bibitem| are redefined. With |safe=ref| only |\newlabel|, |\ref| -and |\pageref| are redefined (as well as a few macros from -\textsf{varioref} and \textsf{ifthen}). - -With |safe=none| no macro is redefined. This option is strongly -recommended, because a good deal of incompatibilities and errors are -related to these redefinitions. As of \New{3.34}, in $\epsilon$\TeX{} -based engines (ie, almost every engine except the oldest ones) -shorthands can be used in these macros (formerly you could not). - -\Describe{math=}{\texttt{active} $\string|$ \texttt{normal}} -Shorthands are mainly intended for text, not for math. By setting this -option with the value |normal| they are deactivated in math mode -(default is |active|) and things like |${a'}$| (a closing brace after -a shorthand) are not a source of trouble anymore. - -\Describe{config=}{\meta{file}} Load \meta{file}\texttt{.cfg} instead -of the default config file |bblopts.cfg| (the file is loaded even -with |noconfigs|). - -\Describe{main=}{\meta{language}} Sets the main language, as explained -above, ie, this language is always loaded last. If it is not given as -package or global option, it is added to the list of requested -languages. - -\Describe{headfoot=}{\meta{language}} By default, headlines and -footlines are not touched (only marks), and if they contain -language-dependent macros (which is not usual) there may be unexpected -results. With this option you may set the language in heads and foots. -An alternative is to set the language explicitly when heads and foots -are redefined. - -\Describe{noconfigs}{} Global and language default config files are -not loaded, so you can make sure your document is not spoilt by an -unexpected \texttt{.cfg} file. However, if the key |config| is set, -this file is loaded. - -\Describe{showlanguages}{} Prints to the log the list of languages -loaded when the format was created: number (remember dialects can -share it), name, hyphenation file and exceptions file. - -% \Describe{nocase}{} \New{3.9l} Language settings for uppercase and -% lowercase mapping (as set by |\SetCase|) are ignored. Use only if there -% are incompatibilities with other packages. - -\Describe{silent}{} \New{3.9l} No warnings and no \textit{infos} are -written to the log file.\footnote{You can use alternatively the -package \textsf{silence}.} - -\Describe{hyphenmap=}{\texttt{off} $\string|$ \texttt{first} -$\string|$ \texttt{select} $\string|$ \texttt{other} $\string|$ -\texttt{other*}} - -\New{3.9g} Sets the behavior of case mapping for hyphenation, -provided the language defines it.\footnote{Turned off in plain.} It -can take the following values: -\begin{description} -\renewcommand\makelabel[1]{% - \hspace\labelsep\normalfont\ttfamily\color{thered}#1} -\itemsep=-\parskip -\item[off] deactivates this feature and no case mapping is applied; -\item[first] sets it at the first switching commands in the - current or parent scope (typically, when the aux file is first read - and at |\begin{document}|, but also the first |\selectlanguage| in - the preamble), and it's the default if a single - language option has been stated;\footnote{Duplicated options count - as several ones.} -\item[select] sets it only at |\selectlanguage|; -\item[other] also sets it at |otherlanguage|; -\item[other*] also sets it at |otherlanguage*| as well as in heads and - foots (if the option |headfoot| is used) and in auxiliary files (ie, - at |\select@language|), and it's the default if several language - options have been stated. The option |first| can be regarded as an - optimized version of \texttt{other*} for monolingual - documents.\footnote{Providing |foreign| is pointless, because the - case mapping applied is that at the end of the paragraph, but if either - \xetex{} or \luatex{} change this behavior it might be added. On - the other hand, |other| is provided even if I [JBL] think it isn't - really useful, but who knows.} -\end{description} - -\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic} - $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$ - \texttt{bidi-r}} - -\New{3.14} Selects the bidi algorithm to be used in \luatex{} and -\xetex{}. See sec.~\ref{bidi}. - -\Describe{layout=}{} - -\New{3.16} Selects which layout elements are adapted in bidi -documents. See sec.~\ref{bidi}. - -\Describe{provide=}{\texttt{*}} -\New{3.49} An alternative to |\babelprovide| for languages passed as -options. See section~\ref{inifiles}, which describes also the variants -|provide+=| and |provide*=|. - -\subsection{The \texttt{base} option} - -With this package option \babel{} just loads some basic macros (mainly -the selectors), defines |\AfterBabelLanguage| and exits. It also -selects the hyphenation patterns for the last language passed as option -(by its name in |language.dat|). There are two main uses: classes and -packages, and as a last resort in case there are, for some reason, -incompatible languages. It can be used if you just want to select the -hyphenation patterns of a single language, too. - -\Describe\AfterBabelLanguage{\marg{option-name}\marg{code}} - -This command is currently the only provided by |base|. Executes -\meta{code} when the file loaded by the corresponding package option -is finished (at |\ldf@finish|). The setting is global. So -\begin{verbatim} -\AfterBabelLanguage{french}{...} -\end{verbatim} -does ... at the end of |french.ldf|. It can be used in |ldf| files, -too, but in such a case the code is executed only if -\meta{option-name} is the same as |\CurrentOption| (which could not -be the same as the option name as set in |\usepackage|!). +Most of them work out of the box, but some may require extra fonts, +encoding files, a preprocessor or even a complete framework (like +\textsf{CJK} or \textsf{luatexja}). -\begin{example} - Consider two languages \textsf{foo} and \textsf{bar} defining the - same |\macro| with |\newcommand|. An error is raised if you attempt - to load both. Here is a way to overcome this problem: -\begin{verbatim} -\usepackage[base]{babel} -\AfterBabelLanguage{foo}{% - \let\macroFoo\macro - \let\macro\relax} -\usepackage[foo,bar]{babel} -\end{verbatim} -\end{example} +\begingroup -\begin{note} - With a recent version of \LaTeX, an alternative method to execute - some code just after an |ldf| file is loaded is with |\AddToHook| and - the hook |file/<language>.ldf/after|. \Babel{} does not predeclare - it, and you have to do it yourself with |\ActivateGenericHook|. -\end{note} +\bigskip\hrule\nobreak -\begin{warning} - Currently this option is not compatible with languages loaded on the - fly. -\end{warning} +\makeatletter +\newcommand\tag[3][?]{\par + \hspace{-2em}\textcolor{thered}{\texttt{#2}}#3\enspace + \ifx\relax#1\relax\else + \ifx?#1% + \href{https://ctan.org/pkg/babel-#2}{\scriptsize ※}% + \else + \href{https://ctan.org/pkg/#1}{\scriptsize ※}% + \fi + \fi} +\def\subtag#1#2{\par + \hspace{-1em}\texttt{#1}#2\enspace} +\def\subtagalt#1#2{\par + \hspace{-1em}\textcolor{thered}{\texttt{#1}}#2\enspace} +\def\tagmin#1#2{\par + \hspace{-2em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace} +\def\subtagmin#1#2{\par + \hspace{-1em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace} +\def\note#1{\par{\footnotesize#1\par}} +\small -\subsection{\texttt{ini} files} -\label{inifiles} +\bigskip -An alternative approach to define a language (or, more precisely, a -\textit{locale}) is by means of an \texttt{ini} file. Currently -\babel{} provides about 380 of these files containing the basic data -required for a locale, covering about 300 languages, plus basic -templates for about 400 locales. +\textit{This list is still under revision.}\\ +Recommended names are set in \textcolor{thered}{red}.\\ +Additional languages are set in \textcolor[gray]{.4}{gray}.\\ +Discouraged and deprecated names are not included.\\ +There are some notes in a few languages.\\ +The reference mark ({\scriptsize ※}) is a link to CTAN. -|ini| files are not meant only for \babel, and they has been devised as -a resource for other packages. To easy interoperability between \TeX{} -and other systems, they are identified with the BCP 47 codes as -preferred by the Unicode Common Locale Data Repository, which was -used as source for most of the data provided by these files, too (the -main exception being the |\...name| strings). +\bigskip\hrule\nobreak -Most of them set the date, and many also the captions (Unicode and -LICR). They will be evolving with the time to add more features -(something to keep in mind if backward compatibility is important). The -following section shows how to make use of them by means of -|\babelprovide|. In other words, |\babelprovide| is mainly meant as -alternative when the |ldf| does not exists or does not work as -expected, and for secondary tasks. +\begin{multicols}{2} +\leftskip2em\parindent0pt +\tag[babel-dutch]{afrikaans}{} +\tag{albanian}{} +\tag[arabi]{arabic}{} +\note{Requires \textsf{arabi}.} +\tag{azerbaijani}{} +\tag{basque}{} +\tag{belarusian}{} +\tag{bosnian}{} +\tag{breton}{} +\tag{bulgarian}{} +\tag{catalan}{} +\tag{croatian}{} +\tag{czech}{} +\tag{danish}{} +\tag{dutch}{} +\tag{english}{} +\subtagalt{american}{} +\subtag{USenglish}{}{} +\subtagalt{australian}{} +\subtagalt{british}{} +\subtag{UKenglish}{} +\subtagalt{canadian}{} +\subtagalt{newzealand}{} +\tag{esperanto}{} +\tag{estonian}{} +\tagmin{ethiop}{} %%%%%% +\tag[arabi]{farsi}{} +\note{Requires \textsf{arabi}.} +\tag{finnish}{} +\tag{french}{} +\subtagalt{acadian}{} +\tag[babel-friulan]{friulian}{} +\tag{galician}{} +\tag{georgian}{} +\tag{german}{} +\note{This block refers to the old ortography. For the modern one, use +the names in the block \textsf{ngerman}.} +\subtagalt{austrian}{} +\subtagalt{swissgerman}{} +\note{Swiss High German} +\tag{greek}{} +% \subtagalt{polutonicogreek}{} +\subtagmin{ibycus}{} +\subtagmin{bgreek}{} +\tag{hebrew}{} +\tag[devanagari]{hindi}{} +\note{Requires \textsf{velthuis}.} +\tag{hungarian}{} +\subtag{magyar}{} +\tag{icelandic}{} +\tag{indonesian}{} +\tag{interlingua}{} +\tag{irish}{} +\tag{italian}{} +\tag{japanese}{} +\tag{kurmanji}{} +\tag{latin}{} +% \subtagalt{classiclatin}{} +% \subtagalt{medievallatin}{} +% \subtagalt{ecclesiasticlatin}{} +\tag{latvian}{} +\tag{lithuanian}{} +\tag[babel-sorbian]{lowersorbian}{} +\tag{macedonian}{} +\tag{malay}{} +\tag[mongolian-babel]{mongolian}{} +\tag[babel-german]{ngerman}{} +\note{This block refers to the new ortography.} +\subtagalt{naustrian}{} +\subtagalt{nswissgerman}{} +\note{Swiss High German} +\tag[babel-samin]{northernsami}{} +\tag[babel-norsk]{norwegian}{} +\subtag{norsk}{} +\tag[babel-norsk]{nynorsk}{} +\tag{occitan}{} +\tag{piedmontese}{} +\tagmin{pinyin}{} +\tag{polish}{} +\tag[babel-portuges]{portuguese}{} +\subtagalt{brazilian}{} +\tag{romanian}{} +\tag{romansh}{} +\tag{russian}{} +\tag[babel-scottish]{scottishgaelic}{} +\subtag{scottish}{} +\tag{serbianc}{} +\note{Cyrillic script} +\subtagalt{serbian}{} +\note{Latin script} +\tag{slovak}{} +\tag[]{slovene}{} +\tag{slovenian}{} %%%%%% <- and ini +\tag{spanglish}{} +\tag{spanish}{} +\tag{swedish}{} +\tag{thai}{} +\subtagmin{thaicjk}{} +\tag{turkish}{} +\tag[turkmen]{turkmen}{} +\tag{ukrainian}{} +\tag[sorbian]{uppersorbian}{} +\tag{vietnamese}{} +\tag{welsh}{} +\end{multicols} +\endgroup +\hrule +\bigskip \begin{example} - Although Georgian has its own \texttt{ldf} file, here is how to - declare this language with an |ini| file in Unicode engines. -\setengine{luatex/xetex} + An example of a language requiring a preprocessor and a separate + package is \texttt{hindi}. If you have got the + \textsf{velthuis/devnag} package, create a file with + extension |.dn|: \begin{verbatim} -\documentclass{book} - -\usepackage{babel} -_\babelprovide[import, main]{georgian}_ - -\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans} - +\documentclass{article} +\usepackage[hindi]{babel} \begin{document} - -\tableofcontents - -\chapter{სამზარეულო და სუფრის ტრადიციები} - -ქართული ტრადიციული სამზარეულო ერთ-ერთი უმდიდრესია მთელ მსოფლიოში. - +{\dn devaanaa.m priya.h} \end{document} \end{verbatim} + Then preprocess it with |devnag| \m{file}, which creates + \m{file}|.tex|; you can then typeset the latter with \LaTeX. \end{example} -\begin{more} - There is an example of how to use an |ini| template file - \href{https://github.com/latex3/babel/issues/176#issuecomment-1080846575}{here}, - for Phoenician (although currently this locale is bundled with - \babel). -\end{more} - -\New{3.49} Alternatively, you can tell babel to load all or some -languages passed as options with |\babelprovide| and not from the |ldf| -file in a few few typical cases. Thus, |provide=*| means ‘load the main -language with the |\babelprovide| mechanism instead of the |ldf| file’ -applying the basic features, which in this case means |import,| |main|. -There are (currently) three options: -\begin{itemize} -\item |provide=*| is the option just explained, for the main language; -\item |provide+=*| is the same for additional languages (the main - language is still the |ldf| file); -\item |provide*=*| is the same for all languages, ie, main and - additional. -\end{itemize} - -\begin{example} - The preamble in the previous example can be more compactly written - as: -\begin{verbatim} -\documentclass{book} -\usepackage[_georgian, provide=*_]{babel} -\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans} -\end{verbatim} -Or also: -\begin{verbatim} -\documentclass[_georgian_]{book} -\usepackage[_provide=*_]{babel} -\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans} -\end{verbatim} -\end{example} - -\begin{note} - The \texttt{ini} files just define and set some parameters, but the - corresponding behavior is not always implemented. Also, there are - some limitations in the engines. A few remarks follow (which could no - longer be valid when you read this manual, if the packages involved - have been updated). The Harfbuzz renderer still has some issues, so as - a rule of thumb prefer the default renderer, and resort to Harfbuzz - only if the former does not work for you. Fortunately, fonts can be - loaded twice with different renderers; for example: -\begin{verbatim} -\babelfont[spanish]{rm}{FreeSerif} -\babelfont[hindi]{rm}[Renderer=Harfbuzz]{FreeSerif} -\end{verbatim} -\begin{description} -\itemsep=-\parskip -\item[Arabic] Monolingual documents mostly work in \luatex, but it must - be fine tuned, particularly math and graphical elements like - |picture|. In \xetex{} \babel{} resorts to the \textsf{bidi} package, - which seems to work. -\item[Hebrew] Niqqud marks seem to work in both engines, but depending - on the font cantillation marks might be misplaced (\xetex{} or - \luatex{} with Harfbuzz seems better). -\item[Devanagari] In \luatex{} and the default renderer many fonts -work, but some others do not, the main issue being the ‘ra’. You may -need to set explicitly the script to either |deva| or |dev2|, eg: -\begin{verbatim} -\newfontscript{Devanagari}{deva} -\end{verbatim} - Other Indic scripts are still under development in the default - \luatex{} renderer, but should work with |Renderer=Harfbuzz|. They - also work with \xetex{}, although unlike with \luatex{} fine tuning - the font behavior is not always possible. -\item[Southeast scripts] Thai works in both \luatex{} and \xetex{}, but - line breaking differs (rules are hard-coded in \xetex, but they can - be modified in \luatex). Lao seems to work, too, but there are no - patterns for the latter in \luatex{}. Khemer clusters are rendered - wrongly with the default renderer. The comment about Indic scripts - and \textsf{lualatex} also applies here. Some quick patterns can - help, with something similar to: -\begin{verbatim} -\babelprovide[import, hyphenrules=+]{lao} -\babelpatterns[lao]{1ດ 1ມ 1ອ 1ງ 1ກ 1າ} % Random -\end{verbatim} -\item[East Asia scripts] Settings for either Simplified of Traditional - should work out of the box, with basic line breaking with any - renderer. Although for a few words and shorts texts the |ini| files - should be fine, CJK texts are best set with a dedicated framework - (\textsf{CJK}, \textsf{luatexja}, \textsf{kotex}, \textsf{CTeX}, - etc.). This is what the class |ltjbook| does with \luatex, which can - be used in conjunction with the |ldf| for |japanese|, because the - following piece of code loads \textsf{luatexja}: -\begin{verbatim} -\documentclass[japanese]{ltjbook} -\usepackage{babel} -\end{verbatim} -\item[Latin, Greek, Cyrillic] Combining chars with the default - \luatex{} font renderer might be wrong; on then other hand, with the - Harfbuzz renderer diacritics are stacked correctly, but many - hyphenations points are discarded (this bug is related to kerning, - so it depends on the font). With \xetex{} both combining characters - and hyphenation work as expected (not quite, but in most cases it - works; the problem here are font clusters). -\end{description} -\end{note} - -\begin{note} - Wikipedia defines a \textit{locale} as follows: “In computing, a - locale is a set of parameters that defines the user’s language, - region and any special variant preferences that the user wants to see - in their user interface. Usually a locale identifier consists of at - least a language code and a country/region code.” \Babel{} is moving - gradually from the old and fuzzy concept of \textit{language} to the - more modern of \textit{locale}. Note each locale is by itself a - separate “language”, which explains why there are so many files. This - is on purpose, so that possible variants can be created and/or - redefined easily. -\end{note} - -\textbf{Modifying and adding values to |ini| files} - -\nobreak -\New{3.39} There is a way to modify the values of |ini| files when they -get loaded with |\babelprovide| and |import|. To set, say, -|digits.native| in the |numbers| section, use something like -|numbers/digits.native=abcdefghij|. Keys may be added, too. Without -|import| you may modify the identification keys. - -This can be used to create private variants easily. All you need is to -import the same |ini| file with a different locale name and different -parameters. - -% \begin{example} -% Let's assume you need only the basic features of `spanish`, so that -% the |ini| file is enough, and also a variant with your own -% hyphenation with -% \end{example} - -\subsection{List of locales available in \cs{babelprovide}} +\subsection{Languages supported by \babel{} in the ‘modern’ mode} Here is the list of the names currently supported with |ini| locale files, with |\babelprovide| (or |provide=|). With these languages, @@ -1600,28 +1040,25 @@ files, with |\babelprovide| (or |provide=|). With these languages, |\babelprovide| with a valueless |import|, which will load the |ini| file with the tag given in parenthesis. -Many locale are quite usable, provided captions and dates are -not required (which is a very frequent case, particularly in ancient +Following the current common practice (for example, the Unicode CLDR), +all locales are organized in a flat structure. This eases their +identification and customization. + +Many locale are quite usable, provided captions and dates are not +required (which is a very frequent case, particularly in ancient languages). So, they are included in the default \babel{} distribution. This can serve to encourage contributions, too. A warning will remember they are ‘bare minimum locales’. They are set in \textcolor[gray]{.4}{gray} in the following list. -\begin{note} - Although the names of the corresponding |lfd| files match those in - this list, there are some exceptions, particularly in German and - Serbian. So, |ngerman| is called here |german|, which is the name in - the CLDR and, actually, the most logical. -\end{note} - \begingroup \bigskip\hrule\nobreak \makeatletter -\def\tag#1{\par\@hangfrom{\makebox[10em][l]{#1}}\ignorespaces} \def\tag#1#2#3{\par \hspace{-2em}\textcolor{thered}{\texttt{#1}}#2\enspace - \mbox{\footnotesize(#3)}} + \mbox{\footnotesize(#3)}\enspace + \href{https://latex3.github.io/babel/guides/locale-#1.html}{\scriptsize ※}} \def\subtag#1#2#3{\par \hspace{-1em}\texttt{#1}#2\enspace \mbox{\footnotesize(#3)}} @@ -1630,7 +1067,8 @@ they are ‘bare minimum locales’. They are set in \mbox{\footnotesize(#3)}} \def\tagmin#1#2#3{\par \hspace{-2em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace - \mbox{\footnotesize(#3)}} + \mbox{\footnotesize(#3)}\enspace + \href{https://latex3.github.io/babel/guides/locale-#1.html}{\scriptsize ※}} \def\subtagmin#1#2#3{\par \hspace{-1em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace \mbox{\footnotesize(#3)}} @@ -1647,12 +1085,13 @@ highlighted), prefer the full forms.\\ Bare minimum locales are set in \textcolor[gray]{.4}{gray}.\\ Discouraged and deprecated names are not included.\\ \hascapu{} means Unicode captions; \hascapl{} means LICR captions.\\ -There are some notes in a few locales. +There are some notes in a few locales.\\ +The reference mark ({\scriptsize ※}) is a link to the \babel{} site. \bigskip\hrule\nobreak \begin{multicols}{2} -\leftskip2em +\leftskip2em\parindent0pt \tag{abkhazian}{}{ab} \tag{afar}{}{aa} \tag{afrikaans}{\hascapu\hascapl}{af} @@ -1660,6 +1099,9 @@ There are some notes in a few locales. \tag{akan}{}{ak} \tagmin{akkadian}{}{akk} \tag{albanian}{\hascapu\hascapl}{sq} +\tagmin{algerianarabic}{}{arq} +\note{Darija or Lahja Djazairia, with tag \texttt{arq}, different +from Standard Arabic as spoken in Alger, with tag \texttt{ar-DZ}.} \tag{amharic}{\hascapu\hascapl}{am} \tagmin{ancientegyptian}{}{egy} \tag{ancientgreek}{\hascapu\hascapl}{grc}\note{It’s a different @@ -1708,6 +1150,7 @@ language from \texttt{greek}.} \tag{baluchi}{}{bal} \tag{bambara}{}{bm} \tag{bangla}{\hascapu}{bn} +\subtag{bengali}{\hascapu}{bn} \tag{basaa}{}{bas} \tagmin{bashkir}{}{ba} \tag{basque}{\hascapu\hascapl}{eu} @@ -1716,7 +1159,7 @@ language from \texttt{greek}.} \tag{belarusian}{\hascapu\hascapl}{be} \tag{bemba}{}{bem} \tag{bena}{}{bez} -\tag{bengali}{\hascapu}{bn} +\tag{betawi}{}{bew} \tag{bhojpuri}{}{bho} \tag{blin}{}{byn} \tag{bodo}{}{brx} @@ -1730,10 +1173,12 @@ language from \texttt{greek}.} \tag{buriat}{\hascapu\hascapl}{bua} \tag{burmese}{}{my} \tag{cantonese}{}{yue} +\tagmin{carian}{}{xcr} \tag{catalan}{\hascapu\hascapl}{ca} \tag{cebuano}{}{ceb} \tag{centralatlastamazight}{}{tzm} \tag{centralkurdish}{\hascapu}{ckb} +\subtag{sorani}{\hascapu}{ckb} \subtag{centralkurdish-latin}{\hascapu}{ckb-Latn} \subtag{centralkurdish-latn}{\hascapu}{ckb-Latn} \tag{chakma}{}{ccp} @@ -1784,10 +1229,12 @@ Egypt, with tag \texttt{ar-EG}.} \tag{english}{\hascapu\hascapl}{en} \subtagalt{american}{\hascapu\hascapl}{en-US} \subtag{americanenglish}{\hascapu\hascapl}{en-US} +\subtag{usenglish}{\hascapu\hascapl}{en-US} \subtagalt{australian}{\hascapu\hascapl}{en-AU} \subtag{australianenglish}{\hascapu\hascapl}{en-AU} \subtagalt{british}{\hascapu\hascapl}{en-GB} \subtag{britishenglish}{\hascapu\hascapl}{en-GB} +\subtag{ukenglish}{\hascapu\hascapl}{en-GB} \subtagalt{canadian}{\hascapu\hascapl}{en-CA} \subtag{canadianenglish}{\hascapu\hascapl}{en-CA} \subtag{english-australia}{\hascapu\hascapl}{en-AU} @@ -1797,16 +1244,17 @@ Egypt, with tag \texttt{ar-EG}.} \subtag{english-unitedkingdom}{\hascapu\hascapl}{en-GB} \subtag{english-gb}{\hascapu\hascapl}{en-GB} \subtag{english-newzealand}{\hascapu\hascapl}{en-NZ} +\subtag{newzealand}{\hascapu\hascapl}{en-NZ} \subtag{english-unitedstates}{\hascapu\hascapl}{en-US} \subtag{english-nz}{\hascapu\hascapl}{en-NZ} \subtag{english-us}{\hascapu\hascapl}{en-US} \tag{erzya}{}{myv} \tag{esperanto}{\hascapu\hascapl}{eo} \tag{estonian}{\hascapu\hascapl}{et} +\tagmin{etruscan}{}{ett} \tag{ewe}{}{ee} \tag{ewondo}{}{ewo} \tag{faroese}{}{fo} -\tag{farsi}{\hascapu}{fa} \tag{filipino}{}{fil} \tag{finnish}{\hascapu\hascapl}{fi} \tag{french}{\hascapu\hascapl}{fr} @@ -1857,13 +1305,15 @@ with tag \texttt{gsw} is a different language.} \tag{hebrew}{\hascapu\hascapl}{he} \tag{hindi}{\hascapu}{hi} \tag{hmongnjua}{}{hnj} -\tag{hungarian}{\hascapu\hascapl\hascapl\hascapl}{hu} +\tag{hungarian}{\hascapu\hascapl}{hu} +\subtag{magyar}{\hascapu\hascapl}{hu} \tag{icelandic}{\hascapu\hascapl}{is} \tag{igbo}{}{ig} \tag{inarisami}{}{smn} \tag{indonesian}{\hascapu\hascapl}{id} \tagmin{ingush}{}{inh} \tag{interlingua}{\hascapu\hascapl}{ia} +\tag{interslavic}{\hascapu\hascapl}{isv} \tag{inuktitut}{}{iu} \tag{irish}{\hascapu\hascapl}{ga} \tag{italian}{\hascapu\hascapl}{it} @@ -1878,6 +1328,7 @@ with tag \texttt{gsw} is a different language.} \tag{kalaallisut}{}{kl} \tag{kalenjin}{}{kln} \tag{kamba}{}{kam} +\tag{kangri}{}{xnr} \tag{kannada}{\hascapu}{kn} \tag{kashmiri}{}{ks} \tag{kazakh}{}{kk} @@ -1891,7 +1342,6 @@ with tag \texttt{gsw} is a different language.} \subtag{korean-hani}{\hascapu}{ko-Hani} \tag{koyraborosenni}{}{ses} \tag{koyrachiini}{}{khq} -\tag{kurmanji}{\hascapu\hascapl}{kmr} \tag{kwasio}{}{nmg} \tag{kyrgyz}{}{ky} \tagmin{ladino}{}{lad} @@ -1916,17 +1366,19 @@ with tag \texttt{gsw} is a different language.} \tag{lowgerman}{}{nds} % \tag{lsorbian}{\hascapu\hascapl}{dsb} \tagmin{lu}{}{khb} +\tagmin{lycian}{}{xlc} +\tagmin{lydian}{}{xld} \tag{lubakatanga}{}{lu} \tag{luo}{}{luo} \tag{luxembourgish}{\hascapu\hascapl}{lb} \tag{luyia}{}{luy} \tag{macedonian}{\hascapu\hascapl}{mk} \tag{machame}{}{jmc} -\tag{magyar}{\hascapu\hascapl\hascapl\hascapl}{hu} \tag{maithili}{}{mai} \tagmin{makasar}{}{mak} \subtagmin{makasar-bugi}{}{mak-Bugi} \subtagmin{makasar-buginese}{}{mak-Bugi} +\tag{makhuwa}{}{vmw} \tag{makhuwameetto}{}{mgh} \tag{makonde}{}{kde} \tag{malagasy}{}{mg} @@ -1955,7 +1407,6 @@ with tag \texttt{gsw} is a different language.} \tagmin{navajo}{}{nv} \tag{nepali}{}{ne} \tagmin{newari}{}{new} -\tag{newzealand}{\hascapu\hascapl}{en-NZ} % \tag{ngerman}{\hascapu\hascapl}{de} \tag{ngiemboon}{}{nnh} \tag{ngomba}{}{jgo} @@ -1964,10 +1415,12 @@ with tag \texttt{gsw} is a different language.} \tag{nko}{}{nqo} \tag{northernfrisian}{}{frr} \tag{northernkurdish}{\hascapu\hascapl}{kmr} +\subtag{kurmanji}{\hascapu\hascapl}{kmr} \subtag{northernkurdish-arab}{\hascapu}{kmr-Arab} \subtag{northernkurdish-arabic}{\hascapu}{kmr-Arab} \tag{northernluri}{}{lrc} \tag{northernsami}{\hascapu\hascapl}{se} +\subtag{samin}{\hascapu\hascapl}{se} \tag{northernsotho}{}{nso} \tag{northndebele}{}{nd} \tag{norwegian}{\hascapu\hascapl}{no} @@ -1975,7 +1428,6 @@ with tag \texttt{gsw} is a different language.} \note{In the CLDR, \texttt{norwegianbokmal} (nb) just inherites from \texttt{norwegian}, so use the latter.} % \tag{norwegianbokmal}{\hascapu\hascapl}{nb} -\tag{nswissgerman}{\hascapu\hascapl}{de-CH} \tag{nuer}{}{nus} \tag{nyanja}{}{ny} \tag{nyankole}{}{nyn} @@ -1983,9 +1435,14 @@ with tag \texttt{gsw} is a different language.} \subtag{norwegiannynorsk}{\hascapu\hascapl}{nn} \tag{occitan}{\hascapu\hascapl}{oc} \tag{odia}{\hascapu}{or} +\note{Preferred to \texttt{oriya}.} +\tagmin{oldirish}{}{sga} \tagmin{oldnorse}{}{non} +\tagmin{oldpersian}{}{peo} +\tagmin{olduighur}{}{oui} % \tag{oriya}{\hascapu}{or} \tag{oromo}{}{om} +\tag{osage}{}{osa} \tag{ossetic}{}{os} \tag{papiamento}{}{pap} \tag{pashto}{}{ps} @@ -2019,11 +1476,11 @@ with tag \texttt{gsw} is a different language.} \tag{rundi}{}{rn} \tag{russian}{\hascapu\hascapl}{ru} \tag{rwa}{}{rwk} +\tagmin{sabaean}{}{xsa} \tag{saho}{}{ssy} \tag{sakha}{}{sah} \tagmin{samaritan}{}{smp} \tag{samburu}{}{saq} -\tag{samin}{\hascapu\hascapl}{se} \tag{sango}{}{sg} \tag{sangu}{}{sbp} \tag{sanskrit}{}{sa} @@ -2081,11 +1538,10 @@ with tag \texttt{gsw} is a different language.} \tag{sinhala}{\hascapu}{si} \tagmin{sinteromani}{}{rmo} \tag{slovak}{\hascapu\hascapl}{sk} -\tag{slovene}{\hascapu\hascapl}{sl} \tag{slovenian}{\hascapu\hascapl}{sl} +\subtag{slovene}{\hascapu\hascapl}{sl} \tag{soga}{}{xog} \tag{somali}{}{so} -\tag{sorani}{\hascapu}{ckb} \tagmin{southernaltai}{}{alt} \tag{southernsotho}{}{st} \tag{southndebele}{}{nr} @@ -2129,12 +1585,10 @@ in Switzerland.} \tag{turkish}{\hascapu\hascapl}{tr} \tag{turkmen}{\hascapu\hascapl}{tk} \tag{tyap}{}{kcg} -\tag{ukenglish}{\hascapu\hascapl}{en-GB} +\tagmin{ugaritic}{}{uga} \tag{ukrainian}{\hascapu\hascapl}{uk} \tag{uppersorbian}{\hascapu\hascapl}{hsb} \tag{urdu}{\hascapu}{ur} -\tag{usenglish}{\hascapu\hascapl}{en-US} -\tag{usorbian}{\hascapu\hascapl}{hsb} \tag{uyghur}{\hascapu}{ug} \tag{uzbek}{}{uz} \subtag{uzbek-arabic}{}{uz-Arab} @@ -2149,6 +1603,7 @@ in Switzerland.} \subtag{vai-vai}{}{vai-Vaii} \subtag{vai-vaii}{}{vai-Vaii} \tag{venda}{}{ve} +\tag{venetian}{}{vec} \tag{vietnamese}{\hascapu\hascapl}{vi} \tag{volapuk}{}{vo} \tag{vunjo}{}{vun} @@ -2163,60 +1618,112 @@ in Switzerland.} \tag{yiddish}{}{yi} \tag{yoruba}{}{yo} \tag{zarma}{}{dje} +\tag{zhuang}{}{za} \tag{zulu}{}{zu} \end{multicols} \endgroup \hrule \bigskip -\subsection{Selecting fonts} +\subsection{Fonts in Unicode engines} +\label{fonts} + +\begin{note} + For \textsf{pdflatex} and the standard \textsf{fontenc} mechanism, + refer to the \LaTeX{} manuals or \textit{The \LaTeX{} Companion}, + vol.~I, ch.~9, and vol.~II, ch.~10. +\end{note} + +\New{3.15} \Babel{} has native support for Unicode fonts (OpenType and +TrueType) in \luatex{} and \xetex{} by means of a high level interface +on top of |fontspec|. This makes it easier to handle a wide range of +languages and scripts, and simplifies the process of typesetting +multilingual documents. As described below, with \luatex{} the font can +be switched automatically based on the script without explicit markup. -\New{3.15} Babel provides a high level interface on top of |fontspec| -to select fonts. There is no need to load \textsf{fontspec} explicitly --- \babel{} does it for you with the first |\babelfont|.\footnote{See -also the package \textsf{combofont} for a complementary approach.} +There is no need to load \textsf{fontspec} explicitly – \babel{} does +it for you with the first |\babelfont|. (See also the package +\textsf{combofont} for a complementary approach.) \Describe\babelfont{\oarg{language-list}\marg{font-family}% \oarg{font-options}\marg{font-name}} -\begin{note} - See the note in the previous section about some issues in - specific languages. -\end{note} - -The main purpose of |\babelfont| is to define at once in a multilingual -document the fonts required by the different languages, with their -corresponding language systems (script and language). So, if you load, -say, 4 languages, |\babelfont{rm}{FreeSerif}| defines 4 fonts (with -their variants, of course), which are switched with the language by -\babel. It is a tool to make things easier and transparent to the user. +The main purpose of |\babelfont| is to define at once the fonts +required by the different languages, with their corresponding language +systems (script and language). So, if you load, say, 4 languages, +|\babelfont{rm}{FreeSerif}| defines 4 fonts (with their variants, of +course), which are switched with the language by \babel. It is a tool +to make things easier and transparent to the user. Here \textit{font-family} is |rm|, |sf| or |tt| (or newly defined ones, as explained below), and \textit{font-name} is the same as in \textsf{fontspec} and the like. -If no language is given, then it is considered the default font for -the family, activated when a language is selected. +If no language is given, then it is considered the default font for the +family. On the other hand, if there is one or more languages in the +optional argument, the font will be assigned to all of them, overriding +the default one. Alternatively, you may set a font for a script -- just +precede its name (lowercase) with a star (e.g., |*devanagari|). -On the other hand, if there is one or more languages in the optional -argument, the font will be assigned to them, overriding the default one. -Alternatively, you may set a font for a script -- just precede its name -(lowercase) with a star (eg, |*devanagari|). With this optional -argument, the font is \textit{not} yet defined, but just predeclared. -This means you may define as many fonts as you want ‘just in case’, -because if the language is never selected, the corresponding -|\babelfont| declaration is just ignored. +With the optional argument, the font is \textit{not} yet loaded, but +just predeclared. In other words, font loading is lazy, which means you +may define as many fonts as you want ‘just in case’, because if the +language is never selected, the corresponding |\babelfont| declaration +is just ignored. \Babel{} takes care of the font language and the font script when -languages are selected (as well as the writing direction); see the -recognized languages above. In most cases, you will not need -\textit{font-options}, which is the same as in \textsf{fontspec}, but -you may add further key/value pairs if necessary. +languages are selected (as well as the writing direction). In other +words, there is usually no need to set the |Language| and the |Script| +explicitly; in fact, it’s even discouraged. In most cases, you will not +need \textit{font-options}, which is the same as in \textsf{fontspec}, +but you may add further key/value pairs if necessary. + +|\babelfont| can be used to implicitly define a new font family. Just +write its name instead of |rm|, |sf| or |tt|. This is the preferred way +to select fonts in addition to the three basic families. + +\New{24.14} With \luatex, \Babel\ selects the renderer in the following +way: +\begin{itemize} +\item The default renderer in alphabetic scripts, so that the tools + provided by \textsf{luaotfload} for ligatures, kerning and the like, + which are essential typographical features in these scripts, are + directly available: Armenian, Coptic, Cyrillic, Georgian, Glagolitic, + Gothic, Greek, Latin, Old Church Slavonic Cyrillic. +\item Harfbuzz in the rest of scripts, particularly complex scripts with + heavy contextual analysis (like Arabic and Devanagari). +\end{itemize} +You can still select a different renderer with the \textsf{fontspec} +key |Renderer|. Note also the same font can be loaded with different +renderers. See +\href{https://github.com/latex3/luaotfload/wiki/Comparing-the-modes}{Comparing +the modes} for further info. + +\begin{note} + There is a list of fonts in + \href{https://latex3.github.io/babel/guides/which-method-for-which-language.html}{Which + method for which language}. If you know the codepoint of a character + in the script you need, you can find fonts containing it with + \textsf{albatross} (requires Java) or with something like + \texttt{fc-list :charset=1033C family} in the commands line (in this + case, a Gothic character, the script required by the |gothic| + language). +\end{note} + +\begin{note} + As \babel{} sets the font language system, the following setup is + redundant, so avoid it and use only the first line: +\begin{verbatim} +\babelfont{rm}{DejaVu Serif} +\babelfont[armenian]{rm}[Script=Armenian, Language=Armenian]{DejaVu Serif} +\end{verbatim} +\end{note} \begin{example} Usage in most cases is very simple. Let us assume you are setting up a document in Swedish, with some words in Hebrew, with a font suited - for both languages. + for both languages. Here the option |bidi=default| activates a simple + (or, rather, simplistic) bidirectional mode. \begingroup % If you are looking at the code to see how it has been written, you % will be disappointed :-). The following example is built ad hoc to @@ -2253,15 +1760,39 @@ replace the red line above with, say: \end{verbatim} \end{example} -|\babelfont| can be used to implicitly define a new font family. Just -write its name instead of |rm|, |sf| or |tt|. This is the preferred way -to select fonts in addition to the three basic families. +\begin{example} +Thanks to this high level interface to |fontspec|, the roman fonts for +all secondary languages in the Cyrillic and Greek scripts can be set +at once with the following single line: +\setengine{luatex/xetex} +\begin{verbatim} +\babelfont[_*cyrillic, *greek_]{rm}{NewComputerModern10} +\end{verbatim} +And if you need, say, Arabic and Devanagari: +\begin{verbatim} + \babelfont[_*arabic, *devanagari_]{rm}{FreeSerif} +\end{verbatim} +\Babel{} does the rest for you, including setting the font script +\textit{and} language. +\end{example} + +\begin{example} + Since each locale is a separate ‘language’, they can be assigned + different fonts. In this example, we set Simplified and Tradicional + Chinese: +\begin{verbatim} +\babelfont[chinese-_simplified_]{rm}{Noto Serif CJK _SC_} +\babelfont[chinese-_simplified_]{sf}{Noto Sans CJK _SC_} +\babelfont[chinese-_traditional_]{rm}{Noto Serif CJK _TC_} +\babelfont[chinese-_traditional_]{sf}{Noto Sans CJK _TC_} +\end{verbatim} +\end{example} \begin{example} - Here is how to do it: + Here is how to declare a new family: \setengine{luatex/xetex} \begin{verbatim} -\babelfont{kai}{FandolKai} +\babelfont{_kai_}{FandolKai} \end{verbatim} Now, |\kaifamily| and |\kaidefault|, as well as |\textkai| are at your disposal. @@ -2276,11 +1807,7 @@ to select fonts in addition to the three basic families. \babelfont[hindi]{rm}{Shobhika} \end{verbatim} This makes sure the OpenType script for Devanagari is |deva| and not - |dev2|, in case it is not detected correctly. -% You may also pass some -% options to \textsf{fontspec}: with |silent|, the warnings about -% unavailable scripts or languages are not shown (they are only really -% useful when the document format is being set up). + |dev2|, in case you need it. \end{note} \begin{note} @@ -2312,6 +1839,16 @@ to select fonts in addition to the three basic families. above for the reasons of this behavior. \end{note} +\begin{note} + |\babelfont| is a high level interface to \textsf{fontspec}, and + therefore in \xetex{} you can apply |Mapping|s. For example, there is + a set of + \href{https://github.com/davidmjones/brahmic-maps}{transliterations + for Brahmic scripts} by David M. Jones. After installing + them in you distribution, just set the map as you would do with + \textsf{fontspec}. +\end{note} + \begin{warning} Using |\set|\textit{xxxx}|font| and |\babelfont| at the same time is discouraged, but very often works as expected. However, be aware with @@ -2320,6 +1857,28 @@ to select fonts in addition to the three basic families. \end{warning} \begin{troubleshooting} + \trouble{Package fontspec Info: Language '<lang>' not explicitly + supported within font '<font>' with script '<script>'.} + \textit{Package fontspec Info: Language '<lang>' not explicitly + supported within font '<font>' with script '<script>'.}. + + \textbf{This is \textit{not} and error.} This info is shown by + \textsf{fontspec}, not by \babel. If everything is okay in your + document (and almost always it is), the best thing you can do is just + to ignore it altogether. + + In some forums you can find the advice to set, more or less + mechanically, |Language=Default|. \textit{Do not follow it}, because + font features for the language will not be applied, which can be + relevant for many languages, like Urdu and Turkish. Set the + |Language| explicitly only if there is a reason to do it. If you + really want to conceal this message, use instead: +\begin{verbatim} +\PassOptionsToPackage{silent}{fontspec} +\end{verbatim} +\end{troubleshooting} + +\begin{troubleshooting} \trouble{Package babel Info: The following fonts are not babel standard families} \textit{Package babel Info: The following fonts are not babel standard families}. @@ -2341,22 +1900,785 @@ to select fonts in addition to the three basic families. be aware that this may lead to some problems. \end{troubleshooting} +\subsection{Basic language selectors} +\label{selectors} + +This section describes the commands to be used in the document to +switch the language in multilingual documents. In most cases, only the +two basic macros |\selectlanguage| and |\foreignlanguage| are +necessary. The environments |otherlanguage|, |otherlanguage*| are +auxiliary, and described in the next section. + +The main language is selected automatically when the |document| +environment begins. + +\Describe{\selectlanguage}{\marg{language}} +\DescribeOther{\begin\menv{selectlanguage}}% + {\marg{language}\Eenv{selectlanguage}} + +When a user wants to switch from one language to another he can do so +using the macro |\selectlanguage|. It is meant for blocks of texts, and +therefore should be used mainly in vertical mode, although it also +works in horizontal mode. +\begin{verbatim} +\selectlanguage{german} +\end{verbatim} + +This command can be used as environment, too, in case there are +relatively short texts and you do not want to reset the language with a +hardcode value. + \begin{note} - |\babelfont| is a high level interface to \textsf{fontspec}, and - therefore in \xetex{} you can apply |Mapping|s. For example, there is - a set of - \href{https://github.com/davidmjones/brahmic-maps}{transliterations - for Brahmic scripts} by Davis M. Jones. After installing - them in you distribution, just set the map as you would do with - \textsf{fontspec}. + Bear in mind |\selectlanguage| can be automatically executed, in some + cases, in the auxiliary files, at heads and foots, and after the + environment |otherlanguage*|. +\end{note} + +\begin{warning} + If used inside braces or a group there might be some non-local + changes, as it would be roughly equivalent to: +\begin{verbatim} +\bgroup +\selectlanguage{<inner-language>} +... +\egroup +\selectlanguage{<outer-language>} +\end{verbatim} + If you want a change which is really local, you must enclose this + code with an additional grouping level. The same applies to the + environment version. +\end{warning} + +\begin{warning} + There are a couple of issues related to the way the language + information is written to the auxiliary files: +\begin{itemize} + \item |\selectlanguage| should not be used inside some boxed environments + (like floats or |minipage|) to switch the language if you need the + information written to the |aux| be correctly synchronized. This + rarely happens, but if it were the case, you must use the + environment version or |otherlanguage| instead. + \item In addition, this macro inserts a |\write| in vertical mode, + which may break the vertical spacing in some cases (for example, + between lists or at the beginning of a table cell). \New{3.64} The + behavior can be adjusted with + |\babeladjust{select.write=<mode>}|, where \m{mode} is |shift| + (which shifts the skips down and adds a |\penalty|); |keep| (the + default -- with it the |\write| and the skips are kept in the order + they are written), and |omit| (which may seem a too drastic + solution, because nothing is written, but more often than not this + command is applied to more or less shorts texts with no sectioning + or similar commands, and therefore no language synchronization is + necessary). In a table cell, a |\leavevmode| just before the + selector may be enough. +\end{itemize} +\end{warning} + +\Describe{\foreignlanguage}{\oarg{option-list}\marg{language}\marg{text}} + +It takes two mandatory arguments; the second argument is a phrase to be +typeset according to the rules of the language named in its first one. + +This command (1) only switches the extra definitions and the +hyphenation rules for the language, \emph{not} the names and dates, (2) +does not send information about the language to auxiliary files (i.e., +the surrounding language is still in force), and (3) it works even if +the language has not been set as package option (but in such a case it +only sets the hyphenation patterns and a warning is shown). With the +|bidi| option, it also enters in horizontal mode (this is not done +always for backwards compatibility), and since it is meant for phrases +only the text direction (and not the paragraph one) is set. + +\New{3.44} As already said, captions and dates are not switched. +However, with the optional argument you can switch them, too. So, you +can write: +\begin{verbatim} +\foreignlanguage[date]{polish}{\today} +\end{verbatim} +In addition, captions can be switched with |captions| (or both, of +course, with |date,| |captions|). Until 3.43 you had to write something +like |{\selectlanguage{..} ..}|, which was not always the most +convenient way. + +\begin{note} + |\bibitem| is out of sync with |\selectlanguage| in the \file{aux} + file. The reason is |\bibitem| uses |\immediate| (and others, in + fact), while |\selectlanguage| doesn't. There is a similar issue with + floats, too. There is no known workaround, but it’s not usually a + real issue. \end{note} -\subsection{Modifying a language} +\subsection{Auxiliary language selectors} + +\Describe{\begin\menv{otherlanguage}}{\marg{language}\Eenv{otherlanguage}} + +Same as |selectlanguage| as environment, except spaces after the +|\begin| and |\end| commands are ignored. (Very likely, and because of +the limitations of many old editors with bidi text, the idea was +\cs{end}\texttt{\{otherlanguage\}} had to be a line by itself.) The +warning above about the internal |\write| also applies here. The +current mode (vertical or horizontal) also remains unchanged. + +\Describe{\begin\menv{otherlanguage*}}% +{\oarg{option-list}\marg{language}\Eenv{otherlanguage*}} + +Same as |\foreignlanguage| but as environment. Spaces are \textit{not} +ignored. + +It was originally devised for intermixing left-to-right +typesetting with right-to-left typesetting in engines not supporting a +change in the writing direction inside a line. However, by default it +never complied with the documented behavior and it is just a version as +environment of |\foreignlanguage|, except when the package option +|bidi| is set -- in this case, |\foreignlanguage| emits a +|\leavevmode|, while |otherlanguage*| does not. Like |\foreignlanguage| +it is a \textit{text} command, and therefore it doesn’t change the +paragraph direction. + +\begin{example} +Here is a document putting in practice some of the techniques described, +which shows how to deal neatly with complex multilingual documents +in \luatex{} and \xetex, with the help of logical markup. You are +writing a book on Indic literature with many extracts in several +languages, which fits in the category of ‘mostly monolingual’. Loading +of locales and fonts is lazy, which greatly simplifies the preamble. +\catcode`@=13 \def@#1@{{\fontspec[Script=Devanagari]{FreeSans}#1}} +\begin{verbatim} +\documentclass{article} + +_\usepackage[english]{babel}_ + +_\babelfont[*devanagari]{rm}{FreeSans}_ + +\newenvironment{excerpt}[1] + {\begin{quote}_\begin{otherlanguage*}{#1}_} + {_\end{otherlanguage*}_\end{quote}} + +\begin{document} + +\section{Sanskrit literature} + +Here is an excerpt: +\begin{excerpt}{sanskrit} + @संस्कृतम्@ +\end{excerpt} + +\section{Hindi literature} + +Here is an excerpt: +\begin{excerpt}{hindi} + @हिन्दी@ +\end{excerpt} + +\section{Marathi literature} + +Here is an excerpt: +\begin{excerpt}{marathi} + @मराठी@ +\end{excerpt} + +\section{Nepali literature} + +Here is an excerpt: +\begin{excerpt}{nepali} + @नेपाली@ +\end{excerpt} + +\section{Rajasthani literature} + +Here is an excerpt: +\begin{excerpt}{rajasthani} + @संस्कृतम्@ +\end{excerpt} + +\end{document} +\end{verbatim} +\end{example} + +\subsection{Plain} + +In e-Plain and pdf-Plain, load languages styles with |\input| and then use +|\begindocument| (the latter is defined by \babel): +\begin{verbatim} +\input estonian.sty +\begindocument +\end{verbatim} + +\begin{warning} + Not all languages provide a |sty| file and some of them are not + compatible with those formats. Please, refer to + \href{https://latex3.github.io/babel/guides/using-babel-with-plain.html}% + {Using babel with Plain} for further details. +\end{warning} + +\section{More on language loading and selection} + +\subsection{A couple of tools} + +% Also Plain +\Describe{\babeltags}{\char`\{\m{tag1} \texttt{=} \m{language1}, \m{tag2} +\texttt{=} \m{language2}, \dots\char`\}} + +\New{3.9i} In multilingual documents with many language-switches the +commands above can be cumbersome. With this tool shorter names can be +defined. It adds nothing really new -- it is just syntactical sugar. + +It defines |\text<tag1>{<text>}| to be +|\foreignlanguage{<language1>}{<text>}|, and |\begin{<tag1>}| +to be |\begin{otherlanguage*}{<language1>}|, and so on. Note +|\<tag1>| is also allowed, but remember to set it locally inside a +group. + +\begin{warning} + There is a clear drawback to this feature, namely, the ‘prefix’ + |\text...| is heavily overloaded in \LaTeX{} and conflicts with + existing macros may arise (|\textlatin|, |\textbar|, |\textit|, + |\textcolor| and many others). The same applies to environments, + because |arabic| conflicts with |\arabic|. Furthermore, and because of + this overloading, detecting the language of a chunk of text by + external tools can become unfeasible (is |\textga| the locale for the + African language Gã or something else?). Except if there is a reason for + this ‘syntactical sugar’, the best option is to stick to the default + selectors or even to define your own alternatives. +\end{warning} + +\begin{example} +With +\begin{verbatim} +\babeltags{de = german} +\end{verbatim} +you can write +\begin{verbatim} +text \textde{German text} text +\end{verbatim} +and +\begin{verbatim} +text +\begin{de} + German text +\end{de} +text +\end{verbatim} +\end{example} + +\begin{note} + Something like \verb|\babeltags{finnish = finnish}| is legitimate -- + it defines |\textfinnish| and |\finnish| (and, of course, + |\begin{finnish}|). +\end{note} + +% Also Plain +\Describe{\babelensure}{|[include=|\m{commands}|,exclude=|\m{commands}% + |,fontenc=|\m{encoding}|]|\marg{language}} + +\New{3.9i} Except in a few languages, like \textsf{russian}, +captions and dates are just strings, and do not switch the +language. That means you should set it explicitly if you want to use +them, or hyphenation (and in some cases the text itself) will be +wrong. For example: +\begin{verbatim} +\foreignlanguage{russian}{text \foreignlanguage{polish}{\seename} text} +\end{verbatim} + +Of course, \TeX{} can do it for you. To avoid switching the language +all the while, |\babelensure| redefines the captions for a given +language to wrap them with a selector: +\begin{verbatim} +\babelensure{polish} +\end{verbatim} +By default only the basic captions and |\today| are redefined, but you +can add further macros with the key |include| in the optional argument +(without commas). Macros not to be modified are listed in +|exclude|. You can also enforce a font encoding with the option +|fontenc| (with it, encoded strings may not work as expected). +A couple of examples: +\begin{verbatim} +\babelensure[include=\Today]{spanish} +\babelensure[fontenc=T5]{vietnamese} +\end{verbatim} + +They are activated when the language is selected (at the |afterextras| +event), and it makes some assumptions which could not be fulfilled in +some languages. Note also you should include only macros defined by +the language, not global macros (e.g., |\TeX| of |\dag|). + +With |ini| files (see below), captions are ensured by default. + +\subsection{Accessing language info} + +% Also Plain +\Describe{\localename}{} +\DescribeOther{\mainlocalename}{} +\DescribeOther{\languagename}{} + +\New{24.10} The control sequence |\localename| contains the name of the current +locale. This is now the recommended way to retrieve the current +language. In addtion, |\mainlocalename| contains the main language. + +|\languagename| is still used internally, but it is now discouraged at +the user level. + +\begin{warning} + Due to a bug, which led to some internal inconsistencies in + catcodes, |\languagename| should \textit{not} be used to test which + is the current language. Rely on |\localename| or, if you still need + |\languagename| for some reason, on \textsf{iflang}, by Heiko Oberdiek. +\end{warning} + +\Describe{\iflanguage}{\marg{language}\marg{true}\marg{false}} + +Here ``language'' is used in the \TeX{} sense, as a set of hyphenation +patterns, and \textit{not} as its \textsf{babel} name. The first +argument is the name of a language. + +\Describe{\localeinfo}{\optstar{\marg{field}}} + +\New{3.38} If an |ini| file has been loaded for the current language, +you may access the information stored in it. Note with the ‘classical’ +|ldf| files the corresponding |ini| ones are also loaded, but only some +basic data required for fonts, casing and a few more. + +This macro is fully expandable, but raises an error if the info doesn’t +exist. \New{3.75} Sometimes, it comes in handy to be able to use +|\localeinfo| in a quite fully expandable way even if something went +wrong (for example, the locale currently active is undefined). For +these cases, |localeinfo*| just returns an empty string instead of +raising an error. + +The available fields are: +\begin{description} +\itemsep=-\parskip +\item[|name.english|] as provided by the Unicode CLDR. +\item[|tag.ini|] is the tag of the |ini| file (the way this + file is identified in its name). +\item[|tag.bcp47|] is the full BCP 47 tag. This + is the value to be used for the ‘real' provided tag (\babel{} may + fill other fields if they are considered necessary). +\item[|language.tag.bcp47|] is the BCP 47 language tag. +\item[|tag.opentype|] is the tag used by OpenType (usually, but not + always, the same as BCP 47). It can be useful when customizing fonts + with \textsf{luaotfload}. +\item[|script.name|], as provided by the Unicode CLDR. +\item[|script.tag.bcp47|] is the BCP 47 tag of the script + used by this locale. This is a required field for the fonts to be + correctly set up, and therefore it should always be defined. +\item[|script.tag.opentype|] is the tag used by OpenType (usually, + but not always, the same as BCP 47). It can be useful when + customizing fonts with \textsf{luaotfload}. +\item[|region.tag.bcp47|] is the BCP 47 tag of the region or territory. + Defined only if the locale loaded actually contains it (e.g., |es-MX| + does, but |es| doesn’t), which is how locales behave in the CLDR. + \New{3.75} +\item[|variant.tag.bcp47|] is the BCP 47 tag of the variant (in the BCP 47 + sense, like |1901| for German). \New{3.75} +\item[|extension.|\m{s}|.tag.bcp47|] is the BCP 47 value of the + extension whose singleton is \m{s} (currently the recognized + singletons are |x|, |t| and |u|). The internal syntax can be somewhat + complex, and this feature is still somewhat tentative. An example is + \textsf{classicallatin} which sets |extension.x.tag.bcp47| to |classic|. + \New{3.75} +\end{description} + +% All of these keys can be preceded by |main.| (e.g., |main.tag.ini|), +% which retrieves the values of the main locale. + +\begin{note} + Currently, |x| is used for two separate functions, namely, + identifying a \babel{} locale without a BCP 47 tag and setting an + alternative set of rules for casing. +\end{note} + +\begin{note} + Bear in mind that \babel{}, following the CLDR, may leave the region + unset, which means |\getlocaleproperty*|, described below, is the + preferred command, so that the existence of a field can be checked + before. This also means building a string with the language and the + region with something like + |\localeinfo*{language.tab.bcp47}|\allowbreak |-|\allowbreak + |\localeinfo*{region.tab.bcp47}| is not usually a good idea (because + of the hyphen). +\end{note} + +\begin{warning} + \New{3.46} As of version 3.46 |tag.bcp47| returns the full BCP 47 + tag. Formerly it returned just the language subtag, which was clearly + counterintuitive. +\end{warning} + +\Describe{\getlocaleproperty}{% + \optstar\marg{macro}\marg{locale}\marg{property}} + +\New{3.42} The value of any locale property as set by the |ini| files +(or added/modified with |\babelprovide|) can be retrieved and stored in +a macro with this command. For example, after: +\begin{verbatim} + \getlocaleproperty\hechap{hebrew}{captions/chapter} +\end{verbatim} +the macro |\hechap| will contain the string +{\fontspec[Scale=.87,Script=Hebrew]{Liberation Mono}\textdir TRT פרק}. + +If the key does not exist, the macro is set to |\relax| and an error is +raised. \New{3.47} With the starred version no error is raised, so that +you can take your own actions with undefined properties. + +\Describe{\localeid}{} +Each language in the \babel{} sense has its own unique numeric +identifier, which can be retrieved with |\localeid|. + +The |\localeid| is not the same as the |\language| identifier, which +refers to a set of hyphenation patterns (which, in turn, is just a +component of the line breaking algorithm described in the next +section). The data about preloaded patterns are store in an internal +macro named |\bbl@languages| (see the code for further details), but +note several locales may share a single |\language|, so they are +separated concepts. In \luatex, the |\localeid| is saved in each node +(when it makes sense) as an attribute, too. + +\Describe{\ShowLocaleProperties}{\marg{language}} +\New{3.98} Prints to the |log| file all the loaded key/value pairs from +the |ini| locale file for \meta{language}. + +\Describe{\LocaleForEach}{\marg{code}} +\Babel{} remembers which |ini| files have been loaded. There is a loop +named |\LocaleForEach| to traverse the list, where |#1| is the name of +the current item, so that |\LocaleForEach{\message{ **#1** }}| just +shows the loaded |ini|’s. + +\subsection{Package options} + +\New{3.9a} +These package options are processed before language options, so +that they are taken into account irrespective of their order. The first +three options have been available in previous versions. + +\Describe{KeepShorthandsActive}{} +Tells \babel{} not to deactivate shorthands after loading a language +file, so that they are also available in the preamble. + +\Describe{headfoot=}{\meta{language}} By default, headlines and +footlines are not touched (only marks), and if they contain +language-dependent macros (which is not usual) there may be unexpected +results. With this option you may set the language in heads and feet. +An alternative is to set the language explicitly when heads and feet +are redefined. + +\Describe{noconfigs}{} Global and language default config files are +not loaded, so you can make sure your document is not spoilt by an +unexpected \texttt{.cfg} file. However, if the key |config| is set, +this file is loaded. + +\Describe{config=}{\meta{file}} Load \meta{file}\texttt{.cfg} instead +of the default config file |bblopts.cfg| (forced even with +|noconfigs|). + +\Describe{showlanguages}{} Prints to the log the list of languages +loaded when the format was created: number (remember dialects can +share it), name, hyphenation file and exceptions file. + +\Describe{silent}{} \New{3.9l} No warnings and no \textit{infos} are +written to the log file.\footnote{You can use alternatively the +package \textsf{silence}.} + +\Describe{hyphenmap=}{\texttt{off} $\string|$ \texttt{first} +$\string|$ \texttt{select} $\string|$ \texttt{other} $\string|$ +\texttt{other*}} + +\New{3.9g} Sets the behavior of case mapping for hyphenation, +provided the language defines it.\footnote{Turned off in plain.} It +can take the following values: +\begin{description} +\renewcommand\makelabel[1]{% + \hspace\labelsep\normalfont\ttfamily\color{thered}#1} +\itemsep=-\parskip +\item[off] deactivates this feature and no case mapping is applied; +\item[first] sets it at the first switching commands in the + current or parent scope (typically, when the |aux| file is first read + and at |\begin{document}|, but also the first |\selectlanguage| in + the preamble), and it's the default if a single language option has + been stated. If a language option is repeated (e.g., |malay, malay|), + it counts as several ones, even if there is only a language. +\item[select] sets it only at |\selectlanguage|; +\item[other] also sets it at |otherlanguage|; +\item[other*] also sets it at |otherlanguage*| as well as in heads and + feet (if the option |headfoot| is used) and in auxiliary files (i.e., + at |\select@language|), and it's the default if several language + options have been stated. The option |first| can be regarded as an + optimized version of \texttt{other*} for monolingual + documents.\footnote{Providing |foreign| is pointless, because the + case mapping applied is that at the end of the paragraph, but if either + \luatex{} or \xetex{} change this behavior it might be added. On + the other hand, |other| is provided even if I [JBL] think it isn't + really useful, but who knows.} +\end{description} + +\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic} + $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$ + \texttt{bidi-r}} + +\New{3.14} Selects the bidi algorithm to be used in \luatex{} and +\xetex{}. See sec.~\ref{bidi}. + +\Describe{layout=}{} + +\New{3.16} Selects which layout elements are adapted in bidi +documents. See sec.~\ref{bidi}. + +\Describe{provide=}{\texttt{*} $\string|$ \meta{option-list}} +\New{3.49} An alternative to |\babelprovide| for languages passed as +options. See section~\ref{inifiles}, which describes also the variants +|provide+=| and |provide*=|. + +\Describe{main=}{\meta{language}} Forces the main language, but this +option should not be used except if there a need to do it. If the +language is not given as such as package or global option, it is added +to the list of requested languages. For example: +\begin{verbatim} +\documentclass{article} +\usepackage[_main=english_,dutch]{babel} +\end{verbatim} +Some classes load \babel{} with a hardcoded language option. Sometimes, +the main language can be overridden with something like that before +|\documentclass|: +\begin{verbatim} +\PassOptionsToPackage{main=english}{babel} +\end{verbatim} + +\subsection{The \texttt{base} option} + +With this package option \babel{} just loads some basic macros (mainly +the selectors), defines |\AfterBabelLanguage| and exits. It also +selects the hyphenation patterns for the last language passed as option +(by its name in |language.dat|). There are two main uses: classes and +packages, and as a last resort in case there are, for some reason, +incompatible languages. It can be used if you just want to select the +hyphenation patterns of a single language, too. + +\Describe\AfterBabelLanguage{\marg{option-name}\marg{code}} + +This command is currently the only one provided by |base|. Executes +\meta{code} when the file loaded by the corresponding package option +is finished (at |\ldf@finish|). The setting is global. So +\begin{verbatim} +\AfterBabelLanguage{french}{...} +\end{verbatim} +does |...|\ at the end of |french.ldf|. It can be used in |ldf| files, +too, but in such a case the code is executed only if +\meta{option-name} is the same as |\CurrentOption| (which could not +be the same as the option name as set in |\usepackage|!). + +\begin{example} + Consider two languages \textsf{foo} and \textsf{bar} defining the + same |\macro| with |\newcommand|. An error is raised if you attempt + to load both. Here is a way to overcome this problem: +\begin{verbatim} +\usepackage[base]{babel} +\AfterBabelLanguage{foo}{% + \let\macroFoo\macro + \let\macro\relax} +\usepackage[foo,bar]{babel} +\end{verbatim} +\end{example} + +\begin{note} + An alternative method to execute some code just after an |ldf| file + is loaded is with |\AddToHook| and the hook + |file/<language>.ldf/after|. You can also execute some code before + with |file/<language>.ldf/before|. +\end{note} + +\begin{warning} + Currently this option is not compatible with languages loaded on the + fly. +\end{warning} + +\subsection{\texttt{provide} and \cs{babelprovide} – \texttt{ini} files} +\label{inifiles} + +An alternative approach to define a language (or, more precisely, a +\textit{locale}) is by means of an \texttt{ini} file. Currently +\babel{} provides about 380 of these files containing the basic data +required for a locale, covering about 300 languages and 40 scripts, +plus basic templates for about 400 locales. + +|ini| files are not meant only for \babel, and they has been devised as +a resource for other packages. To ease interoperability between \TeX{} +and other systems, they are identified with the BCP 47 codes as +preferred by the Unicode Common Locale Data Repository, which was +used as source for most of the data provided by these files, where +available. + +Most of them set the date, and many also the captions (Unicode and +LICR). They will be evolving with the time to add more features +(something to keep in mind if backward compatibility is important). The +following section shows how to make use of them by means of +|\babelprovide|. + +Not all languages in the CLDR are complete, and therefore neither are +the |ini| files. A few languages may show a warning about the current +lack of suitability of some features. + +\begin{example} + There is an example of how to use an |ini| template file + \href{https://github.com/latex3/babel/issues/176#issuecomment-1080846575}{here}, + for Phoenician (although currently this locale is bundled with + \babel). +\end{example} + +\begin{note} + The \texttt{ini} files just define and set some parameters, but the + corresponding behavior is not always implemented. Also, there are + some limitations in the engines. A few remarks follow (which could no + longer be valid when you read this manual, if the packages involved + have been updated). +\begin{description} +\itemsep=-\parskip +\item[Arabic] Math and graphical elements like |picture| are complex + and requires some additional fine tuning. In \xetex{} \babel{} + resorts to the \textsf{bidi} package, which seems to work. +\item[Southeast scripts] Thai works in both \luatex{} and \xetex{}, but + line breaking differs (rules are hard-coded in \xetex, but they can + be modified in \luatex). Lao seems to work, too, but there are no + patterns for the latter in \luatex{}. Some quick patterns can + help, with something similar to: +\begin{verbatim} +\babelprovide[import, hyphenrules=+]{lao} +\babelpatterns[lao]{1ດ 1ມ 1ອ 1ງ 1ກ 1າ} % Random +\end{verbatim} +\item[East Asia scripts] Settings for either Simplified of Traditional + (Chinese) should work out of the box, with basic line breaking with any + renderer. Although for a few words and shorts texts the |ini| files + should be fine, CJK texts are best set with a dedicated framework + (\textsf{CJK}, \textsf{luatexja}, \textsf{kotex}, \textsf{CTeX}, + etc.). This is what the class |ltjbook| does with \luatex, which can + be used in conjunction with the |ldf| for |japanese|, because the + following piece of code loads \textsf{luatexja}: +\begin{verbatim} +\documentclass[japanese]{ltjbook} +\usepackage{babel} +\end{verbatim} +\item[Latin, Greek, Cyrillic] Combining chars with the default + \luatex{} font renderer might be wrong; on the other hand, with the + Harfbuzz renderer diacritics are stacked correctly, but many + hyphenations points are discarded (this bug is related to kerning, + so it depends on the font). With \xetex{} both combining characters + and hyphenation work as expected (not quite, but in most cases it + works; the problem here are font clusters). +\end{description} +\end{note} + +\begin{note} + Wikipedia defines a \textit{locale} as follows: “In computing, a + locale is a set of parameters that defines the user’s language, + region and any special variant preferences that the user wants to see + in their user interface. Usually a locale identifier consists of at + least a language code and a country/region code.” \Babel{} is moving + gradually from the old and fuzzy concept of \textit{language} to the + more modern of \textit{locale}. Note each locale is by itself a + separate “language”, which explains why there are so many files. This + is on purpose, so that possible variants can be created and/or + redefined easily. +\end{note} + +% \begin{example} +% Let's assume you need only the basic features of `spanish`, so that +% the |ini| file is enough, and also a variant with your own +% hyphenation with +% \end{example} + +\subsection{Selection based on BCP 47 tags} +\label{bcp47} + +\New{3.43} The recommended way to select languages is that described at +the beginning of this document. However, BCP 47 tags are becoming +customary, particularly in documents (or parts of documents) generated +by external sources, and therefore \babel{} will provide a set of tools +to select the locales in different situations, adapted to the +particular needs of each case. Currently, \babel{} provides autoloading +of locales as described in this section. In these contexts autoloading +is particularly important because we may not know beforehand which +languages will be requested. + +It must be activated explicitly, because it is primarily meant for +special tasks. Mapping from BCP 47 codes to locale names is not +hardcoded in \babel. Instead the data is taken from the \texttt{ini} +files, which means currently about 350 tags are already recognized. +\Babel{} performs a simple lookup in the following way: |fr-Latn-FR| $\to$ +|fr-Latn| $\to$ |fr-FR| $\to$ |fr|. Languages with the same resolved +name are considered the same. Case is normalized before, so that +|fr-latn-fr| $\to$ |fr-Latn-FR|. If a tag and a name overlap, the tag +takes precedence. + +Here is a minimal example: +\begin{verbatim} +\documentclass{article} + +\usepackage[danish]{babel} + +_\babeladjust{_ +_ autoload.bcp47 = on_ +_}_ + +\begin{document} + +Chapter in Danish: \chaptername. + +_\selectlanguage{de-AT}_ + +\localedate{2020}{1}{30} + +\end{document} +\end{verbatim} + +Currently the locales loaded are based on the \texttt{ini} files and +decoupled from the main \texttt{ldf} files. This is by design, to +ensure code generated externally produces the same result regardless of +the languages requested in the document, but an option to use the +\texttt{ldf} instead will be added in a future release, because both +options make sense depending on the particular needs of each document +(there will be some restrictions, however). + +The behavior is adjusted with |\babeladjust| with the following parameters: +\begin{description} +\item \texttt{autoload.bcp47} with values |on| and |off|. +\item \texttt{autoload.bcp47.options}, which are passed to + |\babelprovide|; \New{24.14} |import| by default (features defined in + the corresponding |babel-...tex| file might not be available), but + you can set it to another value (even empty). +\item \texttt{autoload.bcp47.prefix}. Although the public name used in + selectors is the tag, the internal name will be different and + generated by prepending a prefix, which by default is + \texttt{bcp47-}. You may change it with this key. +\end{description} + +\New{3.46} If an |ldf| file has been loaded, you can enable the +corresponding language tags as selector names with: +\begin{verbatim} +\babeladjust{ bcp47.toname = on } +\end{verbatim} +(You can deactivate it with |off|.) So, if |dutch| is one of the +package (or class) options, you can write |\selectlanguage{nl}|. Note +the language name does not change (in this example is still |dutch|), +but you can get it with |\localeinfo| or |\getlocaleproperty|. It +must be turned on explicitly for similar reasons to those explained +above. + +\section{Tailoring, customizing and modifying a language} Modifying the behavior of a language (say, the chapter -“caption”), is sometimes necessary, but not always trivial. In the case -of caption names a specific macro is provided, because this is perhaps -the most frequent change: +“caption”) is sometimes necessary. + +Several language definition files use their own methods to set +options. For example, \textsf{french} uses |\frenchsetup|, +\textsf{magyar} (1.5) uses |\magyarOptions|; modifiers provided by +|spanish| have no attribute counterparts. Macros setting +options are also used (e.g., |\ProsodicMarksOn| in \textsf{latin}). + +This section describes the general tools provided by the \babel{} core. + +\subsection{Captions} + +This is perhaps the most frequent change, so a specific macro is +provided. \Describe{\setlocalecaption}{% \marg{language-name}\marg{caption-name}\marg{string}} @@ -2372,19 +2694,36 @@ define new ones by setting the \textit{caption-name} to the name of your choice (|name| will be postpended). Captions so defined or redefined behave with the ‘new way’ described in the following note. +Note the string should not contain a language selector or changes in +the text direction, which is done by \babel{} when necessary. With +|arabic|, all you need is: +\begingroup +% If you are looking at the code to see how it has been written, you +% will be disappointed :-). The following example is built ad hoc to +% emulate the final result to avoid dependencies, and therefore it's +% not "real" code. +\setmonofont[Scale=.86, FakeStretch=.97,Script=Arabic]{DejaVu Sans Mono} +\catcode`@=13 +\def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else +\bgroup\textdir TRT \pardir TRT \fi} +\begin{verbatim} +\setlocalecaption{arabic}{part}{@2القسم@0} +\end{verbatim} +\endgroup + \begin{note} There are a few alternative methods: \begin{itemize} \item With data |import|’ed from |ini| files, you can modify the values - of specific keys, like: + of specific keys when loaded, like: \begin{verbatim} \babelprovide[import, _captions/listtable = Lista de tablas_]{spanish} \end{verbatim} (In this particular case, instead of the |captions| group you may need to modify the |captions.licr| one.) -\item The ‘old way’, still valid for many languages, to redefine a - caption is the following: +\item The low-level ‘old way’ to redefine a caption, still valid for +many languages but discouraged in general, is the following: \begin{verbatim} \addto\captionsenglish{% \renewcommand\contentsname{Foo}% @@ -2397,11 +2736,11 @@ redefined behave with the ‘new way’ described in the following note. \item The ‘new way’, which is found in |bulgarian|, |azerbaijani|, |spanish|, |french|, |turkish|, |icelandic|, |vietnamese| and a few more, as well as in languages created with |\babelprovide| and its - key |import|, is: + key |import|, or with the package option |provide=|, is: \begin{verbatim} \renewcommand\spanishchaptername{Foo} \end{verbatim} -This redefinition is immediate. +This redefinition is immediate. \end{itemize} \end{note} @@ -2413,16 +2752,16 @@ The changes may be discarded with a language selector, and the original value restored. \end{note} -Macros to be run when a language is selected can be add to - |\extras|\m{lang}: +Macros to be run when a language is selected can be added to + |\extras<language>|: \begin{verbatim} \addto\extrasrussian{\mymacro} \end{verbatim} There is a counterpart for code to be run when a language is -unselected: |\noextras|\m{lang}. +unselected: |\noextras<language>|. \begin{note} - These macros (|\captions|\m{lang}, |\extras|\m{lang}) may be + These macros (|\captions<language>|, |\extras<language>|) may be redefined, but \textit{must not} be used as such -- they just pass information to \babel{}, which executes them in the proper context. \end{note} @@ -2432,13 +2771,54 @@ is by means of |\babelprovide|, described below in depth. So, something like: \begin{verbatim} \usepackage[danish]{babel} -\babelprovide[captions=da, hyphenrules=nohyphenation]{danish} +\babelprovide[_hyphenrules=nohyphenation_]{danish} +\end{verbatim} +first loads |danish.ldf|, and then prevents hyphenation for this +locale. The rest of the language definitions are not touched. Without +the optional argument it just loads some additional tools if provided +by the |ini| file, like extra counters. + +\subsection{Modifiers} + +\New{3.9c} The basic behavior of some languages can be modified when +loading \babel{} by means of \textit{modifiers}. They are set after +the language name, and are prefixed with a dot (only when the language +is set as package option -- neither global options nor the |main| key +accepts them). An example is (spaces are not significant and they can +be added or removed):\footnote{No predefined ``axis'' for modifiers +is provided because languages and their scripts have quite different +needs.} +\begin{verbatim} +\usepackage[latin_.medieval_, spanish_.notilde.lcroman_, danish]{babel} \end{verbatim} -first loads |danish.ldf|, and then redefines the captions for -\texttt{danish} (as provided by the |ini| file) and prevents -hyphenation. The rest of the language definitions are not touched. -Without the optional argument it just loads some additional tools if -provided by the |ini| file, like extra counters. + +Attributes (described below) are considered modifiers, i.e., you can +set an attribute by including it in the list of modifiers. + +\New{3.89} Alternatively, modifiers can be set with a separate option, +with the keyword |modifiers| followed by a dot and the language name +(note the language is not selected or loaded with this option). It is +useful to activate some feature when the language is declared as a +class option: +\begin{verbatim} +\documentclass[spanish]{report} +\usepackage[_modifiers.spanish = notilde.lcroman_]{babel} +\end{verbatim} + +\subsection{Language attributes} + +\Describe{\languageattribute}{\marg{language}} + +This is a user-level command, to be used in the preamble of a +document (after |\usepackage[...]{babel}|), that declares which +attributes are to be used for a given language. It takes two +arguments: the first is the name of the language; the second, +a (list of) attribute(s) to be used. Attributes must be set in the +preamble and only once -- they cannot be turned on and off. +The command checks whether the language is known in this document +and whether the attribute(s) are known for this language. + +\subsection{Casing} \Describe{\BabelUppercaseMapping} {\marg{locale-name}\marg{codepoint}\marg{output}} @@ -2453,9 +2833,9 @@ with \babel. They are the equivalent of |\DeclareUppercaseMapping|, |\DeclareLowercaseMapping|, and |\DeclareTitlecaseMapping| (see \textsf{usrguide.pdf}). The purpose is twofold: (1) a user-friendly way to declare them, because often BCP 47 tags are not known (and sometimes -can be complex); (2) if for some reason the tag changes (eg, you decide +can be complex); (2) if for some reason the tag changes (e.g., you decide to tag |english| as |en-001| instead of |en-US|), the new mappings will -be still assigned to that language. +still be assigned to that language. \begin{example} For Classical Latin (no need to know the tag is \texttt{la-x-classic}): @@ -2470,7 +2850,271 @@ be still assigned to that language. tag. These issues are expected be sorted out in future releases. \end{note} -\subsection{Creating a language} +\subsection{Modifying and adding values to \texttt{ini} files} + +\New{3.39} There is a way to modify or even add values of |ini| files +when they are imported with |\babelprovide| or |provide=|. This can be +used to create private variants easily. All you need is to import the +same |ini| file with a different locale name and different parameters. +Without |import| you may still modify the identification keys. + +Examples of the fine-grained control you have at your disposal are the +following. All of them assume |\usepackage[english]{babel}|. + +\begin{example} + Here is how to change the hyphenation rules because there are several + criteria, or you must follow an editorial style. The following + example just uses the default Spanish rules in English: +\begin{verbatim} +\babelprovide[hyphenrules=spanish]{english} +\end{verbatim} +\end{example} + +\begin{example} + The required native digits are already defined in the corresponding + |ini| files, but they can be modified and even added as shown: +\begin{verbatim} +\babelprovide[numbers/digits.native=abcdefghij]{english} +\end{verbatim} +This example is somewhat absurd, but now |\englishdigits{264}| will +print ‘cge’. (It doesn't work with \pdftex.) +\end{example} + +\begin{example} + Currently the date format can be changed only with imported data, but + with its high level interface it’s quite straightforward: +\begin{verbatim} +\babelprovide[ + import, + date.gregorian/date.long = {[d] ([MMMM]) [y]}] + {english} +\end{verbatim} + Here |[d]| is the day number, |[MMMM]| the month name and |[y]| the + year. It will print something like ‘5 (October) 2024’. +\end{example} + +\begin{example} + To set the hyphen to ‘none’ (only \luatex). +\begin{verbatim} +\babelprovide[typography/prehyphenchar = 0]{english} +\end{verbatim} +This setting \textit{may} work with `xetex`, but getting rid of the +hyphen char in this engine is not trivial, because you must rely on the +font, and not all fonts behave the same. +\end{example} + +\begin{example} +You can define new counters freely, and assign them to |\alph|: +\begin{verbatim} +\babelprovide[ + counters/acute = á é í ó ú, % Define a counter named `acute` + alph = acute % Assign it to \alph + ]{english} +\end{verbatim} +You can choose the name, and instead of `alphabetic` it can be another one. +\end{example} + +\subsection{Hooks} + +\New{3.9a} A hook is a piece of code to be executed at certain +events. Some hooks are predefined when \luatex{} and \xetex{} are +used. + +\New{3.64} This is not the only way to inject code at those points. The +events listed below can be used as a hook name in |\AddToHook| in the +form |babel/<language-name>/<event-name>| (with |*| it’s applied to +all languages), but there is a limitation, because the parameters +passed with the \babel{} mechanism are not allowed. The |\AddToHook| +mechanism does \textit{not} replace the current one in \babel. Its +main advantage is you can reconfigure \babel\ even before loading it. +See the example below. + +\Describe{\AddBabelHook}{\oarg{language}\marg{name}\marg{event}\marg{code}} + +The same name can be applied to several events. Hooks with a certain +\marg{name} may be enabled and disabled for all defined events with +|\EnableBabelHook|\marg{name}, |\DisableBabelHook|\marg{name}. Names +containing the string |babel| are reserved (they are used, for example, +by |\useshortands*| to add a hook for the event |afterextras|). +\New{3.33} They may be also applied to a specific language with the +optional argument; language-specific settings are executed after global +ones. + +Current events are the following; in some of them you can use one to +three \TeX{} parameters (|#1|, |#2|, |#3|), with the meaning given: +\begin{description} +\renewcommand\makelabel[1]{% + \hspace\labelsep\normalfont\ttfamily\color{thered}#1} +\itemsep=-\parskip +\item[adddialect] (language name, dialect name) Used by + \file{luababel.def} to load the patterns if not preloaded. +\item[patterns] (language name, language with encoding) Executed just + after the |\language| has been set. The second argument has the + patterns name actually selected (in the form of either |lang:ENC| or + |lang|). +\item[hyphenation] (language name, language with encoding) Executed + locally just before exceptions given in |\babelhyphenation| are + actually set. +\item[defaultcommands] Used (locally) in |\StartBabelCommands|. +\item[encodedcommands] (input, font encodings) Used (locally) in + |\StartBabelCommands|. Both \luatex{} and \xetex{} make sure the + encoded text is read correctly. +\item[stopcommands] Used to reset the above, if necessary. +\item[write] This event comes just after the switching commands are + written to the |aux| file. +\item[beforeextras] Just before executing |\extras<language>|. This + event and the next one should not contain language-dependent code + (for that, add it to |\extras<language>|). +\item[afterextras] Just after executing |\extras<language>|. For + example, the following deactivates shorthands in all languages: +\begin{verbatim} +\AddBabelHook{noshort}{afterextras}{\languageshorthands{none}} +\end{verbatim} +\item[stringprocess] Instead of a parameter, you can manipulate the + macro |\BabelString| containing the string to be defined with + |\SetString|. For example, to use an expanded version of the string + in the definition, write: +\begin{verbatim} +\AddBabelHook{myhook}{stringprocess}{% + \protected@edef\BabelString{\BabelString}} +\end{verbatim} +\item[initiateactive] (char as active, char as other, original char) + \New{3.9i} Executed just after a shorthand has been `initiated'. The three + parameters are the same character with different catcodes: active, + other (|\string|'ed) and the original one. +\item[afterreset] \New{3.9i} Executed when selecting a language just after + |\originalTeX| is run and reset to its base value, before executing + |\captions<language>| and |\date<language>|. +\item[begindocument] \New{3.88} Executed before the code written by + |ldf| files with |\AtBeginDocument|. The optional argument with the + language in this particular case is the language that wrote the code. + The special value |/| means ‘return to the core \babel{} definitions’ + (in other words, what follows hasn’t been written by any language). +\item[foreign] \New{24.8} Executed by |\foreignlanguage| after the + language has been set up and just before typesetting the text from the + second argument. Its main purpose it to wrap the text with some + code, with the help of |\BabelWrapText|. For example, with: +\begin{verbatim} +\AddBabelHook{one}{foreign}{\BabelWrapText{\textit{##1}} +\AddBabelHook{two}{foreign}{\BabelWrapText{\parse{##1}} +\end{verbatim} +the text becomes |\textit{\parse{<text>}}|. + +\end{description} + +Four events are used in \file{hyphen.cfg}, which are handled in a +quite different way for efficiency reasons -- unlike the precedent +ones, they only have a single hook and replace a default definition. +\begin{description} +\renewcommand\makelabel[1]{% + \hspace\labelsep\normalfont\ttfamily\color{thered}#1} +\itemsep=-\parskip +\item[everylanguage] (language) Executed before every language patterns + are loaded. +\item[loadkernel] (file) By default just defines a few basic commands. + It can be used to define different versions of them or to load a file. +\item[loadpatterns] (patterns file) Loads the patterns file. Used by + \file{luababel.def}. +\item[loadexceptions] (exceptions file) Loads the exceptions + file. Used by \file{luababel.def}. +\end{description} + +\begin{example} +The generic unlocalized \LaTeX{} hooks are predefined, so that you can +write: +\begin{verbatim} +\AddToHook{babel/*/afterextras}{\frenchspacing} +\end{verbatim} +which is executed always after the extras for the language being +selected (and just before the non-localized hooks defined with +|\AddBabelHook|). + +In addition, locale-specific hooks in the form +|babel/<language-name>/<event-name>| are \textit{recognized} +(executed just before the localized \babel{} hooks), but they are +\textit{not predefined}. You have to do it yourself. For example, to +set |\frenchspacing| only in |bengali|: +\begin{verbatim} +\ActivateGenericHook{babel/bengali/afterextras} +\AddToHook{babel/bengali/afterextras}{\frenchspacing} +\end{verbatim} +\end{example} + +\subsection{Manage auxiliary files} + +\Describe{\BabelContentsFiles}{} +\New{3.9a} This macro contains a list of ``toc'' types requiring a +command to switch the language. Its default value is |toc,lof,lot|, but +you may redefine it with |\renewcommand| to add further types in case +you need or there is a package enabling additional files, e.g., for +theorems, algorithms, notation (it's up to you to make sure no toc type +is duplicated). + +\subsection{Code based on the selector} + +\Describe{\IfBabelSelectorTF}{\marg{selectors}\marg{true}\marg{false}} + +\New{3.67} Sometimes a different setup is desired depending on the +selector used. Values allowed in \m{selectors} are |select|, |other|, +|foreign|, |other*| (and also |foreign*| for the tentative starred +version), and it can consist of a comma-separated list. For example: +\begin{verbatim} +\IfBabelSelectorTF{other, other*}{A}{B} +\end{verbatim} +is true with any of these two environment selectors. + +Its natural place of use is in hooks or in |\extras<language>|. + +\subsection{Presets} + +\New{24.12} Apart from configuration files, which are loaded before the +locale files, you can preset some options even before loading \babel. +One on the aims of this feature is to ease the integration with +automated document generation or conversion workflows. + +\Describe{\AddToHook\{babel/presets\}}{\marg{settings}} + +This \LaTeX{} hook is executed just before locale files (either +\texttt{ini} or \texttt{ldf}) are loaded. It’s in fact, similar to the +config files, but it’s executed a little later and there is no need for +a separate file. The following command has been devised for this hook, +but other candidates are |\AfterBabelLanguage| and |\DeclareOption| +(although the latter can be somewhat dangerous). + +Note these declarations are valid ‘just in case’. If \babel{} is not +loaded, they are ignored. + +\Describe{\PassOptionsToLocale}{\marg{option-list}\marg{locale-name}} + +Its purpose is what its name suggests, and it was devised to be used +with the previous hook. + +\begin{example} + You are writing a class and expect lazy loading of secondary + languages. You also want to make sure |french|, if used, activates + its rules for punctuation spacing, and |malayalam|, if used, maps + digits to the native ones (with \luatex): +\setengine{luatex} +\begin{verbatim} +\AddToHook{babel/presets}{% + \PassOptionsToLocale{transforms=punctuation.space}{french}% + \PassOptionsToLocale{mapdigits}{malayalam}} +\end{verbatim} + If you want to take a step further and force \babel{} to always use + |ini| files in all secondary languages, you can resort to the \LaTeX{} + mechanism to pass options to packages: +\begin{verbatim} + \PassOptionsToPackage{provide+=*}{babel} +\end{verbatim} +\end{example} + +\begin{note} + Remember localized fonts are preset, too, with lazy loading. In + the previous example you can set, for example, + |\babelfont[malayalam]{rm}{FreeSerif}|. +\end{note} + +\section{Creating a language} \New{3.10} And what if there is no style for your language or none fits your needs? You may then define quickly a language with the help of the @@ -2494,7 +3138,7 @@ to OpenType language and script. Conveniently, some options allow to fill the language, and \babel{} warns you about what to do if there is a missing string. Very likely -you will find alerts like that in the |log| file: +you will find alerts like this in the |log| file: \begin{verbatim} Package babel Warning: \chaptername not set for 'mylang'. Please, (babel) define it after the language has been loaded @@ -2513,7 +3157,7 @@ languages loaded on the fly are not yet available in the preamble. \babelprovide{arhinish} \setlocalecaption{arhinish}{chapter}{Chapitula} \setlocalecaption{arhinish}{refname}{Refirenke} -\renewcommand\arhinishhyphenmins{22} +\babelhyphenmins[arhinish]{2}{2} \end{verbatim} \end{example} @@ -2528,14 +3172,15 @@ languages loaded on the fly are not yet available in the preamble. Blah \foreignlanguage{ipa}{ɔːlˈðəʊ} Blah. \end{document} \end{verbatim} - Then you can define shorthands, transforms (with \luatex), and so on. + Then you can define shorthands, transforms (with \luatex), interchars + (with \xetex) and so on, specific to this new ‘language’. \end{example} \begin{example} Locales with names based on BCP 47 codes can be created with something like: \begin{verbatim} - \babelprovide[import=en-US]{enUS} + \babelprovide[import=en-US]{en-US} \end{verbatim} Note, however, mixing ways to identify locales can lead to problems. For example, is \verb|yi| the name of the language spoken by the Yi @@ -2549,43 +3194,32 @@ necessary. If the language has been loaded as an argument in |\documentclass| or |\usepackage|, then |\babelprovide| redefines the requested data. -\Describe{import=}{\meta{language-tag}} -\New{3.13} Imports data from an |ini| file, including captions and date -(also line breaking rules in newly defined languages). For example: -\begin{verbatim} -\babelprovide[_import=hu_]{hungarian} -\end{verbatim} -Unicode engines load the UTF-8 variants, while 8-bit engines load the -LICR (ie, with macros like |\'| or |\ss|) ones. - -\New{3.23} It may be used without a value, and that is often the -recommended option. In such a case, the |ini| file set in the -corresponding |babel-<language>.tex| (where |<language>| is the last -argument in |\babelprovide|) is imported. See the list of recognized -languages above. So, the previous example is best written as: +\Describe{import=}{\meta{locale-tag}} The |<language-tag>| is optional. +It imports the full data from the |ini| file corresponding to the locale +being loaded, as set in |babel-<locale>.tex| (where |<locale>| is the +last argument in |\babelprovide|), including captions and date (and +also line breaking rules in newly defined languages). Unicode engines +load the UTF-8 variants, while 8-bit engines load the LICR (i.e., with +macros like |\'| or |\ss|) ones. + +However, in some cases you may want to load a different |ini| file. In +such a case, you can set its value. + +\begin{example} + For example, the locale |ar-DZ| is named |arabic-algeria|. You may + prefer the shorter name |arabic| if there are no conflicts: \begin{verbatim} -\babelprovide[_import_]{hungarian} +\babelprovide[_import=ar-DZ_]{arabic} \end{verbatim} - -There are 380 |ini| files for about 300 languages, with data taken from -the |ldf| files and the CLDR provided by Unicode. Not all languages in -the latter are complete, and therefore neither are the |ini| files. A -few languages may show a warning about the current lack of suitability -of some features. +\end{example} Besides |\today|, this option defines an additional command for dates: |\<language>date|, which takes three arguments, namely, year, month and day numbers. In fact, |\today| calls |\<language>today|, which in turn calls |\<language>date{\the\year}{\the\month}{\the\day}|. \New{3.44} -More convenient is usually |\localedate|, with prints the date for the +More convenient is usually |\localedate|, which prints the date for the current locale. -\Describe{captions=}{\meta{language-tag}} -Loads only the strings. For example: -\begin{verbatim} -\babelprovide[_captions=hu_]{hungarian} -\end{verbatim} - \Describe{hyphenrules=}{\meta{language-list}} With this option, with a space-separated list of hyphenation rules, \babel{} assigns to the language the first valid hyphenation rules in the list. For example: @@ -2613,11 +3247,10 @@ list is empty). alternative to |justification=unhyphenated|. \Describe{main}{} This valueless option makes the language the main one -(thus overriding that set when \babel\ is loaded). Only in newly defined -languages. +(thus overriding that set when \babel\ is loaded). \begin{example} - Let's assume your document (\xetex{} or \luatex{}) is mainly in - Polytonic Greek with but with some sections in Italian. Then, the + Let's assume your document (\luatex{} or \xetex{}) is mainly in + Polytonic Greek but with some sections in Italian. Then, the first attempt should be: \begin{verbatim} \usepackage[italian, greek.polutoniko]{babel} @@ -2626,7 +3259,7 @@ languages. \begin{verbatim} \usepackage[italian, polytonicgreek, provide=*]{babel} \end{verbatim} -Remerber there is an alternative syntax for the latter: +Remember there is an alternative syntax for the latter: \begin{verbatim} \usepackage[italian]{babel} \babelprovide[import, main]{polytonicgreek} @@ -2637,7 +3270,7 @@ there are only a few word in this language (see~\ref{mostlymono}). \end{example} \Describe{script=}{\meta{script-name}} -\New{3.15} Sets the script name to be used by \textsf{fontspec} (eg, +\New{3.15} Sets the script name to be used by \textsf{fontspec} (e.g., |Devanagari|). Overrides the value in the |ini| file. If \textsf{fontspec} does not define it, then \babel{} sets its tag to that provided by the |ini| file. This value is particularly important @@ -2645,7 +3278,7 @@ because it sets the writing direction, so you must use it if for some reason the default value is wrong. \Describe{language=}{\meta{language-name}} \New{3.15} -Sets the language name to be used by \textsf{fontspec} (eg, |Hindi|). +Sets the language name to be used by \textsf{fontspec} (e.g., |Hindi|). Overrides the value in the |ini| file. If \textsf{fontspec} does not define it, then \babel{} sets its tag to that provided by the |ini| file. Not so important, but sometimes still relevant. @@ -2655,7 +3288,7 @@ See the next section. \Describe{Alph=}{\meta{counter-name}} Same for |\Alph|. -\Describe{casing}{\meta{rules}} \New{3.90} Selects the casing rules in a few +\Describe{casing=}{\meta{rules}} \New{3.90} Selects the casing rules in a few languages. The first ones are predefined by \LaTeX{} (see \textsf{interface3.pdf}), while the following are defined by \babel: \begin{description} @@ -2666,9 +3299,10 @@ languages. The first ones are predefined by \LaTeX{} (see \item[Greek] |iota| converts the \textit{ypogegrammeni} (subscript muted iota) to capital iota when uppercasing. \item[Latin] |nouv| in |classicallatin| and |medievallatin| reverts - the default rules, which maps u ↔ V; |uv| in |ecclesianticallatin| - and the basic |latin| locale applies the map u ↔ V (by default it’s - u ↔ U and v ↔ V). + the default rules, which maps u $\leftrightarrow$ V; |uv| in + |ecclesianticallatin| and the basic |latin| locale applies the map + u $\leftrightarrow$ V (by default it’s u $\leftrightarrow$ U and v + $\leftrightarrow$ V). \end{description} \begin{example} For the latter: @@ -2690,20 +3324,31 @@ cases. \Describe{onchar=}{\texttt{ids} $\string|$ \texttt{fonts} $\string|$ \texttt{letters}} + \New{3.38} This option is much like an ‘event’ called when a character belonging to the script of this locale is found (as its name implies, -it acts on characters, not on spaces). There are currently two -‘actions’, which can be used at the same time (separated by a space): -with |ids| the |\language| and the |\localeid| are set to the values of -this locale; with |fonts|, the fonts are changed to those of this -locale (as set with |\babelfont|). Characters can be added or modified with -|\babelcharproperty|. - -\New{3.81} Option |letters| restricts the ‘actions’ to letters, in the -\TeX{} sense (i.~e., with catcode 11). Digits and punctuation are then -considered part of current locale (as set by a selector). This option -is useful when the main script in non-Latin and there is a secondary -one whose script is Latin. +it acts on characters, not on spaces). + +This option is particularly useful in pure Unicode multilingual text, +because you can intermingle with no explicit markup differents scripts, +each of which with its own hyphenation rules and font, and even its +characteristic writing direction. + +There are currently 3 ‘actions’, which can be used at the same time +(separated by spaces): +\begin{itemize} +\item With |ids|, both |\language| and |\localeid| are set to the values + associated with this locale, affecting the hyphenation rules, as well + as any transforms declared for it. +\item With |fonts|, the fonts are switched to those specified for this + locale (as set with |\babelfont|). Characters assigned to a locale can + be customized with |\babelcharproperty|. +\item \New{3.81} Option |letters| restricts the ‘actions’ to letters, in + the \TeX{} sense (i.e., with catcode 11). Digits and punctuation are + then considered part of current locale (as set by a selector). This + option is useful when the main script is non-Latin and there is a + secondary one whose script is Latin. +\end{itemize} \begin{note} An alternative approach with \luatex{} and Harfbuzz is the font @@ -2724,24 +3369,255 @@ one whose script is Latin. complex. Several criteria are possible, like the main language (the default in \babel), the first letter in the paragraph, or the surrounding letters, among others, but even so manual switching can - be still necessary. + still be necessary. \end{note} -\Describe{intraspace=}{\meta{base} \meta{shrink} \meta{stretch}} -Sets the interword space for the writing system of the language, in em -units (so, |0 .1 0| is |0em plus .1em|). Like |\spaceskip|, the em unit -applied is that of the current text (more precisely, the previous -glyph). Currently used only in Southeast Asian scripts, like Thai, and -CJK. - -\Describe{intrapenalty=}{\meta{penalty}} -Sets the interword penalty for the writing system of this language. -Currently used only in Southeast Asian scripts, like Thai. Ignored if 0 -(which is the default value). - \Describe{transforms=}{\meta{transform-list}} See section~\ref{transforms}. +\Describe{interchar=}{\meta{interchar-list}} +See section~\ref{interchar}. + +\begin{note} + (1) If you need shorthands, you can define them with |\useshorthands| + and |\defineshorthand| as described above. (2) Captions and |\today| + are ``ensured'' with |\babelensure| (this is the default in + |ini|-based languages). +\end{note} + +\begin{example} When creating a locale from another locale, you may want +to reset some properties, like the BCP 47 tags. Here is an example of +how to do it: +\begin{verbatim} +\babelprovide{spanish} % import=es by default +\babelprovide[ + import=es, + _identification/tag.bcp47 = es-x-medieval_, + _identification/extension.x.tag.bcp47 = medieval_] + {medievalspanish} +\end{verbatim} +\end{example} + +\section{Locale features} + +\subsection{Hyphenation and line breaking – 1. Commands} + +\Babel{} deals with three kinds of line breaking rules: Western, +typically the LGC group, South East Asian, like Thai, and CJK, but +support depends on the engine: \textsf{pdftex} only deals with the +former, \xetex{} also with the second one (although in a limited way) +and CJK, while \luatex{} provides basic rules for all of them, as well +as additional rules (like Uyghur and Tibetan). With \luatex{} there are +also tools for non-standard hyphenation and line breaking rules, +explained in the next section. + +\Describe{\babelhyphenation}{\texttt{[}\langlist\texttt{]}% + \marg{exceptions}} + +\New{3.9a} Sets hyphenation exceptions for the languages given +or, without the optional argument, for \textit{all} languages (e.g., +proper nouns or common loan words, and of course monolingual +documents). Multiple declarations work much like |\hyphenation| (last +wins), but language exceptions take precedence over global ones. + +It can be used only in the preamble, and exceptions are set when the +language is first selected, thus taking into account changes of +|\lccodes|'s done in |\extras<language>| as well as the language-specific +encoding (not set in the preamble by default). For example: +\begin{verbatim} +\babelhyphenation{Wal-hal-la Dar-bhan-ga} +\end{verbatim} + +Listed words are saved expanded and therefore it relies on the +LICR\@. Of course, it also works without the LICR if the input and the +font encodings are the same, like in Unicode based engines. + +\begin{note} + Using |\babelhyphenation| with Southeast Asian scripts is mostly + pointless. But with |\babelpatterns| (below) you may fine-tune line + breaking (only \luatex). For example: +\begingroup +\catcode`@=13 +\def@#1@{{\fontspec{Loma}#1}} +\begin{verbatim} +\babelpatterns[thai]{@ศึก@2@ษา@} +\end{verbatim} +\endgroup + Even if there are no patterns for the language, you can add at least + some typical cases. +\end{note} + +\begin{note} + Use |\babelhyphenation| instead of |\hyphenation| to set hyphenation + exceptions in the preamble before any language is explicitly set with + a selector. In the preamble the hyphenation rules are not always + fully set up and an error can be raised. +\end{note} + +\Describe{\babelpatterns}{\texttt{[}\langlist\texttt{]}% + \marg{patterns}} + +\New{3.9m} \textit{In \textsf{luatex} only},\footnote{With +\textsf{luatex} exceptions and patterns can be modified almost +freely. However, this is very likely a task for a separate package +and \texttt{babel} only provides the most basic tools.} adds or +replaces patterns for the languages given or, without the optional +argument, for \textit{all} languages. If a pattern for a certain +combination already exists, it gets replaced by the new one. + +It can be used only in the preamble, and patterns are added when the +language is first selected, thus taking into account changes of +|\lccodes|'s done in |\extras<language>| as well as the language-specific +encoding (not set in the preamble by default). Multiple +|\babelpatterns|'s are allowed. + +Listed patterns are saved expanded and therefore it relies on the +LICR\@. Of course, it also works without the LICR if the input and the +font encodings are the same, like in Unicode based engines. + +\New{3.31} (Only \luatex.) With |\babelprovide| and |import|ed CJK +languages, a simple generic line breaking algorithm (push-out-first) is +applied, based on a selection of the Unicode rules (\New{3.32} it is +disabled in verbatim mode, or more precisely when the hyphenrules +are set to |nohyphenation|). It can be activated alternatively by +setting explicitly the |intraspace|. + +\New{3.27} Interword spacing for Thai, Lao and Khmer is activated +automatically if a language with one of those scripts is loaded with +|\babelprovide|. See the sample on the \babel{} repository. With both +Unicode engines, spacing is based on the ``current'' em unit (the size +of the previous char in \luatex, and the font size set by the last +|\selectfont| in \xetex). + +\begin{note} + With Unicode engines, a line break can happen just before an explicit + combining char (e.g., \textit{\~{g}}, used in Guarani and Filipino, is + not included as a combined char and it’s represented in Unicode as + |U+0067|~|U+0303|. This issue is not directly related to \babel, but + to the hyphenation patterns and/or the font renderer. However, at + least with \luatex{} there is a workaround (change the language name + to what you are using): +\begin{verbatim} +\babelposthyphenation{guarani}{ | [{0300}-{036F}] }{ remove, {} } +\end{verbatim} +The Lua pattern means ‘a discretionary followed by a character in the +range |U+0300|--|U+0367| (which contains combining chars)’. An +alternative to a transform is |\babelpatterns|. +\end{note} + +\Describe{\babelhyphenmins}{% + \optstar\texttt{[}\langlist\texttt{]}% + \marg{left}\marg{right}\oarg{hyphenationmin}} + +\New{24.10} See the news page for the rationale for this command. It +sets the corresponding values for the given languages (all languages +without the optional argument). With the star, the values are also +applied immediately (the optional argument and the star are currently +incompatible). The optional argument is available only in \luatex. +\begin{example} +You are typesetting a book with wide lines and want to limit the +number of hyphens in all languages: +\begin{verbatim} + \babelhyphenmins{3}{4} +\end{verbatim} +But there is also some 3-column text and you want to be more flexible: +\begin{verbatim} + \begin{multicols}{3} + \babelhyphenmins*{2}{3} + ... + \end{multicols} +\end{verbatim} +\end{example} + +\Describe{\babelhyphen}{\optstar\marg{type}} +\DescribeOther{\babelhyphen}{\optstar\marg{text}} + +\New{3.9a} It is customary to classify hyphens in two types: (1) +\textit{explicit} or \textit{hard hyphens}, which in \TeX\ are +entered as \verb|-|, and (2) \textit{optional} or \textit{soft +hyphens}, which are entered as \verb|\-|. Strictly, a \textit{soft +hyphen} is not a hyphen, but just a breaking opportunity or, in +\TeX\ terms, a ``discretionary''; a \textit{hard hyphen} is a hyphen +with a breaking opportunity after it. A further type is a +\textit{non-breaking hyphen}, a hyphen without a breaking +opportunity. + +In \TeX, \verb|-| and \verb|\-| forbid further breaking opportunities +in the word. This is the desired behavior very often, but not always, +and therefore many languages provide shorthands for these +cases. Unfortunately, this has not been done consistently: for +example, \verb|"-| in Dutch, Portuguese, Catalan or Danish is a hard +hyphen, while in German, Spanish, Norwegian, Slovak or Russian it is a +soft hyphen. Furthermore, some of them even redefine |\-|, so that you +cannot insert a soft hyphen without breaking opportunities in the rest +of the word. + +Therefore, some macros are provided with a set of basic ``hyphens'' +which can be used by themselves, to define a user shorthand, or even +in language files. +\begin{itemize} +\item |\babelhyphen{soft}| and |\babelhyphen{hard}| are self + explanatory. +\item |\babelhyphen{repeat}| inserts a hard hyphen which is repeated + at the beginning of the next line, as done in languages like + Polish, Portuguese and Spanish. +\item |\babelhyphen{nobreak}| inserts a hard hyphen without a break + after it (even if a space follows). +\item |\babelhyphen{empty}| inserts a break opportunity without + a hyphen at all. +\item |\babelhyphen|\marg{text} is a hard ``hyphen'' using \m{text} + instead. A typical case is |\babelhyphen{/}|. +\end{itemize} +With all of them, hyphenation in the rest of the word is enabled. If +you don't want to enable it, there is a starred counterpart: +|\babelhyphen*{soft}| (which in most cases is equivalent to the +original |\-|), |\babelhyphen*{hard}|, etc. + +Note |hard| is also good for isolated prefixes (e.g., \textit{anti-}) +and |nobreak| for isolated suffixes (e.g., \textit{-ism}), but in both +cases |\babelhyphen*{nobreak}| is usually better. + +There are also some differences with \LaTeX: (1) the character used is +that set for the current font, while in \LaTeX{} it is hardwired to +|-| (a typical value); (2) the hyphen to be used in fonts with a +negative |\hyphenchar| is |-|, as in \LaTeX, but it can be changed to +another value by redefining |\babelnullhyphen|; (3) a break after the +hyphen is forbidden if preceded by a glue ${>}0$~pt (at the beginning +of a word, provided it is not immediately preceded by, say, a +parenthesis). + +\Describe{\begin\menv{hyphenrules}}{\marg{language}\Eenv{hyphenrules}} + +The environment \Lenv{hyphenrules} can be used to select \emph{only} the +hyphenation rules to be used (it can be used as command, too). This can +for instance be used to select ‘nohyphenation’, provided that in +\file{language.dat} the ‘language’ \textsf{nohyphenation} is defined by +loading \file{zerohyph.tex}. It deactivates language shorthands, too +(but not user shorthands). + +Except for these simple uses, |hyphenrules| is deprecated and +|otherlanguage*| (the starred version) is preferred, because the former +does not take into account possible changes in encodings of characters +like, say, |'| done by some languages (e.g., \textsf{italian}, +\textsf{french}, \textsf{ukrainian}). + +\begin{note} + For the hyphenation to work correctly, lccodes cannot change, because + \TeX{} only takes into account the values when the paragraph is + hyphenated, i.e., when it has been finished.\footnote{This explains + why \LaTeX{} assumes the lowercase mapping of T1 and does not provide + a tool for multiple mappings. Unfortunately, \cs{savinghyphcodes} is + not a solution either, because lccodes for hyphenation are frozen in + the format and cannot be changed.} So, if you write a chunk of French + text with |\foreignlanguage|, the apostrophes might not be taken into + account. This is a limitation of \TeX, not of \babel. Alternatively, + you may use |\useshorthands| to activate |'| and |\defineshorthand|, + or redefine |\textquoteright| (the latter is called by the non-ASCII + right quote). +\end{note} + +\subsection{Hyphenation and line breaking – 2. ‘Provide’ options} + \Describe{justification=}{\texttt{unhyphenated} $\string|$ \texttt{kashida} $\string|$ \texttt{elongated} $\string|$ \texttt{padding}} @@ -2749,14 +3625,14 @@ See section~\ref{transforms}. dependent, so that they will not be applied to other languages. The first one (|unhyphenated|) activates a line breaking mode that -allows spaces to be stretched to arbitrary amounts. Although for -European standards the result may look odd, in some writing systems, -like Malayalam and other Indic scripts, this has been the customary -(although not always the desired) practice. Because of that, no locale -sets currently this mode by default (Amharic is an exception). Unlike -|\sloppy|, the |\hfuzz| and the |\vfuzz| are not changed, because this -line breaking mode is not really ‘sloppy’ (in other words, overfull -boxes are reported as usual). +allows breaks only at spaces, which can be stretched to arbitrary +amounts. Although for European standards the result may look odd, in +some writing systems, like Malayalam and other Indic scripts, this has +been the customary (although not always the desired) practice. Because +of that, no locale enables currently this mode by default (Amharic is an +exception). Unlike |\sloppy|, the |\hfuzz| and the |\vfuzz| are not +changed, because this line breaking mode is not really ‘sloppy’ (in +other words, overfull boxes are reported as usual). The second and the third are for the Arabic script. It sets the linebreaking and justification method, which can be based on the @@ -2775,19 +3651,323 @@ It’s still somewhat experimental. Again, there is an explanation in the \New{3.59} Just a synonymous for \texttt{justification}. Depending on the language, this name can make more sense. +\Describe{intraspace=}{\meta{base} \meta{shrink} \meta{stretch}} +Sets the interword space for the writing system of the language, in em +units (so, |0 .1 0| is |0em plus .1em|). Like |\spaceskip|, the em unit +applied is that of the current text (more precisely, the previous +glyph). Currently used only in Southeast Asian scripts, like Thai, and +CJK. + +\Describe{intrapenalty=}{\meta{penalty}} +Sets the interword penalty for the writing system of this language. +Currently used only in Southeast Asian scripts, like Thai. If 0, which +is the default value, no penalty is inserted. + +\subsection{Shorthands – 1. Commands} + +A \textit{shorthand} is a sequence of one or two characters that +expands to arbitrary \TeX{} code. + +Shorthands can be used for different kinds of things; for example: +(1) in some languages shorthands such as |"a| are defined to be able +to hyphenate the word if the encoding is |OT1|; (2) in some languages +shorthands such as |!| are used to insert the right amount of white +space; (3) several kinds of discretionaries and breaks can be inserted +easily with |"-|, |"=|, etc. + +The package \textsf{inputenc} as well as \luatex{} and \xetex{} have +alleviated entering non-ASCII characters, but minority languages and +some kinds of text can still require characters not directly available +on the keyboards (and sometimes not even as separated or precomposed +Unicode characters). As to the point 2, now \textsf{pdfTeX} provides +|\knbccode|, and \luatex{} can manipulate the glyph list. Tools for +point 3 can still be very useful in general. + +There are four levels of shorthands: \textit{user}, \textit{language}, +\textit{system}, and \textit{language user} (by order of precedence). +In most cases, you will use only shorthands provided by languages. + +\begin{note} Keep in mind the following: +\begin{enumerate} +\item Activated chars used for two-char shorthands cannot be followed + by a closing brace |}| and the spaces following are gobbled. With + one-char shorthands (e.g.,~|:|), they are preserved. +\item If on a certain level (system, language, user, language user) + there is a one-char shorthand, two-char ones starting with that char + and on the same level are ignored. +\item Since they are active, a shorthand cannot contain the same + character in its definition (except if deactivated with, e.g., + |\string|). +\end{enumerate} +\end{note} + +\begin{troubleshooting} +\trouble{Argument of \textbackslash language@active@arg" +has an extra \textbraceright} +A typical error when using shorthands is the following: +\begin{verbatim} +! Argument of \language@active@arg" has an extra }. +\end{verbatim} +It means there is a closing brace just after a shorthand, which is not +allowed (e.g.,~|"}|). Just add |{}| after (e.g.,~|"{}}|). +\end{troubleshooting} + +\Describe{\shorthandon}{\marg{shorthands-list}} +\DescribeOther{\shorthandoff}{\optstar\marg{shorthands-list}} +It is sometimes necessary to switch a shorthand +character off temporarily, because it must be used in an +entirely different way. For this purpose, the user commands +|\shorthandoff| and |\shorthandon| are provided. They each take a +list of characters as their arguments. + +The command |\shorthandoff| sets the |\catcode| for each of the +characters in its argument to other (12); the command |\shorthandon| +sets the |\catcode| to active (13). Both commands work on only `known' +shorthand characters, and an error will be raised otherwise. You can +check if a character is a shorthand with |\ifbabelshorthand| (see +below). + +\New{3.9a} However, |\shorthandoff| does not behave as +you would expect with characters like |~| or |^|, because they +usually are not ``other''. For them |\shorthandoff*| is provided, +so that with +\begin{verbatim} +\shorthandoff*{~^} +\end{verbatim} +|~| is still active, very likely with the meaning of a non-breaking +space, and |^| is the superscript character. The catcodes used are +those when the shorthands are defined, usually when language files are +loaded. + +If you do not need shorthands, or prefer an alternative approach of +your own, you may want to switch them off with the package option +|shorthands=off|, as described below. + +\begin{warning} + It is worth emphasizing that these macros are meant for temporary changes. + Whenever possible, shorthands must be always enabled or disabled. +\end{warning} + +\Describe{\useshorthands}{\optstar\marg{char}} + +It initiates the definition of user-defined +shorthand sequences. It has one argument, the character that starts +these personal shorthands. + +\New{3.9a} User shorthands are not always alive, as they may +be deactivated by languages (for example, if you use |"| for your user +shorthands and switch from \textsf{german} to \textsf{french}, they +stop working). Therefore, a starred version +|\useshorthands*|\marg{char} is provided, which makes sure shorthands +are always activated. + +If the package option |shorthands| is used, you must include any +character to be activated with |\useshorthands|. + +\Describe\defineshorthand{\texttt{[}\langlist\texttt{]}% + \marg{shorthand}\marg{code}} + +It takes two arguments: the first is a one- or two-character shorthand +sequence, and the second is the code the shorthand should expand to. + +\New{3.9a} An optional argument allows to (re)define language and +system shorthands (some languages do not activate shorthands, so you +may want to add |\languageshorthands|\marg{language} to the corresponding +|\extras<language>|, as explained below). By default, user shorthands +are (re)defined. + +User shorthands override language ones, which in turn override system +shorthands. Language-dependent user shorthands take precedence over +``normal'' user shorthands. + +\begin{example} + Let's assume you want a unified set of shorthands for discretionaries + (languages do not define shorthands consistently, and |"-|, |\-|, + |"=| have different meanings). You can start with, say: +\begin{verbatim} +\useshorthands*{"} +\defineshorthand{"*}{\babelhyphen{soft}} +\defineshorthand{"-}{\babelhyphen{hard}} +\end{verbatim} + However, the behavior of hyphens is language-dependent. For example, in + languages like Polish and Portuguese, a hard hyphen inside compound + words are repeated at the beginning of the next line. You can then + set: +\begin{verbatim} +\defineshorthand[*polish,*portuguese]{"-}{\babelhyphen{repeat}} +\end{verbatim} + Here, options with |*| set a language-dependent user shorthand, which + means the generic declarations above for |"-| apply to all languages + \textit{except} |polish| and |portuguese|; without |*| they would + (re)define the language shorthands instead, which are overridden by + user ones. + + Now, you have a single unified shorthand (|"-|), with a + content-based meaning (`compound word hyphen') whose visual behavior + is that expected in each context. +\end{example} + +\Describe{\languageshorthands}{\marg{language}} + +Used to switch the shorthands on the +language level. It takes one argument, the name of a language or +|none| (the latter does what its name suggests).\footnote{Actually, +any name not corresponding to a language group does the same as +\texttt{none}. However, follow this convention because it might be +enforced in future releases of \babel{} to catch possible errors.} +Note that for this to work the language should have been specified as +an option when loading the \babel\ package. For example, you can use +in \textsf{english} the shorthands defined by \textsf{ngerman} with +\begin{verbatim} +\addto\extrasenglish{\languageshorthands{ngerman}} +\end{verbatim} +(You may also need to activate them as user shorthands in the preamble +with, for example, |\useshorthands| or |\useshorthands*|.) + +\begin{example} + Very often, this is a more convenient way to deactivate shorthands + than |\shorthandoff|, for example if you want to define a macro + to ease typing phonetic characters with \textsf{tipa}: +\begin{verbatim} +\newcommand{\myipa}[1]{{_\languageshorthands{none}_\tipaencoding#1}} +\end{verbatim} +\end{example} + +\Describe{\babelshorthand}{\marg{shorthand}} +With this command you can use a shorthand even if (1) not activated in +\texttt{shorthands} (in this case only shorthands for the current +language are taken into account, i.e., not user shorthands), (2) turned +off with |\shorthandoff| or (3) deactivated with the internal +|\bbl@deactivate|; for example, \verb|\babelshorthand{"u}| or +\verb|\babelshorthand{:}|. (You can conveniently define your own +macros, or even your own user shorthands provided they do not overlap.) + +\begin{example} + Since by default shorthands are not activated until + |\begin{document}|, you may use this macro when defining the |\title| + in the preamble: +\begin{verbatim} +\title{Documento científico_\babelshorthand{"-}_técnico} +\end{verbatim} +\end{example} + +\bigskip + +For your records, here is a list of shorthands, but you must double +check them, as they may change:\footnote{Thanks to Enrico Gregorio.} + +\begin{description} +\itemsep=-\parskip +\item[Languages with no shorthands] Croatian, English (any variety), + Indonesian, Hebrew, Interlingua, Irish, Lower Sorbian, Malaysian, + North Sami, Romanian, Scottish, Welsh +\item[Languages with only \texttt{"} as defined shorthand character] + Albanian, Bulgarian, Danish, Dutch, Finnish, German (old and new + orthography, also Austrian), Icelandic, Italian, Norwegian, Polish, + Portuguese (also Brazilian), Russian, Serbian (with Latin script), + Slovene, Swedish, Ukrainian, Upper Sorbian +\item[Basque] |" ' ~| +\item[Breton] |: ; ? !| +\item[Catalan] |" ' `| +\item[Czech] |" -| +\item[Esperanto] |^| +\item[Estonian] |" ~| +\item[French] (all varieties) |: ; ? !| +\item[Galician] |" . ' ~ < >| +\item[Greek] (ancient, polutoniko, only 8-bit \TeX) |~|, (optional, see +the manual for Greek) |;| +\item[Hungarian] |`| +\item[Kurmanji] |^| +\item[Latin] |" ^ =| +\item[Slovak] |" ^ ' -| +\item[Spanish] |" . < > ' ~| +\item[Turkish] |: ! =| +\end{description} +In addition, the \babel{} core declares |~| as a one-char shorthand +which is let, like the standard |~|, to a non breaking space. Actually, +this declaration serves to nothing, but it is preserved for backward +compatibility. + +\Describe\ifbabelshorthand{\marg{character}\marg{true}\marg{false}} + +\New{3.23} Tests if a character has been made a shorthand. + \begin{note} - (1) If you need shorthands, you can define them with |\useshorthands| - and |\defineshorthand| as described above. (2) Captions and |\today| - are ``ensured'' with |\babelensure| (this is the default in - |ini|-based languages). + \catcode`\|=12\relax Both \textsf{ltxdoc} and \textsf{babel} use + \verb|\AtBeginDocument| to change some catcodes, and \babel{} reloads + \textsf{hhline} to make sure \verb|:| has the right one, so if you + want to change the catcode of \verb/|/ it has to be done using the + same method at the proper place, with +\begin{verbatim} +\AtBeginDocument{\DeleteShortVerb{\|}} +\end{verbatim} + \textit{before} loading \babel. This way, when the document begins + the sequence is (1) make \verb/|/ active (\textsf{ltxdoc}); (2) make + it inactive (your settings); (3) make \babel{} shorthands active + (\textsf{babel}); (4) reload \textsf{hhline} (\textsf{babel}, now + with the correct catcodes for \verb/|/ and + \verb|:|).\catcode`\|=\active +\end{note} + +\begin{note} +Using a character mathematically active (i.e., with math code |"8000|) as +a shorthand can make \TeX{} enter in an infinite loop in some rare +cases. (There is a partial solution.) \end{note} +\subsection{Shorthands – 2. Package options} + +\Describe{activeacute}{} +\DescribeOther{activegrave}{} + +For some languages \babel\ supports these options to set |'| and |`|, +respectively, as a shorthand in case it is not done by default. + +\Describe{shorthands=}{\meta{char}\meta{char}... +$\string|$ \texttt{off}} +The only language shorthands activated +are those given, like, e.g.: +\begin{verbatim} +\usepackage[esperanto,french,_shorthands=:;!?_]{babel} +\end{verbatim} +If \verb|'| is included, \texttt{activeacute} is set; if \verb|`| is +included, \texttt{activegrave} is set. Active characters (like +\verb|~|) should be preceded by \verb|\string| (otherwise they will be +expanded by \LaTeX{} before they are passed to the package and +therefore they will not be recognized); however, |t| is provided for +the common case of |~| (as well as |c| for not so common case of the +comma). + +With |shorthands=off| no language shorthands are defined. +As some languages use this mechanism for tools not available +otherwise, a macro \verb|\babelshorthand| is defined, which allows +using them; see above. + +\Describe{safe=}{\texttt{none} $\string|$ \texttt{ref} $\string|$ +\texttt{bib}} Some \LaTeX{} macros are redefined so that using +shorthands is safe. With \texttt{safe=bib} only |\nocite|, |\bibcite| +and |\bibitem| are redefined. With |safe=ref| only |\newlabel|, |\ref| +and |\pageref| are redefined (as well as a few macros from +\textsf{varioref} and \textsf{ifthen}). + +With |safe=none| no macro is redefined. This option is strongly +recommended, because a good deal of incompatibilities and errors are +related to these redefinitions. As of \New{3.34}, in $\varepsilon$-\TeX{} +based engines (i.e., almost every engine except the oldest ones) +shorthands can be used in these macros (formerly you could not). + +\Describe{math=}{\texttt{active} $\string|$ \texttt{normal}} +Shorthands are mainly intended for text, not for math. By setting this +option with the value |normal| they are deactivated in math mode +(default is |active|) and things like |${a'}$| (a closing brace after +a shorthand) are not a source of trouble anymore. + \subsection{Digits and counters} \New{3.20} About thirty |ini| files define a field named |digits.native|. When it is present, two macros are created: -|\<language>digits| and |\<language>counter| (only \xetex{} and -\luatex{}). With the first, a string of ‘Latin’ digits are converted to +|\<language>digits| and |\<language>counter| (only \luatex{} and +\xetex{}). With the first, a string of ‘Latin’ digits are converted to the native digits of that language; the second takes a counter name as argument. With the option |maparabic| in |\babelprovide|, |\arabic| is redefined to produce the native digits (this is done \textit{globally}, @@ -2796,10 +3976,10 @@ well dates do not rely on |\arabic|.) For example: \begin{verbatim} -\babelprovide[import]{telugu} - % Or also, if you want: - % \babelprovide[import, maparabic]{telugu} -\babelfont{rm}{Gautami} % With luatex, better with Harfbuzz +\usepackage[telugu, provide=*]{babel} + % Or also, if you want, with: + % provide={ maparabic } +\babelfont{rm}{Gautami} \begin{document} _\telugudigits{1234}_ _\telugucounter{section}_ @@ -2808,60 +3988,61 @@ _\telugucounter{section}_ Languages providing native digits in all or some variants are: \begin{multicols}{5} +\parindent0pt Arabic\\ -Assamese\\ +Assamese\\ Bangla\\ -Bhojpuri\\ -Bodo\\ +Bhojpuri\\ +Bodo\\ Burmese\\ -Cantonese\\ -Central Kurdish\\ +Cantonese\\ +Central Kurdish\\ Chinese\\ -Dogri\\ -Dzongkha\\ -Gujarati\\ -Haryanvi\\ -Hindi\\ -Hmong Njua\\ +Dogri\\ +Dzongkha\\ +Gujarati\\ +Haryanvi\\ +Hindi\\ +Hmong Njua\\ Kannada\\ -Kashmiri\\ -Khmer\\ +Kashmiri\\ +Khmer\\ Konkani\\ -Korean\\ -Lao\\ -Maithili\\ -Malayalam\\ -Manipuri\\ +Korean\\ +Lao\\ +Maithili\\ +Malayalam\\ +Manipuri\\ Marathi\\ Mazanderani\\ Nepali\\ Northern Kurdish\\ -Northern Luri\\ -Odia\\ +Northern Luri\\ +Odia\\ Pashto\\ Persian\\ Punjabi\\ -Rajasthani\\ -Sanskrit\\ -Santali\\ +Rajasthani\\ +Sanskrit\\ +Santali\\ Sindhi\\ -Tamil\\ +Tamil\\ Telugu\\ -Thai\\ +Thai\\ Tibetan\\ -Urdu\\ +Urdu\\ Uyghur\\ -Uzbek\\ -Vai +Uzbek\\ +Vai \end{multicols} \New{3.30} With \luatex{} there is an alternative approach for mapping digits, namely, |mapdigits|. Conversion is based on the language and it -is applied to the typeset text (not math, PDF bookmarks, etc.) before -bidi and fonts are processed (ie, to the node list as generated by the +is applied to the typeset text (not math, PDF bookmarks, etc.)\ before +bidi and fonts are processed (i.e., to the node list as generated by the \TeX{} code). This means the local digits have the correct bidirectional behavior (unlike |Numbers=Arabic| in \textsf{fontspec}, -which is deprecated). +which is deprecated). Another option is the transform |digits.native|. \begin{note} With \xetex{} you can use the option |Mapping| when defining a @@ -2871,9 +4052,9 @@ which is deprecated). \Describe{\localenumeral}{\marg{style}\marg{number}} \DescribeOther{\localecounter}{\marg{style}\marg{counter}} -\New{3.41} Many `ini` locale files provide information +\New{3.41} Many |ini| locale files provide information about non-positional numerical systems, based on those predefined in -CSS. They only work with \xetex{} and \luatex{} and are fully +CSS\@. They only work with \luatex{} and \xetex{} and are fully expandable (even inside an unprotected |\edef|). Currently, they are limited to numbers below 10000. @@ -2888,7 +4069,7 @@ language, see the list below): \item In |\babelprovide|, as an argument to the keys |alph| and |Alph|, which redefine what |\alph| and |\Alph| print. For example: \begin{verbatim} -\babelprovide[alph=alphabetic]{thai} +\babelprovide[_alph=alphabetic_]{thai} \end{verbatim} \end{itemize} @@ -2978,8 +4159,8 @@ strings for other calendars: |am| (|ethiopic|), |ar| and |ar-|* (|islamic|), |cop| (|coptic|), |fa| (|islamic|, |persian|), |he| (|hebrew|), |hi| (|indian|), |th| (|buddhist|). In the latter case, the three arguments are the year, the month, and -the day in those in the corresponding calendar. They are \textit{not} -the Gregorian data to be converted (which means, say, 13 is a valid +the day for those in the corresponding calendar. They are \textit{not} +the Gregorian date to be converted (which means, say, 13 is a valid month number with |calendar=hebrew| and |calendar=coptic|). However, with the option |convert| it’s converted (using internally the following command). @@ -3040,313 +4221,6 @@ The optional argument converts the given date, in the form calendars accept only a restricted range of years. Please, refer to the page on the news for 3.76 in the \babel{} site for further details. -\subsection{Accessing language info} - -\Describe{\languagename}{} -The control sequence |\languagename| contains the name of the -current language. - -\begin{warning} - Due to some internal inconsistencies in catcodes, it should - \textit{not} be used to test its value. Use \textsf{iflang}, by - Heiko Oberdiek. -\end{warning} - -\Describe{\iflanguage}{\marg{language}\marg{true}\marg{false}} - -If more than one language is used, it might be necessary to know which -language is active at a specific time. This can be checked by a call -to |\iflanguage|, but note here ``language'' is used in the \TeX{} -sense, as a set of hyphenation patterns, and \textit{not} as its -\textsf{babel} name. This macro takes three arguments. The first -argument is the name of a language; the second and third arguments are -the actions to take if the result of the test is true or false -respectively. - -\Describe{\localeinfo}{% - \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}{\marg{field}}} - -\New{3.38} If an |ini| file has been loaded for the current language, -you may access the information stored in it. This macro is fully -expandable, and the available fields are: -\begin{description} -\itemsep=-\parskip -\item[|name.english|] as provided by the Unicode CLDR. -%%% \item[|name.locale|] is the equivalent of |\languagename|. Not yet -%%% activated because the bug in \languagename is far from trivial. -\item[|tag.ini|] is the tag of the |ini| file (the way this - file is identified in its name). -\item[|tag.bcp47|] is the full BCP 47 tag (see the warning below). This - is the value to be used for the ‘real' provided tag (\babel{} may - fill other fields if they are considered necessary). -\item[|language.tag.bcp47|] is the BCP 47 language tag. -\item[|tag.opentype|] is the tag used by OpenType (usually, but not - always, the same as BCP 47). -\item[|script.name|], as provided by the Unicode CLDR. -\item[|script.tag.bcp47|] is the BCP 47 tag of the script - used by this locale. This is a required field for the fonts to be - correctly set up, and therefore it should be always defined. -\item[|script.tag.opentype|] is the tag used by OpenType (usually, - but not always, the same as BCP 47). -\item[|region.tag.bcp47|] is the BCP 47 tag of the region or territory. - Defined only if the locale loaded actually contains it (eg, |es-MX| - does, but |es| doesn’t), which is how locales behave in the CLDR. - \New{3.75} -\item[|variant.tag.bcp47|] is the BCP 47 tag of the variant (in the BCP 47 - sense, like |1901| for German). \New{3.75} -\item[|extension.|\m{s}|.tag.bcp47|] is the BCP 47 value of the - extension whose singleton is \m{s} (currently the recognized - singletons are |x|, |t| and |u|). The internal syntax can be somewhat - complex, and this feature is still somewhat tentative. An example is - \textsf{classicallatin} which sets |extension.x.tag.bcp47| to |classic|. - \New{3.75} -\end{description} - -\begin{note} - Currently, |x| is used for two separate functions, namely, - identifying a \babel{} locale without a BCP47 tag and setting an - alternative set of rules for casing. -\end{note} - -\begin{warning} - \New{3.46} As of version 3.46 |tag.bcp47| returns the full BCP 47 - tag. Formerly it returned just the language subtag, which was clearly - counterintuitive. -\end{warning} - -\New{3.75} Sometimes, it comes in handy to be able to use |\localeinfo| -in an expandable way even if something went wrong (for example, the -locale currently active is undefined). For these cases, |localeinfo*| -just returns an empty string instead of raising an error. Bear in mind -that \babel{}, following the CLDR, may leave the region unset, which -means |\getlocaleproperty*|, described below, is the preferred -command, so that the existence of a field can be checked before. This -also means building a string with the language and the region with -|\localeinfo*{language.tab.bcp47}|\allowbreak |-|\allowbreak -|\localeinfo*{region.tab.bcp47}| is not usually a good idea (because of -the hyphen). - -\Describe{\getlocaleproperty}{% - \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}% - \marg{macro}\marg{locale}\marg{property}} - -\New{3.42} The value of any locale property as set by the |ini| files -(or added/modified with |\babelprovide|) can be retrieved and stored in -a macro with this command. For example, after: -\begin{verbatim} - \getlocaleproperty\hechap{hebrew}{captions/chapter} -\end{verbatim} -the macro |\hechap| will contain the string -{\fontspec[Scale=.87,Script=Hebrew]{Liberation Mono}\textdir TRT פרק}. - -If the key does not exist, the macro is set to |\relax| and an error is -raised. \New{3.47} With the starred version no error is raised, so that -you can take your own actions with undefined properties. - -\Describe{\localeid}{} -Each language in the \babel{} sense has its own unique numeric -identifier, which can be retrieved with |\localeid|. - -The |\localeid| is not the same as the |\language| identifier, which -refers to a set of hyphenation patterns (which, in turn, is just a -component of the line breaking algorithm described in the next -section). The data about preloaded patterns are store in an internal -macro named |\bbl@languages| (see the code for further details), but -note several locales may share a single |\language|, so they are -separated concepts. In \luatex, the |\localeid| is saved in each node -(when it makes sense) as an attribute, too. - -\Describe{\ShowLocaleProperties}{\marg{language}} -\New{3.98} Prints to the |log| file all the loaded key/value pairs from -the |ini| locale file for \meta{language}. - -\Describe{\LocaleForEach}{\marg{code}} -\Babel{} remembers which |ini| files have been loaded. There is a loop -named |\LocaleForEach| to traverse the list, where |#1| is the name of -the current item, so that |\LocaleForEach{\message{ **#1** }}| just -shows the loaded |ini|’s. - -\Describe{ensureinfo=off}{} -\New{3.75} Previously, |ini| files were loaded only with |\babelprovide| -and also when languages are selected if there is a |\babelfont| or they -have not been explicitly declared. Now the |ini| files are loaded (and -therefore the corresponding data) even if these two conditions are not -met (in previous versions you had to enable it with |\BabelEnsureInfo| -in the preamble). Because of the way this feature works, problems are -very unlikely, but there is switch as a package option to turn the new -behavior off (|ensureinfo=off|). - -\subsection{Hyphenation and line breaking} - -\Babel{} deals with three kinds of line breaking rules: Western, -typically the LGC group, South East Asian, like Thai, and CJK, but -support depends on the engine: \textsf{pdftex} only deals with the -former, \xetex{} also with the second one (although in a limited way), -while \luatex{} provides basic rules for the latter, too. With \luatex{} -there are also tools for non-standard hyphenation rules, explained in -the next section. - -\Describe{\babelhyphen}{% - \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{type}} -\DescribeOther\babelhyphen{% - \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{text}} - -\New{3.9a} It is customary to classify hyphens in two types: (1) -\textit{explicit} or \textit{hard hyphens}, which in \TeX\ are -entered as \verb|-|, and (2) \textit{optional} or \textit{soft -hyphens}, which are entered as \verb|\-|. Strictly, a \textit{soft -hyphen} is not a hyphen, but just a breaking opportunity or, in -\TeX\ terms, a ``discretionary''; a \textit{hard hyphen} is a hyphen -with a breaking opportunity after it. A further type is a -\textit{non-breaking hyphen}, a hyphen without a breaking -opportunity. - -In \TeX, \verb|-| and \verb|\-| forbid further breaking opportunities -in the word. This is the desired behavior very often, but not always, -and therefore many languages provide shorthands for these -cases. Unfortunately, this has not been done consistently: for -example, \verb|"-| in Dutch, Portuguese, Catalan or Danish is a hard -hyphen, while in German, Spanish, Norwegian, Slovak or Russian is a -soft hyphen. Furthermore, some of them even redefine |\-|, so that you -cannot insert a soft hyphen without breaking opportunities in the rest -of the word. - -Therefore, some macros are provided with a set of basic ``hyphens'' -which can be used by themselves, to define a user shorthand, or even -in language files. -\begin{itemize} -\item |\babelhyphen{soft}| and |\babelhyphen{hard}| are self - explanatory. -\item |\babelhyphen{repeat}| inserts a hard hyphen which is repeated - at the beginning of the next line, as done in languages like - Polish, Portuguese and Spanish. -\item |\babelhyphen{nobreak}| inserts a hard hyphen without a break - after it (even if a space follows). -\item |\babelhyphen{empty}| inserts a break opportunity without - a hyphen at all. -\item |\babelhyphen|\marg{text} is a hard ``hyphen'' using \m{text} - instead. A typical case is |\babelhyphen{/}|. -\end{itemize} -With all of them, hyphenation in the rest of the word is enabled. If -you don't want to enable it, there is a starred counterpart: -|\babelhyphen*{soft}| (which in most cases is equivalent to the -original |\-|), |\babelhyphen*{hard}|, etc. - -Note |hard| is also good for isolated prefixes (eg, \textit{anti-}) -and |nobreak| for isolated suffixes (eg, \textit{-ism}), but in both -cases |\babelhyphen*{nobreak}| is usually better. - -There are also some differences with \LaTeX: (1) the character used is -that set for the current font, while in \LaTeX{} it is hardwired to -|-| (a typical value); (2) the hyphen to be used in fonts with a -negative |\hyphenchar| is |-|, like in \LaTeX, but it can be changed to -another value by redefining |\babelnullhyphen|; (3) a break after the -hyphen is forbidden if preceded by a glue ${>}0$~pt (at the beginning -of a word, provided it is not immediately preceded by, say, a -parenthesis). - -\Describe\babelhyphenation{\texttt{[}\langlist\texttt{]}% - \marg{exceptions}} - -\New{3.9a} Sets hyphenation exceptions for the languages given -or, without the optional argument, for \textit{all} languages (eg, -proper nouns or common loan words, and of course monolingual -documents). Multiple declarations work much like |\hyphenation| (last -wins), but language exceptions take precedence over global ones. - -It can be used only in the preamble, and exceptions are set when the -language is first selected, thus taking into account changes of -|\lccodes|'s done in |\extras|\m{lang} as well as the language-specific -encoding (not set in the preamble by default). Multiple -|\babelhyphenation|'s are allowed. For example: -\begin{verbatim} -\babelhyphenation{Wal-hal-la Dar-bhan-ga} -\end{verbatim} - -Listed words are saved expanded and therefore it relies on the -LICR. Of course, it also works without the LICR if the input and the -font encodings are the same, like in Unicode based engines. - -\begin{note} - Using |\babelhyphenation| with Southeast Asian scripts is mostly - pointless. But with |\babelpatterns| (below) you may fine-tune line - breaking (only \luatex). Even if there are no patterns for the - language, you can add at least some typical cases. -\end{note} - -\begin{note} - Use |\babelhyphenation| instead of |\hyphenation| to set hyphenation - exceptions in the preamble before any language is explicitly set with - a selector. In the preamble the hyphenation rules are not always - fully set up and an error can be raised. -\end{note} - -\Describe{\begin\menv{hyphenrules}}{\marg{language}\Eenv{hyphenrules}} - -The environment \Lenv{hyphenrules} can be used to select \emph{only} the -hyphenation rules to be used (it can be used as command, too). This can -for instance be used to select ‘nohyphenation’, provided that in -\file{language.dat} the ‘language’ \textsf{nohyphenation} is defined by -loading \file{zerohyph.tex}. It deactivates language shorthands, too -(but not user shorthands). - -Except for these simple uses, |hyphenrules| is deprecated and -|otherlanguage*| (the starred version) is preferred, because the former -does not take into account possible changes in encodings of characters -like, say, |'| done by some languages (eg, \textsf{italian}, -\textsf{french}, \textsf{ukrainian}). - -\Describe{\babelpatterns}{\texttt{[}\langlist\texttt{]}% - \marg{patterns}} - -\New{3.9m} \textit{In \textsf{luatex} only},\footnote{With -\textsf{luatex} exceptions and patterns can be modified almost -freely. However, this is very likely a task for a separate package -and \texttt{babel} only provides the most basic tools.} adds or -replaces patterns for the languages given or, without the optional -argument, for \textit{all} languages. If a pattern for a certain -combination already exists, it gets replaced by the new one. - -It can be used only in the preamble, and patterns are added when the -language is first selected, thus taking into account changes of -|\lccodes|'s done in |\extras|\m{lang} as well as the language-specific -encoding (not set in the preamble by default). Multiple -|\babelpatterns|'s are allowed. - -Listed patterns are saved expanded and therefore it relies on the -LICR. Of course, it also works without the LICR if the input and the -font encodings are the same, like in Unicode based engines. - -\New{3.31} (Only \luatex.) With |\babelprovide| and |import|ed CJK -languages, a simple generic line breaking algorithm (push-out-first) is -applied, based on a selection of the Unicode rules (\New{3.32} it is -disabled in verbatim mode, or more precisely when the hyphenrules -are set to |nohyphenation|). It can be activated alternatively by -setting explicitly the |intraspace|. - -\New{3.27} Interword spacing for Thai, Lao and Khemer is activated -automatically if a language with one of those scripts are loaded with -|\babelprovide|. See the sample on the \babel{} repository. With both -Unicode engines, spacing is based on the ``current'' em unit (the size -of the previous char in \luatex, and the font size set by the last -|\selectfont| in \xetex). - -\begin{note} - With Unicode engines, a line break can happen just before an explicit - combining char (eg, \textit{\~{g}}, used in Guarani and Filipino, is - not included as a combined char and it’s represented in Unicode as - |U+0067|~|U+0303|. This issue is not directly related to \babel, but - to the hyphenation patterns and/or the font renderer. However, at - least with \luatex{} there is a workaround (change the language name - to what you are using): -\begin{verbatim} -\babelposthyphenation{guarani}{ | [{0300}-{036F}] }{ remove, {} } -\end{verbatim} -The Lua pattern means ‘a discretionary followed by a character in the -range |U+0300|--|U+0367| (which contains combining chars)’. An -alternative to a transform is |\babelpatterns|. -\end{note} - \subsection{Transforms} \label{transforms} @@ -3391,9 +4265,15 @@ some fine-tuning. More to follow in future releases.) \parbox[t]{4.0cm}{\strut\ttfamily#2}% \hspace{2mm}% \parbox[t]{6.6cm}{\strut#3}\par} -\bigskip\hrule\nobreak\vspace{.5mm} -% \strut\hfil Transforms -% \medskip\hrule\nobreak +\bigskip\hrule\nobreak\vspace{.5mm}\parindent0pt + +\trans{}{digits.native}{\New{24.9} An alternative to |mapdigits|, +available in the same locales. This transform is applied before the +first prehyphenation, while |mapdigits| is applied after the last +posthyphenation. Another difference is |mapdigits| cannot be disabled +in the middle of a paragraph. (This transform is \textit{not} declared +explicitly in |ini| files. Instead, it’s defined by |babel| if the key +\texttt{numbers/digits.native} exists.)} \trans{Arabic}{transliteration.dad}{Applies the transliteration system devised by Yannis Haralambous for \textsf{dad} (simple and @@ -3403,7 +4283,7 @@ devised by Yannis Haralambous for \textsf{dad} (simple and \textit{dž}, \textit{LJ}, \textit{Lj}, \textit{lj}, \textit{NJ}, \textit{Nj}, \textit{nj}. It assumes they exist. This is not the recommended way to make these transformations (the best way is with -OTF features), but it can get you out of a hurry.} +OTF features), but it can get you out in a hurry.} \trans{Croatian, Czech, Polish, Portuguese, Slovak, Spanish}{hyphen.repeat}{Explicit hyphens behave like @@ -3413,7 +4293,7 @@ Spanish}{hyphen.repeat}{Explicit hyphens behave like a non-syllabic preposition or conjunction into a non-breaking space.} \trans{Finnish}{prehyphen.nobreak}{Line breaks just after hyphens -prepended to words are prevented, like in “pakastekaapit ja -arkut”.} +prepended to words are prevented, as in “pakastekaapit ja -arkut”.} \trans{French}{punctuation.space}{Rules for proper spacing with characters \textit{;:!?«»} are applied.} @@ -3429,7 +4309,7 @@ alternative to |=|. |'| is tonos in Monotonic Greek, but oxia in Polytonic and Ancient Greek.} \trans{Greek}{sigma.final}{The transliteration system above does not -convert the sigma at the end of a word (on purpose). This transforms +convert the sigma at the end of a word (on purpose). This transform does it. To prevent the conversion (an abbreviation, for example), write |"s|.} @@ -3463,7 +4343,7 @@ Gujarati, Hindi, Kannada, Malayalam, Marathi, Odia, Tamil, Telugu.} \textit{u}, \textit{V}.} \trans{Sanskrit}{transliteration.iast}{The IAST system to -romanize Devanagari.\footnote{Thanks to Maximilian Mehner}} +romanize Devanagari (thanks to Maximilian Mehner).} \trans{Serbian}{transliteration.gajica}{(Note |serbian| with |ini| files refers to the Cyrillic script, which is here the target.) The @@ -3471,7 +4351,7 @@ standard system devised by Ljudevit Gaj.} \trans{Arabic, Persian}{kashida.plain}{Experimental. A very simple and basic transform for ‘plain’ Arabic fonts, which attempts to distribute -the tatwil as evenly as possible (starting at the end of the line). See +the tatweel as evenly as possible (starting at the end of the line). See the news for version 3.59.} \trans{Arabic, Persian}{kashida.base}{Experimental \New{3.94}. Much @@ -3530,18 +4410,18 @@ like |sf/m/it sf/b/it|. Transforms set for specific fonts (at least once in any language) are always reset with a font selector. -In |\babelprovide|, transform labels can be tagged before its name, +In |\babelprovide|, transform labels can be tagged before their name, with a list separated with colons, like: \begin{verbatim} transforms = _rm:sf:_transform.name \end{verbatim} -\New{3.67} With the optional argument you can associate a user defined +\New{3.67} With the optional argument you can associate a user-defined transform to an attribute, so that it’s active only when it’s set (currently its attribute value is ignored). With this mechanism transforms can be set or unset even in the middle of paragraphs, and applied to single words. To define, set and unset the attribute, the -LaTeX kernel provides the macros |\newattribute|, |\setattribute| and +\LaTeX{} kernel provides the macros |\newattribute|, |\setattribute| and |\unsetattribute|. The following example shows how to use it, provided an attribute named |\latinnoj| has been declared: \begin{verbatim} @@ -3625,6 +4505,7 @@ This feature is activated with the first |\babelposthyphenation| or the current language. \subsection{Support for \xetex{} interchar} +\label{interchar} \New{3.97} A few macros are provided to deal with locale dependent inter-character rules (aka ‘interchar’). @@ -3633,16 +4514,15 @@ inter-character rules (aka ‘interchar’). Declares a new character class, which is assigned to the characters in \marg{char-list}, entered either as characters or in macro form -(eg,~|\}|). If you need to enter them by their numeric value, use the -\TeX{} |^|-notation (eg,~|^^^^1fa0|). Ranges are allowed, with a -hyphen (eg,~|.,;a-zA-Z|). If you need the hyphen to be assigned a +(e.g.,~|\}|). If you need to enter them by their numeric value, use the +\TeX{} |^|-notation (e.g.,~|^^^^1fa0|). Ranges are allowed, with a +hyphen (e.g.,~|.,;a-zA-Z|). If you need the hyphen to be assigned a class, write it at the very beginning of the list. -There are several predefined ‘global’ classes, namely -|default|, |cjkideogram|, |cjkleftpunctuation|, |cjkrightpunctuation|, -|boundary|, and |ignore|, which are described in the \xetex{} manual -(currently CJK classes are ‘empty’, but they will be assigned in a -future release). +There are several predefined ‘global’ classes, namely |default|, +|cjkideogram|, |cjkleftpunctuation|, |cjkrightpunctuation|, |boundary|, +and |ignore|, which are described in the \xetex{} manual. These classes +are used by the |linebreak.basic|, described below. \Describe{\babelinterchar}{\oarg{options}\marg{locale} \marg{class-first}\marg{class-second}\marg{code}} @@ -3704,7 +4584,7 @@ the ‘provided’ locale. Currently the following |interchar|’s are defined: \parbox[t]{4.0cm}{\strut\ttfamily#2}% \hspace{2mm}% \parbox[t]{6.6cm}{\strut#3}\par} -\bigskip\hrule\nobreak\vspace{.5mm} +\bigskip\hrule\nobreak\vspace{.5mm}\parindent0pt \trans{Cantonese, Chinese, Japanese, Korean}{linebreak.basic}{\New{24.4} Basic settings for CJK @@ -3725,104 +4605,83 @@ characters \textit{;:!?«»} are applied.} relevant key for the current engine is taken into account. \end{note} -\subsection{Selection based on BCP 47 tags} -\label{bcp47} - -\New{3.43} The recommended way to select languages is that described at -the beginning of this document. However, BCP 47 tags are becoming -customary, particularly in documents (or parts of documents) generated -by external sources, and therefore \babel{} will provide a set of tools -to select the locales in different situations, adapted to the -particular needs of each case. Currently, \babel{} provides autoloading -of locales as described in this section. In these contexts autoloading -is particularly important because we may not know on beforehand which -languages will be requested. - -It must be activated explicitly, because it is primarily meant for -special tasks. Mapping from BCP 47 codes to locale names are not -hardcoded in \babel. Instead the data is taken from the \texttt{ini} -files, which means currently about 250 tags are already recognized. -\Babel{} performs a simple lookup in the following way: |fr-Latn-FR| $\to$ -|fr-Latn| $\to$ |fr-FR| $\to$ |fr|. Languages with the same resolved -name are considered the same. Case is normalized before, so that -|fr-latn-fr| $\to$ |fr-Latn-FR|. If a tag and a name overlap, the tag -takes precedence. - -Here is a minimal example: -\begin{verbatim} -\documentclass{article} - -\usepackage[danish]{babel} - -_\babeladjust{_ -_ autoload.bcp47 = on,_ -_ autoload.bcp47.options = import_ -_}_ - -\begin{document} - -Chapter in Danish: \chaptername. - -_\selectlanguage{de-AT}_ - -\localedate{2020}{1}{30} - -\end{document} -\end{verbatim} - -Currently the locales loaded are based on the \texttt{ini} files and -decoupled from the main \texttt{ldf} files. This is by design, to -ensure code generated externally produces the same result regardless of -the languages requested in the document, but an option to use the -\texttt{ldf} instead will be added in a future release, because both -options make sense depending on the particular needs of each document -(there will be some restrictions, however). - -The behaviour is adjusted with |\babeladjust| with the following parameters: -\begin{description} -\item \texttt{autoload.bcp47} with values |on| and |off|. -\item \texttt{autoload.bcp47.options}, which are passed to - |\babelprovide|; empty by default, but you may add \texttt{import} - (features defined in the corresponding |babel-...tex| file might not - be available). -\item \texttt{autoload.bcp47.prefix}. Although the public name used in - selectors is the tag, the internal name will be different and - generated by prepending a prefix, which by default is - \texttt{bcp47-}. You may change it with this key. -\end{description} - -\New{3.46} If an |ldf| file has been loaded, you can enable the -corresponding language tags as selector names with: -\begin{verbatim} -\babeladjust{ bcp47.toname = on } -\end{verbatim} -(You can deactivate it with |off|.) So, if |dutch| is one of the -package (or class) options, you can write |\selectlanguage{nl}|. Note -the language name does not change (in this example is still |dutch|), -but you can get it with |\localeinfo| or |\getlocaleproperty|. It -must be turned on explicitly for similar reasons to those explained -above. +\subsection{Scripts} -\subsection{Selecting scripts} - -Currently \babel{} provides no standard interface to select -scripts, because they are best selected with either |\fontencoding| -(low-level) or a language name (high-level). Even the Latin script may -require different encodings (ie, sets of glyphs) depending on the -language, and therefore such a switch would be in a sense -incomplete.\footnote{The so-called Unicode fonts do not improve the +\Babel{} provides no standard interface to select scripts, because they +are best selected with languages tied to them. In \pdftex, scripts are +indirectly managed by means of the low-level |\fontencoding|, whose +direct use is discouraged — even the Latin script may require different +encodings (i.e., sets of glyphs) depending on the language, and +therefore such a switch would be in a sense incomplete. Note the +so-called Unicode fonts (in \luatex\ and \xetex) do not improve the situation either. So, a font suited for Vietnamese is not necessarily suited for, say, the romanization of Indic languages, and the fact it contains glyphs for Modern Greek does not mean it includes them for -Classic Greek.} +Classic Greek. + +\begin{note} + Some languages sharing the same script define macros to switch it + (e.g., |\textcyrillic|), but be aware they may also set the language + to a certain default. Even the \babel{} core defined |\textlatin|, + but it was somewhat buggy because in some cases it messed up + encodings and fonts (for example, if the main Latin encoding was + |LY1|), and therefore it has been deprecated (but still defined for + backwards compatibility). +\end{note} -Some languages sharing the same script define macros to switch it (eg, -|\textcyrillic|), but be aware they may also set the language to a -certain default. Even the \babel{} core defined |\textlatin|, but is -was somewhat buggy because in some cases it messed up encodings and -fonts (for example, if the main Latin encoding was |LY1|), and -therefore it has been deprecated.\footnote{But still defined for -backwards compatibility.} +The locales currently available cover the following scripts: +\begin{multicols}{4} +\parindent-.5em +\leftskip.5em +Arabic\\ +Armenian\\ +Bangla\\ +Bengali\\ +Cherokee\\ +Coptic\\ +Cyrillic\\ +Devanagari\\ +Egyptian hieroglyphs\\ +Ethiopic\\ +Georgian\\ +Glagolitic\\ +Gothic\\ +Greek\\ +Gujarati\\ +Gurmukhi\\ +Han\\ +Hebrew\\ +Japanese\\ +Kannada\\ +Khmer\\ +Khojki\\ +Khudawadi\\ +Korean\\ +Lao\\ +Latin\\ +Malayalam\\ +Myanmar\\ +Nyiakeng Puachue Hmong\\ +N’Ko\\ +Ol Chiki\\ +Old Church Slavonic Cyrillic\\ +Oriya\\ +Phoenician\\ +Runic\\ +Simplified\\ +Sinhala\\ +Sumero-Akkadian Cuneiform\\ +Tamil\\ +Telugu\\ +Thaana\\ +Thai\\ +Tibetan\\ +Tifinagh\\ +Traditional\\ +Unified Canadian Aboriginal Syllabics\\ +Vai\\ +Yi +\end{multicols} \Describe{\ensureascii}{\marg{text}} @@ -3849,14 +4708,14 @@ most of the cases. No assumption is made on characters above 127, which may not follow the LICR conventions -- the goal is just to ensure most of the ASCII letters and symbols are the right ones. -\subsection{Selecting directions} +\subsection{Bidirectional and right-to-left text} \label{bidi} No macros to select the writing direction are provided, either -- writing direction is intrinsic to each script and therefore it is best set by the language (which can be a dummy one). Furthermore, there are in fact two right-to-left modes, depending on the language, which -differ in the way `weak' numeric characters are ordered (eg, Arabic +differ in the way `weak' numeric characters are ordered (e.g., Arabic \%123 \textit{vs} Hebrew 123\%). \begin{warning} @@ -3873,7 +4732,7 @@ differ in the way `weak' numeric characters are ordered (eg, Arabic |gathered| may fail). An effort is being made to avoid incompatibilities in the future - (this one of the reason currently bidi must be explicitly requested + (this one of the reasons currently bidi must be explicitly requested as a package option, with a certain bidi model, and also the |layout| options described below). \end{warning} @@ -3896,22 +4755,26 @@ There are some package options controlling bidi writing. With |default| the bidi mechanism is just activated (by default it is not), but every change must be marked up. In \pdftex{} this is the only -option. If the RL text only consists of letters and punctuation, it +option. If the RL text consists of only letters and punctuation, it will be fine in most cases, but numbers, for example, will be rendered in the wrong order. In \luatex, the preferred method is |basic|, which supports both L and R text. |basic-r| was a first attempt to create a bidi algorithm and provides a simple and fast method for R text in some typical cases. -(They are named \texttt{basic} mainly because they only consider the +(They are named \texttt{basic} mainly because they consider only the intrinsic direction of scripts and weak directionality.) In \xetex, |bidi-r| and |bidi-l| resort to the package \textsf{bidi} (by Vafa Khalighi). For RL documents use the former, and for LR ones -use the latter. However, this package patches heavily lots of macros -and packages even if the RL script is not the main one, which can lead -to some surprising results, so for short and simple texts (letters and -punctuation) the |default| method can be preferable. +use the latter. + +\begin{warning} + This package patches heavily lots of macros and packages even if the + RL script is not the main one, which can lead to some surprising + results, so for short and simple texts (letters and punctuation) the + |default| method is more often than not much preferable. +\end{warning} There are samples on GitHub, under \texttt{/required/babel/samples}. See particularly |lua-bidibasic.tex| and |lua-secenum.tex|. @@ -3930,12 +4793,11 @@ See particularly |lua-bidibasic.tex| and |lua-secenum.tex|. \catcode`@=13 \def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else \bgroup\textdir TRT \pardir TRT \fi} +\setengine{luatex} \begin{verbatim} -\documentclass{article} +\documentclass[arabic]{article} -\usepackage[_bidi=basic_]{babel} - -_\babelprovide[import, main]{arabic}_ +\usepackage[_bidi=basic_, provide=*]{babel} \babelfont{rm}{FreeSerif} @@ -3953,7 +4815,7 @@ _\babelprovide[import, main]{arabic}_ \begin{example} With |bidi=basic| \textit{both} L and R text can be - mixed without explicit markup (the latter will be only necessary in + mixed without explicit markup (the latter will be necessary only in some special cases where the Unicode algorithm fails). It is used much like |bidi=basic-r|, but with R text inside L text you may want to map the font so that the correct features are in force. This is accomplished @@ -4015,7 +4877,7 @@ Arabic as @1فصحى العصر@0 \textit{fuṣḥā l-ʻaṣr} (MSA) and \texttt{contents} $\string|$ \texttt{footnotes} $\string|$ \texttt{captions} $\string|$ - \texttt{columns} $\string|$ + \texttt{columns} $\string|$ \texttt{graphics} $\string|$ \texttt{extras}} @@ -4038,7 +4900,7 @@ options are required by all engines. below |\BabelPatchSection| for further details). \item[counters] required in all engines (except \luatex{} with - |bidi=basic|) to reorder section numbers and the like (eg, + |bidi=basic|) to reorder section numbers and the like (e.g., \m{subsection}.\m{section}); required in \xetex{} and \pdftex{} for counters in general, as well as in \luatex{} with |bidi=default|; required in \luatex{} for numeric footnote marks $>$9 with @@ -4094,7 +4956,7 @@ bidirectional (with both R and L paragraphs) documents in \luatex{}. packages and classes (or even raise an error). \New{3.18}. \item[graphics] modifies the |picture| environment so that the whole -figure is L but the text is R. It \textit{does not} work with the +figure is L but the text is R\@. It \textit{does not} work with the standard |picture|, and \textit{pict2e} is required. It attempts to do the same for \textsf{pgf/tikz}. Somewhat experimental. \New{3.32}. @@ -4105,10 +4967,17 @@ the same for \textsf{pgf/tikz}. Somewhat experimental. \New{3.32}. \begin{example} Typically, in an Arabic document you would need: +\setengine{luatex} \begin{verbatim} \usepackage[bidi=basic, layout=counters tabular]{babel} \end{verbatim} +or +\setengine{xetex} +\begin{verbatim} +\usepackage[bidi=bidi, + layout=counters tabular]{babel} +\end{verbatim} \end{example} \Describe{\babelsublr}{\marg{lr-text}} @@ -4140,7 +5009,7 @@ RTL A \foreignlanguage{english}{ltr text \thechapter{} and still ltr} RTL B \New{3.86} \textit{LuaTeX}. This command resets the internal text, paragraph and body directions to those of the current locale (if -different). Sometimes changing directly these values can be useful for +different). Sometimes changing these values directly can be useful for some hacks, and this command helps in restoring the directions to the correct ones. It can be used in |>| arguments of \textsf{array}, too. @@ -4165,18 +5034,18 @@ necessary (but note then tocs and marks are not touched). \New{3.17} Something like: \begin{verbatim} -\BabelFootnote{\parsfootnote}{\languagename}{(}{)} +\BabelFootnote{\parsfootnote}{\localename}{(}{)} \end{verbatim} defines |\parsfootnote| so that |\parsfootnote{note}| is equivalent to: \begin{verbatim} -\footnote{(\foreignlanguage{\languagename}{note})} +\footnote{(\foreignlanguage{\localename}{note})} \end{verbatim} but the footnote itself is typeset in the main language (to unify its direction). In addition, |\parsfootnotetext| is defined. The option |footnotes| just does the following: \begin{verbatim} -\BabelFootnote{\footnote}{\languagename}{}{}% -\BabelFootnote{\localfootnote}{\languagename}{}{}% +\BabelFootnote{\footnote}{\localename}{}{}% +\BabelFootnote{\localfootnote}{\localename}{}{}% \BabelFootnote{\mainfootnote}{}{}{} \end{verbatim} (which also redefine |\footnotetext| and define |\localfootnotetext| @@ -4192,258 +5061,15 @@ command is available always in bidi documents, even without \BabelFootnote{\enfootnote}{english}{}{.} \end{verbatim} It adds a period outside the English part, so that it is placed - at the left in the last line. This means the dot the end of the + at the left in the last line. This means the dot at the end of the footnote text should be omitted. \end{example} -\subsection{Language attributes} - -\DescribeMacro{\languageattribute} - -This is a user-level command, to be used in the preamble of a -document (after |\usepackage[...]{babel}|), that declares which -attributes are to be used for a given language. It takes two -arguments: the first is the name of the language; the second, -a (list of) attribute(s) to be used. Attributes must be set in the -preamble and only once -- they cannot be turned on and off. -The command checks whether the language is known in this document -and whether the attribute(s) are known for this language. - -Very often, using a \textit{modifier} in a package option is better. - -Several language definition files use their own methods to set -options. For example, \textsf{french} uses |\frenchsetup|, -\textsf{magyar} (1.5) uses |\magyarOptions|; modifiers provided by -|spanish| have no attribute counterparts. Macros setting -options are also used (eg, |\ProsodicMarksOn| in \textsf{latin}). - -\subsection{Hooks} - -\New{3.9a} A hook is a piece of code to be executed at certain -events. Some hooks are predefined when \luatex{} and \xetex{} are -used. - -\New{3.64} This is not the only way to inject code at those points. The -events listed below can be used as a hook name in |\AddToHook| in the -form |babel/|\m{language-name}|/|\m{event-name} (with |*| it’s applied to -all languages), but there is a limitation, because the parameters -passed with the \babel{} mechanism are not allowed. The |\AddToHook| -mechanism does \textit{not} replace the current one in `babel`. Its -main advantage is you can reconfigure `babel` even before loading it. -See the example below. - -\Describe{\AddBabelHook}{\oarg{lang}\marg{name}\marg{event}\marg{code}} - -The same name can be applied to several events. Hooks with a certain -\marg{name} may be enabled and disabled for all defined events with -|\EnableBabelHook|\marg{name}, |\DisableBabelHook|\marg{name}. Names -containing the string |babel| are reserved (they are used, for example, -by |\useshortands*| to add a hook for the event |afterextras|). -\New{3.33} They may be also applied to a specific language with the -optional argument; language-specific settings are executed after global -ones. - -Current events are the following; in some of them you can use one to -three \TeX{} parameters (|#1|, |#2|, |#3|), with the meaning given: -\begin{description} -\renewcommand\makelabel[1]{% - \hspace\labelsep\normalfont\ttfamily\color{thered}#1} -\itemsep=-\parskip -\item[adddialect] (language name, dialect name) Used by - \file{luababel.def} to load the patterns if not preloaded. -\item[patterns] (language name, language with encoding) Executed just - after the |\language| has been set. The second argument has the - patterns name actually selected (in the form of either |lang:ENC| or - |lang|). -\item[hyphenation] (language name, language with encoding) Executed - locally just before exceptions given in |\babelhyphenation| are - actually set. -\item[defaultcommands] Used (locally) in |\StartBabelCommands|. -\item[encodedcommands] (input, font encodings) Used (locally) in - |\StartBabelCommands|. Both \xetex{} and \luatex{} make sure the - encoded text is read correctly. -\item[stopcommands] Used to reset the above, if necessary. -\item[write] This event comes just after the switching commands are - written to the |aux| file. -\item[beforeextras] Just before executing |\extras|\m{language}. This - event and the next one should not contain language-dependent code - (for that, add it to |\extras|\m{language}). -\item[afterextras] Just after executing |\extras|\m{language}. For - example, the following deactivates shorthands in all languages: -\begin{verbatim} -\AddBabelHook{noshort}{afterextras}{\languageshorthands{none}} -\end{verbatim} -\item[stringprocess] Instead of a parameter, you can manipulate the - macro |\BabelString| containing the string to be defined with - |\SetString|. For example, to use an expanded version of the string - in the definition, write: -\begin{verbatim} -\AddBabelHook{myhook}{stringprocess}{% - \protected@edef\BabelString{\BabelString}} -\end{verbatim} -\item[initiateactive] (char as active, char as other, original char) - \New{3.9i} Executed just after a shorthand has been `initiated'. The three - parameters are the same character with different catcodes: active, - other (|\string|'ed) and the original one. -\item[afterreset] \New{3.9i} Executed when selecting a language just after - |\originalTeX| is run and reset to its base value, before executing - |\captions|\m{language} and |\date|\m{language}. -\item[begindocument] \New{3.88} Executed before the code written by - |ldf| files with |\AtBeginDocument|. The optional argument with the - language in this particular case is the language that wrote the code. - The special value |/| means ‘return to the core \babel{} definitions’ - (in other words, what follows hasn’t been written by any language). -% STILL UNDER STUDY: -% \item[beforestart] \New{3.34} Executed either at the beginning of the -% |aux| file (when read at the start of the document), or else at begin -% document. In other words, it makes sure the code is executed always -% and executed once. But be aware it is a somewhat dangerous, because -% the scope in the first case is local, while in the second case is -% global, so be careful with assignments. -\end{description} - -Four events are used in \file{hyphen.cfg}, which are handled in a -quite different way for efficiency reasons -- unlike the precedent -ones, they only have a single hook and replace a default definition. -\begin{description} -\renewcommand\makelabel[1]{% - \hspace\labelsep\normalfont\ttfamily\color{thered}#1} -\itemsep=-\parskip -\item[everylanguage] (language) Executed before every language patterns - are loaded. -\item[loadkernel] (file) By default just defines a few basic commands. - It can be used to define different versions of them or to load a file. -\item[loadpatterns] (patterns file) Loads the patterns file. Used by - \file{luababel.def}. -\item[loadexceptions] (exceptions file) Loads the exceptions - file. Used by \file{luababel.def}. -\end{description} - -\begin{example} -The generic unlocalized \LaTeX{} hooks are predefined, so that you can -write: -\begin{verbatim} -\AddToHook{babel/*/afterextras}{\frenchspacing} -\end{verbatim} -which is executed always after the extras for the language being -selected (and just before the non-localized hooks defined with -|\AddBabelHook|). - -In addition, locale-specific hooks in the form -|babel/|\m{language-name}|/|\m{event-name} are \textit{recognized} -(executed just before the localized \babel{} hooks), but they are -\textit{not predefined}. You have to do it yourself. For example, to -set |\frenchspacing| only in |bengali|: -\begin{verbatim} -\ActivateGenericHook{babel/bengali/afterextras} -\AddToHook{babel/bengali/afterextras}{\frenchspacing} -\end{verbatim} -\end{example} - -\Describe{\BabelContentsFiles}{} -\New{3.9a} This macro contains a list of ``toc'' types -requiring a command to switch the language. Its default value is -|toc,lof,lot|, but you may redefine it with |\renewcommand| (it's up -to you to make sure no toc type is duplicated). - -\subsection{Languages supported by \babel{} with \textsf{ldf} files} - -In the following table most of the languages supported by \babel{} with -and |.ldf| file are listed, together with the names of the option which -you can load \babel\ with for each language. Note this list is open and -the current options may be different. It does not include |ini| files -(see below). Except in a few cases (eg, |ngerman|, |serbianc|, -|acadian|) names are those of the Unicode CLDR (or based on them). - -\begin{description} -\itemsep=-\parskip -\sffamily -\item[Afrikaans] afrikaans -\item[Azerbaijani] azerbaijani -\item[Basque] basque -\item[Breton] breton -\item[Bulgarian] bulgarian -\item[Catalan] catalan -\item[Croatian] croatian -\item[Czech] czech -\item[Danish] danish -\item[Dutch] dutch -\item[English] english, american (\textit{preferred to} USenglish), british (\textit{preferred to} - UKenglish), canadian, australian, newzealand -\item[Esperanto] esperanto -\item[Estonian] estonian -\item[Finnish] finnish -\item[French] french, acadian -\item[Galician] galician -\item[German] ngerman, naustrian, german, austrian -\item[Greek] greek, polutonikogreek -\item[Hebrew] hebrew -\item[Icelandic] icelandic -\item[Indonesian] indonesian -\item[Interlingua] interlingua -\item[Irish Gaelic] irish -\item[Italian] italian -\item[Latin] latin -\item[Lower Sorbian] lowersorbian -\item[Malay] malay (\textit{preferred to} melayu) -\item[Northern Sami] northernsami -\item[Norwegian] norsk, nynorsk -\item[Polish] polish -\item[Portuguese] portuguese, brazilian -\item[Romanian] romanian -\item[Russian] russian -\item[Scottish Gaelic] scottishgaelic (\textit{preferred to} scottish) -\item[Spanish] spanish -\item[Slovakian] slovak -\item[Slovenian] slovene -\item[Swedish] swedish -\item[Serbian] serbian -\item[Turkish] turkish -\item[Ukrainian] ukrainian -\item[Upper Sorbian] uppersorbian -\item[Welsh] welsh -\end{description} - -There are more languages not listed above, including \textsf{hindi, -thai, thaicjk, latvian, turkmen, magyar, mongolian, romansh, -lithuanian, spanglish, vietnamese, japanese, pinyin, arabic, farsi, -ibygreek, bgreek, serbianc, frenchle, ethiop} and \textsf{friulan}. - -\begin{note} - There are also some deprecated names (a few has been even removed): - \textsf{frenchb} or \textsf{francais}, as well as \textsf{canadien} - (\textsf{french}), \textsf{germanb} (\textsf{german}), - \textsf{bahasa}, \textsf{indon} or \textsf{bahasai} - (\textsf{indonesian}), \textsf{lsorbian} (\textsf{lowersorbian}), - \textsf{bahasam} (\textsf{malay}), \textsf{portuges} - (\textsf{portuguese}), \textsf{brazil} (\textsf{brazilian}), - \textsf{russianb} (\textsf{russian}), \textsf{usorbian} - (\textsf{uppersorbian}), \textsf{vietnam} (\textsf{vietnamese}), - \textsf{samin} (\textsf{northernsami}), \textsf{ukraineb} - (\textsf{ukrainian}). Deprecated names come in many cases from the - times when they had to be shortened to 8 characters. -\end{note} - -Most of them work out of the box, but some may require extra fonts, -encoding files, a preprocessor or even a complete framework (like -\textsf{CJK} or \textsf{luatexja}). For example, if you have got the -\textsf{velthuis/devnag} package, you can create a file with extension -|.dn|: -\begin{verbatim} -\documentclass{article} -\usepackage[hindi]{babel} -\begin{document} -{\dn devaanaa.m priya.h} -\end{document} -\end{verbatim} -Then you preprocess it with |devnag| \m{file}, which creates -\m{file}|.tex|; you can then typeset the latter with \LaTeX. - \subsection{Unicode character properties in \luatex} \New{3.32} Part of the \babel{} job is to apply Unicode rules to some script-specific features based on some properties. Currently, they are -3, namely, direction (ie, bidi class), mirroring glyphs, and line +3, namely, direction (i.e., bidi class), mirroring glyphs, and line breaking for CJK scripts. These properties are stored in \textsf{lua} tables, which you can modify with the following macro (for example, to set them for glyphs in the PUA). @@ -4460,7 +5086,7 @@ between paragraphs). For example: \begin{verbatim} -\babelcharproperty{`¿}{mirror}{`?} +\babelcharproperty{`¿}{mirror}{`?} \babelcharproperty{`-}{direction}{l} % or al, r, en, an, on, et, cs \babelcharproperty{`)}{linebreak}{cl} % or id, op, cl, ns, ex, in, hy \end{verbatim} @@ -4476,7 +5102,7 @@ empty, removes them. The last argument is the locale name: \babelcharproperty{`,}{locale}{english} \end{verbatim} -\subsection{Tweaking some features} +\subsection{Tweaking some \babel{} features} \Describe{\babeladjust}{\marg{key-value-list}} @@ -4502,7 +5128,7 @@ The first four are documented elsewhere. The following are by default preamble) changes for math or \textsf{amsmath}, |linebreak.sea|, |linebreak.cjk| and |justify.arabic| the corresponding algorithms, |layout.tabular| and |layout.lists| changes for tabular and lists. -Some of the are reverted only to some extent. +Some of them are reverted only to some extent. Other keys are: \begin{multicols}{3} @@ -4528,102 +5154,89 @@ an alternative algorithm or with large sections not requiring it. Use with care, because these options do not deactivate other related options (like paragraph direction with |bidi.text|). -\subsection{Tips, workarounds, known issues and notes} +\section{Relation with other packages} -\begin{itemize} - \item For the hyphenation to work correctly, lccodes cannot change, - because \TeX{} only takes into account the values when the - paragraph is hyphenated, i.e., when it has been - finished.\footnote{This explains why \LaTeX{} assumes the lowercase - mapping of T1 and does not provide a tool for multiple - mappings. Unfortunately, \cs{savinghyphcodes} is not a solution - either, because lccodes for hyphenation are frozen in the format - and cannot be changed.} So, if you write a chunk of French text - with |\foreignlanguage|, the apostrophes might not be taken into - account. This is a limitation of \TeX, not of - \babel. Alternatively, you may use |\useshorthands| to activate |'| - and |\defineshorthand|, or redefine |\textquoteright| (the latter - is called by the non-ASCII right quote). -\item Babel does not take into account |\normalsfcodes| and - (non-)French spacing is not always properly (un)set by - languages. However, problems are unlikely to happen and therefore - this part remains untouched (but it is in the `to do' list). -\item Using a character mathematically active (ie, with math code - |"8000|) as a shorthand can make \TeX{} enter in an infinite loop in - some rare cases. (Another issue in the ‘to do’ list, although there - is a partial solution.) -\end{itemize} +\subsection{Compatibility} + +There are compatibility issues with the following packages. + +\begingroup +\parindent0pt +\def\trans#1#2{% + \vspace{1.5mm}% + \parbox[t]{3.0cm}{\strut\sffamily#1}% + \hspace{2mm}% + \parbox[t]{10cm}{\strut#2}\par} +\bigskip\hrule\nobreak\vspace{.5mm} + +\trans{polyglossia}{This package is not compatible at all with \babel. +They should never be used together, because macros are different, and +even those with the same name don’t behave in the same way. Also, +languages are organized quite differently (\babel{} treats all locales +on an equal footing).} + +\trans{tikz/pgf}{There are some issues with shorthands, which are +usually solved with \texttt{\string\usetikzlibrary\{babel\}}.} -The following packages can be useful, too (the list is still -far from complete): +\trans{cleveref}{Because of a long standing bug in this package, some +languages can raise an error (particularly |spanish| and |greek|).} + +\trans{natbib}{Load it before \babel.} + +\trans{bidi}{\Babel\ relies on \textsc{bidi} with \xetex{} and +|bidi=bidi|, which has a multitude of incompatibilities. Please, refer +to its manual, and remember for short and simple texts you can rely on +|bidi=default| instead.} + +\vspace{2mm}\hrule\nobreak\bigskip +\endgroup + +\subsection{Related packages} + +The following packages can be useful in multilingual contexts (the list +is far from exhaustive): \begin{description} \itemsep=-\parskip -\item[csquotes] Logical markup for quotes. -\item[iflang] Tests correctly the current language. -\item[hyphsubst] Selects a different set of patterns for a language. -\item[translator] An open platform for packages that need to be +\item[\sffamily babelbib] Multilingual bibliographies. +\item[\sffamily biblatex] Programmable bibliographies and citations. +\item[\sffamily bicaption] Bilingual captions. +\item[\sffamily csquotes] Logical markup for quotes. +\item[\sffamily hyphsubst] Selects a different set of patterns for a language. +\item[\sffamily iflang] Tests correctly the current language. +\item[\sffamily microtype] Adjusts the typesetting according to + some languages (kerning and spacing). Ligatures can be disabled. + Search in its manual for |babel| and |DeclareMicrotypeBabelHook|. +\item[\sffamily mkpattern] Generates hyphenation patterns. +\item[\sffamily siunitx] Typesetting of numbers and physical quantities. +\item[\sffamily substitutefont] Combines fonts in several encodings. +\item[\sffamily tracklang] Tracks which languages have been requested. +\item[\sffamily translator] An open platform for packages that need to be localized. -\item[siunitx] Typesetting of numbers and physical quantities. -\item[biblatex] Programmable bibliographies and citations. -\item[bicaption] Bilingual captions. -\item[babelbib] Multilingual bibliographies. -\item[microtype] Adjusts the typesetting according to -some languages (kerning and spacing). Ligatures can be disabled. -\item[substitutefont] Combines fonts in several encodings. -\item[mkpattern] Generates hyphenation patterns. -\item[tracklang] Tracks which languages have been requested. -\item[ucharclasses] (\xetex) Switches fonts when you switch from one - Unicode block to another. -\item[zhspacing] Spacing for CJK documents in \xetex. +\item[\sffamily ucharclasses] (\xetex) Switches fonts when you switch from one + Unicode block to another. Note it doesn’t work with RTL scripts. +\item[\sffamily zhspacing] Spacing for CJK documents in \xetex. \end{description} -\subsection{Current and future work} - -The current work is focused on the so-called complex scripts in \luatex{}. -In 8-bit engines, \babel{} provided a basic support for bidi text as -part of the style for Hebrew, but it is somewhat unsatisfactory and -internally replaces some hardwired commands by other hardwired commands -(generic changes would be much better). - -Useful additions would be, for example, time, currency, addresses and -personal names.\footnote{See for example POSIX, ISO 14652 and the -Unicode Common Locale Data Repository (CLDR). Those systems, however, -have limited application to \TeX\ because their aim is just to display -information and not fine typesetting.}. But that is the easy -part, because they don't require modifying the \LaTeX{} internals. -Calendars (Arabic, Persian, Indic, etc.) are under study. - -Also interesting are differences in the sentence structure or related -to it. For example, in Basque the number precedes the name (including -chapters), in Hungarian ``from (1)'' is ``(1)-b\H{o}l'', but ``from -(3)'' is ``(3)-b\'{o}l'', in Spanish an item labelled -``3.$^{\textrm{\scriptsize o}}$'' may be referred to as either -``\'{\i}tem 3.$^{\textrm{\scriptsize o}}$'' or -``3.$^{\textrm{\scriptsize er}}$ \'{\i}tem'', and so on. - -An option to manage bidirectional document layout in \luatex{} (lists, -footnotes, etc.) is almost finished, but \xetex{} required more work. -Unfortunately, proper support for \xetex{} requires patching somehow -lots of macros and packages (and some issues related to |\special|s -remain, like color and hyperlinks), so \babel{} resorts to the -\textsf{bidi} package (by Vafa Khalighi). See the \babel{} repository -for a small example (|xe-bidi|). - -\subsection{Tentative and experimental code} +\subsection{Indexing} + +For multilingual indexing, see \textsf{upmendex} and \textsf{xindex}, +currently preferred to \textsf{xindy}. + +\section{Tentative and experimental code} See the code section for |\foreignlanguage*| (a new starred version of |\foreignlanguage|). -For old an deprecated functions, see the \babel{} site. +For old and deprecated functions, see the \babel{} site. \medskip \textbf{Options for locales loaded on the fly} \New{3.51} |\babeladjust{ autoload.options = ... }| sets the options -when a language is loaded on the fly (by default, no options). A -typical value would be |import|, which defines captions, date, -numerals, etc., but ignores the code in the |tex| file (for example, -extended numerals in Greek). +when a language is loaded on the fly. \New{24.14} By default, it is +|import|, which defines captions, date, numerals, etc., but ignores the +code in the |tex| file (for example, extended numerals in Greek). It +can be set to empty. \medskip \textbf{Labels} @@ -4634,12 +5247,12 @@ counters are used to define them. It is still somewhat tentative because it is far from trivial -- see the \babel{} site for further details. -\section{Loading languages with \file{language.dat}} +\section{Loading language hyphenation rules with \file{language.dat}} -\TeX{} and most engines based on it (pdf\TeX, \xetex, $\epsilon$-\TeX, +\TeX{} and most engines based on it (pdf\TeX, \xetex, $\varepsilon$-\TeX, the main exception being \luatex) require hyphenation patterns to be -preloaded when a format is created (eg, \LaTeX, Xe\LaTeX, -pdf\LaTeX). \babel{} provides a tool which has become standard in many +preloaded when a format is created (e.g., \LaTeX, Xe\LaTeX, pdf\LaTeX). +\babel{} provides a tool which has become standard in many distributions and based on a ``configuration file'' named \file{language.dat}. The exact way this file is used depends on the distribution, so please, read the documentation for the latter (note @@ -4647,29 +5260,21 @@ also some distributions generate the file with some tool). \New{3.9q} With \luatex, however, patterns are loaded on the fly when requested by the language (except the ``0th'' language, typically -\textsf{english}, which is preloaded always).\footnote{This feature -was added to 3.9o, but it was buggy. Both 3.9o and 3.9p are -deprecated.} Until 3.9n, this task was delegated to the package -\textsf{luatex-hyphen}, by Khaled Hosny, \'Elie Roux, and Manuel -P\'egouri\'e-Gonnard, and required an extra file named -|language.dat.lua|, but now a new mechanism has been devised based -solely on |language.dat|. \textbf{You must rebuild the formats} if -upgrading from a previous version. You may want to have a local -|language.dat| for a particular project (for example, a book on -Chemistry).\footnote{The loader for lua(e)tex is slightly different as -it's not based on \babel{} but on \texttt{etex.src}. Until 3.9p it -just didn't work, but thanks to the new code it works by reloading the -data in the \babel{} way, i.e., with \texttt{language.dat}.} +\textsf{english}, which is preloaded always). You may want to have a +local |language.dat| for a particular project (for example, a book on +Chemistry). The loader for lua(e)tex is slightly different as it's not +based on \babel{}, but on \texttt{etex.src}; however, \babel{} reloads +the data so that it works as expected. \subsection{Format} In that file the person who maintains a \TeX\ environment has to record for which languages he has hyphenation patterns \emph{and} in which -files these are stored\footnote{This is because different operating -systems sometimes use \emph{very} different file-naming -conventions.}. When hyphenation exceptions are stored in a separate -file this can be indicated by naming that file \emph{after} the file -with the hyphenation patterns. +files these are stored (this was because different operating systems +sometimes used \emph{very} different file-naming conventions, but this +issue is not currently so serious as before). When hyphenation +exceptions are stored in a separate file this can be indicated by +naming that file \emph{after} the file with the hyphenation patterns. The file can contain empty lines and comments, as well as lines which start with an equals (\texttt{=}) sign. Such a line will instruct @@ -4685,10 +5290,9 @@ dutch hyphen.dutch exceptions.dutch % Nederlands german hyphen.ger \end{verbatim} -You may also set the font encoding the patterns are intended for by -following the language name by a colon and the encoding -code.\footnote{This is not a new feature, but in former versions it -didn't work correctly.} For example: +You may also set the font encoding that the patterns are intended for by +following the language name by a colon and the encoding code. For +example: \begin{verbatim} german:T1 hyphenT1.ger german hyphen.ger @@ -4696,25 +5300,14 @@ german hyphen.ger With the previous settings, if the encoding when the language is selected is |T1| then the patterns in \file{hyphenT1.ger} are used, but otherwise use those in \file{hyphen.ger} (note the encoding -can be set in |\extras|\m{lang}). - -A typical error when using \babel{} is the following: -\begin{verbatim} -No hyphenation patterns were preloaded for -the language `<lang>' into the format. -Please, configure your TeX system to add them and -rebuild the format. Now I will use the patterns -preloaded for english instead}} -\end{verbatim} -It simply means you must reconfigure \file{language.dat}, either by -hand or with the tools provided by your distribution. +can be set in |\extras<language>|). \section{The interface between the core of \babel{} and the language definition files} The \textit{language definition files} (ldf) must conform to a number of conventions, because these files have to fill in the gaps -left by the common code in \file{babel.def}, i.\,e., the +left by the common code in \file{babel.def}, i.e., the definitions of the macros that produce texts. Also the language-switching possibility which has been built into the \babel{} system has its implications. @@ -4737,7 +5330,7 @@ The following assumptions are made: last two may be left empty); where \langvar\ is either the name of the language definition file or the name of the \LaTeX\ option that is to be used. These macros and their functions are discussed - below. You must define all or none for a language (or a dialect); + below. You must define all or none for a language; defining, say, |\date|\langvar\ but not |\captions|\langvar\ does not raise an error but can lead to unexpected results. \item When a language definition file is loaded, it can define @@ -4746,53 +5339,54 @@ The following assumptions are made: \item Language names must be all lowercase. If an unknown language is selected, \babel{} will attempt setting it after lowercasing its name. -\item The semantics of modifiers is not defined (on purpose). In - most cases, they will just be simple separated options (eg, +\item The semantics of modifiers is not defined (on purpose). In most + cases, they will just be simple separated options (e.g., \texttt{spanish}), but a language might require, say, a set of options organized as a tree with suboptions (in such a case, the - recommended separator is \verb|/|). + recommended separator is \verb|/|). How modifiers (saved in + |\BabelModifiers|) are handled are left to language styles; they can + use |\in@|, loop them with |\@for| or load |keyval|, for example. \end{itemize} Some recommendations: \begin{itemize} \item The preferred shorthand is |"|, which is not used in \LaTeX{} (quotes are entered as |``| and |''|). Other good choices are - characters which are not used in a certain context (eg, |=| in an - ancient language). Note however |=|, |<|, |>|, |:| and the like + characters which are not used in a certain context (e.g., |=| in an + ancient language). Note however |=|, \texttt{<}, |>|, |:| and the like can be dangerous, because they may be used as part of the syntax of some elements (numeric expressions, key/value pairs, etc.). \item Captions should not contain shorthands or encoding-dependent commands (the latter is not always possible, but should be clearly - documented). They should be defined using the LICR. You may + documented). They should be defined using the LICR\@. You may also use the new tools for encoded strings, described below. -\item Avoid adding things to |\noextras|\m{lang} except for umlauthigh +\item Avoid adding things to |\noextras<language>| except for umlauthigh and friends, |\bbl@deactivate|, |\bbl@(non)frenchspacing|, and - language-specific macros. Use always, if possible, |\babel@save| and + language-specific macros. Use always, wherever possible, |\babel@save| and |\babel@savevariable| (except if you still want to have access to the previous value). Do not reset a macro or a setting to a hardcoded - value. Never. Instead save its value in |\extras|\m{lang}. + value. Never. Instead save its value in |\extras<language>|. \item Do not switch scripts. If you want to make sure a set of glyphs is used, switch either the font encoding (low-level) or the language (high-level, which in turn may switch the font encoding). Usage of things - like |\latintext| is deprecated.\footnote{But not removed, for backward - compatibility.} + like |\latintext| is deprecated (but not removed, for backward + compatibility). \item Please, for ``private'' internal macros do not use the |\bbl@| prefix. It is used by \babel{} and it can lead to incompatibilities. \end{itemize} -There are no special requirements for documenting your language -files. Now they are not included in the base \babel{} manual, so -provide a standalone document suited for your needs, as well as other -files you think can be useful. A PDF and a ``readme'' are strongly -recommended. +There are no special requirements for documenting your language files. +Just provide a standalone document suited to your needs, as well as +other files you think can be useful. A PDF and a ``readme'' are +strongly recommended. \subsection{Guidelines for contributed languages} \label{contribute} Currently, the easiest way to contribute a new language is by taking one of the 500 or so |ini| templates available on GitHub as a basis. -Just make a pull request or download it and then, after filling the -fields, sent it to me. Fell free to ask for help or to make feature +Just make a pull request or download it, and then, after filling out the +fields, sent it to me. Feel free to ask for help or to make feature requests. As to \texttt{ldf} files, now language files are “outsourced” and are @@ -4806,8 +5400,8 @@ but if you want to do it, here are a few guidelines. \begin{itemize} \item Do not hesitate stating on the file heads you are the author and the - maintainer, if you actually are. There is no need to state the babel - maintainer(s) as authors if they have not contributed significantly + maintainer, if you actually are. There is no need to state the \babel{} + maintainer(s) as author(s) if they have not contributed significantly to your language files. \item Fonts are not strictly part of a language, so they are best placed in the corresponding TeX tree. This includes not only \texttt{tfm}, @@ -4815,19 +5409,20 @@ but if you want to do it, here are a few guidelines. like, but also \texttt{fd} ones. \item Font and input encodings are usually best placed in the corresponding tree, too, but sometimes they belong more naturally to - the babel style. Note you may also need to define a LICR. -\item \Babel{} ldf files may just interface a framework, as it happens often - with Oriental languages/scripts. This framework is best placed in its - own directory. + the \babel{} style. Note you may also need to define a LICR + (\textit{TLC3}, I, 757f.). +\item \Babel{} \texttt{ldf} files may just interface a framework, as it + happens often with Oriental languages/scripts. This framework is best + placed in its own directory. \end{itemize} The following page provides a starting point for \texttt{ldf} files: \texttt{http://www.texnia.com/incubator.html}. See also \texttt{https://latex3.github.io/babel/guides/list-of-locale-templates.html}. -If you need further assistance and technical advice in the -development of language styles, I am willing to help you. And of -course, you can make any suggestion you like. +If you need further assistance and technical advice in the development +of language styles, I will be happy to help you. And of course, you can +make any suggestion you like. \subsection{Basic macros} @@ -4842,14 +5437,15 @@ The macro |\addlanguage| is a non-outer version of the macro patterns. \DescribeMacro{\adddialect} -The macro |\adddialect| can be used when two languages can (or -must) use the same hyphenation patterns. This can also be useful -for languages for which no patterns are preloaded in the -format. In such cases the default behavior of the \babel{} -system is to define this language as a `dialect' of the language -for which the patterns were loaded as |\language0|. Here -``language'' is used in the \TeX{} sense of set of hyphenation -patterns. +The macro |\adddialect| can be used when two languages can (or must) +use the same hyphenation patterns. This can also be useful for +languages for which no patterns are preloaded in the format. In such +cases the default behavior of the \babel{} system is to define this +language as a ‘dialect’ of the language for which the patterns were +loaded as |\language0|. Here ``language'' is used in the \TeX{} sense +of set of hyphenation patterns, while “dialect”, which is misnomer, +refers just to a language with the same hyphenation patterns as another +(there is no relation with its linguistic meaning). \DescribeMacro{\<lang>hyphenmins} The macro |\|\langvar|hyphenmins| is used to store the values of @@ -4860,7 +5456,8 @@ two parameters. For example: \renewcommand\spanishhyphenmins{34} \end{verbatim} (Assigning |\lefthyphenmin| and |\righthyphenmin| directly in -|\extras<lang>| has no effect.) +|\extras<language>| has no effect.) This is a low-level setting. In +documents you should rely on |\babelhyphenmins|. \DescribeMacro{\providehyphenmins} The macro |\providehyphenmins| should be used in the language @@ -4912,16 +5509,16 @@ of the \LaTeX\ command |\ProvidesPackage|. The macro |\LdfInit| performs a couple of standard checks that must be made at the beginning of a language definition file, such as checking the category code of the @-sign, preventing -the \file{.ldf} file from being processed twice, etc. +the \file{ldf} file from being processed twice, etc. \DescribeMacro{\ldf@quit} -The macro |\ldf@quit| does work needed if a \file{.ldf} file was +The macro |\ldf@quit| does work needed if an \file{ldf} file was processed earlier. This includes resetting the category code of the @-sign, preparing the language to be activated at |\begin{document}| time, and ending the input stream. \DescribeMacro{\ldf@finish} -The macro |\ldf@finish| does work needed at the end of each \file{.ldf} +The macro |\ldf@finish| does work needed at the end of each \file{ldf} file. This includes resetting the category code of the @-sign, loading a local configuration file, and preparing the language to be activated at |\begin{document}| time. @@ -5009,38 +5606,35 @@ In quite a number of language definition files, active characters are introduced. To facilitate this, some support macros are provided. \DescribeMacro{\initiate@active@char} -The internal macro |\initiate@active@char| is used in language +Used in language definition files to instruct \LaTeX\ to give a character the category code `active'. When a character has been made active it will remain that way until the end of the document. Its definition may vary. \DescribeMacro{\bbl@activate} \DescribeMacro{\bbl@deactivate} -The command |\bbl@activate| is used to change the way an active +Used to change the way an active character expands. |\bbl@activate| `switches on' the active behavior of the character. |\bbl@deactivate| lets the active character expand to its former (mostly) non-active self. \DescribeMacro{\declare@shorthand} -The macro |\declare@shorthand| is used to define the various +Used to define the various shorthands. It takes three arguments: the name for the collection of shorthands this definition belongs to; the character (sequence) that -makes up the shorthand, i.e.\ |~| or |"a|; and the code to be executed +makes up the shorthand, i.e., |~| or |"a|; and the code to be executed when the shorthand is encountered. (It does \textit{not} raise an error if the shorthand character has not been ``initiated''.) -\DescribeMacro{\bbl@add@special} -\DescribeMacro{\bbl@remove@special} -The \TeX book states: ``Plain \TeX\ includes a macro called -|\dospecials| that is essentially a set macro, representing the set of -all characters that have a special category code.'' \cite[p.~380]{DEK} -It is used to set text `verbatim'. To make this work if more -characters get a special category code, you have to add this character -to the macro |\dospecials|. \LaTeX\ adds another macro called -|\@sanitize| representing the same character set, but without the -curly braces. The macros |\bbl@add@special|\meta{char} and -|\bbl@remove@special|\meta{char} add and remove the character -\meta{char} to these two sets. +\DescribeMacro{\bbl@add@special} The \TeX book states: ``Plain \TeX\ +includes a macro called |\dospecials| that is essentially a set macro, +representing the set of all characters that have a special category +code.'' \cite[p.~380]{DEK} It is used to set text `verbatim'. To make +this work if more characters get a special category code, you have to +add this character to the macro |\dospecials|. \LaTeX\ adds another +macro called |\@sanitize| representing the same character set, but +without the curly braces. The macros |\bbl@add@special|\meta{char} add +the character \meta{char} to these two sets. \DescribeMacro{\@safe@activestrue} \DescribeMacro{\@safe@activesfalse} @@ -5052,7 +5646,7 @@ authors. See the description below. Language definition files may want to \emph{re}define macros that already exist. Therefore a mechanism for saving (and restoring) the original definition of those macros is provided. We provide two macros -for this\footnote{This mechanism was introduced by Bernd Raichle.}. +for this.\footnote{This mechanism was introduced by Bernd Raichle.} \DescribeMacro{\babel@save} To save the current meaning of any control sequence, the macro @@ -5075,7 +5669,7 @@ sequence or the previous value of the variable. \DescribeMacro{\addto} The macro |\addto{|\meta{control sequence}|}{|\meta{\TeX\ code}|}| can be used to extend the definition of a macro. The macro need not be -defined (ie, it can be undefined or |\relax|). This macro can, for +defined (i.e., it can be undefined or |\relax|). This macro can, for instance, be used in adding instructions to a macro like |\extrasenglish|. @@ -5119,9 +5713,16 @@ spacefactor. \DescribeMacro{\bbl@frenchspacing} \DescribeMacro{\bbl@nonfrenchspacing} -The commands |\bbl@frenchspacing| and |\bbl@nonfrenchspacing| can be +Those commands can be used to properly switch French spacing on and off. +\begin{note} + With |ldf| files, \babel{} does not take into account |\normalsfcodes| + and (non-)French spacing is not always properly (un)set by languages + However, problems are unlikely to happen and therefore this part + remains untouched. With |ini| files, this issue has been addressed. +\end{note} + \subsection{Encoding-dependent strings} \label{s:strings} @@ -5129,16 +5730,16 @@ used to properly switch French spacing on and off. encodings, intended mainly for \luatex{} and \xetex, although the old way of defining/switching strings still works and it's used by default. -It consist is a series of blocks started with +It consists in a series of blocks started with |\StartBabelCommands|. The last block is closed with -|\EndBabelCommands|. Each block is a single group (ie, local +|\EndBabelCommands|. Each block is a single group (i.e., local declarations apply until the next |\StartBabelCommands| or |\EndBabelCommands|). An |ldf| may contain several series of this kind. Thanks to this new feature, string values and string language switching -are not mixed any more. Furthermore, strings do no need to be wrapped -with formatting commands (eg, to select the writing direction) +are not mixed any more. Furthermore, strings do not need to be wrapped +with formatting commands (e.g., to select the writing direction) because \babel{} takes care of it automatically. (See also |\setlocalecaption|.) @@ -5151,20 +5752,20 @@ intended for. A block is taken into account only if the |\BabelLanguages| to a comma-separated list of languages to be defined (if undefined, |\StartBabelCommands| sets it to |\CurrentOption|). You may write |\CurrentOption| as the language, -but this is discouraged -- a explicit name (or names) is much better +but this is discouraged -- an explicit name (or names) is much better and clearer. -A ``selector'' selects a group of definition are to be used, optionally +A ``selector'' selects a group of definition that are to be used, optionally followed by extra info about the encodings to be used. The name -|unicode| must be used for \xetex{} and \luatex{}. Without a selector, -the LICR representation (ie, with macros like |\~{n}| instead of |ñ|) +|unicode| must be used for \luatex{} and \xetex{}. Without a selector, +the LICR representation (i.e., with macros like |\~{n}| instead of |ñ|) is assumed. If a string is set several times (because several blocks are read), -the first one takes precedence (ie, it works much like +the first one takes precedence (i.e., it works much like |\providecommand|). -Encoding info is |charset=| followed by a charset, which if given sets +Encoding info is |charset=| followed by a charset, which, if given, sets how the strings should be translated to the internal representation used by the engine, typically |utf8|, which is the only value supported currently (default is no translations). Note |charset| is @@ -5239,12 +5840,12 @@ A real example can be: \EndBabelCommands \end{verbatim} -When used in |ldf| files, previous values of |\|\m{category}\m{language} +When used in |ldf| files, previous values of |\<category><language>| are overridden, which means the old way to define strings still works and used by default (to be precise, is first set to undefined and then strings are added). However, when used in the preamble or in a package, new settings are added to the previous ones, if the language -exists (in the \babel{} sense, ie, if |\date|\m{language} exists). +exists (in the \babel{} sense, i.e., if |\date<language>| exists). \begin{note} The package option |strings| introduced in version 3.9 (around 2013) @@ -5257,17 +5858,14 @@ exists (in the \babel{} sense, ie, if |\date|\m{language} exists). with the help of these macros. \end{note} -\Describe\StartBabelCommands{% - \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}% +\Describe\StartBabelCommands{\optstar \marg{language-list}\marg{category}\oarg{selector}} The starred version just forces |strings| to take a value -- if not set as package option (which is now deprecated), then the default for the engine is used. This is not done by default to prevent backward incompatibilities, but if you are creating a new language this version is better. It's up to the maintainers of the current languages to -decide if using it is appropriate.\footnote{This replaces in 3.9g a -short-lived \texttt{\string\UseStrings} which has been removed because -it did not work.} +decide if using it is appropriate. \Describe{\EndBabelCommands}{} Marks the end of the series of blocks. @@ -5283,7 +5881,7 @@ transformation corresponding to the current charset or defined with the hook |stringprocess|). Use this command to define strings, without including any ``logic'' if -possible, which should be a separated macro. See the example above for +possible, which should be a separate macro. See the example above for the date. \Describe{\SetStringLoop}{\marg{macro-name}\marg{string-list}} @@ -5323,25 +5921,10 @@ by both \luatex{} and \xetex{}): \begin{note} This macro is not intended to fix wrong mappings done by Unicode - (which are the default in both \xetex{} and \luatex{}) -- if an + (which are the default in both \luatex{} and \xetex{}) -- if an assignment is wrong, fix it directly. \end{note} -\subsection{Executing code based on the selector} - -\Describe{\IfBabelSelectorTF}{\marg{selectors}\marg{true}\marg{false}} - -\New{3.67} Sometimes a different setup is desired depending on the -selector used. Values allowed in \m{selectors} are |select|, |other|, -|foreign|, |other*| (and also |foreign*| for the tentative starred -version), and it can consist of a comma-separated list. For example: -\begin{verbatim} -\IfBabelSelectorTF{other, other*}{A}{B} -\end{verbatim} -is true with any of these two environment selectors. - -Its natural place of use is in hooks or in |\extras|\m{language}. - \else \DocInput{babel.dtx} @@ -5350,13 +5933,16 @@ Its natural place of use is in hooks or in |\extras|\m{language}. \section{Acknowledgements} -I would like to thank all who volunteered as $\beta$-testers for their -time. Michel Goossens supplied contributions for most of the other -languages. Nico Poppelier helped polish the text of the documentation -and supplied parts of the macros for the Dutch language. Paul Wackers -and Werenfried Spit helped find and repair bugs. During the further -development of the babel system I received much help from Bernd -Raichle, for which I am grateful. +In the initial stages of the development of \babel, Bernd Raichle +provided many helpful suggestions and Michel Goossens supplied +contributions for many languages. Ideas from Nico Poppelier, Piet van +Oostrum and many others have been used. Paul Wackers and Werenfried +Spit helped find and repair bugs. + +More recently, there are significant contributions by Salim Bou, Ulrike +Fischer, Loren Davis and Udi Fogiel. + +Barbara Beeton has helped in improving the manual. There are also many contributors for specific languages, which are mentioned in the respective files. Without them, \babel{} just @@ -5367,7 +5953,7 @@ wouldn’t exist. Saqi, 2001. \bibitem{BEP} Johannes Braams, Victor Eijkhout and Nico Poppelier, \emph{The development of national \LaTeX\ styles}, - \emph{TUGboat} 10 (1989) \#3, p.~401--406. + \emph{TUGboat} 10 (1989) \#3, pp.~401--406. \bibitem{FE} Yannis Haralambous, \emph{Fonts \& Encodings}, O'Reilly, 2007. \bibitem{DEK} Donald E. Knuth, @@ -5386,14 +5972,14 @@ wouldn’t exist. Cambridge University Press, 2018 \bibitem{HP} Hubert Partl, \emph{German \TeX}, - \emph{TUGboat} 9 (1988) \#1, p.~70--72. + \emph{TUGboat} 9 (1988) \#1, pp.~70--72. \bibitem{ilatex} Joachim Schrod, \emph{International \LaTeX\ is ready to use}, - \emph{TUGboat} 11 (1990) \#1, p.~87--90. + \emph{TUGboat} 11 (1990) \#1, pp.~87--90. \bibitem{STS} Apostolos Syropoulos, Antonis Tsolomitis and Nick Sofroniu, \emph{Digital typography using \LaTeX}, - Springer, 2002, p.~301--373. + Springer, 2002, pp.~301--373. \bibitem{treebus} K.F. Treebus. \emph{Tekstwijzer, een gids voor het grafisch verwerken van tekst}, @@ -5401,24 +5987,11 @@ wouldn’t exist. \end{thebibliography} \end{document} %</filedriver> -% % \fi % -% \addtolength{\oddsidemargin}{-15pt} +% \addtolength{\oddsidemargin}{-5pt} % \addtolength{\textwidth}{50pt} -% -%\begingroup -% \catcode`<=\active% -% \catcode`>=\active -% \makeatletter -% \gdef\MakePrivateLetters{% -% \catcode`@=11\relax -% \gdef<##1{\ifx##1@$\langle\langle$\bgroup\itshape\rmfamily -% \expandafter\bblref -% \else\string<##1\fi}% -% \gdef\bblref##1@>{##1\/\egroup$\rangle\rangle$}}% -% \global\let\check@percent\saved@check@percent -%\endgroup +% \reversemarginpar % % \small % @@ -5430,8 +6003,6 @@ wouldn’t exist. % % \section{Identification and loading of required files} % -% \textit{Code documentation is still under revision.} - % The \babel{} package after unpacking consists of the following files: % \begin{description} % \itemsep=-\parskip @@ -5445,29 +6016,29 @@ wouldn’t exist. % \item[hyphen.cfg] is the file to be used when generating the % formats to load hyphenation patterns. % \end{description} -% There some additional |tex|, |def| and |lua| files +% There some additional |tex|, |def| and |lua| files. % % The \babel{} installer extends \textsf{docstrip} with a few % ``pseudo-guards'' to set ``variables'' used at installation time. -% They are used with |<||@name@>| at the appropriate places in the +% They are used with \texttt{<@name@>} at the appropriate places in the % source code and defined with either % $\langle\langle$\textit{name}=\textit{value}$\rangle\rangle$, or with % a series of lines between % $\langle\langle$|*|\textit{name}$\rangle\rangle$ and % $\langle\langle$|/|\textit{name}$\rangle\rangle$. The latter is -% cumulative (eg, with \textit{More package options}). That brings a -% little bit of literate programming. The guards |<-name>| and -% |<+name>| have been redefined, too. See |babel.ins| for further +% cumulative (e.g., with \textit{More package options}). That brings a +% little bit of literate programming. The guards \texttt{<-name>} and +% \texttt{<+name>} have been redefined, too. See |babel.ins| for further % details. % % \section{\texttt{locale} directory} % % A required component of \babel{} is a set of |ini| files with basic -% definitions for about 250 languages. They are distributed as a -% separate |zip| file, not packed as |dtx|. Most of them are +% definitions for about 300 languages. They are distributed as a +% separate |zip| file, not packed as |dtx|. Many of them are % essentially finished (except bugs and mistakes, of course). Some of % them are still incomplete (but they will be usable), and there are -% some omissions (eg, there are no geographic areas in Spanish). Not +% some omissions (e.g., there are no geographic areas in Spanish). Not % all include LICR variants. % % |babel-*.ini| files contain the actual data; |babel-*.tex| files are @@ -5479,15 +6050,14 @@ wouldn’t exist. % \section{Tools} % % \begin{macrocode} -%<<version=24.7>> -%<<date=2024/06/26>> +%<<version=25.4>> +%<<date=2025/02/14>> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They -% may change in the future}. This applies mainly to those recently +% may change in the future.} This applies mainly to those recently % added for replacing, trimming and looping. The older ones, like % |\bbl@afterfi|, will not change. -% % We define some basic macros which just make the code cleaner. % |\bbl@add| is now used internally instead of |\addto| because of % the unpredictable behavior of the latter. Used in @@ -5521,11 +6091,11 @@ wouldn’t exist. \def\bbl@for#1#2#3{\bbl@loopx#1{#2}{\ifx#1\@empty\else#3\fi}} % \end{macrocode} % -% \begin{macro}{\bbl@add@list} -% This internal macro adds its second argument to a comma -% separated list in its first argument. When the list is not -% defined yet (or empty), it will be initiated. It presumes -% expandable character strings. +% \macro{\bbl@add@list} +% This internal macro adds its second argument to a comma separated +% list in its first argument. When the list is not defined yet (or +% empty), it will be initiated. It presumes expandable character +% strings. % % \begin{macrocode} \def\bbl@add@list#1#2{% @@ -5536,36 +6106,30 @@ wouldn’t exist. #2}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@afterelse} -% \begin{macro}{\bbl@afterfi} -% Because the code that is used in the handling of active -% characters may need to look ahead, we take extra care to `throw' -% it over the |\else| and |\fi| parts of an -% |\if|-statement\footnote{This code is based on code presented in -% TUGboat vol. 12, no2, June 1991 in ``An expansion Power Lemma'' -% by Sonja Maus.}. These macros will break if another |\if...\fi| -% statement appears in one of the arguments and it is not enclosed -% in braces. +% \macro{\bbl@afterelse} +% \macro{\bbl@afterfi} +% Because the code that is used in the handling of active characters +% may need to look ahead, we take extra care to `throw' it over the +% |\else| and |\fi| parts of an |\if|-statement\footnote{This code is +% based on code presented in TUGboat vol. 12, no2, June 1991 in ``An +% expansion Power Lemma'' by Sonja Maus.}. These macros will break if +% another |\if...\fi| statement appears in one of the arguments and it +% is not enclosed in braces. % % \begin{macrocode} \long\def\bbl@afterelse#1\else#2\fi{\fi#1} \long\def\bbl@afterfi#1\fi{\fi#1} % \end{macrocode} % -% \end{macro} -% \end{macro} +% \macro{\bbl@exp} % -% \begin{macro}{\bbl@exp} -% -% Now, just syntactical sugar, but it makes partial expansion of -% some code a lot more simple and readable. Here |\\| stands for -% |\noexpand|, |\<..>| for |\noexpand| applied to a built macro -% name (which does not define the macro if undefined to -% |\relax|, because it is created locally), and |\[..]| for one-level -% expansion (where |..| is the macro name without the backslash). The -% result may be followed by extra arguments, if necessary. +% Now, just syntactical sugar, but it makes partial expansion of some +% code a lot more simple and readable. Here |\\| stands for +% |\noexpand|, |\<..>| for |\noexpand| applied to a built macro name +% (which does not define the macro if undefined to |\relax|, because it +% is created locally), and |\[..]| for one-level expansion (where |..| +% is the macro name without the backslash). The result may be followed +% by extra arguments, if necessary. % % \begin{macrocode} \def\bbl@exp#1{% @@ -5579,16 +6143,15 @@ wouldn’t exist. \def\bbl@exp@ue#1]{% \unexpanded\expandafter\expandafter\expandafter{\csname#1\endcsname}}% % \end{macrocode} -% \end{macro} % -% \begin{macro}{\bbl@trim} -% The following piece of code is stolen (with some changes) from -% \textsf{keyval}, by David Carlisle. It defines two macros: -% |\bbl@trim| and |\bbl@trim@def|. The first one strips the leading -% and trailing spaces from the second argument and then applies the -% first argument (a macro, |\toks@| and the like). The second one, -% as its name suggests, defines the first argument as the stripped -% second argument. +% \macro{\bbl@trim} +% The following piece of code is stolen (with some changes) from +% \textsf{keyval}, by David Carlisle. It defines two macros: +% |\bbl@trim| and |\bbl@trim@def|. The first one strips the leading and +% trailing spaces from the second argument and then applies the first +% argument (a macro, |\toks@| and the like). The second one, as its +% name suggests, defines the first argument as the stripped second +% argument. % % \begin{macrocode} \def\bbl@tempa#1{% @@ -5605,14 +6168,13 @@ wouldn’t exist. \long\def\bbl@trim@i#1\@nil#2\relax#3{#3{#1}} \long\def\bbl@trim@def#1{\bbl@trim{\def#1}} % \end{macrocode} -% \end{macro} % -% \begin{macro}{\bbl@ifunset} -% To check if a macro is defined, we create a new macro, which does -% the same as |\@ifundefined|. However, in an $\epsilon$-tex engine, -% it is based on |\ifcsname|, which is more efficient, and does not -% waste memory. Defined inside a group, to avoid \cs{ifcsname} being -% implicitly set to |\relax| by the |\csname| test. +% \macro{\bbl@ifunset} +% To check if a macro is defined, we create a new macro, which does the +% same as |\@ifundefined|. However, in an $\varepsilon$-tex engine, it is +% based on |\ifcsname|, which is more efficient, and does not waste +% memory. Defined inside a group, to avoid \cs{ifcsname} being +% implicitly set to |\relax| by the |\csname| test. % % \begin{macrocode} \begingroup @@ -5636,12 +6198,11 @@ wouldn’t exist. \fi}} \endgroup % \end{macrocode} -% \end{macro} % -% \begin{macro}{\bbl@ifblank} -% A tool from \textsf{url}, by Donald Arseneau, which tests if a -% string is empty or space. The companion macros tests if a macro is -% defined with some `real' value, ie, not |\relax| and not empty, +% \macro{\bbl@ifblank} +% A tool from \textsf{url}, by Donald Arseneau, which tests if a string +% is empty or space. The companion macros tests if a macro is defined +% with some `real' value, i.e., not |\relax| and not empty, % % \begin{macrocode} \def\bbl@ifblank#1{% @@ -5650,12 +6211,11 @@ wouldn’t exist. \def\bbl@ifset#1#2#3{% \bbl@ifunset{#1}{#3}{\bbl@exp{\\\bbl@ifblank{\@nameuse{#1}}}{#3}{#2}}} % \end{macrocode} -% \end{macro} % % For each element in the comma separated <key>|=|<value> list, % execute <code> with |#1| and |#2| as the key and the value of % current item (trimmed). In addition, the item is passed verbatim as -% |#3|. With the <key> alone, it passes |\@empty| (ie, the macro thus +% |#3|. With the <key> alone, it passes |\@empty| (i.e., the macro thus % named, not an empty argument, which is what you get with <key>|=| % and no value). % @@ -5688,7 +6248,7 @@ wouldn’t exist. \def\bbl@foreach#1{\expandafter\bbl@vforeach\expandafter{#1}} % \end{macrocode} % -% \begin{macro}{\bbl@replace} +% \macro{\bbl@replace} % % Returns implicitly |\toks@| with the modified string. % @@ -5708,7 +6268,7 @@ wouldn’t exist. % \end{macrocode} % % An extension to the previous macro. It takes into account the -% parameters, and it is string based (ie, if you replace |elax| by +% parameters, and it is string based (i.e., if you replace |elax| by % |ho|, then |\relax| becomes |\rho|). No checking is done at all, % because it is not a general purpose macro, and it is used by \babel{} % only when it works (an example where it does \textit{not} work is in @@ -5716,7 +6276,7 @@ wouldn’t exist. % because they are retokenized). It may change! (or even merged with % |\bbl@replace|; I'm not sure checking the replacement is really % necessary or just paranoia). -% +% % \begin{macrocode} \ifx\detokenize\@undefined\else % Unused macros if old Plain TeX \bbl@exp{\def\\\bbl@parsedef##1\detokenize{macro:}}#2->#3\relax{% @@ -5746,7 +6306,6 @@ wouldn’t exist. \bbl@tempc}} % empty or expand to set #1 with changes \fi % \end{macrocode} -% \end{macro} % % Two further tools. |\bbl@ifsamestring| first expand its arguments and % then compare their expansion (sanitized, so that the catcodes do not @@ -5803,9 +6362,9 @@ wouldn’t exist. {\expandafter\OE\expandafter}\expandafter{\oe}% \ifin@ \bbl@afterelse\expandafter\MakeUppercase - \else + \else \bbl@afterfi\expandafter\MakeLowercase - \fi + \fi \else \expandafter\@firstofone \fi} @@ -5816,7 +6375,7 @@ wouldn’t exist. % |#|'s. Used to deal with alph, Alph and frenchspacing when there are % already changes (with |\babel@save|). % -% \begin{macrocode} +% \begin{macrocode} \def\bbl@extras@wrap#1#2#3{% 1:in-test, 2:before, 3:after \toks@\expandafter\expandafter\expandafter{% \csname extras\languagename\endcsname}% @@ -5844,16 +6403,11 @@ wouldn’t exist. %<</Make sure ProvidesFile is defined>> % \end{macrocode} % -% \subsection{Multiple languages} +% \subsection{A few core definitions} % -% \begin{macro}{\language} +% \macro{\language} % -% Plain \TeX\ version~3.0 provides the primitive |\language| that -% is used to store the current language. When used with a pre-3.0 -% version this function has to be implemented by allocating a -% counter. The following block is used in \file{switch.def} and -% \file{hyphen.cfg}; the latter may seem redundant, but remember -% \babel{} doesn't requires loading \file{switch.def} in the format. +% Just for compatibility, for not to touch |hyphen.cfg|. % % \begin{macrocode} %<<*Define core switching macros>> @@ -5863,14 +6417,12 @@ wouldn’t exist. %<</Define core switching macros>> % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\last@language} +% \macro{\last@language} % % Another counter is used to keep track of the allocated languages. % \TeX{} and \LaTeX{} reserves for this purpose the count 19. % -% \begin{macro}{\addlanguage} +% \macro{\addlanguage} % % This macro was introduced for \TeX{} $<$ 2. Preserved for % compatibility. @@ -5882,50 +6434,59 @@ wouldn’t exist. %<</Define core switching macros>> % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% Now we make sure all required files are loaded. When the command -% |\AtBeginDocument| doesn't exist we assume that we are dealing -% with a plain-based format. In that case the file -% \file{plain.def} is needed (which also defines -% |\AtBeginDocument|, and therefore it is not loaded twice). We -% need the first part when the format is created, and |\orig@dump| -% is used as a flag. Otherwise, we need to use the second part, so -% |\orig@dump| is not defined (\file{plain.def} undefines it). +% Now we make sure all required files are loaded. When the command +% |\AtBeginDocument| doesn't exist we assume that we are dealing with a +% plain-based format. In that case the file \file{plain.def} is needed +% (which also defines |\AtBeginDocument|, and therefore it is not +% loaded twice). We need the first part when the format is created, and +% |\orig@dump| is used as a flag. Otherwise, we need to use the second +% part, so |\orig@dump| is not defined (\file{plain.def} undefines it). % -% Check if the current version of \file{switch.def} has been -% previously loaded (mainly, \file{hyphen.cfg}). If not, load it -% now. We cannot load |babel.def| here because we first need to -% declare and process the package options. +% Check if the current version of \file{switch.def} has been previously +% loaded (mainly, \file{hyphen.cfg}). If not, load it now. We cannot +% load |babel.def| here because we first need to declare and process +% the package options. % +% \subsection{\LaTeX: \texttt{babel.sty} (start)} % -% \subsection{The Package File (\LaTeX, \texttt{babel.sty})} +% Here starts the style file for \LaTeX. It also takes care of a number +% of compatibility issues with other packages. % % \begin{macrocode} %<*package> -\NeedsTeXFormat{LaTeX2e}[2005/12/01] -\ProvidesPackage{babel}[<@date@> v<@version@> The Babel package] +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{babel}% + [<@date@> v<@version@> + The multilingual framework for pdfLaTeX, LuaLaTeX and XeLaTeX] % \end{macrocode} -% -% Start with some “private” debugging tool, and then define macros for -% errors. +% +% Start with some “private” debugging tools, and then define macros for +% errors. The global lua ‘space’ |Babel| is declared here, too (inside +% the test for |debug|). % % \begin{macrocode} \@ifpackagewith{babel}{debug} {\providecommand\bbl@trace[1]{\message{^^J[ #1 ]}}% \let\bbl@debug\@firstofone \ifx\directlua\@undefined\else - \directlua{ Babel = Babel or {} + \directlua{ + Babel = Babel or {} Babel.debug = true }% \input{babel-debug.tex}% \fi} {\providecommand\bbl@trace[1]{}% \let\bbl@debug\@gobble \ifx\directlua\@undefined\else - \directlua{ Babel = Babel or {} + \directlua{ + Babel = Babel or {} Babel.debug = false }% \fi} +% \end{macrocode} +% +% Macros to deal with errors, warnings, etc. Errors are stored in a +% separate file. +% +% \begin{macrocode} \def\bbl@error#1{% Implicit #2#3#4 \begingroup \catcode`\\=0 \catcode`\==12 \catcode`\`=12 @@ -5949,13 +6510,8 @@ wouldn’t exist. \endgroup} % \end{macrocode} % -% This file also takes care of a number of compatibility issues with -% other packages an defines a few additional package options. Apart from -% all the language options below we also have a few options that -% influence the behavior of language definition files. -% % Many of the following options don’t do anything themselves, they are -% just defined in order to make it possible for babel and language +% just defined in order to make it possible for \babel{} and language % definition files to check if one of them was specified by the user. % % But first, include here the \textit{Basic macros} defined above. @@ -6000,14 +6556,14 @@ wouldn’t exist. % \subsection{\texttt{base}} % % The first `real' option to be processed is |base|, which set the -% hyphenation patterns then resets |ver@babel.sty| so that \LaTeX +% hyphenation patterns then resets |ver@babel.sty| so that \LaTeX{} % forgets about the first loading. After a subset of |babel.def| has % been loaded (the old |switch.def|) and |\AfterBabelLanguage| defined, % it exits. % % Now the \texttt{base} option. With it we can define (and load, with % \luatex) hyphenation patterns, even if we are not interested in the -% rest of babel. +% rest of \babel{}. % % \begin{macrocode} \bbl@trace{Defining option 'base'} @@ -6034,12 +6590,10 @@ wouldn’t exist. % % \subsection{\texttt{key=value} options and other general option} % -% The following macros extract language modifiers, and only real -% package options are kept in the option list. Modifiers are saved -% and assigned to |\BabelModifiers| at |\bbl@load@language|; when -% no modifiers have been given, the former is |\relax|. How -% modifiers are handled are left to language styles; they can use -% |\in@|, loop them with |\@for| or load |keyval|, for example. +% The following macros extract language modifiers, and only real +% package options are kept in the option list. Modifiers are saved and +% assigned to |\BabelModifiers| at |\bbl@load@language|; when no +% modifiers have been given, the former is |\relax|. % % \begin{macrocode} \bbl@trace{key=value and another general options} @@ -6048,7 +6602,7 @@ wouldn’t exist. #1\ifx\@empty#2\else,\bbl@afterfi\bbl@tempb#2\fi}% \def\bbl@tempe#1=#2\@@{% \bbl@csarg\edef{mod@#1}{\bbl@tempb#2}} -\def\bbl@tempd#1.#2\@nnil{% TODO. Refactor lists? +\def\bbl@tempd#1.#2\@nnil{% \ifx\@empty#2% \edef\bbl@tempc{\ifx\bbl@tempc\@empty\else\bbl@tempc,\fi#1}% \else @@ -6057,10 +6611,10 @@ wouldn’t exist. \edef\bbl@tempc{% \ifx\bbl@tempc\@empty\else\bbl@tempc,\fi#1.\bbl@tempb#2}% \else - \in@{$modifiers$}{$#1$}% TODO. Allow spaces. + \in@{$modifiers$}{$#1$}% \ifin@ \bbl@tempe#2\@@ - \else + \else \in@{=}{#1}% \ifin@ \edef\bbl@tempc{\ifx\bbl@tempc\@empty\else\bbl@tempc,\fi#1.#2}% @@ -6090,15 +6644,11 @@ wouldn’t exist. \DeclareOption{noconfigs}{} \DeclareOption{showlanguages}{} \DeclareOption{silent}{} -% \DeclareOption{mono}{} \DeclareOption{shorthands=off}{\bbl@tempa shorthands=\bbl@tempa} \chardef\bbl@iniflag\z@ -\DeclareOption{provide=*}{\chardef\bbl@iniflag\@ne} % main -> +1 -\DeclareOption{provide+=*}{\chardef\bbl@iniflag\tw@} % add = 2 -\DeclareOption{provide*=*}{\chardef\bbl@iniflag\thr@@} % add + main -% A separate option -\let\bbl@autoload@options\@empty -\DeclareOption{provide@=*}{\def\bbl@autoload@options{import}} +\DeclareOption{provide=*}{\chardef\bbl@iniflag\@ne} % main = 1 +\DeclareOption{provide+=*}{\chardef\bbl@iniflag\tw@} % second = 2 +\DeclareOption{provide*=*}{\chardef\bbl@iniflag\thr@@} % second + main % Don't use. Experimental. TODO. \newif\ifbbl@single \DeclareOption{selectors=off}{\bbl@singletrue} @@ -6145,7 +6695,7 @@ wouldn’t exist. \bbl@xin@{\string=}{\CurrentOption}% \ifin@ \expandafter\bbl@tempa\CurrentOption\bbl@tempa - \else + \else \bbl@add@list\bbl@language@opts{\CurrentOption}% \fi} % \end{macrocode} @@ -6156,6 +6706,8 @@ wouldn’t exist. \ProcessOptions* % \end{macrocode} % +% \subsection{Post-process some options} +% % \begin{macrocode} \ifx\bbl@opt@provide\@nnil \let\bbl@opt@provide\@empty % %%% MOVE above @@ -6165,14 +6717,10 @@ wouldn’t exist. \in@{,provide,}{,#1,}% \ifin@ \def\bbl@opt@provide{#2}% - \bbl@replace\bbl@opt@provide{;}{,}% \fi} \fi -% % \end{macrocode} % -% \subsection{Conditional loading of shorthands} -% % If there is no |shorthands=<chars>|, the original \textsf{babel} % macros are left untouched, but if there is, these macros are % wrapped (in |babel.def|) to define only those given. @@ -6199,8 +6747,7 @@ wouldn’t exist. \else % \end{macrocode} % -% The following macro tests if a shorthand is one of the allowed -% ones. +% The following macro tests if a shorthand is one of the allowed ones. % % \begin{macrocode} \def\bbl@ifshorthand#1{% @@ -6231,7 +6778,7 @@ wouldn’t exist. \fi\fi % \end{macrocode} % -% With |headfoot=lang| we can set the language used in heads/foots. +% With |headfoot=lang| we can set the language used in heads/feet. % For example, in babel/3796 just add |headfoot=english|. It % misuses \cs{@resetactivechars}, but seems to work. % @@ -6280,10 +6827,9 @@ wouldn’t exist. \fi} \fi %</package> -%<*core> % \end{macrocode} % -% \subsection{Interlude for Plain} +% \subsection{Plain: \texttt{babel.def} (start)} % % Because of the way \pkg{docstrip} works, we need to insert some code % for Plain here. However, the tools provided by the \babel{} @@ -6291,41 +6837,34 @@ wouldn’t exist. % interlude, because the actual code is below, tagged as % \textit{Emulate LaTeX}. % +% First, exit immediately if previouly loaded. +% % \begin{macrocode} +%<*core> \ifx\ldf@quit\@undefined\else \endinput\fi % Same line! <@Make sure ProvidesFile is defined@> \ProvidesFile{babel.def}[<@date@> v<@version@> Babel common definitions] -\ifx\AtBeginDocument\@undefined % TODO. change test. +\ifx\AtBeginDocument\@undefined <@Emulate LaTeX@> \fi <@Basic macros@> +%</core> % \end{macrocode} % % That is all for the moment. Now follows some common stuff, for both % Plain and \LaTeX{}. After it, we will resume the \LaTeX-only stuff. % -% \begin{macrocode} -%</core> -%<*package|core> -% \end{macrocode} -% -% \section{Multiple languages} -% -% This is not a separate file (\texttt{switch.def}) anymore. -% -% Plain \TeX\ version~3.0 provides the primitive |\language| that -% is used to store the current language. When used with a pre-3.0 -% version this function has to be implemented by allocating a -% counter. +% \section{\texttt{babel.sty} and \texttt{babel.def} (common)} % % \begin{macrocode} +%<*package|core> \def\bbl@version{<@version@>} \def\bbl@date{<@date@>} <@Define core switching macros@> % \end{macrocode} % -% \begin{macro}{\adddialect} +% \macro{\adddialect} % The macro |\adddialect| can be used to add the name of a dialect % or variant language, for which an already defined hyphenation % table can be used. @@ -6348,19 +6887,16 @@ wouldn’t exist. \endgroup} % \end{macrocode} % -% \end{macro} -% -% |\bbl@iflanguage| executes code only if the language |l@| -% exists. Otherwise raises an error. +% |\bbl@iflanguage| executes code only if the language |l@| exists. +% Otherwise raises an error. % -% The argument of |\bbl@fixname| has to be a macro name, as it may get -% ``fixed'' if casing (lc/uc) is wrong. It's an attempt to fix a -% long-standing bug when |\foreignlanguage| and the like appear in -% a |\MakeXXXcase|. However, a lowercase form is not imposed to -% improve backward compatibility (perhaps you defined a language -% named |MYLANG|, but unfortunately mixed case names cannot be -% trapped). Note |l@| is encapsulated, so that its case does not -% change. +% The argument of |\bbl@fixname| has to be a macro name, as it may get +% ``fixed'' if casing (lc/uc) is wrong. It's an attempt to fix a +% long-standing bug when |\foreignlanguage| and the like appear in a +% |\MakeXXXcase|. However, a lowercase form is not imposed to improve +% backward compatibility (perhaps you defined a language named +% |MYLANG|, but unfortunately mixed case names cannot be trapped). Note +% |l@| is encapsulated, so that its case does not change. % % \begin{macrocode} \def\bbl@fixname#1{% @@ -6385,14 +6921,14 @@ wouldn’t exist. % % After a name has been ‘fixed’, the selectors will try to load the % language. If even the fixed name is not defined, will load it on the -% fly, either based on its name, or if activated, its BCP47 code. +% fly, either based on its name, or if activated, its BCP 47 code. % % We first need a couple of macros for a simple BCP 47 look up. It also % makes sure, with |\bbl@bcpcase|, casing is the correct one, so that % sr-latn-ba becomes fr-Latn-BA. Note |#4| may contain some % |\@empty|'s, but they are eventually removed. |\bbl@bcplookup| either % returns the found |ini| or it is |\relax|. -% +% % \begin{macrocode} \def\bbl@bcpcase#1#2#3#4\@@#5{% \ifx\@empty#3% @@ -6411,7 +6947,7 @@ wouldn’t exist. \IfFileExists{babel-\bbl@tempa-\bbl@tempb.ini}% {\edef\bbl@bcp{\bbl@tempa-\bbl@tempb}}% {}% - \ifx\bbl@bcp\relax + \ifx\bbl@bcp\relax \IfFileExists{babel-\bbl@tempa.ini}{\let\bbl@bcp\bbl@tempa}{}% \fi \else @@ -6420,54 +6956,24 @@ wouldn’t exist. \IfFileExists{babel-\bbl@tempa-\bbl@tempb-\bbl@tempc.ini}% {\edef\bbl@bcp{\bbl@tempa-\bbl@tempb-\bbl@tempc}}% {}% - \ifx\bbl@bcp\relax + \ifx\bbl@bcp\relax \IfFileExists{babel-\bbl@tempa-\bbl@tempc.ini}% {\edef\bbl@bcp{\bbl@tempa-\bbl@tempc}}% {}% \fi - \ifx\bbl@bcp\relax + \ifx\bbl@bcp\relax \IfFileExists{babel-\bbl@tempa-\bbl@tempc.ini}% {\edef\bbl@bcp{\bbl@tempa-\bbl@tempc}}% {}% \fi - \ifx\bbl@bcp\relax + \ifx\bbl@bcp\relax \IfFileExists{babel-\bbl@tempa.ini}{\let\bbl@bcp\bbl@tempa}{}% \fi \fi\fi} \let\bbl@initoload\relax -%<-core> -\def\bbl@provide@locale{% - \ifx\babelprovide\@undefined - \bbl@error{base-on-the-fly}{}{}{}% - \fi - \let\bbl@auxname\languagename % Still necessary. TODO - \bbl@ifunset{bbl@bcp@map@\languagename}{}% Move uplevel?? - {\edef\languagename{\@nameuse{bbl@bcp@map@\languagename}}}% - \ifbbl@bcpallowed - \expandafter\ifx\csname date\languagename\endcsname\relax - \expandafter - \bbl@bcplookup\languagename-\@empty-\@empty-\@empty\@@ - \ifx\bbl@bcp\relax\else % Returned by \bbl@bcplookup - \edef\languagename{\bbl@bcp@prefix\bbl@bcp}% - \edef\localename{\bbl@bcp@prefix\bbl@bcp}% - \expandafter\ifx\csname date\languagename\endcsname\relax - \let\bbl@initoload\bbl@bcp - \bbl@exp{\\\babelprovide[\bbl@autoload@bcpoptions]{\languagename}}% - \let\bbl@initoload\relax - \fi - \bbl@csarg\xdef{bcp@map@\bbl@bcp}{\localename}% - \fi - \fi - \fi - \expandafter\ifx\csname date\languagename\endcsname\relax - \IfFileExists{babel-\languagename.tex}% - {\bbl@exp{\\\babelprovide[\bbl@autoload@options]{\languagename}}}% - {}% - \fi} -%<+core> % \end{macrocode} % -% \begin{macro}{\iflanguage} +% \macro{\iflanguage} % Users might want to test (in a private package for instance) % which language is currently active. For this we provide a test % macro, |\iflanguage|, that has three arguments. It checks @@ -6486,13 +6992,11 @@ wouldn’t exist. \fi}} % \end{macrocode} % -% \end{macro} -% % \subsection{Selecting the language} % -% \begin{macro}{\selectlanguage} +% \macro{\selectlanguage} % -% The macro |\selectlanguage| checks whether the language is +% It checks whether the language is % already defined before it performs its actual task, which is to % update |\language| and activate language-specific definitions. % @@ -6513,20 +7017,18 @@ wouldn’t exist. % \end{macrocode} % % The following definition is preserved for backwards compatibility -% (eg, \textsf{arabi}, \textsf{koma}). It is related to a trick for +% (e.g., \textsf{arabi}, \textsf{koma}). It is related to a trick for % 2.09, now discarded. % % \begin{macrocode} \let\xstring\string % \end{macrocode} % -% \end{macro} +% Since version 3.5 \babel\ writes entries to the auxiliary files in +% order to typeset table of contents etc. in the correct language +% environment. % -% Since version 3.5 \babel\ writes entries to the auxiliary files in -% order to typeset table of contents etc. in the correct language -% environment. -% -% \begin{macro}{\bbl@pop@language} +% \macro{\bbl@pop@language} % % \emph{But} when the language change happens \emph{inside} a group % the end of the group doesn't write anything to the auxiliary @@ -6537,7 +7039,7 @@ wouldn’t exist. % executed at the end of the group. It calls |\bbl@set@language| % with the name of the current language as its argument. % -% \begin{macro}{\bbl@language@stack} +% \macro{\bbl@language@stack} % The previous solution works for one level of nesting groups, but % as soon as more levels are used it is no longer adequate. For % that case we need to keep track of the nested languages using a @@ -6551,8 +7053,8 @@ wouldn’t exist. % When using a stack we need a mechanism to push an element on the % stack and to retrieve the information afterwards. % -% \begin{macro}{\bbl@push@language} -% \begin{macro}{\bbl@pop@language} +% \macro{\bbl@push@language} +% \macro{\bbl@pop@language} % The stack is simply a list of languagenames, separated with a `+' % sign; the push function can be simple: % @@ -6566,7 +7068,7 @@ wouldn’t exist. \xdef\bbl@language@stack{\languagename+}% \else \xdef\bbl@language@stack{\languagename+\bbl@language@stack}% - \fi + \fi \fi \fi} % \end{macrocode} @@ -6575,10 +7077,10 @@ wouldn’t exist. % we need to remove the element from the stack while storing it in the % macro |\languagename|. For this we first define a helper function. % -% \begin{macro}{\bbl@pop@lang} -% This macro stores its first element (which is delimited by the -% `+'-sign) in |\languagename| and stores the rest of the string -% in |\bbl@language@stack|. +% \macro{\bbl@pop@lang} +% This macro stores its first element (which is delimited by the +% `+'-sign) in |\languagename| and stores the rest of the string in +% |\bbl@language@stack|. % % \begin{macrocode} \def\bbl@pop@lang#1+#2\@@{% @@ -6586,7 +7088,6 @@ wouldn’t exist. \xdef\bbl@language@stack{#2}} % \end{macrocode} % -% \end{macro} % The reason for the somewhat weird arrangement of arguments to the % helper function is the fact it is called in the following way. % This means that before |\bbl@pop@lang| is executed \TeX\ first @@ -6608,9 +7109,6 @@ wouldn’t exist. % Once the name of the previous language is retrieved from the stack, % it is fed to |\bbl@set@language| to do the actual work of % switching everything that needs switching. -% \end{macro} -% \end{macro} -% \end{macro} % % An alternative way to identify languages (in the \babel{} sense) % with a numerical value is introduced in 3.30. This is one of the @@ -6626,14 +7124,13 @@ wouldn’t exist. \bbl@ifunset{bbl@id@@\languagename}% {\count@\bbl@id@last\relax \advance\count@\@ne - \bbl@csarg\chardef{id@@\languagename}\count@ + \global\bbl@csarg\chardef{id@@\languagename}\count@ \edef\bbl@id@last{\the\count@}% \ifcase\bbl@engine\or \directlua{ - Babel = Babel or {} - Babel.locale_props = Babel.locale_props or {} Babel.locale_props[\bbl@id@last] = {} Babel.locale_props[\bbl@id@last].name = '\languagename' + Babel.locale_props[\bbl@id@last].vars = {} }% \fi}% {}% @@ -6652,9 +7149,7 @@ wouldn’t exist. \let\endselectlanguage\relax % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@set@language} +% \macro{\bbl@set@language} % % The macro |\bbl@set@language| takes care of switching the language % environment \emph{and} of writing entries on the auxiliary files. @@ -6681,30 +7176,8 @@ wouldn’t exist. % \begin{macrocode} \def\BabelContentsFiles{toc,lof,lot} \def\bbl@set@language#1{% from selectlanguage, pop@ - % The old buggy way. Preserved for compatibility. - \edef\languagename{% - \ifnum\escapechar=\expandafter`\string#1\@empty - \else\string#1\@empty\fi}% - \ifcat\relax\noexpand#1% - \expandafter\ifx\csname date\languagename\endcsname\relax - \edef\languagename{#1}% - \let\localename\languagename - \else - \bbl@info{Using '\string\language' instead of 'language' is\\% - deprecated. If what you want is to use a\\% - macro containing the actual locale, make\\% - sure it does not not match any language.\\% - Reported}% - \ifx\scantokens\@undefined - \def\localename{??}% - \else - \scantokens\expandafter{\expandafter - \def\expandafter\localename\expandafter{\languagename}}% - \fi - \fi - \else - \def\localename{#1}% This one has the correct catcodes - \fi + % The old buggy way. Preserved for compatibility, but simplified + \edef\languagename{\expandafter\string#1\@empty}% \select@language{\languagename}% % write to auxs \expandafter\ifx\csname date\languagename\endcsname\relax\else @@ -6721,18 +7194,21 @@ wouldn’t exist. \let\bbl@restorelastskip\relax \let\bbl@savelastskip\relax % -\newif\ifbbl@bcpallowed -\bbl@bcpallowedfalse -\def\select@language#1{% from set@, babel@aux +\def\select@language#1{% from set@, babel@aux, babel@toc \ifx\bbl@selectorname\@empty \def\bbl@selectorname{select}% - % set hymap \fi + % set hymap \ifnum\bbl@hymapsel=\@cclv\chardef\bbl@hymapsel4\relax\fi - % set name + % set name (when coming from babel@aux) \edef\languagename{#1}% \bbl@fixname\languagename - % TODO. name@map must be here? + % define \localename when coming from set@, with a trick + \ifx\scantokens\@undefined + \def\localename{??}% + \else + \bbl@exp{\\\scantokens{\def\\\localename{\languagename}\\\noexpand}\relax}% + \fi \bbl@provide@locale \bbl@iflanguage\languagename{% \let\bbl@select@type\z@ @@ -6740,13 +7216,11 @@ wouldn’t exist. \def\babel@aux#1#2{% \select@language{#1}% \bbl@foreach\BabelContentsFiles{% \relax -> don't assume vertical mode - \@writefile{##1}{\babel@toc{#1}{#2}\relax}}}% TODO - plain? + \@writefile{##1}{\babel@toc{#1}{#2}\relax}}}% \def\babel@toc#1#2{% \select@language{#1}} % \end{macrocode} % -% \end{macro} -% % First, check if the user asks for a known language. If so, % update the value of |\language| and call |\originalTeX| % to bring \TeX\ in a certain pre-defined state. @@ -6772,7 +7246,7 @@ wouldn’t exist. % current values, then we check if |\|\langvar|hyphenmins| is % defined. If it is not, we set default values (2 and 3), otherwise % the values in |\|\langvar|hyphenmins| will be used. -% +% % No text is supposed to be added with switching captions and date, so % we remove any spurious spaces with |\bbl@bsphack| and |\bbl@esphack|. % @@ -6803,7 +7277,7 @@ wouldn’t exist. \csname captions#1\endcsname\relax \fi \bbl@xin@{,date,}{,\bbl@select@opts,}% - \ifin@ % if \foreign... within \<lang>date + \ifin@ % if \foreign... within \<language>date \csname date#1\endcsname\relax \fi \fi @@ -6841,8 +7315,14 @@ wouldn’t exist. \bbl@xin@{/u}{/\bbl@tempa}% \ifin@\else\bbl@xin@{/e}{/\bbl@tempa}\fi % elongated forms \ifin@\else\bbl@xin@{/k}{/\bbl@tempa}\fi % only kashida - \ifin@\else\bbl@xin@{/p}{/\bbl@tempa}\fi % padding (eg, Tibetan) + \ifin@\else\bbl@xin@{/p}{/\bbl@tempa}\fi % padding (e.g., Tibetan) \ifin@\else\bbl@xin@{/v}{/\bbl@tempa}\fi % variable font + % hyphenation - save mins + \babel@savevariable\lefthyphenmin + \babel@savevariable\righthyphenmin + \ifnum\bbl@engine=\@ne + \babel@savevariable\hyphenationmin + \fi \ifin@ % unhyphenated/kashida/elongated/padding = allow stretching \language\l@unhyphenated @@ -6854,21 +7334,23 @@ wouldn’t exist. % other = select patterns \bbl@patterns{#1}% \fi - % hyphenation - mins - \babel@savevariable\lefthyphenmin - \babel@savevariable\righthyphenmin + % hyphenation - set mins \expandafter\ifx\csname #1hyphenmins\endcsname\relax \set@hyphenmins\tw@\thr@@\relax + \@nameuse{bbl@hyphenmins@}% \else \expandafter\expandafter\expandafter\set@hyphenmins \csname #1hyphenmins\endcsname\relax \fi - % reset selector name + \@nameuse{bbl@hyphenmins@}% + \@nameuse{bbl@hyphenmins@\languagename}% + \@nameuse{bbl@hyphenatmin@}% + \@nameuse{bbl@hyphenatmin@\languagename}% \let\bbl@selectorname\@empty} % \end{macrocode} % -% \begin{environment}{otherlanguage} -% The \Lenv{otherlanguage} environment can be used as an alternative to +% \environment{otherlanguage} +% It can be used as an alternative to % using the |\selectlanguage| declarative command. The |\ignorespaces| % command is necessary to hide the environment when it is entered in % horizontal mode. @@ -6888,13 +7370,11 @@ wouldn’t exist. \long\def\endotherlanguage{\@ignoretrue\ignorespaces} % \end{macrocode} % -% \end{environment} -% -% \begin{environment}{otherlanguage*} -% The \Lenv{otherlanguage} environment is meant to be used when a +% \environment{otherlanguage*} +% It is meant to be used when a % large part of text from a different language needs to be typeset, % but without changing the translation of words such as `figure'. -% This environment makes use of |\foreign@language|. +% It makes use of |\foreign@language|. % % \begin{macrocode} \expandafter\def\csname otherlanguage*\endcsname{% @@ -6914,14 +7394,11 @@ wouldn’t exist. \expandafter\let\csname endotherlanguage*\endcsname\relax % \end{macrocode} % -% \end{environment} -% -% \begin{macro}{\foreignlanguage} +% \macro{\foreignlanguage} % -% The |\foreignlanguage| command is another substitute for the -% |\selectlanguage| command. This command takes two arguments, the -% first argument is the name of the language to use for typesetting -% the text specified in the second argument. +% This command takes two arguments, the first argument is the name of +% the language to use for typesetting the text specified in the second +% argument. % % Unlike |\selectlanguage| this command doesn't switch % \emph{everything}, it only switches the hyphenation rules and the @@ -6984,11 +7461,12 @@ wouldn’t exist. \BabelText{#2}% Still in vertical mode! {\par}% \endgroup} +\providecommand\BabelWrapText[1]{% + \def\bbl@tempa{\def\BabelText####1}% + \expandafter\bbl@tempa\expandafter{\BabelText{#1}}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\foreign@language} +% \macro{\foreign@language} % % This macro does the work for |\foreignlanguage| and the % \Lenv{otherlanguage*} environment. First we need to store the name @@ -7004,6 +7482,7 @@ wouldn’t exist. \bbl@usedategroupfalse \fi \bbl@fixname\languagename + \let\localename\languagename % TODO. name@map here? \bbl@provide@locale \bbl@iflanguage\languagename{% @@ -7011,8 +7490,6 @@ wouldn’t exist. \expandafter\bbl@switch\expandafter{\languagename}}} % \end{macrocode} % -% \end{macro} -% % The following macro executes conditionally some code based on the % selector being used. % @@ -7026,7 +7503,7 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \begin{macro}{\bbl@patterns} +% \macro{\bbl@patterns} % % This macro selects the hyphenation patterns by changing the % \cs{language} register. If special hyphenation patterns @@ -7073,12 +7550,10 @@ wouldn’t exist. \endgroup}} % \end{macrocode} % -% \end{macro} +% \environment{hyphenrules} % -% \begin{environment}{hyphenrules} -% -% The environment \Lenv{hyphenrules} can be used to select -% \emph{just} the hyphenation rules. This environment does +% It can be used to select +% \emph{just} the hyphenation rules. It does % \emph{not} change |\languagename| and when the hyphenation rules % specified were not loaded it has no effect. Note however, % |\lccode|'s and font encodings are not set at all, so in most @@ -7102,9 +7577,7 @@ wouldn’t exist. \let\endhyphenrules\@empty % \end{macrocode} % -% \end{environment} -% -% \begin{macro}{\providehyphenmins} +% \macro{\providehyphenmins} % The macro |\providehyphenmins| should be used in the language % definition files to provide a \emph{default} setting for the % hyphenation parameters |\lefthyphenmin| and |\righthyphenmin|. If @@ -7118,11 +7591,9 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\set@hyphenmins} -% This macro sets the values of |\lefthyphenmin| and -% |\righthyphenmin|. It expects two values as its argument. +% \macro{\set@hyphenmins} +% This macro sets the values of |\lefthyphenmin| and |\righthyphenmin|. +% It expects two values as its argument. % % \begin{macrocode} \def\set@hyphenmins#1#2{% @@ -7130,16 +7601,14 @@ wouldn’t exist. \righthyphenmin#2\relax} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\ProvidesLanguage} +% \macro{\ProvidesLanguage} % The identification code for each file is something that was % introduced in \LaTeXe. When the command |\ProvidesFile| does not % exist, a dummy definition is provided temporarily. For use in the % language definition file the command |\ProvidesLanguage| is % defined by \babel. % -% Depending on the format, ie, on if the former is defined, we use +% Depending on the format, i.e., or if the former is defined, we use % a similar definition or not. % % \begin{macrocode} @@ -7161,27 +7630,23 @@ wouldn’t exist. \fi % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\originalTeX} -% The macro|\originalTeX| should be known to \TeX\ at this moment. -% As it has to be expandable we |\let| it to |\@empty| instead of -% |\relax|. +% \macro{\originalTeX} +% The macro|\originalTeX| should be known to \TeX\ at this moment. As +% it has to be expandable we |\let| it to |\@empty| instead of +% |\relax|. % % \begin{macrocode} \ifx\originalTeX\@undefined\let\originalTeX\@empty\fi % \end{macrocode} % -% Because this part of the code can be included in a format, we -% make sure that the macro which initializes the save mechanism, -% |\babel@beginsave|, is not considered to be undefined. +% Because this part of the code can be included in a format, we make +% sure that the macro which initializes the save mechanism, +% |\babel@beginsave|, is not considered to be undefined. % % \begin{macrocode} \ifx\babel@beginsave\@undefined\let\babel@beginsave\relax\fi % \end{macrocode} % -% \end{macro} -% % A few macro names are reserved for future releases of \babel, which % will use the concept of `locale': % @@ -7197,8 +7662,8 @@ wouldn’t exist. % % \subsection{Errors} % -% \begin{macro}{\@nolanerr} -% \begin{macro}{\@nopatterns} +% \macro{\@nolanerr} +% \macro{\@nopatterns} % % The \babel\ package will signal an error when a documents tries % to select a language that hasn't been defined earlier. When a @@ -7208,7 +7673,7 @@ wouldn’t exist. % In most formats that will be (US)english, but it might also be % empty. % -% \begin{macro}{\@noopterr} +% \macro{\@noopterr} % When the package was loaded without options not everything will % work as expected. An error message is issued in that case. % @@ -7231,7 +7696,7 @@ wouldn’t exist. \bbl@warning{% \@backslashchar#1 not set for '\languagename'. Please,\\% define it after the language has been loaded\\% - (typically in the preamble) with:\\% + (typically in the preamble) with:\\% \string\setlocalecaption{\languagename}{\bbl@tempa}{..}\\% Feel free to contribute on github.com/latex3/babel.\\% Reported}} @@ -7251,20 +7716,142 @@ wouldn’t exist. rebuild the format. Now I will use the patterns\\% preloaded for \bbl@nulllanguage\space instead}} \let\bbl@usehooks\@gobbletwo +% \end{macrocode} +% +% Here ended the now discarded |switch.def|. +% +% Here also (currently) ends the \textsf{base} option. +% +% \begin{macrocode} \ifx\bbl@onlyswitch\@empty\endinput\fi - % Here ended switch.def % \end{macrocode} % -% Here ended the now discarded |switch.def|. Here also (currently) ends -% the \textsf{base} option. +% \subsection{More on selection} +% +% \macro{\babelensure} +% +% The user command just parses the optional argument and creates a +% new macro named |\bbl@e@<language>|. We register a hook at the +% |afterextras| event which just executes this macro in a +% ``complete'' selection (which, if undefined, is |\relax| and does +% nothing). This part is somewhat involved because we have to make +% sure things are expanded the correct number of times. +% +% The macro |\bbl@e@<language>| contains +% |\bbl@ensure|\marg{include}\marg{exclude}\marg{fontenc}, which in in +% turn loops over the macros names in |\bbl@captionslist|, excluding +% (with the help of |\in@|) those in the |exclude| list. If the +% |fontenc| is given (and not |\relax|), the |\fontencoding| is also +% added. Then we loop over the |include| list, but if the macro +% already contains |\foreignlanguage|, nothing is done. Note this +% macro (1) is not restricted to the preamble, and (2) changes are +% local. % % \begin{macrocode} +\bbl@trace{Defining babelensure} +\newcommand\babelensure[2][]{% + \AddBabelHook{babel-ensure}{afterextras}{% + \ifcase\bbl@select@type + \bbl@cl{e}% + \fi}% + \begingroup + \let\bbl@ens@include\@empty + \let\bbl@ens@exclude\@empty + \def\bbl@ens@fontenc{\relax}% + \def\bbl@tempb##1{% + \ifx\@empty##1\else\noexpand##1\expandafter\bbl@tempb\fi}% + \edef\bbl@tempa{\bbl@tempb#1\@empty}% + \def\bbl@tempb##1=##2\@@{\@namedef{bbl@ens@##1}{##2}}% + \bbl@foreach\bbl@tempa{\bbl@tempb##1\@@}% + \def\bbl@tempc{\bbl@ensure}% + \expandafter\bbl@add\expandafter\bbl@tempc\expandafter{% + \expandafter{\bbl@ens@include}}% + \expandafter\bbl@add\expandafter\bbl@tempc\expandafter{% + \expandafter{\bbl@ens@exclude}}% + \toks@\expandafter{\bbl@tempc}% + \bbl@exp{% + \endgroup + \def\<bbl@e@#2>{\the\toks@{\bbl@ens@fontenc}}}} +\def\bbl@ensure#1#2#3{% 1: include 2: exclude 3: fontenc + \def\bbl@tempb##1{% elt for (excluding) \bbl@captionslist list + \ifx##1\@undefined % 3.32 - Don't assume the macro exists + \edef##1{\noexpand\bbl@nocaption + {\bbl@stripslash##1}{\languagename\bbl@stripslash##1}}% + \fi + \ifx##1\@empty\else + \in@{##1}{#2}% + \ifin@\else + \bbl@ifunset{bbl@ensure@\languagename}% + {\bbl@exp{% + \\\DeclareRobustCommand\<bbl@ensure@\languagename>[1]{% + \\\foreignlanguage{\languagename}% + {\ifx\relax#3\else + \\\fontencoding{#3}\\\selectfont + \fi + ########1}}}}% + {}% + \toks@\expandafter{##1}% + \edef##1{% + \bbl@csarg\noexpand{ensure@\languagename}% + {\the\toks@}}% + \fi + \expandafter\bbl@tempb + \fi}% + \expandafter\bbl@tempb\bbl@captionslist\today\@empty + \def\bbl@tempa##1{% elt for include list + \ifx##1\@empty\else + \bbl@csarg\in@{ensure@\languagename\expandafter}\expandafter{##1}% + \ifin@\else + \bbl@tempb##1\@empty + \fi + \expandafter\bbl@tempa + \fi}% + \bbl@tempa#1\@empty} +\def\bbl@captionslist{% + \prefacename\refname\abstractname\bibname\chaptername\appendixname + \contentsname\listfigurename\listtablename\indexname\figurename + \tablename\partname\enclname\ccname\headtoname\pagename\seename + \alsoname\proofname\glossaryname} +% \end{macrocode} +% +% \subsection{Short tags} +% +% \macro{\babeltags} +% This macro is straightforward. After zapping spaces, we +% loop over the list and define the macros |\text<tag>| and +% |\<tag>|. Definitions are first expanded so that they don't +% contain |\csname| but the actual macro. +% +% \begin{macrocode} +\bbl@trace{Short tags} +\newcommand\babeltags[1]{% + \edef\bbl@tempa{\zap@space#1 \@empty}% + \def\bbl@tempb##1=##2\@@{% + \edef\bbl@tempc{% + \noexpand\newcommand + \expandafter\noexpand\csname ##1\endcsname{% + \noexpand\protect + \expandafter\noexpand\csname otherlanguage*\endcsname{##2}} + \noexpand\newcommand + \expandafter\noexpand\csname text##1\endcsname{% + \noexpand\foreignlanguage{##2}}} + \bbl@tempc}% + \bbl@for\bbl@tempa\bbl@tempa{% + \expandafter\bbl@tempb\bbl@tempa\@@}} +% \end{macrocode} +% +% \subsection{Compatibility with language.def} +% +% Plain e-\TeX{} doesn’t rely on language.dat, but babel can be made +% compatible with this format easily. +% +% \begin{macrocode} +\bbl@trace{Compatibility with language.def} \ifx\directlua\@undefined\else \ifx\bbl@luapatterns\@undefined \input luababel.def \fi \fi -\bbl@trace{Compatibility with language.def} \ifx\bbl@languages\@undefined \ifx\directlua\@undefined \openin1 = language.def % TODO. Remove hardcoded number @@ -7288,7 +7875,7 @@ wouldn’t exist. \fi % \end{macrocode} % -% \begin{macro}{\addto} +% \macro{\addto} % It takes two arguments, a \meta{control sequence} and \TeX-code to % be added to the \meta{control sequence}. % @@ -7312,74 +7899,6 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% The macro |\initiate@active@char| below takes all the necessary -% actions to make its argument a shorthand character. The real work -% is performed once for each character. But first we define a little -% tool. -% -% \begin{macrocode} -\def\bbl@withactive#1#2{% - \begingroup - \lccode`~=`#2\relax - \lowercase{\endgroup#1~}} -% \end{macrocode} -% -% \begin{macro}{\bbl@redefine} -% -% To redefine a command, we save the old meaning of the macro. Then -% we redefine it to call the original macro with the `sanitized' -% argument. The reason why we do it this way is that we don't want -% to redefine the \LaTeX\ macros completely in case their -% definitions change (they have changed in the past). A macro named -% |\macro| will be saved new control sequences named |\org@macro|. -% -% \begin{macrocode} -\def\bbl@redefine#1{% - \edef\bbl@tempa{\bbl@stripslash#1}% - \expandafter\let\csname org@\bbl@tempa\endcsname#1% - \expandafter\def\csname\bbl@tempa\endcsname} -\@onlypreamble\bbl@redefine -% \end{macrocode} -% -% \end{macro} -% -% \begin{macro}{\bbl@redefine@long} -% This version of |\babel@redefine| can be used to redefine |\long| -% commands such as |\ifthenelse|. -% -% \begin{macrocode} -\def\bbl@redefine@long#1{% - \edef\bbl@tempa{\bbl@stripslash#1}% - \expandafter\let\csname org@\bbl@tempa\endcsname#1% - \long\expandafter\def\csname\bbl@tempa\endcsname} -\@onlypreamble\bbl@redefine@long -% \end{macrocode} -% -% \end{macro} -% -% \begin{macro}{\bbl@redefinerobust} -% For commands that are redefined, but which \textit{might} be -% robust we need a slightly more intelligent macro. A robust -% command |foo| is defined to expand to |\protect|\verb*|\foo |. So -% it is necessary to check whether \verb*|\foo | exists. The result -% is that the command that is being redefined is always robust -% afterwards. Therefore all we need to do now is define \verb*|\foo |. -% -% \begin{macrocode} -\def\bbl@redefinerobust#1{% - \edef\bbl@tempa{\bbl@stripslash#1}% - \bbl@ifunset{\bbl@tempa\space}% - {\expandafter\let\csname org@\bbl@tempa\endcsname#1% - \bbl@exp{\def\\#1{\\\protect\<\bbl@tempa\space>}}}% - {\bbl@exp{\let\<org@\bbl@tempa>\<\bbl@tempa\space>}}% - \@namedef{\bbl@tempa\space}} -\@onlypreamble\bbl@redefinerobust -% \end{macrocode} -% -% \end{macro} -% % \subsection{Hooks} % % Admittedly, the current implementation is a somewhat simplistic and @@ -7432,97 +7951,17 @@ wouldn’t exist. \fi % \end{macrocode} % -% \begin{macro}{\babelensure} -% -% The user command just parses the optional argument and creates a -% new macro named |\bbl@e@|\m{language}. We register a hook at the -% |afterextras| event which just executes this macro in a -% ``complete'' selection (which, if undefined, is |\relax| and does -% nothing). This part is somewhat involved because we have to make -% sure things are expanded the correct number of times. -% -% The macro |\bbl@e@|\m{language} contains -% |\bbl@ensure|\marg{include}\marg{exclude}\marg{fontenc}, which in in -% turn loops over the macros names in |\bbl@captionslist|, excluding -% (with the help of |\in@|) those in the |exclude| list. If the -% |fontenc| is given (and not |\relax|), the |\fontencoding| is also -% added. Then we loop over the |include| list, but if the macro -% already contains |\foreignlanguage|, nothing is done. Note this -% macro (1) is not restricted to the preamble, and (2) changes are -% local. +% Since the following command is meant for a hook (although a \LaTeX{} +% one), it’s placed here. % % \begin{macrocode} -\bbl@trace{Defining babelensure} -\newcommand\babelensure[2][]{% - \AddBabelHook{babel-ensure}{afterextras}{% - \ifcase\bbl@select@type - \bbl@cl{e}% - \fi}% - \begingroup - \let\bbl@ens@include\@empty - \let\bbl@ens@exclude\@empty - \def\bbl@ens@fontenc{\relax}% - \def\bbl@tempb##1{% - \ifx\@empty##1\else\noexpand##1\expandafter\bbl@tempb\fi}% - \edef\bbl@tempa{\bbl@tempb#1\@empty}% - \def\bbl@tempb##1=##2\@@{\@namedef{bbl@ens@##1}{##2}}% - \bbl@foreach\bbl@tempa{\bbl@tempb##1\@@}% - \def\bbl@tempc{\bbl@ensure}% - \expandafter\bbl@add\expandafter\bbl@tempc\expandafter{% - \expandafter{\bbl@ens@include}}% - \expandafter\bbl@add\expandafter\bbl@tempc\expandafter{% - \expandafter{\bbl@ens@exclude}}% - \toks@\expandafter{\bbl@tempc}% - \bbl@exp{% - \endgroup - \def\<bbl@e@#2>{\the\toks@{\bbl@ens@fontenc}}}} -\def\bbl@ensure#1#2#3{% 1: include 2: exclude 3: fontenc - \def\bbl@tempb##1{% elt for (excluding) \bbl@captionslist list - \ifx##1\@undefined % 3.32 - Don't assume the macro exists - \edef##1{\noexpand\bbl@nocaption - {\bbl@stripslash##1}{\languagename\bbl@stripslash##1}}% - \fi - \ifx##1\@empty\else - \in@{##1}{#2}% - \ifin@\else - \bbl@ifunset{bbl@ensure@\languagename}% - {\bbl@exp{% - \\\DeclareRobustCommand\<bbl@ensure@\languagename>[1]{% - \\\foreignlanguage{\languagename}% - {\ifx\relax#3\else - \\\fontencoding{#3}\\\selectfont - \fi - ########1}}}}% - {}% - \toks@\expandafter{##1}% - \edef##1{% - \bbl@csarg\noexpand{ensure@\languagename}% - {\the\toks@}}% - \fi - \expandafter\bbl@tempb - \fi}% - \expandafter\bbl@tempb\bbl@captionslist\today\@empty - \def\bbl@tempa##1{% elt for include list - \ifx##1\@empty\else - \bbl@csarg\in@{ensure@\languagename\expandafter}\expandafter{##1}% - \ifin@\else - \bbl@tempb##1\@empty - \fi - \expandafter\bbl@tempa - \fi}% - \bbl@tempa#1\@empty} -\def\bbl@captionslist{% - \prefacename\refname\abstractname\bibname\chaptername\appendixname - \contentsname\listfigurename\listtablename\indexname\figurename - \tablename\partname\enclname\ccname\headtoname\pagename\seename - \alsoname\proofname\glossaryname} +\providecommand\PassOptionsToLocale[2]{% + \bbl@csarg\bbl@add@list{passto@#2}{#1}} % \end{macrocode} % -% \end{macro} -% % \subsection{Setting up language files} % -% \begin{macro}{\LdfInit} +% \macro{\LdfInit} % % |\LdfInit| macro takes two arguments. The first % argument is the name of the language that will be defined in the @@ -7587,10 +8026,8 @@ wouldn’t exist. \bbl@ldfinit} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\ldf@quit} -% This macro interrupts the processing of a language definition file. +% \macro{\ldf@quit} +% This macro interrupts the processing of a language definition file. % % \begin{macrocode} \def\ldf@quit#1{% @@ -7600,19 +8037,17 @@ wouldn’t exist. \endinput} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\ldf@finish} -% This macro takes one argument. It is the name of the language -% that was defined in the language definition file. +% \macro{\ldf@finish} +% This macro takes one argument. It is the name of the language that +% was defined in the language definition file. % -% We load the local configuration file if one is present, we set -% the main language (taking into account that the argument might be -% a control sequence that needs to be expanded) and reset the -% category code of the @-sign. +% We load the local configuration file if one is present, we set the +% main language (taking into account that the argument might be a +% control sequence that needs to be expanded) and reset the category +% code of the @-sign. % % \begin{macrocode} -\def\bbl@afterldf#1{% TODO. Merge into the next macro? Unused elsewhere +\def\bbl@afterldf#1{% \bbl@afterlang \let\bbl@afterlang\relax \let\BabelModifiers\relax @@ -7625,11 +8060,9 @@ wouldn’t exist. \catcode`\==\eqcatcode \let\eqcatcode\relax} % \end{macrocode} % -% \end{macro} -% -% After the preamble of the document the commands |\LdfInit|, -% |\ldf@quit| and |\ldf@finish| are no longer needed. Therefore -% they are turned into warning messages in \LaTeX. +% After the preamble of the document the commands |\LdfInit|, +% |\ldf@quit| and |\ldf@finish| are no longer needed. Therefore they +% are turned into warning messages in \LaTeX. % % \begin{macrocode} \@onlypreamble\LdfInit @@ -7637,30 +8070,35 @@ wouldn’t exist. \@onlypreamble\ldf@finish % \end{macrocode} % -% \begin{macro}{\main@language} -% \begin{macro}{\bbl@main@language} -% This command should be used in the various language definition -% files. It stores its argument in |\bbl@main@language|; to be used -% to switch to the correct language at the beginning of the -% document. +% \macro{\main@language} +% \macro{\bbl@main@language} +% This command should be used in the various language definition files. +% It stores its argument in |\bbl@main@language|; to be used to switch +% to the correct language at the beginning of the document. % % \begin{macrocode} \def\main@language#1{% \def\bbl@main@language{#1}% - \let\languagename\bbl@main@language % TODO. Set localename + \let\languagename\bbl@main@language + \let\localename\bbl@main@language + \let\mainlocalename\bbl@main@language \bbl@id@assign \bbl@patterns{\languagename}} % \end{macrocode} % % We also have to make sure that some code gets executed at the -% beginning of the document, either when the |aux| file is read or, -% if it does not exist, when the |\AtBeginDocument| is executed. -% Languages do not set |\pagedir|, so we set here for the whole -% document to the main |\bodydir|. +% beginning of the document, either when the |aux| file is read or, if +% it does not exist, when the |\AtBeginDocument| is executed. Languages +% do not set |\pagedir|, so we set here for the whole document to the +% main |\bodydir|. +% +% The code written to the |aux| file attempts to avoid errors if +% \babel\ is removed from the document. % % \begin{macrocode} \def\bbl@beforestart{% \def\@nolanerr##1{% + \bbl@carg\chardef{l@##1}\z@ \bbl@warning{Undefined language '##1' in aux.\\Reported}}% \bbl@usehooks{beforestart}{}% \global\let\bbl@beforestart\relax} @@ -7668,41 +8106,23 @@ wouldn’t exist. {\@nameuse{bbl@beforestart}}% Group! \if@filesw \providecommand\babel@aux[2]{}% - \immediate\write\@mainaux{% - \string\providecommand\string\babel@aux[2]{}}% + \immediate\write\@mainaux{\unexpanded{% + \providecommand\babel@aux[2]{\global\let\babel@toc\@gobbletwo}}}% \immediate\write\@mainaux{\string\@nameuse{bbl@beforestart}}% \fi \expandafter\selectlanguage\expandafter{\bbl@main@language}% -%<-core> - \ifx\bbl@normalsf\@empty - \ifnum\sfcode`\.=\@m - \let\normalsfcodes\frenchspacing - \else - \let\normalsfcodes\nonfrenchspacing - \fi - \else - \let\normalsfcodes\bbl@normalsf - \fi -%<+core> \ifbbl@single % must go after the line above. \renewcommand\selectlanguage[1]{}% \renewcommand\foreignlanguage[2]{#2}% \global\let\babel@aux\@gobbletwo % Also as flag \fi} -%<-core> -\AddToHook{begindocument/before}{% - \let\bbl@normalsf\normalsfcodes - \let\normalsfcodes\relax} % Hack, to delay the setting -%<+core> +% \ifcase\bbl@engine\or - \AtBeginDocument{\pagedir\bodydir} % TODO - a better place + \AtBeginDocument{\pagedir\bodydir} \fi % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% A bit of optimization. Select in heads/foots the language only if +% A bit of optimization. Select in heads/feet the language only if % necessary. % % \begin{macrocode} @@ -7716,21 +8136,32 @@ wouldn’t exist. % % \subsection{Shorthands} % -% \begin{macro}{\bbl@add@special} -% The macro |\bbl@add@special| is used to add a new character (or -% single character control sequence) to the macro |\dospecials| -% (and |\@sanitize| if \LaTeX\ is used). It is used only at one -% place, namely when |\initiate@active@char| is called (which is -% ignored if the char has been made active before). Because -% |\@sanitize| can be undefined, we put the definition inside a -% conditional. -% -% Items are added to the lists without checking its existence or -% the original catcode. It does not hurt, but should be fixed. It's -% already done with |\nfss@catcodes|, added in 3.10. +% The macro |\initiate@active@char| below takes all the necessary +% actions to make its argument a shorthand character. The real work +% is performed once for each character. But first we define a little +% tool. % % \begin{macrocode} \bbl@trace{Shorhands} +\def\bbl@withactive#1#2{% + \begingroup + \lccode`~=`#2\relax + \lowercase{\endgroup#1~}} +% \end{macrocode} +% +% \macro{\bbl@add@special} +% The macro |\bbl@add@special| is used to add a new character (or +% single character control sequence) to the macro |\dospecials| (and +% |\@sanitize| if \LaTeX\ is used). It is used only at one place, +% namely when |\initiate@active@char| is called (which is ignored if +% the char has been made active before). Because |\@sanitize| can be +% undefined, we put the definition inside a conditional. +% +% Items are added to the lists without checking its existence or the +% original catcode. It does not hurt, but should be fixed. It's already +% done with |\nfss@catcodes|, added in 3.10. +% +% \begin{macrocode} \def\bbl@add@special#1{% 1:a macro like \", \?, etc. \bbl@add\dospecials{\do#1}% test @sanitize = \relax, for back. compat. \bbl@ifunset{@sanitize}{}{\bbl@add\@sanitize{\@makeother#1}}% @@ -7747,61 +8178,34 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@remove@special} -% -% The companion of the former macro is |\bbl@remove@special|. It -% removes a character from the set macros |\dospecials| and -% |\@sanitize|, but it is not used at all in the \babel{} core. -% -% \begin{macrocode} -\def\bbl@remove@special#1{% - \begingroup - \def\x##1##2{\ifnum`#1=`##2\noexpand\@empty - \else\noexpand##1\noexpand##2\fi}% - \def\do{\x\do}% - \def\@makeother{\x\@makeother}% - \edef\x{\endgroup - \def\noexpand\dospecials{\dospecials}% - \expandafter\ifx\csname @sanitize\endcsname\relax\else - \def\noexpand\@sanitize{\@sanitize}% - \fi}% - \x} -% \end{macrocode} -% -% \end{macro} -% -% \begin{macro}{\initiate@active@char} -% A language definition file can call this macro to make a -% character active. This macro takes one argument, the character -% that is to be made active. When the character was already active -% this macro does nothing. Otherwise, this macro defines the -% control sequence |\normal@char|\m{char} to expand to the -% character in its `normal state' and it defines the active -% character to expand to |\normal@char|\m{char} by default -% (\m{char} being the character to be made active). Later its -% definition can be changed to expand to |\active@char|\m{char} -% by calling |\bbl@activate{|\m{char}|}|. -% -% For example, to make the double quote character active one could -% have |\initiate@active@char{"}| in a language definition file. -% This defines |"| as |\active@prefix "\active@char"| (where the -% first |"| is the character with its original catcode, when the -% shorthand is created, and |\active@char"| is a single token). In -% protected contexts, it expands to |\protect "| or |\noexpand "| -% (ie, with the original |"|); otherwise |\active@char"| is -% executed. This macro in turn expands to |\normal@char"| in -% ``safe'' contexts (eg, |\label|), but |\user@active"| in normal -% ``unsafe'' ones. The latter search a definition in the user, -% language and system levels, in this order, but if none is found, -% |\normal@char"| is used. However, a deactivated shorthand (with -% |\bbl@deactivate| is defined as |\active@prefix "\normal@char"|. -% -% The following macro is used to define shorthands in the three -% levels. It takes 4 arguments: the (string'ed) character, -% |\<level>@group|, |<level>@active| and |<next-level>@active| -% (except in |system|). +% \macro{\initiate@active@char} +% A language definition file can call this macro to make a character +% active. This macro takes one argument, the character that is to be +% made active. When the character was already active this macro does +% nothing. Otherwise, this macro defines the control sequence +% |\normal@char<char>| to expand to the character in its `normal +% state' and it defines the active character to expand to +% |\normal@char<char>| by default (\m{char} being the character to be +% made active). Later its definition can be changed to expand to +% |\active@char<char>| by calling |\bbl@activate{<char>}|. +% +% For example, to make the double quote character active one could have +% |\initiate@active@char{"}| in a language definition file. This +% defines |"| as |\active@prefix "\active@char"| (where the first |"| +% is the character with its original catcode, when the shorthand is +% created, and |\active@char"| is a single token). In protected +% contexts, it expands to |\protect "| or |\noexpand "| (i.e., with the +% original |"|); otherwise |\active@char"| is executed. This macro in +% turn expands to |\normal@char"| in ``safe'' contexts (e.g., |\label|), +% but |\user@active"| in normal ``unsafe'' ones. The latter search a +% definition in the user, language and system levels, in this order, +% but if none is found, |\normal@char"| is used. However, a deactivated +% shorthand (with |\bbl@deactivate| is defined as +% |\active@prefix "\normal@char"|. +% +% The following macro is used to define shorthands in the three levels. +% It takes 4 arguments: the (string'ed) character, |\<level>@group|, +% |<level>@active| and |<next-level>@active| (except in |system|). % % \begin{macrocode} \def\bbl@active@def#1#2#3#4{% @@ -7813,9 +8217,9 @@ wouldn’t exist. \fi}% % \end{macrocode} % -% When there is also no current-level shorthand with an argument we -% will check whether there is a next-level defined shorthand for -% this active character. +% When there is also no current-level shorthand with an argument we +% will check whether there is a next-level defined shorthand for this +% active character. % % \begin{macrocode} \long\@namedef{#3@arg#1}##1{% @@ -7826,10 +8230,10 @@ wouldn’t exist. \fi}}% % \end{macrocode} % -% |\initiate@active@char| calls |\@initiate@active@char| with 3 -% arguments. All of them are the same character with different -% catcodes: active, other (|\string|'ed) and the original one. -% This trick simplifies the code a lot. +% |\initiate@active@char| calls |\@initiate@active@char| with 3 +% arguments. All of them are the same character with different +% catcodes: active, other (|\string|'ed) and the original one. This +% trick simplifies the code a lot. % % \begin{macrocode} \def\initiate@active@char#1{% @@ -7839,10 +8243,10 @@ wouldn’t exist. {}} % \end{macrocode} % -% The very first thing to do is saving the original catcode and the -% original definition, even if not active, which is possible -% (undefined characters require a special treatment to avoid -% making them |\relax| and preserving some degree of protection). +% The very first thing to do is saving the original catcode and the +% original definition, even if not active, which is possible (undefined +% characters require a special treatment to avoid making them |\relax| +% and preserving some degree of protection). % % \begin{macrocode} \def\@initiate@active@char#1#2#3{% @@ -7857,14 +8261,14 @@ wouldn’t exist. \fi % \end{macrocode} % -% If the character is already active we provide the default -% expansion under this shorthand mechanism. Otherwise we write a -% message in the transcript file, and define |\normal@char|\m{char} -% to expand to the character in its default state. If the character -% is mathematically active when \babel{} is loaded (for example -% |'|) the normal expansion is somewhat different to avoid an -% infinite loop (but it does not prevent the loop if the mathcode -% is set to |"8000| \textit{a posteriori}). +% If the character is already active we provide the default expansion +% under this shorthand mechanism. Otherwise we write a message in the +% transcript file, and define |\normal@char<char>| to expand to the +% character in its default state. If the character is mathematically +% active when \babel{} is loaded (for example |'|) the normal expansion +% is somewhat different to avoid an infinite loop (but it does not +% prevent the loop if the mathcode is set to |"8000| \textit{a +% posteriori}). % % \begin{macrocode} \ifx#1#3\relax @@ -7879,16 +8283,16 @@ wouldn’t exist. \fi % \end{macrocode} % -% To prevent problems with the loading of other packages after -% \babel\ we reset the catcode of the character to the original one -% at the end of the package and of each language file (except with -% \textsf{KeepShorthandsActive}). It is re-activate again at -% |\begin{document}|. We also need to make sure that the -% shorthands are active during the processing of the \file{.aux} -% file. Otherwise some citations may give unexpected results in -% the printout when a shorthand was used in the optional argument -% of |\bibitem| for example. Then we make it active (not strictly -% necessary, but done for backward compatibility). +% To prevent problems with the loading of other packages after \babel\ +% we reset the catcode of the character to the original one at the end +% of the package and of each language file (except with +% \textsf{KeepShorthandsActive}). It is re-activate again at +% |\begin{document}|. We also need to make sure that the shorthands are +% active during the processing of the \file{aux} file. Otherwise some +% citations may give unexpected results in the printout when a +% shorthand was used in the optional argument of |\bibitem| for +% example. Then we make it active (not strictly necessary, but done for +% backward compatibility). % % \begin{macrocode} \bbl@restoreactive{#2}% @@ -7902,14 +8306,14 @@ wouldn’t exist. \fi % \end{macrocode} % -% Now we have set |\normal@char|\m{char}, we must define -% |\active@char|\m{char}, to be executed when the character is -% activated. We define the first level expansion of -% |\active@char|\m{char} to check the status of the |@safe@actives| -% flag. If it is set to true we expand to the `normal' version of -% this character, otherwise we call |\user@active|\m{char} to start -% the search of a definition in the user, language and system -% levels (or eventually |normal@char|\m{char}). +% Now we have set |\normal@char<char>|, we must define +% |\active@char<char>|, to be executed when the character is +% activated. We define the first level expansion of +% |\active@char<char>| to check the status of the |@safe@actives| +% flag. If it is set to true we expand to the `normal' version of this +% character, otherwise we call |\user@active<char>| to start the +% search of a definition in the user, language and system levels (or +% eventually |normal@char<char>|). % % \begin{macrocode} \let\bbl@tempa\@firstoftwo @@ -7934,13 +8338,13 @@ wouldn’t exist. \expandafter\noexpand\csname user@active#2\endcsname}% % \end{macrocode} % -% We now define the default values which the shorthand is set to -% when activated or deactivated. It is set to the deactivated form -% (globally), so that the character expands to -% \begin{center} -% |\active@prefix| \m{char} |\normal@char|\m{char} -% \end{center} -% (where |\active@char|\m{char} is \emph{one} control sequence!). +% We now define the default values which the shorthand is set to when +% activated or deactivated. It is set to the deactivated form +% (globally), so that the character expands to +% \begin{center} +% |\active@prefix| \m{char} |\normal@char<char>| +% \end{center} +% (where |\active@char<char>| is \emph{one} control sequence!). % % \begin{macrocode} \bbl@csarg\edef{active@#2}{% @@ -7952,10 +8356,10 @@ wouldn’t exist. \bbl@ncarg\let#1{bbl@normal@#2}% % \end{macrocode} % -% The next level of the code checks whether a user has defined a -% shorthand for himself with this character. First we check for a -% single character shorthand. If that doesn't exist we check for a -% shorthand with an argument. +% The next level of the code checks whether a user has defined a +% shorthand for himself with this character. First we check for a +% single character shorthand. If that doesn't exist we check for a +% shorthand with an argument. % % \begin{macrocode} \bbl@active@def#2\user@group{user@active}{language@active}% @@ -7963,13 +8367,13 @@ wouldn’t exist. \bbl@active@def#2\system@group{system@active}{normal@char}% % \end{macrocode} % -% In order to do the right thing when a shorthand with an argument -% is used by itself at the end of the line we provide a definition -% for the case of an empty argument. For that case we let the -% shorthand character expand to its non-active self. Also, When a -% shorthand combination such as |''| ends up in a heading \TeX\ -% would see |\protect'\protect'|. To prevent this from happening a -% couple of shorthand needs to be defined at user level. +% In order to do the right thing when a shorthand with an argument +% is used by itself at the end of the line we provide a definition +% for the case of an empty argument. For that case we let the +% shorthand character expand to its non-active self. Also, When a +% shorthand combination such as |''| ends up in a heading \TeX\ +% would see |\protect'\protect'|. To prevent this from happening a +% couple of shorthand needs to be defined at user level. % % \begin{macrocode} \expandafter\edef\csname\user@group @sh@#2@@\endcsname @@ -7978,13 +8382,13 @@ wouldn’t exist. {\expandafter\noexpand\csname user@active#2\endcsname}% % \end{macrocode} % -% Finally, a couple of special cases are taken care of. (1) If we -% are making the right quote (|'|) active we need to change |\pr@m@s| as -% well. Also, make sure that a single |'| in math mode `does the -% right thing'. (2) If we are using the caret (|^|) as a shorthand -% character special care should be taken to make sure math still -% works. Therefore an extra level of expansion is introduced with a -% check for math mode on the upper level. +% Finally, a couple of special cases are taken care of. (1) If we +% are making the right quote (|'|) active we need to change |\pr@m@s| as +% well. Also, make sure that a single |'| in math mode `does the +% right thing'. (2) If we are using the caret (|^|) as a shorthand +% character special care should be taken to make sure math still +% works. Therefore an extra level of expansion is introduced with a +% check for math mode on the upper level. % % \begin{macrocode} \if\string'#2% @@ -7994,8 +8398,8 @@ wouldn’t exist. \bbl@usehooks{initiateactive}{{#1}{#2}{#3}}} % \end{macrocode} % -% The following package options control the behavior of shorthands -% in math mode. +% The following package options control the behavior of shorthands in +% math mode. % % \begin{macrocode} %<<*More package options>> @@ -8004,10 +8408,10 @@ wouldn’t exist. %<</More package options>> % \end{macrocode} % -% Initiating a shorthand makes active the char. That is not -% strictly necessary but it is still done for backward -% compatibility. So we need to restore the original catcode at the -% end of package \textit{and} and the end of the |ldf|. +% Initiating a shorthand makes active the char. That is not strictly +% necessary but it is still done for backward compatibility. So we need +% to restore the original catcode at the end of package \textit{and} +% and the end of the |ldf|. % % \begin{macrocode} \@ifpackagewith{babel}{KeepShorthandsActive}% @@ -8021,18 +8425,16 @@ wouldn’t exist. \AtEndOfPackage{\let\bbl@restoreactive\@gobble}} % \end{macrocode} % -% \end{macro} +% \macro{\bbl@sh@select} +% This command helps the shorthand supporting macros to select how to +% proceed. Note that this macro needs to be expandable as do all the +% shorthand macros in order for them to work in expansion-only +% environments such as the argument of |\hyphenation|. % -% \begin{macro}{\bbl@sh@select} -% This command helps the shorthand supporting macros to select how -% to proceed. Note that this macro needs to be expandable as do all -% the shorthand macros in order for them to work in expansion-only -% environments such as the argument of |\hyphenation|. -% -% This macro expects the name of a group of shorthands in its first -% argument and a shorthand character in its second argument. It -% will expand to either |\bbl@firstcs| or |\bbl@scndcs|. Hence two -% more arguments need to follow it. +% This macro expects the name of a group of shorthands in its first +% argument and a shorthand character in its second argument. It will +% expand to either |\bbl@firstcs| or |\bbl@scndcs|. Hence two more +% arguments need to follow it. % % \begin{macrocode} \def\bbl@sh@select#1#2{% @@ -8043,21 +8445,18 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\active@prefix} -% The command |\active@prefix| which is used in the expansion of -% active characters has a function similar to |\OT1-cmd| in that it -% |\protect|s the active character whenever |\protect| is -% \emph{not} |\@typeset@protect|. The |\@gobble| is needed to remove -% a token such as |\activechar:| (when the double colon was the -% active character to be dealt with). There are two definitions, -% depending of |\ifincsname| is available. If there is, the -% expansion will be more robust. +% \macro{\active@prefix} +% Used in the expansion of active +% characters has a function similar to |\OT1-cmd| in that it +% |\protect|s the active character whenever |\protect| is \emph{not} +% |\@typeset@protect|. The |\@gobble| is needed to remove a token such +% as |\activechar:| (when the double colon was the active character to +% be dealt with). There are two definitions, depending of |\ifincsname| +% is available. If there is, the expansion will be more robust. % % \begin{macrocode} \begingroup -\bbl@ifunset{ifincsname}% TODO. Ugly. Correct? Only Plain? +\bbl@ifunset{ifincsname}% {\gdef\active@prefix#1{% \ifx\protect\@typeset@protect \else @@ -8086,29 +8485,26 @@ wouldn’t exist. \endgroup % \end{macrocode} % -% \end{macro} +% \macro{if@safe@actives} % -% \begin{macro}{\if@safe@actives} -% In some circumstances it is necessary to be able to reset the -% shorthand to its ‘normal’ value (usually the character with catcode -% ‘other’) on the fly. For this purpose the switch |@safe@actives| is -% available. The setting of this switch should be checked in the first -% level expansion of |\active@char|\m{char}. When this expansion mode -% is active (with |\@safe@activestrue|), something like -% |"|$\sb{13}$|"|$\sb{13}$ becomes |"|$\sb{12}$|"|$\sb{12}$ in an -% |\edef| (in other words, shorthands are |\string|’ed). This -% contrasts with |\protected@edef|, where catcodes are always left -% unchanged. Once converted, they can be used safely even after this -% expansion mode is deactivated (with |\@safe@activefalse|). +% In some circumstances it is necessary to be able to reset the +% shorthand to its ‘normal’ value (usually the character with catcode +% ‘other’) on the fly. For this purpose the switch |@safe@actives| is +% available. The setting of this switch should be checked in the first +% level expansion of |\active@char<char>|. When this expansion mode +% is active (with |\@safe@activestrue|), something like +% |"|$\sb{13}$|"|$\sb{13}$ becomes |"|$\sb{12}$|"|$\sb{12}$ in an +% |\edef| (in other words, shorthands are |\string|’ed). This contrasts +% with |\protected@edef|, where catcodes are always left unchanged. +% Once converted, they can be used safely even after this expansion +% mode is deactivated (with |\@safe@activefalse|). % % \begin{macrocode} \newif\if@safe@actives \@safe@activesfalse % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@restore@actives} +% \macro{\bbl@restore@actives} % When the output routine kicks in while the active characters were % made ``safe'' this must be undone in the headers to prevent % unexpected typeset results. For this situation we define a command to @@ -8118,15 +8514,13 @@ wouldn’t exist. \def\bbl@restore@actives{\if@safe@actives\@safe@activesfalse\fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@activate} -% \begin{macro}{\bbl@deactivate} +% \macro{\bbl@activate} +% \macro{\bbl@deactivate} % % Both macros take one argument, like |\initiate@active@char|. The % macro is used to change the definition of an active character to -% expand to |\active@char|\m{char} in the case of |\bbl@activate|, -% or |\normal@char|\m{char} in the case of |\bbl@deactivate|. +% expand to |\active@char<char>| in the case of |\bbl@activate|, +% or |\normal@char<char>| in the case of |\bbl@deactivate|. % % \begin{macrocode} \chardef\bbl@activated\z@ @@ -8140,11 +8534,8 @@ wouldn’t exist. \csname bbl@normal@\string#1\endcsname} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\bbl@firstcs} -% \begin{macro}{\bbl@scndcs} +% \macro{\bbl@firstcs} +% \macro{\bbl@scndcs} % % These macros are used only as a trick when declaring shorthands. % @@ -8153,17 +8544,14 @@ wouldn’t exist. \def\bbl@scndcs#1#2{\csname#2\endcsname} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\declare@shorthand} -% The command |\declare@shorthand| is used to declare a shorthand +% \macro{\declare@shorthand} +% Used to declare a shorthand % on a certain level. It takes three arguments: % \begin{enumerate} -% \item a name for the collection of shorthands, i.e. `system', or +% \item a name for the collection of shorthands, i.e., `system', or % `dutch'; % \item the character (sequence) that makes up the shorthand, -% i.e. |~| or |"a|; +% i.e., |~| or |"a|; % \item the code to be executed when the shorthand is encountered. % \end{enumerate} % @@ -8174,7 +8562,7 @@ wouldn’t exist. % string in math mode, like a minus sign instead of an hyphen % (currently \textsf{hyperref} doesn't discriminate the mode). This % macro may be used in |ldf| files. - +% % \begin{macrocode} \def\babel@texpdf#1#2#3#4{% \ifx\texorpdfstring\@undefined @@ -8212,12 +8600,10 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\textormath} -% Some of the shorthands that will be declared by the language -% definition files have to be usable in both text and mathmode. To -% achieve this the helper macro |\textormath| is provided. +% \macro{\textormath} +% Some of the shorthands that will be declared by the language +% definition files have to be usable in both text and mathmode. To +% achieve this the helper macro |\textormath| is provided. % % \begin{macrocode} \def\textormath{% @@ -8228,34 +8614,27 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\user@group} -% \begin{macro}{\language@group} -% \begin{macro}{\system@group} -% The current concept of `shorthands' supports three levels or -% groups of shorthands. For each level the name of the level or -% group is stored in a macro. The default is to have a user group; -% use language group `english' and have a system group called -% `system'. +% \macro{\user@group} +% \macro{\language@group} +% \macro{\system@group} +% The current concept of `shorthands' supports three levels or groups +% of shorthands. For each level the name of the level or group is +% stored in a macro. The default is to have a user group; use language +% group `english' and have a system group called `system'. % % \begin{macrocode} \def\user@group{user} -\def\language@group{english} % TODO. I don't like defaults +\def\language@group{english} \def\system@group{system} % \end{macrocode} % -% \end{macro} -% \end{macro} -% \end{macro} +% \macro{\useshorthands} % -% \begin{macro}{\useshorthands} -% -% This is the user level macro. It initializes and activates the -% character for use as a shorthand character (ie, it's active in the -% preamble). Languages can deactivate shorthands, so a starred -% version is also provided which activates them always after the -% language has been switched. +% This is the user level macro. It initializes and activates the +% character for use as a shorthand character (i.e., it's active in the +% preamble). Languages can deactivate shorthands, so a starred version +% is also provided which activates them always after the language has +% been switched. % % \begin{macrocode} \def\useshorthands{% @@ -8273,12 +8652,10 @@ wouldn’t exist. {\bbl@error{shorthand-is-off}{}{#2}{}}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\defineshorthand} +% \macro{\defineshorthand} % % Currently we only support two groups of user level shorthands, -% named internally |user| and |user@<lang>| (language-dependent +% named internally |user| and |user@<language>| (language-dependent % user shorthands). By default, only the first one is taken into % account, but if the former is also used (in the optional argument % of |\defineshorthand|) a new level is inserted for it @@ -8308,30 +8685,25 @@ wouldn’t exist. \declare@shorthand{\bbl@tempb}{#2}{#3}}} % \end{macrocode} % -% \end{macro} +% \macro{\languageshorthands} % -% \begin{macro}{\languageshorthands} +% A user level command to change the language from which shorthands are +% used. Unfortunately, \babel{} currently does not keep track of +% defined groups, and therefore there is no way to catch a possible +% change in casing to fix it in the same way languages names are fixed. % -% A user level command to change the language from which shorthands -% are used. Unfortunately, \babel{} currently does not keep track -% of defined groups, and therefore there is no way to catch a -% possible change in casing to fix it in the same way languages names -% are fixed. [TODO]. -% % % \begin{macrocode} \def\languageshorthands#1{\def\language@group{#1}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\aliasshorthand} +% \macro{\aliasshorthand} % % \textit{Deprecated}. First the new shorthand needs to be % initialized. Then, we define the new shorthand in terms of the % original one, but note with |\aliasshorthands{"}{/}| is % |\active@prefix /\active@char/|, so we still need to let the % latter to |\active@char"|. -% +% % \begin{macrocode} \def\aliasshorthand#1#2{% \bbl@ifshorthand{#2}% @@ -8348,18 +8720,14 @@ wouldn’t exist. {\bbl@error{shorthand-is-off}{}{#2}{}}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\@notshorthand} +% \macro{\@notshorthand} % % \begin{macrocode} \def\@notshorthand#1{\bbl@error{not-a-shorthand}{#1}{}{}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\shorthandon} -% \begin{macro}{\shorthandoff} +% \macro{\shorthandon} +% \macro{\shorthandoff} % % The first level definition of these macros just passes the % argument on to |\bbl@switch@sh|, adding |\@nil| at the end to @@ -8372,7 +8740,7 @@ wouldn’t exist. \def\bbl@shorthandoff#1#2{\bbl@switch@sh#1#2\@nnil} % \end{macrocode} % -% \begin{macro}{\bbl@switch@sh} +% \macro{\bbl@switch@sh} % % The macro |\bbl@switch@sh| takes the list of characters apart one % by one and subsequently switches the category code of the @@ -8418,11 +8786,7 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% \end{macro} -% \end{macro} -% -% Note the value is that at the expansion time; eg, in the preamble +% Note the value is that at the expansion time; e.g., in the preamble % shorthands are usually deactivated. % % \begin{macrocode} @@ -8461,8 +8825,8 @@ wouldn’t exist. \newcommand\ifbabelshorthand[3]{\bbl@ifunset{bbl@active@\string#1}{#3}{#2}} % \end{macrocode} % -% \begin{macro}{\bbl@prim@s} -% \begin{macro}{\bbl@pr@m@s} +% \macro{\bbl@prim@s} +% \macro{\bbl@pr@m@s} % % One of the internal macros that are involved in substituting |\prime| % for each right quote in mathmode is |\prim@s|. This checks if the @@ -8492,11 +8856,8 @@ wouldn’t exist. \endgroup % \end{macrocode} % -% \end{macro} -% \end{macro} -% % Usually the |~| is active and expands to \verb*=\penalty\@M\ =. -% When it is written to the \file{.aux} file it is written +% When it is written to the \file{aux} file it is written % expanded. To prevent that and to be able to use the character |~| % as a start character for a shorthand, it is redefined here as a % one character shorthand on system level. The system declaration @@ -8511,20 +8872,20 @@ wouldn’t exist. \bbl@activate{~} % \end{macrocode} % -% \begin{macro}{\OT1dqpos} -% \begin{macro}{\T1dqpos} -% The position of the double quote character is different for the -% OT1 and T1 encodings. It will later be selected using the -% |\f@encoding| macro. Therefore we define two macros here to store -% the position of the character in these encodings. +% \macro{\OT1dqpos} +% \macro{\T1dqpos} +% The position of the double quote character is different for the OT1 +% and T1 encodings. It will later be selected using the |\f@encoding| +% macro. Therefore we define two macros here to store the position of +% the character in these encodings. % % \begin{macrocode} \expandafter\def\csname OT1dqpos\endcsname{127} \expandafter\def\csname T1dqpos\endcsname{4} % \end{macrocode} % -% When the macro |\f@encoding| is undefined (as it is in plain -% \TeX) we define it here to expand to \texttt{OT1} +% When the macro |\f@encoding| is undefined (as it is in plain \TeX) we +% define it here to expand to \texttt{OT1} % % \begin{macrocode} \ifx\f@encoding\@undefined @@ -8532,21 +8893,17 @@ wouldn’t exist. \fi % \end{macrocode} % -% \end{macro} -% \end{macro} -% % \subsection{Language attributes} % -% Language attributes provide a means to give the user control over -% which features of the language definition files he wants to -% enable. +% Language attributes provide a means to give the user control over +% which features of the language definition files he wants to enable. % -% \begin{macro}{\languageattribute} +% \macro{\languageattribute} % -% The macro |\languageattribute| checks whether its arguments are -% valid and then activates the selected language attribute. -% First check whether the language is known, and then process each -% attribute in the list. +% The macro |\languageattribute| checks whether its arguments are valid +% and then activates the selected language attribute. First check +% whether the language is known, and then process each attribute in the +% list. % % \begin{macrocode} \bbl@trace{Language attributes} @@ -8590,25 +8947,22 @@ wouldn’t exist. \@onlypreamble\languageattribute % \end{macrocode} % -% The error text to be issued when an unknown attribute is -% selected. +% The error text to be issued when an unknown attribute is selected. % % \begin{macrocode} \newcommand*{\@attrerr}[2]{% \bbl@error{unknown-attribute}{#1}{#2}{}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@declare@ttribute} -% This command adds the new language/attribute combination to the -% list of known attributes. +% \macro{\bbl@declare@ttribute} +% This command adds the new language/attribute combination to the list +% of known attributes. % -% Then it defines a control sequence to be executed when the -% attribute is used in a document. The result of this should be -% that the macro |\extras...| for the current language is extended, -% otherwise the attribute will not work as its code is removed from -% memory at |\begin{document}|. +% Then it defines a control sequence to be executed when the attribute +% is used in a document. The result of this should be that the macro +% |\extras...| for the current language is extended, otherwise the +% attribute will not work as its code is removed from memory at +% |\begin{document}|. % % \begin{macrocode} \def\bbl@declare@ttribute#1#2#3{% @@ -8620,18 +8974,17 @@ wouldn’t exist. \expandafter\def\csname#1@attr@#2\endcsname{#3}} % \end{macrocode} % -% \end{macro} +% \macro{\bbl@ifattributeset} % -% \begin{macro}{\bbl@ifattributeset} -% This internal macro has 4 arguments. It can be used to interpret -% \TeX\ code based on whether a certain attribute was set. This -% command should appear inside the argument to |\AtBeginDocument| -% because the attributes are set in the document preamble, -% \emph{after} \babel\ is loaded. +% This internal macro has 4 arguments. It can be used to interpret +% \TeX\ code based on whether a certain attribute was set. This command +% should appear inside the argument to |\AtBeginDocument| because the +% attributes are set in the document preamble, \emph{after} \babel\ is +% loaded. % -% The first argument is the language, the second argument the -% attribute being checked, and the third and fourth arguments are -% the true and false clauses. +% The first argument is the language, the second argument the attribute +% being checked, and the third and fourth arguments are the true and +% false clauses. % % \begin{macrocode} \def\bbl@ifattributeset#1#2#3#4{% @@ -8647,16 +9000,14 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} +% \macro{\bbl@ifknown@ttrib} +% An internal macro to check whether a given language/attribute is +% known. The macro takes 4 arguments, the language/attribute, the +% attribute list, the \TeX-code to be executed when the attribute is +% known and the \TeX-code to be executed otherwise. % -% \begin{macro}{\bbl@ifknown@ttrib} -% An internal macro to check whether a given language/attribute is -% known. The macro takes 4 arguments, the language/attribute, the -% attribute list, the \TeX-code to be executed when the attribute -% is known and the \TeX-code to be executed otherwise. -% -% We first assume the attribute is unknown. Then we loop over the -% list of known attributes, trying to find a match. +% We first assume the attribute is unknown. Then we loop over the list +% of known attributes, trying to find a match. % % \begin{macrocode} \def\bbl@ifknown@ttrib#1#2{% @@ -8670,11 +9021,9 @@ wouldn’t exist. \bbl@tempa} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@clear@ttribs} -% This macro removes all the attribute code from \LaTeX's memory at -% |\begin{document}| time (if any is present). +% \macro{\bbl@clear@ttribs} +% This macro removes all the attribute code from \LaTeX's memory at +% |\begin{document}| time (if any is present). % % \begin{macrocode} \def\bbl@clear@ttribs{% @@ -8688,54 +9037,46 @@ wouldn’t exist. \AtBeginDocument{\bbl@clear@ttribs} % \end{macrocode} % -% \end{macro} +% \subsection{Support for saving and redefining macros} % -% \subsection{Support for saving macro definitions} +% To save the meaning of control sequences using |\babel@save|, we use +% temporary control sequences. To save hash table entries for these +% control sequences, we don't use the name of the control sequence to +% be saved to construct the temporary name. Instead we simply use the +% value of a counter, which is reset to zero each time we begin to save +% new values. This works well because we release the saved meanings +% before we begin to save a new set of control sequence meanings (see +% |\selectlanguage| and |\originalTeX|). Note undefined macros are not +% undefined any more when saved -- they are |\relax|'ed. % -% To save the meaning of control sequences using |\babel@save|, we -% use temporary control sequences. To save hash table entries for -% these control sequences, we don't use the name of the control -% sequence to be saved to construct the temporary name. Instead we -% simply use the value of a counter, which is reset to zero each time -% we begin to save new values. This works well because we release -% the saved meanings before we begin to save a new set of control -% sequence meanings (see |\selectlanguage| and |\originalTeX|). Note -% undefined macros are not undefined any more when saved -- they are -% |\relax|'ed. -% -% \begin{macro}{\babel@savecnt} -% \begin{macro}{\babel@beginsave} -% The initialization of a new save cycle: reset the counter to -% zero. +% \macro{\babel@savecnt} +% \macro{\babel@beginsave} +% The initialization of a new save cycle: reset the counter to zero. % % \begin{macrocode} \bbl@trace{Macros for saving definitions} \def\babel@beginsave{\babel@savecnt\z@} % \end{macrocode} % -% Before it's forgotten, allocate the counter and initialize all. +% Before it's forgotten, allocate the counter and initialize all. % % \begin{macrocode} \newcount\babel@savecnt \babel@beginsave % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\babel@save} -% \begin{macro}{\babel@savevariable} +% \macro{\babel@save} +% \macro{\babel@savevariable} % % The macro |\babel@save|\meta{csname} saves the current meaning of the -% control sequence \meta{csname} to -% |\originalTeX|\footnote{\cs{originalTeX} has to be expandable, -% i.\,e.\ you shouldn't let it to \cs{relax}.}. To do this, we let the -% current meaning to a temporary control sequence, the restore commands -% are appended to |\originalTeX| and the counter is incremented. The -% macro |\babel@savevariable|\meta{variable} saves the value of the -% variable. \meta{variable} can be anything allowed after the |\the| -% primitive. To avoid messing saved definitions up, they are saved only -% the very first time. +% control sequence \meta{csname} to |\originalTeX| (which has to be +% expandable, i.e., you shouldn't let it to \cs{relax}). To do this, +% we let the current meaning to a temporary control sequence, the +% restore commands are appended to |\originalTeX| and the counter is +% incremented. The macro |\babel@savevariable|\meta{variable} saves the +% value of the variable. \meta{variable} can be anything allowed after +% the |\the| primitive. To avoid messing saved definitions up, they are +% saved only the very first time. % % \begin{macrocode} \def\babel@save#1{% @@ -8756,18 +9097,62 @@ wouldn’t exist. \bbl@exp{\def\\\originalTeX{\the\toks@\the#1\relax}}} % \end{macrocode} % -% \end{macro} -% \end{macro} +% \macro{\bbl@redefine} % -% \begin{macro}{\bbl@frenchspacing} -% \begin{macro}{\bbl@nonfrenchspacing} +% To redefine a command, we save the old meaning of the macro. Then +% we redefine it to call the original macro with the `sanitized' +% argument. The reason why we do it this way is that we don't want +% to redefine the \LaTeX\ macros completely in case their +% definitions change (they have changed in the past). A macro named +% |\macro| will be saved new control sequences named |\org@macro|. +% +% \begin{macrocode} +\def\bbl@redefine#1{% + \edef\bbl@tempa{\bbl@stripslash#1}% + \expandafter\let\csname org@\bbl@tempa\endcsname#1% + \expandafter\def\csname\bbl@tempa\endcsname} +\@onlypreamble\bbl@redefine +% \end{macrocode} +% +% \macro{\bbl@redefine@long} +% This version of |\babel@redefine| can be used to redefine |\long| +% commands such as |\ifthenelse|. +% +% \begin{macrocode} +\def\bbl@redefine@long#1{% + \edef\bbl@tempa{\bbl@stripslash#1}% + \expandafter\let\csname org@\bbl@tempa\endcsname#1% + \long\expandafter\def\csname\bbl@tempa\endcsname} +\@onlypreamble\bbl@redefine@long +% \end{macrocode} +% +% \macro{\bbl@redefinerobust} +% For commands that are redefined, but which \textit{might} be +% robust we need a slightly more intelligent macro. A robust +% command |foo| is defined to expand to |\protect|\verb*|\foo |. So +% it is necessary to check whether \verb*|\foo | exists. The result +% is that the command that is being redefined is always robust +% afterwards. Therefore all we need to do now is define \verb*|\foo |. +% +% \begin{macrocode} +\def\bbl@redefinerobust#1{% + \edef\bbl@tempa{\bbl@stripslash#1}% + \bbl@ifunset{\bbl@tempa\space}% + {\expandafter\let\csname org@\bbl@tempa\endcsname#1% + \bbl@exp{\def\\#1{\\\protect\<\bbl@tempa\space>}}}% + {\bbl@exp{\let\<org@\bbl@tempa>\<\bbl@tempa\space>}}% + \@namedef{\bbl@tempa\space}} +\@onlypreamble\bbl@redefinerobust +% \end{macrocode} +% +% \subsection{French spacing} +% +% \macro{\bbl@frenchspacing} +% \macro{\bbl@nonfrenchspacing} % Some languages need to have |\frenchspacing| in effect. Others % don't want that. The command |\bbl@frenchspacing| switches it on % when it isn't already in effect and |\bbl@nonfrenchspacing| -% switches it off if necessary. A more refined way to switch the -% catcodes is done with |ini| files. Here an auxiliary macro is -% defined, but the main part is in |\babelprovide|. This new method -% should be ideally the default one. +% switches it off if necessary. % % \begin{macrocode} \def\bbl@frenchspacing{% @@ -8778,6 +9163,13 @@ wouldn’t exist. \let\bbl@nonfrenchspacing\nonfrenchspacing \fi} \let\bbl@nonfrenchspacing\nonfrenchspacing +% \end{macrocode} +% +% A more refined way to switch the catcodes is done with |ini| files. +% Here an auxiliary macro is defined, but the main part is in +% |\babelprovide|. This new method should be ideally the default one. +% +% \begin{macrocode} \let\bbl@elt\relax \edef\bbl@fs@chars{% \bbl@elt{\string.}\@m{3000}\bbl@elt{\string?}\@m{3000}% @@ -8808,44 +9200,13 @@ wouldn’t exist. \fi\fi\fi} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \subsection{Short tags} -% -% \begin{macro}{\babeltags} -% This macro is straightforward. After zapping spaces, we -% loop over the list and define the macros |\text|\m{tag} and -% |\|\m{tag}. Definitions are first expanded so that they don't -% contain |\csname| but the actual macro. -% -% \begin{macrocode} -\bbl@trace{Short tags} -\def\babeltags#1{% - \edef\bbl@tempa{\zap@space#1 \@empty}% - \def\bbl@tempb##1=##2\@@{% - \edef\bbl@tempc{% - \noexpand\newcommand - \expandafter\noexpand\csname ##1\endcsname{% - \noexpand\protect - \expandafter\noexpand\csname otherlanguage*\endcsname{##2}} - \noexpand\newcommand - \expandafter\noexpand\csname text##1\endcsname{% - \noexpand\foreignlanguage{##2}}} - \bbl@tempc}% - \bbl@for\bbl@tempa\bbl@tempa{% - \expandafter\bbl@tempb\bbl@tempa\@@}} -% \end{macrocode} -% -% \end{macro} -% % \subsection{Hyphens} % -% \begin{macro}{\babelhyphenation} +% \macro{\babelhyphenation} % % This macro saves hyphenation exceptions. Two macros are used to % store them: |\bbl@hyphenation@| for the global ones and -% |\bbl@hyphenation<lang>| for language ones. See |\bbl@patterns| +% |\bbl@hyphenation@<language>| for language ones. See |\bbl@patterns| % above for further details. We make sure there is a space between % words when multiple commands are used. % @@ -8878,14 +9239,36 @@ wouldn’t exist. \fi}} % \end{macrocode} % -% \end{macro} +% \macro{\babelhyphenmins} +% +% Only \LaTeX{} (basically because it’s defined with a \LaTeX{} tool). +% +% \begin{macrocode} +\ifx\NewDocumentCommand\@undefined\else + \NewDocumentCommand\babelhyphenmins{sommo}{% + \IfNoValueTF{#2}% + {\protected@edef\bbl@hyphenmins@{\set@hyphenmins{#3}{#4}}% + \IfValueT{#5}{% + \protected@edef\bbl@hyphenatmin@{\hyphenationmin=#5\relax}}% + \IfBooleanT{#1}{% + \lefthyphenmin=#3\relax + \righthyphenmin=#4\relax + \IfValueT{#5}{\hyphenationmin=#5\relax}}}% + {\edef\bbl@tempb{\zap@space#2 \@empty}% + \bbl@for\bbl@tempa\bbl@tempb{% + \@namedef{bbl@hyphenmins@\bbl@tempa}{\set@hyphenmins{#3}{#4}}% + \IfValueT{#5}{% + \@namedef{bbl@hyphenatmin@\bbl@tempa}{\hyphenationmin=#5\relax}}}% + \IfBooleanT{#1}{\bbl@error{hyphenmins-args}{}{}{}}}} +\fi +% \end{macrocode} % -% \begin{macro}{\bbl@allowhyphens} +% \macro{\bbl@allowhyphens} % -% This macro makes hyphenation possible. Basically its definition -% is nothing more than |\nobreak| |\hskip| \texttt{0pt plus -% 0pt}\footnote{\TeX\ begins and ends a word for hyphenation at a -% glue node. The penalty prevents a linebreak at this glue node.}. +% This macro makes hyphenation possible. Basically its definition is +% nothing more than |\nobreak| |\hskip| \texttt{0pt plus 0pt}. \TeX\ +% begins and ends a word for hyphenation at a glue node. The penalty +% prevents a linebreak at this glue node. % % \begin{macrocode} \def\bbl@allowhyphens{\ifvmode\else\nobreak\hskip\z@skip\fi} @@ -8893,9 +9276,7 @@ wouldn’t exist. \def\allowhyphens{\ifx\cf@encoding\bbl@t@one\else\bbl@allowhyphens\fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\babelhyphen} +% \macro{\babelhyphen} % % Macros to insert common hyphens. Note the space before |@| in % |\babelhyphen|. Instead of protecting it with @@ -8908,9 +9289,9 @@ wouldn’t exist. \def\bbl@hyphen{% \@ifstar{\bbl@hyphen@i @}{\bbl@hyphen@i\@empty}} \def\bbl@hyphen@i#1#2{% - \bbl@ifunset{bbl@hy@#1#2\@empty}% + \lowercase{\bbl@ifunset{bbl@hy@#1#2\@empty}}% {\csname bbl@#1usehyphen\endcsname{\discretionary{#2}{}{#2}}}% - {\csname bbl@hy@#1#2\@empty\endcsname}} + {\lowercase{\csname bbl@hy@#1#2\@empty\endcsname}}} % \end{macrocode} % % The following two commands are used to wrap the ``hyphen'' and @@ -8935,7 +9316,7 @@ wouldn’t exist. \leavevmode\ifdim\lastskip>\z@\mbox{#1}\else#1\fi} % \end{macrocode} % -% The following macro inserts the hyphen char. +% The following macro inserts the hyphen char. % % \begin{macrocode} \def\bbl@hyphenchar{% @@ -8946,9 +9327,9 @@ wouldn’t exist. \fi} % \end{macrocode} % -% Finally, we define the hyphen ``types''. Their names will not -% change, so you may use them in |ldf|'s. After a space, the -% |\mbox| in |\bbl@hy@nobreak| is redundant. +% Finally, we define the hyphen ``types''. Their names will not change, +% so you may use them in |ldf|'s. After a space, the |\mbox| in +% |\bbl@hy@nobreak| is redundant. % % \begin{macrocode} \def\bbl@hy@soft{\bbl@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}} @@ -8967,19 +9348,15 @@ wouldn’t exist. \def\bbl@hy@@empty{\discretionary{}{}{}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@disc} -% For some languages the macro |\bbl@disc| is used to ease the -% insertion of discretionaries for letters that behave `abnormally' -% at a breakpoint. +% \macro{\bbl@disc} +% For some languages the macro |\bbl@disc| is used to ease the +% insertion of discretionaries for letters that behave `abnormally' at +% a breakpoint. % % \begin{macrocode} \def\bbl@disc#1#2{\nobreak\discretionary{#2-}{}{#1}\bbl@allowhyphens} % \end{macrocode} % -% \end{macro} -% % \subsection{Multiencoding strings} % % The aim following commands is to provide a common interface for @@ -9071,10 +9448,10 @@ wouldn’t exist. % depending of if there is an optional argument: without it and % |strings=encoded|, strings are defined % always; otherwise, they are set only if they are still undefined -% (ie, fallback values). With labelled blocks and +% (i.e., fallback values). With labelled blocks and % |strings=encoded|, define the strings, but with another value, % define strings only if the current label or font encoding is the -% value of |strings|; otherwise (ie, no |strings| or a block whose +% value of |strings|; otherwise (i.e., no |strings| or a block whose % label is not in |strings=|) do nothing. % % We presume the current block is not loaded, and therefore set @@ -9117,12 +9494,12 @@ wouldn’t exist. \def\bbl@sctest{% \bbl@xin@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}% \fi - \ifx\bbl@opt@strings\@nnil % ie, no strings key -> defaults - \else\ifx\bbl@opt@strings\relax % ie, strings=encoded + \ifx\bbl@opt@strings\@nnil % i.e., no strings key -> defaults + \else\ifx\bbl@opt@strings\relax % i.e., strings=encoded \let\AfterBabelCommands\bbl@aftercmds \let\SetString\bbl@setstring \let\bbl@stringdef\bbl@encstring - \else % ie, strings=value + \else % i.e., strings=value \bbl@sctest \ifin@ \let\AfterBabelCommands\bbl@aftercmds @@ -9143,14 +9520,14 @@ wouldn’t exist. % \end{macrocode} % % There are two versions of |\bbl@scswitch|. The first version is used -% when |ldf|s are read, and it makes sure |\|\m{group}\m{language} is +% when |ldf|s are read, and it makes sure |\<group><language>| is % reset, but only once (|\bbl@screset| is used to keep track of this). % The second version is used in the preamble and packages loaded after % \babel{} and does nothing. % % The macro |\bbl@forlang| loops |\bbl@L| but its body is executed only % if the value is in |\BabelLanguages| (inside \babel) or -% |\date|\m{language} is defined (after \babel{} has been loaded). +% |\date<language>| is defined (after \babel{} has been loaded). % There are also two version of |\bbl@forlang|. The first one skips the % current iteration if the language is not in |\BabelLanguages| (used % in |ldf|s), and the second one skips undefined languages (after @@ -9191,17 +9568,17 @@ wouldn’t exist. % of |\SetString| when it is ``active'' % % First save the ``switcher''. Create it if undefined. Strings are -% defined only if undefined (ie, like |\providescommmand|). With +% defined only if undefined (i.e., like |\providescommmand|). With % the event |stringprocess| you can preprocess the string by % manipulating the value of |\BabelString|. If there are several % hooks assigned to this event, preprocessing is done in the same % order as defined. Finally, the string is set. % % \begin{macrocode} -\def\bbl@setstring#1#2{% eg, \prefacename{<string>} +\def\bbl@setstring#1#2{% e.g., \prefacename{<string>} \bbl@forlang\bbl@tempa{% \edef\bbl@LC{\bbl@tempa\bbl@stripslash#1}% - \bbl@ifunset{\bbl@LC}% eg, \germanchaptername + \bbl@ifunset{\bbl@LC}% e.g., \germanchaptername {\bbl@exp{% \global\\\bbl@add\<\bbl@G\bbl@tempa>{\\\bbl@scset\\#1\<\bbl@LC>}}}% {}% @@ -9211,7 +9588,7 @@ wouldn’t exist. \csname\bbl@LC\expandafter\endcsname\expandafter{\BabelString}}} % \end{macrocode} % -% A little auxiliary command sets the string. TODO: Formerly used with +% A little auxiliary command sets the string. Formerly used with % casing. Very likely no longer necessary, although it’s used in % |\setlocalecaption|. % @@ -9285,9 +9662,9 @@ wouldn’t exist. %<</Macros local to BabelCommands>> % \end{macrocode} % -% There are 3 helper macros which do most of the work for you. +% There are 3 helper macros which do most of the work for you. % -% \begin{macrocode} +% \begin{macrocode} \newcommand\BabelLower[2]{% one to one. \ifnum\lccode#1=#2\else \babel@savevariable{\lccode#1}% @@ -9328,8 +9705,8 @@ wouldn’t exist. %<</More package options>> % \end{macrocode} % -% Initial setup to provide a default behavior if |hyphenmap| -% is not set. +% Initial setup to provide a default behavior if |hyphenmap| is not +% set. % % \begin{macrocode} \AtEndOfPackage{% @@ -9339,13 +9716,15 @@ wouldn’t exist. \fi} % \end{macrocode} % -% This sections ends with a general tool for resetting the caption +% \subsection{Tailor captions} +% +% A general tool for resetting the caption % names with a unique interface. With the old way, which mixes the % switcher and the string, we convert it to the new one, which % separates these two steps. % % \begin{macrocode} -\newcommand\setlocalecaption{% TODO. Catch typos. +\newcommand\setlocalecaption{% \@ifstar\bbl@setcaption@s\bbl@setcaption@x} \def\bbl@setcaption@x#1#2#3{% language caption-name string \bbl@trim@def\bbl@tempa{#2}% @@ -9360,7 +9739,7 @@ wouldn’t exist. {\expandafter\string\csname #2name\endcsname}% {\bbl@tempd}% \ifin@ % Renew caption - \bbl@xin@{\string\bbl@scset}{\bbl@tempd}% + \bbl@xin@{\string\bbl@scset}{\bbl@tempd}% \ifin@ \bbl@exp{% \\\bbl@ifsamestring{\bbl@tempa}{\languagename}% @@ -9385,7 +9764,7 @@ wouldn’t exist. {}}% \else % Old way, but defined in the new way \bbl@exp{% - \\\bbl@add\<captions#1>{\def\<#2name>{\<#1#2name>}}% + \\\bbl@add\<captions#1>{\def\<#2name>{\<#1#2name>}}% \\\bbl@ifsamestring{\bbl@tempa}{\languagename}% {\def\<#2name>{\<#1#2name>}}% {}}% @@ -9399,12 +9778,15 @@ wouldn’t exist. \bbl@toglobal\bbl@captionslist \fi \fi} -% \def\bbl@setcaption@s#1#2#3{} % TODO. Not yet implemented (w/o 'name') % \end{macrocode} % -% \subsection{Macros common to a number of languages} +% \subsection{Making glyphs available} +% +% This section makes a number of glyphs available that either do not +% exist in the \texttt{OT1} encoding and have to be `faked', or +% that are not accessible through \file{T1enc.def}. % -% \begin{macro}{\set@low@box} +% \macro{\set@low@box} % % The following macro is used to lower quotes to the same level as % the comma. It prepares its argument in box register~0. @@ -9416,11 +9798,9 @@ wouldn’t exist. \setbox\z@\hbox{\lower\dimen\z@ \box\z@}\ht\z@\ht\tw@ \dp\z@\dp\tw@} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\save@sf@q} -% The macro |\save@sf@q| is used to save and reset the current -% space factor. +% \macro{\save@sf@q} +% The macro |\save@sf@q| is used to save and reset the current space +% factor. % % \begin{macrocode} \def\save@sf@q#1{\leavevmode @@ -9429,17 +9809,9 @@ wouldn’t exist. \endgroup} % \end{macrocode} % -% \end{macro} -% -% \subsection{Making glyphs available} -% -% This section makes a number of glyphs available that either do not -% exist in the \texttt{OT1} encoding and have to be `faked', or -% that are not accessible through \file{T1enc.def}. -% % \subsubsection{Quotation marks} % -% \begin{macro}{\quotedblbase} +% \macro{\quotedblbase} % In the \texttt{T1} encoding the opening double quote at the % baseline is available as a separate character, accessible via % |\quotedblbase|. In the \texttt{OT1} encoding it is not @@ -9460,10 +9832,8 @@ wouldn’t exist. \UseTextSymbol{OT1}{\quotedblbase}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\quotesinglbase} -% We also need the single quote character at the baseline. +% \macro{\quotesinglbase} +% We also need the single quote character at the baseline. % % \begin{macrocode} \ProvideTextCommand{\quotesinglbase}{OT1}{% @@ -9471,18 +9841,16 @@ wouldn’t exist. \box\z@\kern-.04em\bbl@allowhyphens}} % \end{macrocode} % -% Make sure that when an encoding other than \texttt{OT1} or -% \texttt{T1} is used this glyph can still be typeset. +% Make sure that when an encoding other than \texttt{OT1} or +% \texttt{T1} is used this glyph can still be typeset. % % \begin{macrocode} \ProvideTextCommandDefault{\quotesinglbase}{% \UseTextSymbol{OT1}{\quotesinglbase}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\guillemetleft} -% \begin{macro}{\guillemetright} +% \macro{\guillemetleft} +% \macro{\guillemetright} % The guillemet characters are not available in \texttt{OT1} % encoding. They are faked. (Wrong names with o preserved for % compatibility.) @@ -9532,13 +9900,10 @@ wouldn’t exist. \UseTextSymbol{OT1}{\guillemotright}} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\guilsinglleft} -% \begin{macro}{\guilsinglright} -% The single guillemets are not available in \texttt{OT1} -% encoding. They are faked. +% \macro{\guilsinglleft} +% \macro{\guilsinglright} +% The single guillemets are not available in \texttt{OT1} encoding. +% They are faked. % % \begin{macrocode} \ProvideTextCommand{\guilsinglleft}{OT1}{% @@ -9567,13 +9932,10 @@ wouldn’t exist. \UseTextSymbol{OT1}{\guilsinglright}} % \end{macrocode} % -% \end{macro} -% \end{macro} -% % \subsubsection{Letters} % -% \begin{macro}{\ij} -% \begin{macro}{\IJ} +% \macro{\ij} +% \macro{\IJ} % The dutch language uses the letter `ij'. It is available in % \texttt{T1} encoded fonts, but not in the \texttt{OT1} encoded % fonts. Therefore we fake it for the \texttt{OT1} encoding. @@ -9587,8 +9949,8 @@ wouldn’t exist. \DeclareTextCommand{\IJ}{T1}{\char156} % \end{macrocode} % -% Make sure that when an encoding other than \texttt{OT1} or -% \texttt{T1} is used these glyphs can still be typeset. +% Make sure that when an encoding other than \texttt{OT1} or +% \texttt{T1} is used these glyphs can still be typeset. % % \begin{macrocode} \ProvideTextCommandDefault{\ij}{% @@ -9597,11 +9959,8 @@ wouldn’t exist. \UseTextSymbol{OT1}{\IJ}} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\dj} -% \begin{macro}{\DJ} +% \macro{\dj} +% \macro{\DJ} % The croatian language needs the letters |\dj| and |\DJ|; they are % available in the \texttt{T1} encoding, but not in the % \texttt{OT1} encoding by default. @@ -9632,8 +9991,8 @@ wouldn’t exist. \DeclareTextCommand{\DJ}{OT1}{\DDJ@ D} % \end{macrocode} % -% Make sure that when an encoding other than \texttt{OT1} or -% \texttt{T1} is used these glyphs can still be typeset. +% Make sure that when an encoding other than \texttt{OT1} or +% \texttt{T1} is used these glyphs can still be typeset. % % \begin{macrocode} \ProvideTextCommandDefault{\dj}{% @@ -9642,41 +10001,36 @@ wouldn’t exist. \UseTextSymbol{OT1}{\DJ}} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\SS} -% For the \texttt{T1} encoding |\SS| is defined and selects a -% specific glyph from the font, but for other encodings it is not -% available. Therefore we make it available here. +% \macro{\SS} +% For the \texttt{T1} encoding |\SS| is defined and selects a specific +% glyph from the font, but for other encodings it is not available. +% Therefore we make it available here. % % \begin{macrocode} \DeclareTextCommand{\SS}{OT1}{SS} \ProvideTextCommandDefault{\SS}{\UseTextSymbol{OT1}{\SS}} % \end{macrocode} % -% \end{macro} -% % \subsubsection{Shorthands for quotation marks} % -% Shorthands are provided for a number of different quotation -% marks, which make them usable both outside and inside mathmode. -% They are defined with |\ProvideTextCommandDefault|, but this is -% very likely not required because their definitions are based on -% encoding-dependent macros. +% Shorthands are provided for a number of different quotation marks, +% which make them usable both outside and inside mathmode. They are +% defined with |\ProvideTextCommandDefault|, but this is very likely +% not required because their definitions are based on +% encoding-dependent macros. % -% \begin{macro}{\glq} -% \begin{macro}{\grq} +% \macro{\glq} +% \macro{\grq} % -% The `german' single quotes. +% The `german' single quotes. % % \begin{macrocode} \ProvideTextCommandDefault{\glq}{% \textormath{\quotesinglbase}{\mbox{\quotesinglbase}}} % \end{macrocode} % -% The definition of |\grq| depends on the fontencoding. With -% \texttt{T1} encoding no extra kerning is needed. +% The definition of |\grq| depends on the fontencoding. With +% \texttt{T1} encoding no extra kerning is needed. % % \begin{macrocode} \ProvideTextCommand{\grq}{T1}{% @@ -9690,21 +10044,18 @@ wouldn’t exist. \ProvideTextCommandDefault{\grq}{\UseTextSymbol{OT1}\grq} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\glqq} -% \begin{macro}{\grqq} +% \macro{\glqq} +% \macro{\grqq} % -% The `german' double quotes. +% The `german' double quotes. % % \begin{macrocode} \ProvideTextCommandDefault{\glqq}{% \textormath{\quotedblbase}{\mbox{\quotedblbase}}} % \end{macrocode} % -% The definition of |\grqq| depends on the fontencoding. With -% \texttt{T1} encoding no extra kerning is needed. +% The definition of |\grqq| depends on the fontencoding. With +% \texttt{T1} encoding no extra kerning is needed. % % \begin{macrocode} \ProvideTextCommand{\grqq}{T1}{% @@ -9718,13 +10069,10 @@ wouldn’t exist. \ProvideTextCommandDefault{\grqq}{\UseTextSymbol{OT1}\grqq} % \end{macrocode} % -% \end{macro} -% \end{macro} +% \macro{\flq} +% \macro{\frq} % -% \begin{macro}{\flq} -% \begin{macro}{\frq} -% -% The `french' single guillemets. +% The `french' single guillemets. % % \begin{macrocode} \ProvideTextCommandDefault{\flq}{% @@ -9733,13 +10081,10 @@ wouldn’t exist. \textormath{\guilsinglright}{\mbox{\guilsinglright}}} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\flqq} -% \begin{macro}{\frqq} +% \macro{\flqq} +% \macro{\frqq} % -% The `french' double guillemets. +% The `french' double guillemets. % % \begin{macrocode} \ProvideTextCommandDefault{\flqq}{% @@ -9748,24 +10093,21 @@ wouldn’t exist. \textormath{\guillemetright}{\mbox{\guillemetright}}} % \end{macrocode} % -% \end{macro} -% \end{macro} -% % \subsubsection{Umlauts and tremas} % -% The command |\"| needs to have a different effect for different -% languages. For German for instance, the `umlaut' should be -% positioned lower than the default position for placing it over -% the letters a, o, u, A, O and U. When placed over an e, i, E or I -% it can retain its normal position. For Dutch the same glyph is -% always placed in the lower position. +% The command |\"| needs to have a different effect for different +% languages. For German for instance, the `umlaut' should be positioned +% lower than the default position for placing it over the letters a, o, +% u, A, O and U. When placed over an e, i, E or I it can retain its +% normal position. For Dutch the same glyph is always placed in the +% lower position. % -% \begin{macro}{\umlauthigh} +% \macro{\umlauthigh} % -% \begin{macro}{\umlautlow} -% To be able to provide both positions of |\"| we provide two -% commands to switch the positioning, the default will be -% |\umlauthigh| (the normal positioning). +% \macro{\umlautlow} +% To be able to provide both positions of |\"| we provide two commands +% to switch the positioning, the default will be |\umlauthigh| (the +% normal positioning). % % \begin{macrocode} \def\umlauthigh{% @@ -9780,15 +10122,10 @@ wouldn’t exist. \umlauthigh % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\lower@umlaut} -% The command |\lower@umlaut| is used to position the |\"| closer -% to the letter. -% -% We want the umlaut character lowered, nearer to the letter. To do -% this we need an extra \meta{dimen} register. +% \macro{\lower@umlaut} +% Used to position the |\"| closer to +% the letter. We want the umlaut character lowered, nearer to the +% letter. To do this we need an extra \meta{dimen} register. % % \begin{macrocode} \expandafter\ifx\csname U@D\endcsname\relax @@ -9796,20 +10133,19 @@ wouldn’t exist. \fi % \end{macrocode} % -% The following code fools \TeX's \texttt{make\_accent} procedure -% about the current x-height of the font to force another placement -% of the umlaut character. -% First we have to save the current x-height of the font, because -% we'll change this font dimension and this is always done -% globally. +% The following code fools \TeX's \texttt{make\_accent} procedure about +% the current x-height of the font to force another placement of the +% umlaut character. First we have to save the current x-height of the +% font, because we'll change this font dimension and this is always +% done globally. % -% Then we compute the new x-height in such a way that the umlaut -% character is lowered to the base character. The value of -% \texttt{.45ex} depends on the \MF\ parameters with which the -% fonts were built. (Just try out, which value will look best.) -% If the new x-height is too low, it is not changed. -% Finally we call the |\accent| primitive, reset the old x-height -% and insert the base character in the argument. +% Then we compute the new x-height in such a way that the umlaut +% character is lowered to the base character. The value of +% \texttt{.45ex} depends on the \MF\ parameters with which the fonts +% were built. (Just try out, which value will look best.) If the new +% x-height is too low, it is not changed. Finally we call the |\accent| +% primitive, reset the old x-height and insert the base character in +% the argument. % % \begin{macrocode} \def\lower@umlaut#1{% @@ -9824,8 +10160,6 @@ wouldn’t exist. \egroup} % \end{macrocode} % -% \end{macro} -% % For all vowels we declare |\"| to be a composite command which % uses |\bbl@umlauta| or |\bbl@umlaute| to position the umlaut % character. We need to be sure that these definitions override the @@ -9833,9 +10167,9 @@ wouldn’t exist. % option \Lopt{OT1} is used. Therefore these declarations are % postponed until the beginning of the document. Note these % definitions only apply to some languages, but -% babel sets them for \textit{all} languages -- you may want to +% \babel{} sets them for \textit{all} languages -- you may want to % redefine |\bbl@umlauta| and/or |\bbl@umlaute| for a language -% in the corresponding |ldf| (using the babel switching mechanism, +% in the corresponding |ldf| (using the \babel{} switching mechanism, % of course). % % \begin{macrocode} @@ -9875,45 +10209,10 @@ wouldn’t exist. % \begin{macrocode} \bbl@trace{Bidi layout} \providecommand\IfBabelLayout[3]{#3}% -%<-core> -\newcommand\BabelPatchSection[1]{% - \@ifundefined{#1}{}{% - \bbl@exp{\let\<bbl@ss@#1>\<#1>}% - \@namedef{#1}{% - \@ifstar{\bbl@presec@s{#1}}% - {\@dblarg{\bbl@presec@x{#1}}}}}} -\def\bbl@presec@x#1[#2]#3{% - \bbl@exp{% - \\\select@language@x{\bbl@main@language}% - \\\bbl@cs{sspre@#1}% - \\\bbl@cs{ss@#1}% - [\\\foreignlanguage{\languagename}{\unexpanded{#2}}]% - {\\\foreignlanguage{\languagename}{\unexpanded{#3}}}% - \\\select@language@x{\languagename}}} -\def\bbl@presec@s#1#2{% - \bbl@exp{% - \\\select@language@x{\bbl@main@language}% - \\\bbl@cs{sspre@#1}% - \\\bbl@cs{ss@#1}*% - {\\\foreignlanguage{\languagename}{\unexpanded{#2}}}% - \\\select@language@x{\languagename}}} -\IfBabelLayout{sectioning}% - {\BabelPatchSection{part}% - \BabelPatchSection{chapter}% - \BabelPatchSection{section}% - \BabelPatchSection{subsection}% - \BabelPatchSection{subsubsection}% - \BabelPatchSection{paragraph}% - \BabelPatchSection{subparagraph}% - \def\babel@toc#1{% - \select@language@x{\bbl@main@language}}}{} -\IfBabelLayout{captions}% - {\BabelPatchSection{caption}}{} -%<+core> % \end{macrocode} % % \subsection{Load engine specific macros} -% +% % Some macros are not defined in all engines, so, after loading the % files define them if necessary to raise an error. % @@ -9933,6 +10232,7 @@ wouldn’t exist. \let\babelpatterns\babelprehyphenation \let\babelcharproperty\babelprehyphenation \fi +%</package|core> % \end{macrocode} % % \subsection{Creating and modifying languages} @@ -9945,7 +10245,6 @@ wouldn’t exist. % loaded |ldf| files. % % \begin{macrocode} -%</package|core> %<*package> \bbl@trace{Creating languages and reading ini files} \let\bbl@extend@ini\@gobble @@ -9959,7 +10258,7 @@ wouldn’t exist. \bbl@vforeach{captions,date,import,main,script,language,% hyphenrules,linebreaking,justification,mapfont,maparabic,% mapdigits,intraspace,intrapenalty,onchar,transforms,alph,% - Alph,labels,labels*,calendar,date,casing,interchar}% + Alph,labels,labels*,calendar,date,casing,interchar,@import}% {\bbl@csarg\let{KVP@##1}\@nnil}% \global\let\bbl@release@transforms\@empty \global\let\bbl@release@casing\@empty @@ -9967,8 +10266,11 @@ wouldn’t exist. \global\let\bbl@inidata\@empty \global\let\bbl@extend@ini\@gobble \global\let\bbl@included@inis\@empty - \gdef\bbl@key@list{;}% - \bbl@forkv{#1}{% + \gdef\bbl@key@list{;}% + \bbl@ifunset{bbl@passto@#2}% + {\def\bbl@tempa{#1}}% + {\bbl@exp{\def\\\bbl@tempa{\[bbl@passto@#2],\unexpanded{#1}}}}% + \expandafter\bbl@forkv\expandafter{\bbl@tempa}{% \in@{/}{##1}% With /, (re)sets a value in the ini \ifin@ \global\let\bbl@extend@ini\bbl@extend@ini@aux @@ -9985,6 +10287,10 @@ wouldn’t exist. \ifx\bbl@screset\@undefined \bbl@ldfinit \fi + % == + \ifx\bbl@KVP@@import\@nnil\else \ifx\bbl@KVP@import\@nnil + \def\bbl@KVP@import{\@empty}% + \fi\fi % == date (as option) == % \ifx\bbl@KVP@date\@nnil\else % \fi @@ -10014,7 +10320,7 @@ wouldn’t exist. {}% \let\bbl@KVP@date\@empty \fi - \let\bbl@KVP@captions@@\bbl@KVP@captions % TODO. A dirty hack + \let\bbl@KVP@captions@@\bbl@KVP@captions \ifx\bbl@KVP@captions\@nnil \let\bbl@KVP@captions\bbl@KVP@import \fi @@ -10082,122 +10388,12 @@ wouldn’t exist. {\directlua{ Babel.set_chranges_b('\bbl@cl{sbcp}', '\bbl@cl{chrng}') }}% \fi - % == onchar == - \ifx\bbl@KVP@onchar\@nnil\else - \bbl@luahyphenate - \bbl@exp{% - \\\AddToHook{env/document/before}{{\\\select@language{#2}{}}}}% - \directlua{ - if Babel.locale_mapped == nil then - Babel.locale_mapped = true - Babel.linebreaking.add_before(Babel.locale_map, 1) - Babel.loc_to_scr = {} - Babel.chr_to_loc = Babel.chr_to_loc or {} - end - Babel.locale_props[\the\localeid].letters = false - }% - \bbl@xin@{ letters }{ \bbl@KVP@onchar\space}% - \ifin@ - \directlua{ - Babel.locale_props[\the\localeid].letters = true - }% - \fi - \bbl@xin@{ ids }{ \bbl@KVP@onchar\space}% - \ifin@ - \ifx\bbl@starthyphens\@undefined % Needed if no explicit selection - \AddBabelHook{babel-onchar}{beforestart}{{\bbl@starthyphens}}% - \fi - \bbl@exp{\\\bbl@add\\\bbl@starthyphens - {\\\bbl@patterns@lua{\languagename}}}% - % TODO - error/warning if no script - \directlua{ - if Babel.script_blocks['\bbl@cl{sbcp}'] then - Babel.loc_to_scr[\the\localeid] = Babel.script_blocks['\bbl@cl{sbcp}'] - Babel.locale_props[\the\localeid].lg = \the\@nameuse{l@\languagename}\space - end - }% - \fi - \bbl@xin@{ fonts }{ \bbl@KVP@onchar\space}% - \ifin@ - \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% - \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}% - \directlua{ - if Babel.script_blocks['\bbl@cl{sbcp}'] then - Babel.loc_to_scr[\the\localeid] = - Babel.script_blocks['\bbl@cl{sbcp}'] - end}% - \ifx\bbl@mapselect\@undefined % TODO. almost the same as mapfont - \AtBeginDocument{% - \bbl@patchfont{{\bbl@mapselect}}% - {\selectfont}}% - \def\bbl@mapselect{% - \let\bbl@mapselect\relax - \edef\bbl@prefontid{\fontid\font}}% - \def\bbl@mapdir##1{% - \begingroup - \setbox\z@\hbox{% Force text mode - \def\languagename{##1}% - \let\bbl@ifrestoring\@firstoftwo % To avoid font warning - \bbl@switchfont - \ifnum\fontid\font>\z@ % A hack, for the pgf nullfont hack - \directlua{ - Babel.locale_props[\the\csname bbl@id@@##1\endcsname]% - ['/\bbl@prefontid'] = \fontid\font\space}% - \fi}% - \endgroup}% - \fi - \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}% - \fi - % TODO - catch non-valid values - \fi - % == mapfont == - % For bidi texts, to switch the font based on direction - \ifx\bbl@KVP@mapfont\@nnil\else - \bbl@ifsamestring{\bbl@KVP@mapfont}{direction}{}% - {\bbl@error{unknown-mapfont}{}{}{}}% - \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% - \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}% - \ifx\bbl@mapselect\@undefined % TODO. See onchar. - \AtBeginDocument{% - \bbl@patchfont{{\bbl@mapselect}}% - {\selectfont}}% - \def\bbl@mapselect{% - \let\bbl@mapselect\relax - \edef\bbl@prefontid{\fontid\font}}% - \def\bbl@mapdir##1{% - {\def\languagename{##1}% - \let\bbl@ifrestoring\@firstoftwo % avoid font warning - \bbl@switchfont - \directlua{Babel.fontmap - [\the\csname bbl@wdir@##1\endcsname]% - [\bbl@prefontid]=\fontid\font}}}% - \fi - \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}% - \fi % == Line breaking: intraspace, intrapenalty == % For CJK, East Asian, Southeast Asian, if interspace in ini \ifx\bbl@KVP@intraspace\@nnil\else % We can override the ini or set \bbl@csarg\edef{intsp@#2}{\bbl@KVP@intraspace}% \fi \bbl@provide@intraspace - % == Line breaking: CJK quotes == TODO -> @extras - \ifcase\bbl@engine\or - \bbl@xin@{/c}{/\bbl@cl{lnbrk}}% - \ifin@ - \bbl@ifunset{bbl@quote@\languagename}{}% - {\directlua{ - Babel.locale_props[\the\localeid].cjk_quotes = {} - local cs = 'op' - for c in string.utfvalues(% - [[\csname bbl@quote@\languagename\endcsname]]) do - if Babel.cjk_characters[c].c == 'qu' then - Babel.locale_props[\the\localeid].cjk_quotes[c] = cs - end - cs = ( cs == 'op') and 'cl' or 'op' - end - }}% - \fi - \fi % == Line breaking: justification == \ifx\bbl@KVP@justification\@nnil\else \let\bbl@KVP@linebreaking\bbl@KVP@justification @@ -10213,6 +10409,7 @@ wouldn’t exist. \bbl@xin@{/e}{/\bbl@cl{lnbrk}}% \ifin@\else\bbl@xin@{/k}{/\bbl@cl{lnbrk}}\fi \ifin@\bbl@arabicjust\fi + % WIP \bbl@xin@{/p}{/\bbl@cl{lnbrk}}% \ifin@\AtBeginDocument{\@nameuse{bbl@tibetanjust}}\fi % == Line breaking: hyphenate.other.(locale|script) == @@ -10251,7 +10448,7 @@ wouldn’t exist. \ifx\bbl@latinarabic\@undefined \expandafter\let\expandafter\@arabic \csname bbl@counter@\languagename\endcsname - \else % ie, if layout=counters, which redefines \@arabic + \else % i.e., if layout=counters, which redefines \@arabic \expandafter\let\expandafter\bbl@latinarabic \csname bbl@counter@\languagename\endcsname \fi @@ -10416,7 +10613,7 @@ wouldn’t exist. % Load the basic parameters (ids, typography, counters, and a few % more), while captions and dates are left out. But it may happen some % data has been loaded before automatically, so we first discard the -% saved values. (TODO. But preserving previous values would be useful.) +% saved values. % % \begin{macrocode} \def\bbl@load@basic#1{% @@ -10425,7 +10622,7 @@ wouldn’t exist. \bbl@csarg\let{lname@\languagename}\relax \fi \fi - \bbl@ifunset{bbl@lname@#1}% + \bbl@ifunset{bbl@lname@#1}% {\def\BabelBeforeIni##1##2{% \begingroup \let\bbl@ini@captions@aux\@gobbletwo @@ -10454,7 +10651,7 @@ wouldn’t exist. \bbl@replace\bbl@KVP@hyphenrules{ }{,}% \bbl@foreach\bbl@KVP@hyphenrules{% \ifnum\@tempcnta=\m@ne % if not yet found - \bbl@ifsamestring{##1}{+}% + \bbl@ifsamestring{##1}{+}% {\bbl@carg\addlanguage{l@##1}}% {}% \bbl@ifunset{l@##1}% After a possible + @@ -10490,7 +10687,7 @@ wouldn’t exist. % \end{macrocode} % % The reader of |babel-...tex| files. We reset temporarily some -% catcodes. +% catcodes (and make sure no space is accidentally inserted). % % \begin{macrocode} \def\bbl@input@texini#1{% @@ -10521,7 +10718,7 @@ wouldn’t exist. \bbl@trim\toks@{#2}% \bbl@xin@{;\bbl@section/\bbl@tempa;}{\bbl@key@list}% \ifin@\else - \bbl@xin@{,identification/include.}% + \bbl@xin@{,identification/include.}% {,\bbl@section/\bbl@tempa}% \ifin@\xdef\bbl@included@inis{\the\toks@}\fi \bbl@exp{% @@ -10538,6 +10735,8 @@ wouldn’t exist. \fi} % \end{macrocode} % +% \subsection{Main loop in ‘provide’} +% % Now, the ‘main loop’, which \textbf{**must be executed inside a % group**}. At this point, |\bbl@inidata| may contain data declared in % |\babelprovide|, with ‘slashed’ keys. There are 3 steps: first read @@ -10622,7 +10821,7 @@ wouldn’t exist. \setlocalecaption{#1}{##1}{##2}}% \def\bbl@inikv@captions##1##2{% \bbl@ini@captions@aux{##1}{##2}}% - \def\bbl@stringdef##1##2{\gdef##1{##2}}% + \def\bbl@stringdef##1##2{\gdef##1{##2}}% \def\bbl@exportkey##1##2##3{% \bbl@ifunset{bbl@@kv@##2}{}% {\expandafter\ifx\csname bbl@@kv@##2\endcsname\@empty\else @@ -10665,7 +10864,7 @@ wouldn’t exist. \xdef\bbl@calendars{\bbl@calendars,\bbl@tempa}% \fi \bbl@exp{% - \def\<bbl@inikv@#1>####1####2{% + \def\<bbl@inikv@#1>####1####2{% \\\bbl@inidate####1...\relax{####2}{\bbl@tempa}}}% \fi} % \end{macrocode} @@ -10676,7 +10875,6 @@ wouldn’t exist. % file has not yet been read), and define a dummy macro. When the |ini| % file is read, just skip the corresponding key and reset the macro (in % |\bbl@inistore| above). -% % % \begin{macrocode} \def\bbl@renewinikey#1/#2\@@#3{% @@ -10713,7 +10911,15 @@ wouldn’t exist. % many other sources do (as a \textit{private use extension}). For % consistency with other single-letter subtags or ‘singletons’, here % is considered an extension, too. -% +% +% The identification section is used internally by \babel\ in the +% following places [to be completed]: BCP 47 script tag in the Unicode +% ranges, which is in turn used by |onchar|; the language system is set +% with the names, and then \textsf{fontspec} maps them to the opentype +% tags, but if the latter package doesn’t define them, then \babel\ +% does it; |encodings| are used in \pdftex{} to select a font encoding +% valid (and preloaded) for a language loaded on the fly. +% % \begin{macrocode} \def\bbl@iniwarning#1{% \bbl@ifunset{bbl@@kv@identification.warning#1}{}% @@ -10768,7 +10974,7 @@ wouldn’t exist. \bbl@exportkey{lnbrk}{typography.linebreaking}{h}% \bbl@exportkey{hyphr}{typography.hyphenrules}{}% \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}% - \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}% + \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}% \bbl@exportkey{prehc}{typography.prehyphenchar}{}% \bbl@exportkey{hyotl}{typography.hyphenate.other.locale}{}% \bbl@exportkey{hyots}{typography.hyphenate.other.script}{}% @@ -10786,6 +10992,8 @@ wouldn’t exist. \fi} % \end{macrocode} % +% \subsection{Processing keys in \texttt{ini}} +% % A shared handler for key=val lines to be stored in % |\bbl@@kv@<section>.<key>|. % @@ -10813,11 +11021,11 @@ wouldn’t exist. % \begin{macrocode} \def\bbl@maybextx{-\bbl@csarg\ifx{extx@\languagename}\@empty x-\fi} \def\bbl@inikv@characters#1#2{% - \bbl@ifsamestring{#1}{casing}% eg, casing = uV + \bbl@ifsamestring{#1}{casing}% e.g., casing = uV {\bbl@exp{% \\\g@addto@macro\\\bbl@release@casing{% \\\bbl@casemapping{}{\languagename}{\unexpanded{#2}}}}}% - {\in@{$casing.}{$#1}% eg, casing.Uv = uV + {\in@{$casing.}{$#1}% e.g., casing.Uv = uV \ifin@ \lowercase{\def\bbl@tempb{#1}}% \bbl@replace\bbl@tempb{casing.}{}% @@ -10881,9 +11089,9 @@ wouldn’t exist. \def\bbl@toreplace{#1{}}% \bbl@replace\bbl@toreplace{[ ]}{\nobreakspace{}}% \bbl@replace\bbl@toreplace{[[}{\csname}% - \bbl@replace\bbl@toreplace{[}{\csname the}% + \bbl@replace\bbl@toreplace{[}{\csname the}% \bbl@replace\bbl@toreplace{]]}{name\endcsname{}}% - \bbl@replace\bbl@toreplace{]}{\endcsname{}}% + \bbl@replace\bbl@toreplace{]}{\endcsname{}}% \bbl@xin@{,\bbl@tempa,}{,chapter,appendix,part,}% \ifin@ \@nameuse{bbl@patch\bbl@tempa}% @@ -10922,7 +11130,7 @@ wouldn’t exist. % % \textbf{Labels.} Captions must contain just strings, no % format at all, so there is new group in ini files. -% +% % \begin{macrocode} \def\bbl@list@the{% part,chapter,section,subsection,subsubsection,paragraph,% @@ -10963,7 +11171,7 @@ wouldn’t exist. \else % % The following code is still under study. You can test it and make - % suggestions. Eg, enumerate.2 = ([enumi]).([enumii]). It's + % suggestions. E.g., enumerate.2 = ([enumi]).([enumii]). It's % language dependent. \in@{enumerate.}{#1}% \ifin@ @@ -10971,8 +11179,8 @@ wouldn’t exist. \bbl@replace\bbl@tempa{enumerate.}{}% \def\bbl@toreplace{#2}% \bbl@replace\bbl@toreplace{[ ]}{\nobreakspace{}}% - \bbl@replace\bbl@toreplace{[}{\csname the}% - \bbl@replace\bbl@toreplace{]}{\endcsname{}}% + \bbl@replace\bbl@toreplace{[}{\csname the}% + \bbl@replace\bbl@toreplace{]}{\endcsname{}}% \toks@\expandafter{\bbl@toreplace}% % TODO. Execute only once: \bbl@exp{% @@ -11044,8 +11252,8 @@ wouldn’t exist. \edef\bbl@tempe{% \bbl@ifunset{bbl@calpr@\languagename}{}{\bbl@cl{calpr}},% #1}% + \bbl@exp{\lowercase{\edef\\\bbl@tempe{\bbl@tempe}}}% \bbl@replace\bbl@tempe{ }{}% - \bbl@replace\bbl@tempe{CONVERT}{convert=}% Hackish \bbl@replace\bbl@tempe{convert}{convert=}% \let\bbl@ld@calendar\@empty \let\bbl@ld@variant\@empty @@ -11059,7 +11267,7 @@ wouldn’t exist. {\bbl@ld@calendar}\bbl@they\bbl@them\bbl@thed \fi \fi - \@nameuse{bbl@precalendar}% Remove, eg, +, -civil (-ca-islamic) + \@nameuse{bbl@precalendar}% Remove, e.g., +, -civil (-ca-islamic) \edef\bbl@calendar{% Used in \month..., too \bbl@ld@calendar \ifx\bbl@ld@variant\@empty\else @@ -11069,7 +11277,7 @@ wouldn’t exist. {\@nameuse{bbl@date@\languagename @\bbl@calendar}% \bbl@they\bbl@them\bbl@thed}% \endgroup} -% eg: 1=months, 2=wide, 3=1, 4=dummy, 5=value, 6=calendar +% e.g.: 1=months, 2=wide, 3=1, 4=dummy, 5=value, 6=calendar \def\bbl@inidate#1.#2.#3.#4\relax#5#6{% TODO - ignore with 'captions' \bbl@trim@def\bbl@tempa{#1.#2}% \bbl@ifsamestring{\bbl@tempa}{months.wide}% to savedate @@ -11088,17 +11296,40 @@ wouldn’t exist. \ifx\bbl@savetoday\@empty \bbl@exp{% TODO. Move to a better place. \\\AfterBabelCommands{% - \def\<\languagename date>{\\\protect\<\languagename date >}% - \\\newcommand\<\languagename date >[4][]{% - \\\bbl@usedategrouptrue - \<bbl@ensure@\languagename>{% - \\\localedate[####1]{####2}{####3}{####4}}}}% + \gdef\<\languagename date>{\\\protect\<\languagename date >}% + \gdef\<\languagename date >{\\\bbl@printdate{\languagename}}}% \def\\\bbl@savetoday{% \\\SetString\\\today{% \<\languagename date>[convert]% {\\\the\year}{\\\the\month}{\\\the\day}}}}% \fi}% {}}} +\def\bbl@printdate#1{% + \@ifnextchar[{\bbl@printdate@i{#1}}{\bbl@printdate@i{#1}[]}} +\def\bbl@printdate@i#1[#2]#3#4#5{% + \bbl@usedategrouptrue + \@nameuse{bbl@ensure@#1}{\localedate[#2]{#3}{#4}{#5}}} +% \end{macrocode} +% +% \subsection{French spacing (again)} +% +% For the following declarations, see issue \#240. |\nonfrenchspacing| +% is set by |document| too early, so it’s a hack. +% +% \begin{macrocode} +\AddToHook{begindocument/before}{% + \let\bbl@normalsf\normalsfcodes + \let\normalsfcodes\relax} +\AtBeginDocument{% + \ifx\bbl@normalsf\@empty + \ifnum\sfcode`\.=\@m + \let\normalsfcodes\frenchspacing + \else + \let\normalsfcodes\nonfrenchspacing + \fi + \else + \let\normalsfcodes\bbl@normalsf + \fi} % \end{macrocode} % % \textbf{Dates} will require some macros for the basic formatting. @@ -11162,7 +11393,7 @@ wouldn’t exist. \bbl@csarg\let{inikv@transforms.posthyphenation}\bbl@inikv \def\bbl@transforms@aux#1#2#3#4,#5\relax{% #1[#2]{#3}{#4}{#5}} -\begingroup % A hack. TODO. Don't require an specific order +\begingroup % A hack. TODO. Don't require a specific order \catcode`\%=12 \catcode`\&=14 \gdef\bbl@transforms#1#2#3{&% @@ -11214,6 +11445,8 @@ wouldn’t exist. \endgroup % \end{macrocode} % +% \subsection{Handle language system} +% % Language and Script values to be used when defining a font or % setting the direction are set with the following macros. % @@ -11258,7 +11491,7 @@ wouldn’t exist. 'HyphenChar' to another value, but be aware\\% this setting is not safe (see the manual).\\% Reported}% - \hyphenchar\font\defaulthyphenchar + \hyphenchar\font\defaulthyphenchar \fi\fi \fi}% {\hyphenchar\font\defaulthyphenchar}} @@ -11266,7 +11499,7 @@ wouldn’t exist. % \end{macrocode} % % The following |ini| reader ignores everything but the -% |identification| section. It is called when a font is defined (ie, +% |identification| section. It is called when a font is defined (i.e., % when the language is first selected) to know which script/language % must be enabled. This means we must make sure a few characters are % not active. The |ini| is not read directly, but with a proxy |tex| @@ -11283,6 +11516,8 @@ wouldn’t exist. {\bbl@input@texini{#1}}} % \end{macrocode} % +% \subsection{Numerals} +% % A tool to define the macros for native digits from the list provided % in the |ini| file. Somewhat convoluted because there are 10 digits, % but only 9 arguments in \TeX. Non-digits characters are kept. The @@ -11291,19 +11526,19 @@ wouldn’t exist. % \begin{macrocode} \def\bbl@setdigits#1#2#3#4#5{% \bbl@exp{% - \def\<\languagename digits>####1{% ie, \langdigits + \def\<\languagename digits>####1{% i.e., \langdigits \<bbl@digits@\languagename>####1\\\@nil}% \let\<bbl@cntr@digits@\languagename>\<\languagename digits>% - \def\<\languagename counter>####1{% ie, \langcounter + \def\<\languagename counter>####1{% i.e., \langcounter \\\expandafter\<bbl@counter@\languagename>% \\\csname c@####1\endcsname}% - \def\<bbl@counter@\languagename>####1{% ie, \bbl@counter@lang + \def\<bbl@counter@\languagename>####1{% i.e., \bbl@counter@lang \\\expandafter\<bbl@digits@\languagename>% \\\number####1\\\@nil}}% \def\bbl@tempa##1##2##3##4##5{% \bbl@exp{% Wow, quite a lot of hashes! :-( \def\<bbl@digits@\languagename>########1{% - \\\ifx########1\\\@nil % ie, \bbl@digits@lang + \\\ifx########1\\\@nil % i.e., \bbl@digits@lang \\\else \\\ifx0########1#1% \\\else\\\ifx1########1#2% @@ -11376,67 +11611,9 @@ wouldn’t exist. \bbl@error{alphabetic-too-large}{#1}{}{}} % \end{macrocode} % -% The information in the identification section can be useful, so the -% following macro just exposes it with a user command. +% \subsection{Casing} % % \begin{macrocode} -\def\bbl@localeinfo#1#2{% - \bbl@ifunset{bbl@info@#2}{#1}% - {\bbl@ifunset{bbl@\csname bbl@info@#2\endcsname @\languagename}{#1}% - {\bbl@cs{\csname bbl@info@#2\endcsname @\languagename}}}} -\newcommand\localeinfo[1]{% - \ifx*#1\@empty % TODO. A bit hackish to make it expandable. - \bbl@afterelse\bbl@localeinfo{}% - \else - \bbl@localeinfo - {\bbl@error{no-ini-info}{}{}{}}% - {#1}% - \fi} -% \@namedef{bbl@info@name.locale}{lcname} -\@namedef{bbl@info@tag.ini}{lini} -\@namedef{bbl@info@name.english}{elname} -\@namedef{bbl@info@name.opentype}{lname} -\@namedef{bbl@info@tag.bcp47}{tbcp} -\@namedef{bbl@info@language.tag.bcp47}{lbcp} -\@namedef{bbl@info@tag.opentype}{lotf} -\@namedef{bbl@info@script.name}{esname} -\@namedef{bbl@info@script.name.opentype}{sname} -\@namedef{bbl@info@script.tag.bcp47}{sbcp} -\@namedef{bbl@info@script.tag.opentype}{sotf} -\@namedef{bbl@info@region.tag.bcp47}{rbcp} -\@namedef{bbl@info@variant.tag.bcp47}{vbcp} -\@namedef{bbl@info@extension.t.tag.bcp47}{extt} -\@namedef{bbl@info@extension.u.tag.bcp47}{extu} -\@namedef{bbl@info@extension.x.tag.bcp47}{extx} -% \end{macrocode} -% -% \LaTeX{} needs to know the BCP 47 codes for some features. For that, -% it expects |\BCPdata| to be defined. While |language|, |region|, -% |script|, and |variant| are recognized, |extension.|\m{s} for -% singletons may change. -% -% \begin{macrocode} -\ifcase\bbl@engine % Converts utf8 to its code (expandable) - \def\bbl@utftocode#1{\the\numexpr\decode@UTFviii#1\relax} -\else - \def\bbl@utftocode#1{\expandafter`\string#1} -\fi -% Still somewhat hackish. WIP. Note |\str_if_eq:nnTF| is fully -% expandable (|\bbl@ifsamestring| isn’t). -\providecommand\BCPdata{} -\ifx\renewcommand\@undefined\else % For plain. TODO. It’s a quick fix - \renewcommand\BCPdata[1]{\bbl@bcpdata@i#1\@empty} - \def\bbl@bcpdata@i#1#2#3#4#5#6\@empty{% - \@nameuse{str_if_eq:nnTF}{#1#2#3#4#5}{main.}% - {\bbl@bcpdata@ii{#6}\bbl@main@language}% - {\bbl@bcpdata@ii{#1#2#3#4#5#6}\languagename}}% - \def\bbl@bcpdata@ii#1#2{% - \bbl@ifunset{bbl@info@#1.tag.bcp47}% - {\bbl@error{unknown-ini-field}{#1}{}{}}% - {\bbl@ifunset{bbl@\csname bbl@info@#1.tag.bcp47\endcsname @#2}{}% - {\bbl@cs{\csname bbl@info@#1.tag.bcp47\endcsname @#2}}}} -\fi -\@namedef{bbl@info@casing.tag.bcp47}{casing} \newcommand\BabelUppercaseMapping[3]{% \DeclareUppercaseMapping[\@nameuse{bbl@casing@#1}]{#2}{#3}} \newcommand\BabelTitlecaseMapping[3]{% @@ -11444,10 +11621,15 @@ wouldn’t exist. \newcommand\BabelLowercaseMapping[3]{% \DeclareLowercaseMapping[\@nameuse{bbl@casing@#1}]{#2}{#3}} % \end{macrocode} -% +% % The parser for |casing| and |casing.|\meta{variant}. -% +% % \begin{macrocode} +\ifcase\bbl@engine % Converts utf8 to its code (expandable) + \def\bbl@utftocode#1{\the\numexpr\decode@UTFviii#1\relax} +\else + \def\bbl@utftocode#1{\expandafter`\string#1} +\fi \def\bbl@casemapping#1#2#3{% 1:variant \def\bbl@tempa##1 ##2{% Loop \bbl@casemapping@i{##1}% @@ -11466,7 +11648,7 @@ wouldn’t exist. \fi \expandafter\bbl@casemapping@ii\bbl@tempb\@@} \def\bbl@casemapping@ii#1#2#3\@@{% - \in@{#1#3}{<>}% ie, if <u>, <l>, <t> + \in@{#1#3}{<>}% i.e., if <u>, <l>, <t> \ifin@ \edef\bbl@tempe{% \if#2u1 \else\if#2l2 \else\if#2t3 \fi\fi\fi}% @@ -11484,9 +11666,45 @@ wouldn’t exist. \fi} % \end{macrocode} % +% \subsection{Getting info} +% +% The information in the identification section can be useful, so the +% following macro just exposes it with a user command. +% +% \begin{macrocode} +\def\bbl@localeinfo#1#2{% + \bbl@ifunset{bbl@info@#2}{#1}% + {\bbl@ifunset{bbl@\csname bbl@info@#2\endcsname @\languagename}{#1}% + {\bbl@cs{\csname bbl@info@#2\endcsname @\languagename}}}} +\newcommand\localeinfo[1]{% + \ifx*#1\@empty % TODO. A bit hackish to make it expandable. + \bbl@afterelse\bbl@localeinfo{}% + \else + \bbl@localeinfo + {\bbl@error{no-ini-info}{}{}{}}% + {#1}% + \fi} +% \@namedef{bbl@info@name.locale}{lcname} +\@namedef{bbl@info@tag.ini}{lini} +\@namedef{bbl@info@name.english}{elname} +\@namedef{bbl@info@name.opentype}{lname} +\@namedef{bbl@info@tag.bcp47}{tbcp} +\@namedef{bbl@info@language.tag.bcp47}{lbcp} +\@namedef{bbl@info@tag.opentype}{lotf} +\@namedef{bbl@info@script.name}{esname} +\@namedef{bbl@info@script.name.opentype}{sname} +\@namedef{bbl@info@script.tag.bcp47}{sbcp} +\@namedef{bbl@info@script.tag.opentype}{sotf} +\@namedef{bbl@info@region.tag.bcp47}{rbcp} +\@namedef{bbl@info@variant.tag.bcp47}{vbcp} +\@namedef{bbl@info@extension.t.tag.bcp47}{extt} +\@namedef{bbl@info@extension.u.tag.bcp47}{extu} +\@namedef{bbl@info@extension.x.tag.bcp47}{extx} +% \end{macrocode} +% % With version 3.75 |\BabelEnsureInfo| is executed always, but there is % an option to disable it. -% +% % \begin{macrocode} %<<*More package options>> \DeclareOption{ensureinfo=off}{} @@ -11511,7 +11729,7 @@ wouldn’t exist. % |\bbl@ini@loaded| is a comma-separated list of locales, built by % |\bbl@read@ini|. % -% \begin{macrocode} +% \begin{macrocode} \newcommand\getlocaleproperty{% \@ifstar\bbl@getproperty@s\bbl@getproperty@x} \def\bbl@getproperty@s#1#2#3{% @@ -11537,6 +11755,69 @@ wouldn’t exist. \typeout{*******}} % \end{macrocode} % +% \subsection{BCP 47 related commands} +% +% \begin{macrocode} +\newif\ifbbl@bcpallowed +\bbl@bcpallowedfalse +\def\bbl@autoload@options{import} +\def\bbl@provide@locale{% + \ifx\babelprovide\@undefined + \bbl@error{base-on-the-fly}{}{}{}% + \fi + \let\bbl@auxname\languagename % Still necessary. + \bbl@ifunset{bbl@bcp@map@\languagename}{}% Move uplevel?? + {\edef\languagename{\@nameuse{bbl@bcp@map@\languagename}}}% + \ifbbl@bcpallowed + \expandafter\ifx\csname date\languagename\endcsname\relax + \expandafter + \bbl@bcplookup\languagename-\@empty-\@empty-\@empty\@@ + \ifx\bbl@bcp\relax\else % Returned by \bbl@bcplookup + \edef\languagename{\bbl@bcp@prefix\bbl@bcp}% + \edef\localename{\bbl@bcp@prefix\bbl@bcp}% + \expandafter\ifx\csname date\languagename\endcsname\relax + \let\bbl@initoload\bbl@bcp + \bbl@exp{\\\babelprovide[\bbl@autoload@bcpoptions]{\languagename}}% + \let\bbl@initoload\relax + \fi + \bbl@csarg\xdef{bcp@map@\bbl@bcp}{\localename}% + \fi + \fi + \fi + \expandafter\ifx\csname date\languagename\endcsname\relax + \IfFileExists{babel-\languagename.tex}% + {\bbl@exp{\\\babelprovide[\bbl@autoload@options]{\languagename}}}% + {}% + \fi} +% \end{macrocode} +% +% \LaTeX{} needs to know the BCP 47 codes for some features. For that, +% it expects |\BCPdata| to be defined. While |language|, |region|, +% |script|, and |variant| are recognized, |extension.<s>| for +% singletons may change. +% +% Still somewhat hackish. WIP. Note |\str_if_eq:nnTF| is fully +% expandable (|\bbl@ifsamestring| isn’t). The argument is the prefix to +% tag.bcp47. +% +% \begin{macrocode} +\providecommand\BCPdata{} +\ifx\renewcommand\@undefined\else % For plain. TODO. It’s a quick fix + \renewcommand\BCPdata[1]{\bbl@bcpdata@i#1\@empty\@empty\@empty} + \def\bbl@bcpdata@i#1#2#3#4#5#6\@empty{% + \@nameuse{str_if_eq:nnTF}{#1#2#3#4#5}{main.}% + {\bbl@bcpdata@ii{#6}\bbl@main@language}% + {\bbl@bcpdata@ii{#1#2#3#4#5#6}\languagename}}% + \def\bbl@bcpdata@ii#1#2{% + \bbl@ifunset{bbl@info@#1.tag.bcp47}% + {\bbl@error{unknown-ini-field}{#1}{}{}}% + {\bbl@ifunset{bbl@\csname bbl@info@#1.tag.bcp47\endcsname @#2}{}% + {\bbl@cs{\csname bbl@info@#1.tag.bcp47\endcsname @#2}}}} +\fi +\@namedef{bbl@info@casing.tag.bcp47}{casing} +\@namedef{bbl@info@tag.tag.bcp47}{tbcp} % For \BCPdata +% \end{macrocode} +% % \section{Adjusting the Babel behavior} % % A generic high level interface is provided to adjust some global @@ -11545,7 +11826,7 @@ wouldn’t exist. % \begin{macrocode} \newcommand\babeladjust[1]{% TODO. Error handling. \bbl@forkv{#1}{% - \bbl@ifunset{bbl@ADJ@##1@##2}% + \bbl@ifunset{bbl@ADJ@##1@##2}% {\bbl@cs{ADJ@##1}{##2}}% {\bbl@cs{ADJ@##1@##2}}}} % @@ -11555,7 +11836,7 @@ wouldn’t exist. \directlua{ Babel.#2 }% \expandafter\expandafter\expandafter\@gobble \fi - \fi + \fi {\bbl@error{adjust-only-vertical}{#1}{}{}}}% Gobbled if everything went ok. \@namedef{bbl@ADJ@bidi.mirroring@on}{% \bbl@adjust@lua{bidi}{mirroring_enabled=true}} @@ -11569,6 +11850,7 @@ wouldn’t exist. \let\bbl@noamsmath\@empty} \@namedef{bbl@ADJ@bidi.math@off}{% \let\bbl@noamsmath\relax} +% \@namedef{bbl@ADJ@bidi.mapdigits@on}{% \bbl@adjust@lua{bidi}{digits_mapped=true}} \@namedef{bbl@ADJ@bidi.mapdigits@off}{% @@ -11619,7 +11901,7 @@ wouldn’t exist. \def\bbl@bcp@prefix{bcp47-} \@namedef{bbl@ADJ@autoload.options}#1{% \def\bbl@autoload@options{#1}} -\let\bbl@autoload@bcpoptions\@empty +\def\bbl@autoload@bcpoptions{import} \@namedef{bbl@ADJ@autoload.bcp47.options}#1{% \def\bbl@autoload@bcpoptions{#1}} \newif\ifbbl@bcptoname @@ -11701,7 +11983,7 @@ wouldn’t exist. %<</More package options>> % \end{macrocode} % -% \begin{macro}{\@newl@bel} +% \macro{\@newl@bel} % % First we open a new group to keep the changed setting of % |\protect| local and then we set the |@safe@actives| switch to @@ -11710,7 +11992,7 @@ wouldn’t exist. % % \begin{macrocode} \bbl@trace{Cross referencing macros} -\ifx\bbl@opt@safe\@empty\else % ie, if 'ref' and/or 'bib' +\ifx\bbl@opt@safe\@empty\else % i.e., if 'ref' and/or 'bib' \def\@newl@bel#1#2#3{% {\@safe@activestrue \bbl@ifunset{#1@#2}% @@ -11721,12 +12003,10 @@ wouldn’t exist. \global\@namedef{#1@#2}{#3}}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\@testdef} +% \macro{\@testdef} % % An internal \LaTeX\ macro used to test if the labels that have -% been written on the |.aux| file have changed. It is called by +% been written on the |aux| file have changed. It is called by % the |\enddocument| macro. % % \begin{macrocode} @@ -11764,10 +12044,8 @@ wouldn’t exist. \fi % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\ref} -% \begin{macro}{\pageref} +% \macro{\ref} +% \macro{\pageref} % % The same holds for the macro |\ref| that references a label and % |\pageref| to reference a page. We make them robust as well (if @@ -11801,10 +12079,7 @@ wouldn’t exist. \fi % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\@citex} +% \macro{\@citex} % % The macro used to cite from a bibliography, |\cite|, uses an % internal macro, |\@citex|. @@ -11828,11 +12103,6 @@ wouldn’t exist. % when |\begin{document}| is executed, so we need to postpone the % different redefinition. % -% \begin{macrocode} - \AtBeginDocument{% - \@ifpackageloaded{natbib}{% -% \end{macrocode} -% % Notice that we use |\def| here instead of |\bbl@redefine| because % |\org@@citex| is already defined and we don't want to overwrite % that definition (it would result in parameter stack overflow @@ -11842,6 +12112,8 @@ wouldn’t exist. % doesn't seem fixable in a simple way. Just load \pkg{natbib} before.) % % \begin{macrocode} + \AtBeginDocument{% + \@ifpackageloaded{natbib}{% \def\@citex[#1][#2]#3{% \@safe@activestrue\edef\bbl@tempa{#3}\@safe@activesfalse \org@@citex[#1][#2]{\bbl@tempa}}% @@ -11859,9 +12131,7 @@ wouldn’t exist. }{}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\nocite} +% \macro{\nocite} % % The macro |\nocite| which is used to instruct BiB\TeX\ to % extract uncited references from the database. @@ -11871,18 +12141,16 @@ wouldn’t exist. \@safe@activestrue\org@nocite{#1}\@safe@activesfalse} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bibcite} +% \macro{\bibcite} % -% The macro that is used in the |.aux| file to +% The macro that is used in the |aux| file to % define citation labels. When packages such as \pkg{natbib} or % \pkg{cite} are not loaded its second argument is used to typeset the % citation label. In that case, this second argument can contain % active characters but is used in an environment where % |\@safe@activestrue| is in effect. This switch needs to be reset % inside the |\hbox| which contains the citation label. In order to -% determine during \file{.aux} file processing which definition of +% determine during \file{aux} file processing which definition of % |\bibcite| is needed we define |\bibcite| in such a way that it % redefines itself with the proper definition. We call % |\bbl@cite@choice| to select the proper definition for |\bibcite|. @@ -11894,9 +12162,7 @@ wouldn’t exist. \bibcite} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@bibcite} +% \macro{\bbl@bibcite} % % The macro |\bbl@bibcite| holds the definition of |\bibcite| % needed when neither \pkg{natbib} nor \pkg{cite} is loaded. @@ -11906,9 +12172,7 @@ wouldn’t exist. \org@bibcite{#1}{\@safe@activesfalse#2}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\bbl@cite@choice} +% \macro{\bbl@cite@choice} % % The macro |\bbl@cite@choice| determines which definition of % |\bibcite| is needed. First we give |\bibcite| its default @@ -11922,7 +12186,7 @@ wouldn’t exist. \global\let\bbl@cite@choice\relax} % \end{macrocode} % -% When a document is run for the first time, no \file{.aux} file is +% When a document is run for the first time, no \file{aux} file is % available, and |\bibcite| will not yet be properly defined. In % this case, this has to happen before the document starts. % @@ -11930,12 +12194,10 @@ wouldn’t exist. \AtBeginDocument{\bbl@cite@choice} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\@bibitem} +% \macro{\@bibitem} % % One of the two internal \LaTeX\ macros called by |\bibitem| -% that write the citation label on the |.aux| file. +% that write the citation label on the |aux| file. % % \begin{macrocode} \bbl@redefine\@bibitem#1{% @@ -11948,11 +12210,47 @@ wouldn’t exist. \fi % \end{macrocode} % -% \end{macro} +% \subsection{Layout} +% +% \begin{macrocode} +\newcommand\BabelPatchSection[1]{% + \@ifundefined{#1}{}{% + \bbl@exp{\let\<bbl@ss@#1>\<#1>}% + \@namedef{#1}{% + \@ifstar{\bbl@presec@s{#1}}% + {\@dblarg{\bbl@presec@x{#1}}}}}} +\def\bbl@presec@x#1[#2]#3{% + \bbl@exp{% + \\\select@language@x{\bbl@main@language}% + \\\bbl@cs{sspre@#1}% + \\\bbl@cs{ss@#1}% + [\\\foreignlanguage{\languagename}{\unexpanded{#2}}]% + {\\\foreignlanguage{\languagename}{\unexpanded{#3}}}% + \\\select@language@x{\languagename}}} +\def\bbl@presec@s#1#2{% + \bbl@exp{% + \\\select@language@x{\bbl@main@language}% + \\\bbl@cs{sspre@#1}% + \\\bbl@cs{ss@#1}*% + {\\\foreignlanguage{\languagename}{\unexpanded{#2}}}% + \\\select@language@x{\languagename}}} +\IfBabelLayout{sectioning}% + {\BabelPatchSection{part}% + \BabelPatchSection{chapter}% + \BabelPatchSection{section}% + \BabelPatchSection{subsection}% + \BabelPatchSection{subsubsection}% + \BabelPatchSection{paragraph}% + \BabelPatchSection{subparagraph}% + \def\babel@toc#1{% + \select@language@x{\bbl@main@language}}}{} +\IfBabelLayout{captions}% + {\BabelPatchSection{caption}}{} +% \end{macrocode} % % \subsection{Marks} % -% \begin{macro}{\markright} +% \macro{\markright} % Because the output routine is asynchronous, we must pass the % current language attribute to the head lines. To achieve this we % need to adapt the definition of |\markright| and |\markboth| @@ -11988,19 +12286,17 @@ wouldn’t exist. {\\\protect\\\bbl@restore@actives\the\toks@}}}}}% % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\markboth} -% \begin{macro}{\@mkboth} -% The definition of |\markboth| is equivalent to that of -% |\markright|, except that we need two token registers. The -% documentclasses \cls{report} and \cls{book} define and set the -% headings for the page. While doing so they also store a copy of -% |\markboth| in |\@mkboth|. Therefore we need to check whether -% |\@mkboth| has already been set. If so we need to do that again -% with the new definition of |\markboth|. (As of Oct 2019, \LaTeX{} -% stores the definition in an intermediate macro, so it's not -% necessary anymore, but it's preserved for older versions.) +% \macro{\markboth} +% \macro{\@mkboth} +% The definition of |\markboth| is equivalent to that of |\markright|, +% except that we need two token registers. The documentclasses +% \cls{report} and \cls{book} define and set the headings for the page. +% While doing so they also store a copy of |\markboth| in |\@mkboth|. +% Therefore we need to check whether |\@mkboth| has already been set. +% If so we need to do that again with the new definition of +% |\markboth|. (As of Oct 2019, \LaTeX{} stores the definition in an +% intermediate macro, so it's not necessary anymore, but it's preserved +% for older versions.) % % \begin{macrocode} \ifx\@mkboth\markboth @@ -12024,22 +12320,19 @@ wouldn’t exist. \fi} % end ifbbl@single, end \IfBabelLayout % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \subsection{Preventing clashes with other packages} +% \subsection{Other packages} % % \subsubsection{\pkg{ifthen}} % -% \begin{macro}{\ifthenelse} +% \macro{\ifthenelse} % % Sometimes a document writer wants to create a special effect % depending on the page a certain fragment of text appears on. This % can be achieved by the following piece of code: %\begin{verbatim} -% \ifthenelse{\isodd{\pageref{some:label}}} -% {code for odd pages} -% {code for even pages} +% \ifthenelse{\isodd{\pageref{some-label}}} +% {code for odd pages} +% {code for even pages} %\end{verbatim} % In order for this to work the argument of |\isodd| needs to be % fully expandable. With the above redefinition of |\pageref| it is @@ -12084,15 +12377,13 @@ wouldn’t exist. \fi % \end{macrocode} % -% \end{macro} -% % \subsubsection{\pkg{varioref}} % -% \begin{macro}{\@@vpageref} -% \begin{macro}{\vrefpagenum} -% \begin{macro}{\Ref} +% \macro{\@@vpageref} +% \macro{\vrefpagenum} +% \macro{\Ref} % -% When the package varioref is in use we need to modify its +% When the package \pkg{varioref} is in use we need to modify its % internal command |\@@vpageref| in order to prevent problems when % an active character ends up in the argument of |\vref|. The same % needs to happen for |\vrefpagenum|. @@ -12127,13 +12418,9 @@ wouldn’t exist. \fi % \end{macrocode} % -% \end{macro} -% \end{macro} -% \end{macro} -% % \subsubsection{\pkg{hhline}} % -% \begin{macro}{\hhline} +% \macro{\hhline} % % Delaying the activation of the shorthand characters has introduced % a problem with the \pkg{hhline} package. The reason is that it @@ -12155,14 +12442,12 @@ wouldn’t exist. {}}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\substitutefontfamily} +% \macro{\substitutefontfamily} % -% \textit{Deprecated.} Use the tools provides by \LaTeX. The command -% |\substitutefontfamily| creates an \file{.fd} file on the fly. The +% \textit{Deprecated.} It creates an \file{fd} file on the fly. The % first argument is an encoding mnemonic, the second and third -% arguments are font family names. +% arguments are font family names. Use the tools provided by \LaTeX\ +% (|\DeclareFontFamilySubstitution|). % % \begin{macrocode} \def\substitutefontfamily#1#2#3{% @@ -12186,20 +12471,18 @@ wouldn’t exist. \@onlypreamble\substitutefontfamily % \end{macrocode} % -% \end{macro} -% % \subsection{Encoding and fonts} % -% Because documents may use non-ASCII font encodings, we make sure -% that the logos of \TeX\ and \LaTeX\ always come out in the right -% encoding. There is a list of non-ASCII encodings. Requested -% encodings are currently stored in |\@fontenc@load@list|. If a -% non-ASCII has been loaded, we define versions of |\TeX| and |\LaTeX| -% for them using |\ensureascii|. The default ASCII encoding is set, -% too (in reverse order): the ``main'' encoding (when the document -% begins), the last loaded, or |OT1|. +% Because documents may use non-ASCII font encodings, we make sure +% that the logos of \TeX\ and \LaTeX\ always come out in the right +% encoding. There is a list of non-ASCII encodings. Requested +% encodings are currently stored in |\@fontenc@load@list|. If a +% non-ASCII has been loaded, we define versions of |\TeX| and |\LaTeX| +% for them using |\ensureascii|. The default ASCII encoding is set, +% too (in reverse order): the ``main'' encoding (when the document +% begins), the last loaded, or |OT1|. % -% \begin{macro}{\ensureascii} +% \macro{\ensureascii} % % \begin{macrocode} \bbl@trace{Encoding and fonts} @@ -12239,30 +12522,27 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% Now comes the old deprecated stuff (with a little change in 3.9l, -% for \textsf{fontspec}). The first thing we need to do is to -% determine, at |\begin{document}|, which latin fontencoding to use. +% Now comes the old deprecated stuff (with a little change in 3.9l, for +% \textsf{fontspec}). The first thing we need to do is to determine, at +% |\begin{document}|, which latin fontencoding to use. % -% \begin{macro}{\latinencoding} -% When text is being typeset in an encoding other than `latin' -% (\texttt{OT1} or \texttt{T1}), it would be nice to still have -% Roman numerals come out in the Latin encoding. -% So we first assume that the current encoding at the end -% of processing the package is the Latin encoding. +% \macro{\latinencoding} +% When text is being typeset in an encoding other than `latin' +% (\texttt{OT1} or \texttt{T1}), it would be nice to still have Roman +% numerals come out in the Latin encoding. So we first assume that the +% current encoding at the end of processing the package is the Latin +% encoding. % % \begin{macrocode} \AtEndOfPackage{\edef\latinencoding{\cf@encoding}} % \end{macrocode} % -% But this might be overruled with a later loading of the package -% \pkg{fontenc}. Therefore we check at the execution of -% |\begin{document}| whether it was loaded with the \Lopt{T1} -% option. The normal way to do this (using |\@ifpackageloaded|) is -% disabled for this package. Now we have to revert to parsing the -% internal macro |\@filelist| which contains all the filenames -% loaded. +% But this might be overruled with a later loading of the package +% \pkg{fontenc}. Therefore we check at the execution of +% |\begin{document}| whether it was loaded with the \Lopt{T1} option. +% The normal way to do this (using |\@ifpackageloaded|) is disabled for +% this package. Now we have to revert to parsing the internal macro +% |\@filelist| which contains all the filenames loaded. % % \begin{macrocode} \AtBeginDocument{% @@ -12287,12 +12567,9 @@ wouldn’t exist. \fi}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\latintext} -% Then we can define the command |\latintext| which is a -% declarative switch to a latin font-encoding. Usage of this macro -% is deprecated. +% \macro{\latintext} +% Then we can define the command |\latintext| which is a declarative +% switch to a latin font-encoding. Usage of this macro is deprecated. % % \begin{macrocode} \DeclareRobustCommand{\latintext}{% @@ -12300,12 +12577,10 @@ wouldn’t exist. \def\encodingdefault{\latinencoding}} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\textlatin} -% This command takes an argument which is then typeset using the -% requested font encoding. In order to avoid many encoding switches -% it operates in a local scope. +% \macro{\textlatin} +% This command takes an argument which is then typeset using the +% requested font encoding. In order to avoid many encoding switches it +% operates in a local scope. % % \begin{macrocode} \ifx\@undefined\DeclareTextFontCommand @@ -12323,11 +12598,9 @@ wouldn’t exist. \def\bbl@patchfont#1{\AddToHook{selectfont}{#1}} % \end{macrocode} % -% \end{macro} -% % \subsection{Basic bidi support} % -% \textbf{Work in progress.} This code is currently placed here for +% This code is currently placed here for % practical reasons. It will be moved to the correct place soon, I % hope. % @@ -12363,8 +12636,8 @@ wouldn’t exist. % \begin{macrocode} \bbl@trace{Loading basic (internal) bidi support} \ifodd\bbl@engine -\else % TODO. Move to txtbabel - \ifnum\bbl@bidimode>100 \ifnum\bbl@bidimode<200 % Any xe+lua bidi= +\else % TODO. Move to txtbabel. Any xe+lua bidi + \ifnum\bbl@bidimode>100 \ifnum\bbl@bidimode<200 \bbl@error{bidi-only-lua}{}{}{}% \let\bbl@beforeforeign\leavevmode \AtEndOfPackage{% @@ -12375,7 +12648,9 @@ wouldn’t exist. \ifx\RTLfootnotetext\@undefined \AtEndOfPackage{% \EnableBabelHook{babel-bidi}% - \bbl@loadfontspec % bidi needs fontspec + \ifx\fontspec\@undefined + \usepackage{fontspec}% bidi needs fontspec + \fi \usepackage#1{bidi}% \let\bbl@digitsdotdash\DigitsDotDashInterCharToks \def\DigitsDotDashInterCharToks{% See the 'bidi' package @@ -12411,18 +12686,23 @@ wouldn’t exist. % \end{macrocode} % % Now come the macros used to set the direction when a language is -% switched. First the (mostly) common macros. +% switched. Testing are based on script names, because it’s the user +% interface (including |language| and |script| in |\babelprovide|. +% First the (mostly) common macros. % % \begin{macrocode} \bbl@trace{Macros to switch the text direction} -\def\bbl@alscripts{,Arabic,Syriac,Thaana,} -\def\bbl@rscripts{% TODO. Base on codes ?? - ,Imperial Aramaic,Avestan,Cypriot,Hatran,Hebrew,% - Old Hungarian,Lydian,Mandaean,Manichaean,% - Meroitic Cursive,Meroitic,Old North Arabian,% - Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,% - Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,% - Old South Arabian,}% +\def\bbl@alscripts{% + ,Arabic,Syriac,Thaana,Hanifi Rohingya,Hanifi,Sogdian,} +\def\bbl@rscripts{% + Adlam,Avestan,Chorasmian,Cypriot,Elymaic,Garay,% + Hatran,Hebrew,Imperial Aramaic,Inscriptional Pahlavi,% + Inscriptional Parthian,Kharoshthi,Lydian,Mandaic,Manichaean,% + Mende Kikakui,Meroitic Cursive,Meroitic Hieroglyphs,Nabataean,% + Nko,Old Hungarian,Old North Arabian,Old Sogdian,% + Old South Arabian,Old Turkic,Old Uyghur,Palmyrene,Phoenician,% + Psalter Pahlavi,Samaritan,Yezidi,Mandaean,% + Meroitic,N'Ko,Orkhon,Todhri} \def\bbl@provide@dirs#1{% \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts\bbl@rscripts}% \ifin@ @@ -12453,9 +12733,10 @@ wouldn’t exist. \bbl@pardir{#1}% <- Must precede \bbl@textdir \fi \bbl@textdir{#1}} -% TODO. Only if \bbl@bidimode > 0?: -\AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir} -\DisableBabelHook{babel-bidi} +\ifnum\bbl@bidimode>\z@ + \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir} + \DisableBabelHook{babel-bidi} +\fi % \end{macrocode} % % Now the engine-dependent macros. TODO. Must be moved to the engine @@ -12525,19 +12806,15 @@ wouldn’t exist. \else {\setbox\z@\lastbox\beginR\box\z@}% \fi}% - \let\bbl@severypar\everypar - \newtoks\everypar - \everypar=\bbl@severypar - \bbl@severypar{\bbl@xeeverypar\the\everypar}} + \AddToHook{para/begin}{\bbl@xeeverypar}} \ifnum\bbl@bidimode>200 % Any xe bidi= \let\bbl@textdir@i\@gobbletwo \let\bbl@xebidipar\@empty \AddBabelHook{bidi}{foreign}{% - \def\bbl@tempa{\def\BabelText####1}% \ifcase\bbl@thetextdir - \expandafter\bbl@tempa\expandafter{\BabelText{\LR{##1}}}% + \BabelWrapText{\LR{##1}}% \else - \expandafter\bbl@tempa\expandafter{\BabelText{\RL{##1}}}% + \BabelWrapText{\RL{##1}}% \fi} \def\bbl@pardir#1{\ifcase#1\relax\setLR\else\setRL\fi} \fi @@ -12559,7 +12836,7 @@ wouldn’t exist. % % \subsection{Local Language Configuration} % -% \begin{macro}{\loadlocalcfg} +% \macro{\loadlocalcfg} % % At some sites it may be necessary to add site-specific actions to % a language definition file. This can be done by creating a file @@ -12584,8 +12861,6 @@ wouldn’t exist. \@empty}} \fi % \end{macrocode}% -% \end{macro} -% % \subsection{Language options} % % Languages are loaded when processing the corresponding option @@ -12629,6 +12904,7 @@ wouldn’t exist. {\bbl@load@language{\CurrentOption}}% {#1\bbl@load@language{#2}#3}} % +\DeclareOption{friulian}{\bbl@try@load@lang{}{friulan}{}} \DeclareOption{hebrew}{% \ifcase\bbl@engine\or \bbl@error{only-pdftex-lang}{hebrew}{luatex}{}% @@ -12637,6 +12913,7 @@ wouldn’t exist. \bbl@load@language{hebrew}} \DeclareOption{hungarian}{\bbl@try@load@lang{}{magyar}{}} \DeclareOption{lowersorbian}{\bbl@try@load@lang{}{lsorbian}{}} +% \DeclareOption{northernkurdish}{\bbl@try@load@lang{}{kurmanji}{}} \DeclareOption{polutonikogreek}{% \bbl@try@load@lang{}{greek}{\languageattribute{greek}{polutoniko}}} \DeclareOption{russian}{\bbl@try@load@lang{}{russianb}{}} @@ -12647,7 +12924,7 @@ wouldn’t exist. % Another way to extend the list of `known' options for \babel\ was % to create the file \file{bblopts.cfg} in which one can add option % declarations. However, this mechanism is deprecated -- if you -% want an alternative name for a language, just create a new |.ldf| +% want an alternative name for a language, just create a new |ldf| % file loading the actual one. You can also set the name % of the file with the package option |config=<name>|, which will % load |<name>.cfg| instead. @@ -12676,19 +12953,29 @@ wouldn’t exist. % above, the names of the option and the file are the same. We first % pre-process the class and package options to determine the main % language, which is processed in the third ‘main’ pass, -% \textit{except} if all files are ldf \textit{and} there is no |main| -% key. In the latter case (|\bbl@opt@main| is still |\@nnil|), the -% traditional way to set the main language is kept — the last loaded is -% the main language. +% \textit{except} if all files are \texttt{ldf} \textit{and} there is +% no |main| key. In the latter case (|\bbl@opt@main| is still +% |\@nnil|), the traditional way to set the main language is kept — the +% last loaded is the main language. +% +% For efficiency, first preprocess the class options to remove those +% with |=|, which are becoming increasingly frequent (no language +% should contain this character). % % \begin{macrocode} +\def\bbl@tempf{,} +\bbl@foreach\@raw@classoptionslist{% + \in@{=}{#1}% + \ifin@\else + \edef\bbl@tempf{\bbl@tempf\zap@space#1 \@empty,}% + \fi} \ifx\bbl@opt@main\@nnil \ifnum\bbl@iniflag>\z@ % if all ldf's: set implicitly, no main pass \let\bbl@tempb\@empty - \edef\bbl@tempa{\@classoptionslist,\bbl@language@opts}% + \edef\bbl@tempa{\bbl@tempf,\bbl@language@opts}% \bbl@foreach\bbl@tempa{\edef\bbl@tempb{#1,\bbl@tempb}}% \bbl@foreach\bbl@tempb{% \bbl@tempb is a reversed list - \ifx\bbl@opt@main\@nnil % ie, if not yet assigned + \ifx\bbl@opt@main\@nnil % i.e., if not yet assigned \ifodd\bbl@iniflag % = *= \IfFileExists{babel-#1.tex}{\def\bbl@opt@main{#1}}{}% \else % n += @@ -12699,7 +12986,7 @@ wouldn’t exist. \else \bbl@info{Main language set with 'main='. Except if you have\\% problems, prefer the default mechanism for setting\\% - the main language, ie, as the last declared.\\% + the main language, i.e., as the last declared.\\% Reported} \fi % \end{macrocode} @@ -12717,7 +13004,7 @@ wouldn’t exist. % Now define the corresponding loaders. With package options, assume % the language exists. With class options, check if the option is a % language by checking if the corresponding file exists. -% +% % \begin{macrocode} \bbl@foreach\bbl@language@opts{% \def\bbl@tempa{#1}% @@ -12729,11 +13016,11 @@ wouldn’t exist. \else % + * (other = ini) \DeclareOption{#1}{% \bbl@ldfinit - \babelprovide[import]{#1}% + \babelprovide[@import]{#1}% %%%%% \bbl@afterldf{}}% \fi \fi} -\bbl@foreach\@classoptionslist{% +\bbl@foreach\bbl@tempf{% \def\bbl@tempa{#1}% \ifx\bbl@tempa\bbl@opt@main\else \ifnum\bbl@iniflag<\tw@ % 0 ø (other = ldf) @@ -12743,24 +13030,27 @@ wouldn’t exist. {}}% {}% \else % + * (other = ini) - \IfFileExists{babel-#1.tex}% - {\DeclareOption{#1}{% + \IfFileExists{babel-#1.tex}% + {\DeclareOption{#1}{% \bbl@ldfinit - \babelprovide[import]{#1}% + \babelprovide[@import]{#1}% %%%%%% \bbl@afterldf{}}}% {}% \fi \fi} % \end{macrocode} % -% And we are done, because all options for this pass has been -% declared. Those already processed in the first pass are just -% ignored. +% And we are done, because all options for this pass has been declared. +% Those already processed in the first pass are just ignored. There is +% still room for last minute changes with a \LaTeX{} hook (not a +% \Babel{} one). % % The options have to be processed in the order in which the user % specified them (but remember class options are processes before): % % \begin{macrocode} +\NewHook{babel/presets} +\UseHook{babel/presets} \def\AfterBabelLanguage#1{% \bbl@ifsamestring\CurrentOption{#1}{\global\bbl@add\bbl@afterlang}{}} \DeclareOption*{} @@ -12780,7 +13070,7 @@ wouldn’t exist. % \begin{macrocode} \bbl@trace{Option 'main'} \ifx\bbl@opt@main\@nnil - \edef\bbl@tempa{\@classoptionslist,\bbl@language@opts} + \edef\bbl@tempa{\bbl@tempf,\bbl@language@opts} \let\bbl@tempc\@empty \edef\bbl@templ{,\bbl@loaded,} \edef\bbl@templ{\expandafter\strip@prefix\meaning\bbl@templ} @@ -12804,7 +13094,9 @@ wouldn’t exist. \bbl@ldfinit \let\CurrentOption\bbl@opt@main \bbl@exp{% \bbl@opt@provide = empty if * - \\\babelprovide[\bbl@opt@provide,import,main]{\bbl@opt@main}}% + \\\babelprovide + [\bbl@opt@provide,@import,main]% %%%%% + {\bbl@opt@main}}% \bbl@afterldf{} \DeclareOption{\bbl@opt@main}{} \else % case 0,2 (main is ldf) @@ -12819,11 +13111,11 @@ wouldn’t exist. \DeclareOption*{} \ProcessOptions* \fi -\bbl@exp{% +\bbl@exp{% \\\AtBeginDocument{\\\bbl@usehooks@lang{/}{begindocument}{{}}}}% \def\AfterBabelLanguage{\bbl@error{late-after-babel}{}{}{}} % \end{macrocode} -% +% % In order to catch the case where the user didn’t specify a % language we check whether |\bbl@main@language|, has become % defined. If not, the |nil| language is loaded. @@ -12838,7 +13130,7 @@ wouldn’t exist. %</package> % \end{macrocode} % -% \section{The kernel of Babel (\texttt{babel.def}, common)} +% \section{The kernel of Babel} % % The kernel of the \babel\ system is currently stored in % \file{babel.def}. The file \file{babel.def} contains most of the @@ -12854,7 +13146,7 @@ wouldn’t exist. % % Plain formats based on etex (etex, xetex, luatex) don't load % |hyphen.cfg| but |etex.src|, which follows a different naming -% convention, so we need to define the babel names. It presumes +% convention, so we need to define the \babel{} names. It presumes % |language.def| exists and it is the same file used when formats were % created. % @@ -12866,6 +13158,7 @@ wouldn’t exist. \input babel.def \let\bbl@onlyswitch\@undefined %</kernel> +% \end{macrocode} % % \section{Error messages} % @@ -12875,6 +13168,7 @@ wouldn’t exist. % catcodes have the right value, although those for |\|, |`|, |^^M|, % |%| and |=| are reset before loading the file. % +% \begin{macrocode} %<*errors> \catcode`\{=1 \catcode`\}=2 \catcode`\#=6 \catcode`\:=12 \catcode`\,=12 \catcode`\.=12 \catcode`\-=12 @@ -12946,19 +13240,19 @@ wouldn’t exist. {This macro is available only in LuaLaTeX and XeLaTeX.}% {Consider switching to these engines.} \bbl@errmessage{only-lua} - {This macro is available only in LuaLaTeX.}% + {This macro is available only in LuaLaTeX}% {Consider switching to that engine.} \bbl@errmessage{unknown-provide-key} {Unknown key '#1' in \string\babelprovide}% {See the manual for valid keys}% \bbl@errmessage{unknown-mapfont} {Option '\bbl@KVP@mapfont' unknown for\\% - mapfont. Use 'direction'.}% + mapfont. Use 'direction'}% {See the manual for details.} \bbl@errmessage{no-ini-file} {There is no ini file for the requested language\\% (#1: \languagename). Perhaps you misspelled it or your\\% - installation is not complete.}% + installation is not complete}% {Fix the name or reinstall babel.} \bbl@errmessage{digits-is-reserved} {The counter name 'digits' is reserved for mapping\\% @@ -12966,7 +13260,7 @@ wouldn’t exist. {Use another name.} \bbl@errmessage{limit-two-digits} {Currently two-digit years are restricted to the\\ - range 0-9999.}% + range 0-9999}% {There is little you can do. Sorry.} \bbl@errmessage{alphabetic-too-large} {Alphabetic numeral too large (#1)}% @@ -12978,20 +13272,20 @@ wouldn’t exist. {See the manual for details.} \bbl@errmessage{unknown-ini-field} {Unknown field '#1' in \string\BCPdata.\\% - Perhaps you misspelled it.}% + Perhaps you misspelled it}% {See the manual for details.} \bbl@errmessage{unknown-locale-key} {Unknown key for locale '#2':\\% #3\\% - \string#1 will be set to \relax}% + \string#1 will be set to \string\relax}% {Perhaps you misspelled it.}% \bbl@errmessage{adjust-only-vertical} {Currently, #1 related features can be adjusted only\\% - in the main vertical list.}% + in the main vertical list}% {Maybe things change in the future, but this is what it is.} \bbl@errmessage{layout-only-vertical} {Currently, layout related features can be adjusted only\\% - in vertical mode.}% + in vertical mode}% {Maybe things change in the future, but this is what it is.} \bbl@errmessage{bidi-only-lua} {The bidi method 'basic' is available only in\\% @@ -13021,11 +13315,11 @@ wouldn’t exist. {See the manual for further info} \bbl@errmessage{unknown-interchar} {'#1' for '\languagename' cannot be enabled.\\% - Maybe there is a typo.}% + Maybe there is a typo}% {See the manual for further details.} \bbl@errmessage{unknown-interchar-b} {'#1' for '\languagename' cannot be disabled.\\% - Maybe there is a typo.}% + Maybe there is a typo}% {See the manual for further details.} \bbl@errmessage{charproperty-only-vertical} {\string\babelcharproperty\space can be used only in\\% @@ -13060,16 +13354,16 @@ wouldn’t exist. {The '#1' ldf style doesn't work with #2,\\% but you can use the ini locale instead.\\% Try adding 'provide=*' to the option list. You may\\% - also want to set 'bidi=' to some value.}% + also want to set 'bidi=' to some value}% + {See the manual for further details.} +\bbl@errmessage{hyphenmins-args} + {\string\babelhyphenmins\ accepts either the optional\\% + argument or the star, but not both at the same time}% {See the manual for further details.} %</errors> %<*patterns> % \end{macrocode} % -% \end{macro} -% \end{macro} -% \end{macro} -% % \section{Loading hyphenation patterns} % % The following code is meant to be read by ini\TeX\ because it @@ -13090,13 +13384,12 @@ wouldn’t exist. <@Define core switching macros@> % \end{macrocode} % -% \begin{macro}{\process@line} -% Each line in the file \file{language.dat} is processed by -% |\process@line| after it is read. The first thing this macro does -% is to check whether the line starts with \texttt{=}. -% When the first token of a line is an \texttt{=}, the macro -% |\process@synonym| is called; otherwise the macro -% |\process@language| will continue. +% \macro{\process@line} +% Each line in the file \file{language.dat} is processed by +% |\process@line| after it is read. The first thing this macro does is +% to check whether the line starts with \texttt{=}. When the first +% token of a line is an \texttt{=}, the macro |\process@synonym| is +% called; otherwise the macro |\process@language| will continue. % % \begin{macrocode} \def\process@line#1#2 #3 #4 {% @@ -13108,9 +13401,7 @@ wouldn’t exist. \ignorespaces} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\process@synonym} +% \macro{\process@synonym} % % This macro takes care of the lines which start with an % \texttt{=}. It needs an empty token register to begin with. @@ -13145,9 +13436,7 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% \begin{macro}{\process@language} +% \macro{\process@language} % % The macro |\process@language| is used to process a non-empty line % from the `configuration file'. It has three arguments, each @@ -13236,9 +13525,9 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \begin{macro}{\bbl@get@enc} +% \macro{\bbl@get@enc} % -% \begin{macro}{\bbl@hyph@enc} +% \macro{\bbl@hyph@enc} % The macro |\bbl@get@enc| extracts the font encoding from the % language name and stores it in |\bbl@hyph@enc|. It uses delimited % arguments to achieve this. @@ -13247,10 +13536,6 @@ wouldn’t exist. \def\bbl@get@enc#1:#2:#3\@@@{\def\bbl@hyph@enc{#2}} % \end{macrocode} % -% \end{macro} -% \end{macro} -% \end{macro} -% % Now, hooks are defined. For efficiency reasons, they are dealt % here in a special way. Besides \luatex, format-specific % configuration files are taken into account. |loadkernel| currently @@ -13284,7 +13569,7 @@ wouldn’t exist. \righthyphenmin##2\relax}% \def\selectlanguage{% \errhelp{Selecting a language requires a package supporting it}% - \errmessage{Not loaded}}% + \errmessage{No multilingual package has been loaded}}% \let\foreignlanguage\selectlanguage \let\otherlanguage\selectlanguage \expandafter\let\csname otherlanguage*\endcsname\selectlanguage @@ -13324,15 +13609,15 @@ wouldn’t exist. \bbl@hook@loadkernel{switch.def} % \end{macrocode} % -% \begin{macro}{\readconfigfile} -% The configuration file can now be opened for reading. +% \macro{\readconfigfile} +% The configuration file can now be opened for reading. % % \begin{macrocode} \openin1 = language.dat % \end{macrocode} % -% See if the file exists, if not, use the default hyphenation file -% \file{hyphen.tex}. The user will be informed about this. +% See if the file exists, if not, use the default hyphenation file +% \file{hyphen.tex}. The user will be informed about this. % % \begin{macrocode} \def\languagename{english}% @@ -13367,11 +13652,11 @@ wouldn’t exist. \endlinechar`\^^M % \end{macrocode} % -% If the file has reached its end, exit from the loop here. If not, -% empty lines are skipped. Add 3 space characters to the end of -% |\bbl@line|. This is needed to be able to recognize the arguments -% of |\process@line| later on. The default language should be the -% very first one. +% If the file has reached its end, exit from the loop here. If not, +% empty lines are skipped. Add 3 space characters to the end of +% |\bbl@line|. This is needed to be able to recognize the arguments of +% |\process@line| later on. The default language should be the very +% first one. % % \begin{macrocode} \if T\ifeof1F\fi T\relax @@ -13398,7 +13683,7 @@ wouldn’t exist. \closein1 % \end{macrocode} % -% We add a message about the fact that babel is loaded in the +% We add a message about the fact that \babel{} is loaded in the % format and with which language patterns to the \cs{everyjob} % register. % @@ -13409,10 +13694,9 @@ wouldn’t exist. \fi % \end{macrocode} % -% Also remove some macros from memory and raise an error -% if |\toks@| is not empty. Finally load \file{switch.def}, but the -% latter is not required and the line inputting it may be commented -% out. +% Also remove some macros from memory and raise an error if |\toks@| is +% not empty. Finally load \file{switch.def}, but the latter is not +% required and the line inputting it may be commented out. % % \begin{macrocode} \let\bbl@line\@undefined @@ -13429,14 +13713,14 @@ wouldn’t exist. %</patterns> % \end{macrocode} % -% Here the code for ini\TeX\ ends. -% \end{macro} +% Here the code for ini\TeX\ ends. % -% \section{Font handling with fontspec} +% \section{\luatex{} + \xetex{}: common stuff} % % Add the bidi handler just before luaoftload, which is loaded by default % by LaTeX. Just in case, consider the possibility it has not been -% loaded. First, a couple of definitions related to bidi [misplaced]. +% loaded. First, a couple of definitions related to bidi (although +% |default| also applies to \pdftex). % % \begin{macrocode} %<<*More package options>> @@ -13450,45 +13734,27 @@ wouldn’t exist. %<</More package options>> % \end{macrocode} % +% \macro{\babelfont} +% % With explicit languages, we could define the font at once, but we % don't. Just wait and see if the language is actually activated. % |bbl@font| replaces hardcoded font names inside |\..family| by the % corresponding macro |\..default|. % -% At the time of this writing, \textsf{fontspec} shows a warning about -% there are languages not available, which some people think refers to -% \babel{}, even if there is nothing wrong. Here is hack to patch -% \textsf{fontspec} to avoid the misleading (and mostly unuseful) -% message. -% % \begin{macrocode} %<<*Font selection>> \bbl@trace{Font handling with fontspec} -\ifx\ExplSyntaxOn\@undefined\else - \def\bbl@fs@warn@nx#1#2{% \bbl@tempfs is the original macro - \in@{,#1,}{,no-script,language-not-exist,}% - \ifin@\else\bbl@tempfs@nx{#1}{#2}\fi} - \def\bbl@fs@warn@nxx#1#2#3{% - \in@{,#1,}{,no-script,language-not-exist,}% - \ifin@\else\bbl@tempfs@nxx{#1}{#2}{#3}\fi} - \def\bbl@loadfontspec{% - \let\bbl@loadfontspec\relax - \ifx\fontspec\@undefined - \usepackage{fontspec}% - \fi}% -\fi +\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont} +\AddBabelHook{babel-fontspec}{beforestart}{\bbl@ckeckstdfonts} +\DisableBabelHook{babel-fontspec} \@onlypreamble\babelfont \newcommand\babelfont[2][]{% 1=langs/scripts 2=fam - \bbl@foreach{#1}{% - \expandafter\ifx\csname date##1\endcsname\relax - \IfFileExists{babel-##1.tex}% - {\babelprovide{##1}}% - {}% - \fi}% + \ifx\fontspec\@undefined + \usepackage{fontspec}% + \fi + \EnableBabelHook{babel-fontspec}% \edef\bbl@tempa{#1}% \def\bbl@tempb{#2}% Used by \bbl@bblfont - \bbl@loadfontspec - \EnableBabelHook{babel-fontspec}% Just calls \bbl@switchfont \bbl@bblfont} \newcommand\bbl@bblfont[2][]{% 1=features 2=fontname, @font=rm|sf|tt \bbl@ifunset{\bbl@tempb family}% @@ -13502,7 +13768,7 @@ wouldn’t exist. \let\<bbl@\bbl@tempb dflt@\languagename>\<bbl@\bbl@tempb dflt@>% \\\bbl@font@set\<bbl@\bbl@tempb dflt@\languagename>% \<\bbl@tempb default>\<\bbl@tempb family>}}% - {\bbl@foreach\bbl@tempa{% ie bbl@rmdflt@lang / *scrt + {\bbl@foreach\bbl@tempa{% i.e., bbl@rmdflt@lang / *scrt \bbl@csarg\def{\bbl@tempb dflt@##1}{<>{#1}{#2}}}}}% % \end{macrocode} % @@ -13544,7 +13810,7 @@ wouldn’t exist. {}}% \gdef\bbl@switchfont{% \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% - \bbl@exp{% eg Arabic -> arabic + \bbl@exp{% e.g., Arabic -> arabic \lowercase{\edef\\\bbl@tempa{\bbl@cl{sname}}}}% \bbl@foreach\bbl@font@fams{% \bbl@ifunset{bbl@##1dflt@\languagename}% (1) language? @@ -13626,47 +13892,46 @@ wouldn’t exist. % inspecting if the variant declaration contains |>ssub*|). % % \begin{macrocode} -\def\bbl@font@set#1#2#3{% eg \bbl@rmdflt@lang \rmdefault \rmfamily +\def\bbl@font@set#1#2#3{% e.g., \bbl@rmdflt@lang \rmdefault \rmfamily \bbl@xin@{<>}{#1}% \ifin@ \bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1\\#3}% \fi \bbl@exp{% 'Unprotected' macros return prev values - \def\\#2{#1}% eg, \rmdefault{\bbl@rmdflt@lang} + \def\\#2{#1}% e.g., \rmdefault{\bbl@rmdflt@lang} \\\bbl@ifsamestring{#2}{\f@family}% {\\#3% \\\bbl@ifsamestring{\f@series}{\bfdefault}{\\\bfseries}{}% \let\\\bbl@tempa\relax}% {}}} -% TODO - next should be global?, but even local does its job. I'm -% still not sure -- must investigate: +% \end{macrocode} +% +% Loaded locally, which does its job, but very must be global. The +% problem is how. +% +% \begin{macrocode} \def\bbl@fontspec@set#1#2#3#4{% eg \bbl@rmdflt@lang fnt-opt fnt-nme \xxfamily \let\bbl@tempe\bbl@mapselect \edef\bbl@tempb{\bbl@stripslash#4/}% Catcodes hack (better pass it). \bbl@exp{\\\bbl@replace\\\bbl@tempb{\bbl@stripslash\family/}{}}% \let\bbl@mapselect\relax - \let\bbl@temp@fam#4% eg, '\rmfamily', to be restored below + \let\bbl@temp@fam#4% e.g., '\rmfamily', to be restored below \let#4\@empty % Make sure \renewfontfamily is valid + \bbl@set@renderer \bbl@exp{% - \let\\\bbl@temp@pfam\<\bbl@stripslash#4\space>% eg, '\rmfamily ' + \let\\\bbl@temp@pfam\<\bbl@stripslash#4\space>% e.g., '\rmfamily ' \<keys_if_exist:nnF>{fontspec-opentype}{Script/\bbl@cl{sname}}% {\\\newfontscript{\bbl@cl{sname}}{\bbl@cl{sotf}}}% \<keys_if_exist:nnF>{fontspec-opentype}{Language/\bbl@cl{lname}}% {\\\newfontlanguage{\bbl@cl{lname}}{\bbl@cl{lotf}}}% - \let\\\bbl@tempfs@nx\<__fontspec_warning:nx>% - \let\<__fontspec_warning:nx>\\\bbl@fs@warn@nx - \let\\\bbl@tempfs@nxx\<__fontspec_warning:nxx>% - \let\<__fontspec_warning:nxx>\\\bbl@fs@warn@nxx \\\renewfontfamily\\#4% [\bbl@cl{lsys},% xetex removes unknown features :-( \ifcase\bbl@engine\or RawFeature={family=\bbl@tempb},\fi - #2]}{#3}% ie \bbl@exp{..}{#3} - \bbl@exp{% - \let\<__fontspec_warning:nx>\\\bbl@tempfs@nx - \let\<__fontspec_warning:nxx>\\\bbl@tempfs@nxx}% + #2]}{#3}% i.e., \bbl@exp{..}{#3} + \bbl@unset@renderer \begingroup #4% - \xdef#1{\f@family}% eg, \bbl@rmdflt@lang{FreeSerif(0)} + \xdef#1{\f@family}% e.g., \bbl@rmdflt@lang{FreeSerif(0)} \endgroup % TODO. Find better tests: \bbl@xin@{\string>\string s\string s\string u\string b\string*}% {\expandafter\meaning\csname TU/#1/bx/sc\endcsname}% @@ -13683,9 +13948,9 @@ wouldn’t exist. \let\bbl@mapselect\bbl@tempe}% % \end{macrocode} % -% font@rst and famrst are only used when there is no global settings, -% to save and restore de previous families. Not really necessary, but -% done for optimization. +% |font@rst| and |famrst| are only used when there is no global +% settings, to save and restore de previous families. Not really +% necessary, but done for optimization. % % \begin{macrocode} \def\bbl@font@rst#1#2#3#4{% @@ -13700,13 +13965,9 @@ wouldn’t exist. %<</Font selection>> % \end{macrocode} % -% \section{Hooks for XeTeX and LuaTeX} -% -% \subsection{XeTeX} +% \macro{\BabelFootnote} % -% Unfortunately, the current encoding cannot be retrieved and -% therefore it is reset always to |utf8|, which seems a sensible -% default. +% Footnotes. % % \begin{macrocode} %<<*Footnote changes>> @@ -13758,6 +14019,14 @@ wouldn’t exist. %<</Footnote changes>> % \end{macrocode} % +% \section{Hooks for XeTeX and LuaTeX} +% +% \subsection{XeTeX} +% +% Unfortunately, the current encoding cannot be retrieved and +% therefore it is reset always to |utf8|, which seems a sensible +% default. +% % Now, the code. % % \begin{macrocode} @@ -13823,14 +14092,13 @@ wouldn’t exist. \fi}% \fi} \ifx\DisableBabelHook\@undefined\endinput\fi %%%% TODO: why -\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont} -\AddBabelHook{babel-fontspec}{beforestart}{\bbl@ckeckstdfonts} -\DisableBabelHook{babel-fontspec} +\let\bbl@set@renderer\relax +\let\bbl@unset@renderer\relax <@Font selection@> \def\bbl@provide@extra#1{} % \end{macrocode} % -% \section{Support for interchar} +% \subsection{Support for interchar} % % \xetex{} reserves some values for CJK (although they are not set in % \textsc{xelatex}), so we make sure they are skipped. Define some user @@ -13883,7 +14151,7 @@ wouldn’t exist. % |\bbl@usingxeclass\bbl@xeclass@punct@english||\bbl@charclass{.}|% % |\bbl@charclass{,}| (etc.), where |\bbl@usingxeclass| stores the class to be % applied to the subsequent characters. The \cs{ifcat} part deals with -% the alternative way to enter characters as macros (eg, |\}|). As a +% the alternative way to enter characters as macros (e.g., |\}|). As a % special case, hyphens are stored as |\bbl@upto|, to deal with ranges. % % \begin{macrocode} @@ -13940,7 +14208,7 @@ wouldn’t exist. % And finally, the command with the code to be inserted. If the language % doesn’t define a class, then use the global one, as defined above. % For the definition there is a intermediate macro, which can be -% ‘disabled’ with |\bbl@ic@<label>@<lang>|. +% ‘disabled’ with |\bbl@ic@<label>@<language>|. % % \begin{macrocode} \def\bbl@ignoreinterchar{% @@ -13956,7 +14224,7 @@ wouldn’t exist. {\bbl@ignoreinterchar{#5}}% \bbl@csarg\let{ic@\bbl@kv@label @#2}\@firstofone \bbl@exp{\\\bbl@for\\\bbl@tempa{\zap@space#3 \@empty}}{% - \bbl@exp{\\\bbl@for\\\bbl@tempb{\zap@space#4 \@empty}}{% + \bbl@exp{\\\bbl@for\\\bbl@tempb{\zap@space#4 \@empty}}{% \XeTeXinterchartoks \@nameuse{bbl@xeclass@\bbl@tempa @% \bbl@ifunset{bbl@xeclass@\bbl@tempa @#2}{}{#2}} % @@ -13968,11 +14236,11 @@ wouldn’t exist. @#3@#4@#2 \@empty\endcsname}}}} \DeclareRobustCommand\enablelocaleinterchar[1]{% \bbl@ifunset{bbl@ic@#1@\languagename}% - {\bbl@error{unknown-interchar}{#1}{}{}}% + {\bbl@error{unknown-interchar}{#1}{}{}}% {\bbl@csarg\let{ic@#1@\languagename}\@firstofone}} \DeclareRobustCommand\disablelocaleinterchar[1]{% \bbl@ifunset{bbl@ic@#1@\languagename}% - {\bbl@error{unknown-interchar-b}{#1}{}{}}% + {\bbl@error{unknown-interchar-b}{#1}{}{}}% {\bbl@csarg\let{ic@#1@\languagename}\@gobble}} %</xetex> % \end{macrocode} @@ -14062,9 +14330,9 @@ wouldn’t exist. {} % \end{macrocode} % -% Implicitly reverses sectioning labels in |bidi=basic|, because -% the full stop is not in contact with L numbers any more. I -% think there must be a better way. +% Implicitly reverses sectioning labels in |bidi=basic|, because the +% full stop is not in contact with L numbers any more. I think there +% must be a better way. % % \begin{macrocode} \IfBabelLayout{counters*}% @@ -14188,11 +14456,12 @@ wouldn’t exist. % starts, to read the list of available languages from |language.dat| % (for the |base| option); (2) at hyphen.cfg, to modify some macros; % (3) in the middle of |plain.def| and |babel.sty|, by |babel.def|, -% with the commands and other definitions for |luatex| (eg, +% with the commands and other definitions for |luatex| (e.g., % |\babelpatterns|). -% +% % \begin{macrocode} %<*luatex> +\directlua{ Babel = Babel or {} } % DL2 \ifx\AddBabelHook\@undefined % When plain.def, babel.sty starts \bbl@trace{Read language.dat} \ifx\bbl@readstream\@undefined @@ -14338,8 +14607,12 @@ wouldn’t exist. {\expandafter\expandafter\expandafter\bbl@luapatterns \csname bbl@hyphendata@\the\language\endcsname}}{}} \endinput\fi - % Here ends \ifx\AddBabelHook\@undefined - % A few lines are only read by hyphen.cfg +% \end{macrocode} +% +% Here ends |\ifx\AddBabelHook\@undefined|. A few lines are only read +% by \textsc{hyphen.cfg}. +% +% \begin{macrocode} \ifx\DisableBabelHook\@undefined \AddBabelHook{luatex}{everylanguage}{% \def\process@language##1##2##3{% @@ -14355,16 +14628,19 @@ wouldn’t exist. {\expandafter\expandafter\expandafter\bbl@tempb \csname bbl@hyphendata@\the\language\endcsname}} \endinput\fi - % Here stops reading code for hyphen.cfg - % The following is read the 2nd time it's loaded - % First, global declarations for lua -\begingroup % TODO - to a lua file +% \end{macrocode} +% +% Here stops reading code for \textsc{hyphen.cfg}. The following is +% read the 2nd time it's loaded. First, global declarations for lua. +% +% \begin{macrocode} +\begingroup % TODO - to a lua file % DL3 \catcode`\%=12 \catcode`\'=12 \catcode`\"=12 \catcode`\:=12 \directlua{ - Babel = Babel or {} + Babel.locale_props = Babel.locale_props or {} function Babel.lua_error(e, a) tex.print([[\noexpand\csname bbl@error\endcsname{]] .. e .. '}{' .. (a or '') .. '}{}{}') @@ -14389,6 +14665,40 @@ wouldn’t exist. callback.register('process_input_buffer',Babel.callback) end end + function Babel.str_to_nodes(fn, matches, base) + local n, head, last + if fn == nil then return nil end + for s in string.utfvalues(fn(matches)) do + if base.id == 7 then + base = base.replace + end + n = node.copy(base) + n.char = s + if not head then + head = n + else + last.next = n + end + last = n + end + return head + end + Babel.linebreaking = Babel.linebreaking or {} + Babel.linebreaking.before = {} + Babel.linebreaking.after = {} + Babel.locale = {} + function Babel.linebreaking.add_before(func, pos) + tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]]) + if pos == nil then + table.insert(Babel.linebreaking.before, func) + else + table.insert(Babel.linebreaking.before, pos, func) + end + end + function Babel.linebreaking.add_after(func) + tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]]) + table.insert(Babel.linebreaking.after, func) + end function Babel.addpatterns(pp, lg) local lg = lang.new(lg) local pats = lang.patterns(lg) or '' @@ -14455,13 +14765,13 @@ wouldn’t exist. str:find( [[\string\babelsublr]] ) then str = str:gsub( [[\string\babelsublr%s*(%b{})]], function(m) return m:sub(2,-2) end ) - end - return str -end + end + return str + end } \endgroup \ifx\newattribute\@undefined\else % Test for plain - \newattribute\bbl@attr@locale + \newattribute\bbl@attr@locale % DL4 \directlua{ Babel.attr_locale = luatexbase.registernumber'bbl@attr@locale' } \AddBabelHook{luatex}{beforeextras}{% \setattribute\bbl@attr@locale\localeid} @@ -14516,12 +14826,12 @@ end {\prehyphenchar=\bbl@cl{prehc}\relax}}}} % \end{macrocode} % -% \begin{macro}{\babelpatterns} +% \macro{\babelpatterns} % -% This macro adds patterns. Two macros are used to store them: -% |\bbl@patterns@| for the global ones and |\bbl@patterns@<lang>| -% for language ones. We make sure there is a space between words -% when multiple commands are used. +% This macro adds patterns. Two macros are used to store them: +% |\bbl@patterns@| for the global ones and |\bbl@patterns@<language>| for +% language ones. We make sure there is a space between words when +% multiple commands are used. % % \begin{macrocode} \@onlypreamble\babelpatterns @@ -14550,42 +14860,20 @@ end #2}}}% \fi}} % \end{macrocode} -% \end{macro} % % \subsection{Southeast Asian scripts} % % First, some general code for line breaking, used by % |\babelposthyphenation|. % -% Replace regular (ie, implicit) discretionaries by spaceskips, based +% Replace regular (i.e., implicit) discretionaries by spaceskips, based % on the previous glyph (which I think makes sense, because the hyphen % and the previous char go always together). Other discretionaries are % not touched. See Unicode UAX 14. % % \begin{macrocode} -% TODO - to a lua file -\directlua{ - Babel = Babel or {} - Babel.linebreaking = Babel.linebreaking or {} - Babel.linebreaking.before = {} - Babel.linebreaking.after = {} - Babel.locale = {} % Free to use, indexed by \localeid - function Babel.linebreaking.add_before(func, pos) - tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]]) - if pos == nil then - table.insert(Babel.linebreaking.before, func) - else - table.insert(Babel.linebreaking.before, pos, func) - end - end - function Babel.linebreaking.add_after(func) - tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]]) - table.insert(Babel.linebreaking.after, func) - end -} \def\bbl@intraspace#1 #2 #3\@@{% \directlua{ - Babel = Babel or {} Babel.intraspaces = Babel.intraspaces or {} Babel.intraspaces['\csname bbl@sbcp@\languagename\endcsname'] = % {b = #1, p = #2, m = #3} @@ -14594,20 +14882,18 @@ end }} \def\bbl@intrapenalty#1\@@{% \directlua{ - Babel = Babel or {} Babel.intrapenalties = Babel.intrapenalties or {} Babel.intrapenalties['\csname bbl@sbcp@\languagename\endcsname'] = #1 Babel.locale_props[\the\localeid].intrapenalty = #1 }} \begingroup \catcode`\%=12 -\catcode`\&=14 +\catcode`\&=14 \catcode`\'=12 \catcode`\~=12 \gdef\bbl@seaintraspace{& \let\bbl@seaintraspace\relax \directlua{ - Babel = Babel or {} Babel.sea_enabled = true Babel.sea_ranges = Babel.sea_ranges or {} function Babel.set_chranges (script, chrng) @@ -14630,7 +14916,7 @@ end quad = font.getfont(last_char.font).size for lg, rg in pairs(sea_ranges) do if last_char.char > rg[1] and last_char.char < rg[2] then - lg = lg:sub(1, 4) &% Remove trailing number of, eg, Cyrl1 + lg = lg:sub(1, 4) &% Remove trailing number of, e.g., Cyrl1 local intraspace = Babel.intraspaces[lg] local intrapenalty = Babel.intrapenalties[lg] local n @@ -14638,7 +14924,7 @@ end n = node.new(14, 0) &% penalty n.penalty = intrapenalty node.insert_before(head, item, n) - end + end n = node.new(12, 13) &% (glue, spaceskip) node.setglue(n, intraspace.b * quad, intraspace.p * quad, @@ -14651,9 +14937,9 @@ end end end }& - \bbl@luahyphenate} + \bbl@luahyphenate} % \end{macrocode} -% +% % \subsection{CJK line breaking} % % Minimal line breaking for CJK scripts, mainly intended for simple @@ -14672,7 +14958,6 @@ end \gdef\bbl@cjkintraspace{% \let\bbl@cjkintraspace\relax \directlua{ - Babel = Babel or {} require('babel-data-cjk.lua') Babel.cjk_enabled = true function Babel.cjk_linebreak(head) @@ -14689,7 +14974,7 @@ end local LOCALE = node.get_attribute(item, Babel.attr_locale) - local props = Babel.locale_props[LOCALE] + local props = Babel.locale_props[LOCALE] or {} local class = Babel.cjk_class[item.char].c @@ -14697,8 +14982,10 @@ end class = props.cjk_quotes[item.char] end - if class == 'cp' then class = 'cl' end % )] as CL - if class == 'id' then class = 'I' end + if class == 'cp' then class = 'cl' % )] as CL + elseif class == 'id' then class = 'I' + elseif class == 'cj' then class = 'I' % loose + end local br = 0 if class and last_class and Babel.cjk_breaks[last_class][class] then @@ -14713,7 +15000,7 @@ end local n = node.new(14, 0) % penalty n.penalty = intrapenalty node.insert_before(head, item, n) - end + end local intraspace = props.intraspace local n = node.new(12, 13) % (glue, spaceskip) node.setglue(n, intraspace.b * quad, @@ -14745,15 +15032,18 @@ end func(head) end end + lang.hyphenate(head) if Babel.cjk_enabled then Babel.cjk_linebreak(head) end - lang.hyphenate(head) if Babel.linebreaking.after then for k, func in ipairs(Babel.linebreaking.after) do func(head) end end + if Babel.set_hboxed then + Babel.set_hboxed(head) + end if Babel.sea_enabled then Babel.sea_disc_to_space(head) end @@ -14769,7 +15059,6 @@ end \ifin@ % cjk \bbl@cjkintraspace \directlua{ - Babel = Babel or {} Babel.locale_props = Babel.locale_props or {} Babel.locale_props[\the\localeid].linebreak = 'c' }% @@ -14781,7 +15070,6 @@ end \bbl@seaintraspace \bbl@exp{\\\bbl@intraspace\bbl@cl{intsp}\\\@@}% \directlua{ - Babel = Babel or {} Babel.sea_ranges = Babel.sea_ranges or {} Babel.set_chranges('\bbl@cl{sbcp}', '\bbl@cl{chrng}') @@ -14800,7 +15088,7 @@ end % % WIP. |\bbl@arabicjust| is executed with both elongated an kashida. % This must be fine tuned. The attribute kashida is set by transforms -% with |kashida|- +% with |kashida|. % % \begin{macrocode} \ifnum\bbl@bidimode>100 \ifnum\bbl@bidimode<200 @@ -14829,7 +15117,7 @@ end Babel.arabic.justify, 'Babel.arabic.justify') luatexbase.add_to_callback('hpack_filter', Babel.arabic.justify_hbox, 'Babel.arabic.justify_hbox') - }}% + }}% % \end{macrocode} % % Save both node lists to make replacement. TODO. Save also widths to @@ -14850,7 +15138,7 @@ end end end Babel.arabic.#3['##1#4'] = last.char - }}} + }}} % \end{macrocode} % % Elongated forms. Brute force. No rules at all, yet. The ideal: look @@ -15016,7 +15304,7 @@ function Babel.arabic.justify_hlist(head, line, gc, size, pack) while width < goal do subst_done = true k_item = k_list[k_curr].node - if k_list[k_curr].weight == Babel.kashida_wts[wt_pos] then + if k_list[k_curr].weight == Babel.kashida_wts[wt_pos] then d = node.copy(k_item) d.char = 0x0640 d.yoffset = 0 % TODO. From the prev char. But 0 seems safe. @@ -15034,7 +15322,7 @@ function Babel.arabic.justify_hlist(head, line, gc, size, pack) end if k_curr == 1 then k_curr = #k_list - wt_pos = (wt_pos >= table.getn(Babel.kashida_wts)) and 1 or wt_pos+1 + wt_pos = (wt_pos >= table.getn(Babel.kashida_wts)) and 1 or wt_pos+1 else k_curr = k_curr - 1 end @@ -15076,10 +15364,33 @@ end % % \subsection{Common stuff} % -% \begin{macrocode} -\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont} -\AddBabelHook{babel-fontspec}{beforestart}{\bbl@ckeckstdfonts} -\DisableBabelHook{babel-fontspec} +% First, a couple of auxiliary macros to set the renderer according +% to the script. This is done by patching temporarily the low-level +% \textsf{fontspec} macro containing the current features set with +% |\defaultfontfeatures|. Admittedly this is somewhat dangerous, but +% that way the latter command still works as expected, because the +% renderer is set just before other settings. In \xetex\ they are set +% to |\relax|. +% +% \begin{macrocode} +\def\bbl@scr@node@list{% + ,Armenian,Coptic,Cyrillic,Georgian,,Glagolitic,Gothic,% + ,Greek,Latin,Old Church Slavonic Cyrillic,} +\ifnum\bbl@bidimode=102 % bidi-r + \bbl@add\bbl@scr@node@list{Arabic,Hebrew,Syriac} +\fi +\def\bbl@set@renderer{% + \bbl@xin@{\bbl@cl{sname}}{\bbl@scr@node@list}% + \ifin@ + \let\bbl@unset@renderer\relax + \else + \bbl@exp{% + \def\\\bbl@unset@renderer{% + \def\<g__fontspec_default_fontopts_clist>{% + \[g__fontspec_default_fontopts_clist]}}% + \def\<g__fontspec_default_fontopts_clist>{% + Renderer=Harfbuzz,\[g__fontspec_default_fontopts_clist]}}% + \fi} <@Font selection@> % \end{macrocode} % @@ -15100,14 +15411,14 @@ end % % \begin{macrocode} % TODO - to a lua file -\directlua{ +\directlua{% DL6 Babel.script_blocks = { ['dflt'] = {}, ['Arab'] = {{0x0600, 0x06FF}, {0x08A0, 0x08FF}, {0x0750, 0x077F}, {0xFE70, 0xFEFF}, {0xFB50, 0xFDFF}, {0x1EE00, 0x1EEFF}}, ['Armn'] = {{0x0530, 0x058F}}, ['Beng'] = {{0x0980, 0x09FF}}, - ['Cher'] = {{0x13A0, 0x13FF}, {0xAB70, 0xABBF}}, + ['Cher'] = {{0x13A0, 0x13FF}, {0xAB70, 0xABBF}}, ['Copt'] = {{0x03E2, 0x03EF}, {0x2C80, 0x2CFF}, {0x102E0, 0x102FF}}, ['Cyrl'] = {{0x0400, 0x04FF}, {0x0500, 0x052F}, {0x1C80, 0x1C8F}, {0x2DE0, 0x2DFF}, {0xA640, 0xA69F}}, @@ -15219,7 +15530,7 @@ function Babel.locale_map(head) elseif not inmath and item.id == 7 then % Apply recursively item.replace = item.replace and Babel.locale_map(item.replace) item.pre = item.pre and Babel.locale_map(item.pre) - item.post = item.post and Babel.locale_map(item.post) + item.post = item.post and Babel.locale_map(item.post) elseif item.id == node.id'math' then inmath = (item.subtype == 0) end @@ -15279,9 +15590,9 @@ end % Post-handling hyphenation patterns for non-standard rules, like |ff| % to |ff-f|. There are still some issues with speed (not very slow, but % still slow). The Lua code is below. -% +% % \begin{macrocode} -\directlua{ +\directlua{% DL7 Babel.nohyphenation = \the\l@nohyphenation } % \end{macrocode} @@ -15299,7 +15610,7 @@ end % this macro at the appropriate place. As |\directlua| does not take % into account the current catcode of |@|, we just avoid this character % in macro names (which explains the internal group, too). -% +% % \begin{macrocode} \begingroup \catcode`\~=12 @@ -15325,27 +15636,38 @@ end \bbl@ifsamestring{##1}{remove}&% {\bbl@add@list\babeltempb{nil}}&% {\directlua{ - local rep = [=[##1]=] + local rep = [=[##1]=] + local three_args = '%s*=%s*([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)' + &% Numeric passes directly: kern, penalty... rep = rep:gsub('^%s*(remove)%s*$', 'remove = true') rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ') rep = rep:gsub('^%s*(after)%s*,', 'after = true, ') rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func) rep = rep:gsub('node%s*=%s*(%a+)%s*(%a*)', Babel.capture_node) - rep = rep:gsub(&% - '(norule)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)', - 'norule = {' .. '%2, %3, %4' .. '}') + rep = rep:gsub( '(norule)' .. three_args, + 'norule = {' .. '%2, %3, %4' .. '}') if #1 == 0 or #1 == 2 then - rep = rep:gsub(&% - '(space)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)', + rep = rep:gsub( '(space)' .. three_args, 'space = {' .. '%2, %3, %4' .. '}') - rep = rep:gsub(&% - '(spacefactor)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)', - 'spacefactor = {' .. '%2, %3, %4' .. '}') + rep = rep:gsub( '(spacefactor)' .. three_args, + 'spacefactor = {' .. '%2, %3, %4' .. '}') rep = rep:gsub('(kashida)%s*=%s*([^%s,]*)', Babel.capture_kashida) - else + &% Transform values + rep, n = rep:gsub( '{([%a%-%.]+)|([%a%_%.]+)}', + function(v,d) + return string.format ( + '{\the\csname bbl@id@@#3\endcsname,"%s",%s}', + v, + load( 'return Babel.locale_props'.. + '[\the\csname bbl@id@@#3\endcsname].' .. d)() ) + end ) + rep, n = rep:gsub( '{([%a%-%.]+)|([%-%d%.]+)}', + '{\the\csname bbl@id@@#3\endcsname,"%1",%2}') + end + if #1 == 1 then rep = rep:gsub( '(no)%s*=%s*([^%s,]*)', Babel.capture_func) rep = rep:gsub( '(pre)%s*=%s*([^%s,]*)', Babel.capture_func) - rep = rep:gsub( '(post)%s*=%s*([^%s,]*)', Babel.capture_func) + rep = rep:gsub( '(post)%s*=%s*([^%s,]*)', Babel.capture_func) end tex.print([[\string\babeltempa{{]] .. rep .. [[}}]]) }}}&% @@ -15355,14 +15677,14 @@ end post,penalty,kashida,space,spacefactor,kern,node,after,norule,}&% \ifin@\else \bbl@error{bad-transform-option}{####1}{}{}&% - \fi}}&% + \fi}}&% \let\bbl@kv@attribute\relax \let\bbl@kv@label\relax \let\bbl@kv@fonts\@empty \bbl@forkv{#2}{\bbl@csarg\edef{kv@##1}{##2}}&% \ifx\bbl@kv@fonts\@empty\else\bbl@settransfont\fi \ifx\bbl@kv@attribute\relax - \ifx\bbl@kv@label\relax\else + \ifx\bbl@kv@label\relax\else \bbl@exp{\\\bbl@trim@def\\\bbl@kv@fonts{\bbl@kv@fonts}}&% \bbl@replace\bbl@kv@fonts{ }{,}&% \edef\bbl@kv@attribute{bbl@ATR@\bbl@kv@label @#3@\bbl@kv@fonts}&% @@ -15422,7 +15744,7 @@ end patt = u.gsub(patt, '{(%x%x%x%x+)}', function (n) return u.gsub(u.char(tonumber(n, 16)), '(%p)', '%%%1') - end) + end) lbkr[id] = lbkr[id] or {} table.insert(lbkr[id], { label=label, attr=attr, pattern=patt, replace={\babeltempb} }) @@ -15464,20 +15786,30 @@ end {\bbl@csarg\setattribute{ATR@#1@\languagename @}\@ne}} \DeclareRobustCommand\disablelocaletransform[1]{% \bbl@ifunset{bbl@ATR@#1@\languagename @}% - {\bbl@error{transform-not-available-b}{#1}{}{}}% + {\bbl@error{transform-not-available-b}{#1}{}{}}% {\bbl@csarg\unsetattribute{ATR@#1@\languagename @}}} \def\bbl@activateposthyphen{% \let\bbl@activateposthyphen\relax + \ifx\bbl@attr@hboxed\@undefined + \newattribute\bbl@attr@hboxed + \fi \directlua{ require('babel-transforms.lua') Babel.linebreaking.add_after(Babel.post_hyphenate_replace) }} \def\bbl@activateprehyphen{% \let\bbl@activateprehyphen\relax + \ifx\bbl@attr@hboxed\@undefined + \newattribute\bbl@attr@hboxed + \fi \directlua{ require('babel-transforms.lua') Babel.linebreaking.add_before(Babel.pre_hyphenate_replace) }} +\newcommand\SetTransformValue[3]{% + \directlua{ + Babel.locale_props[\the\csname bbl@id@@#1\endcsname].vars["#2"] = #3 + }} % \end{macrocode} % % The following experimental (and unfinished) macro applies the @@ -15504,8 +15836,6 @@ end \def\bbl@activate@preotf{% \let\bbl@activate@preotf\relax % only once \directlua{ - Babel = Babel or {} - % function Babel.pre_otfload_v(head) if Babel.numbers and Babel.digits_mapped then head = Babel.numbers(head) @@ -15516,7 +15846,7 @@ end return head end % - function Babel.pre_otfload_h(head, gc, sz, pt, dir) + function Babel.pre_otfload_h(head, gc, sz, pt, dir) %%% TODO if Babel.numbers and Babel.digits_mapped then head = Babel.numbers(head) end @@ -15543,11 +15873,12 @@ end % The basic setup. The output is modified at a very low level to set % the |\bodydir| to the |\pagedir|. Sadly, we have to deal with boxes % in math with basic, so the |\bbl@mathboxdir| hack is activated every -% math with the package option bidi=. +% math with the package option bidi=. The hack for the PUA is no longer +% necessary with |basic| (24.8), but it’s kept in |basic-r|. % % \begin{macrocode} \breakafterdirmode=1 -\ifnum\bbl@bidimode>\@ne % Any bidi= except default=1 +\ifnum\bbl@bidimode>\@ne % Any bidi= except default (=1) \let\bbl@beforeforeign\leavevmode \AtEndOfPackage{\EnableBabelHook{babel-bidi}} \RequirePackage{luatexbase} @@ -15557,9 +15888,12 @@ end \ifcase\expandafter\@gobbletwo\the\bbl@bidimode\or require('babel-bidi-basic.lua') \or - require('babel-bidi-basic-r.lua') + require('babel-bidi-basic-r.lua') + table.insert(Babel.ranges, {0xE000, 0xF8FF, 'on'}) + table.insert(Babel.ranges, {0xF0000, 0xFFFFD, 'on'}) + table.insert(Babel.ranges, {0x100000, 0x10FFFD, 'on'}) \fi} - \newattribute\bbl@attr@dir + \newattribute\bbl@attr@dir \directlua{ Babel.attr_dir = luatexbase.registernumber'bbl@attr@dir' } \bbl@exp{\output{\bodydir\pagedir\the\output}} \fi @@ -15571,6 +15905,8 @@ end tex.sprint('0') elseif tex.#1dir == 'TRT' then tex.sprint('1') + else + tex.sprint('0') end}} \def\bbl@setluadir#1#2#3{% 1=text/par.. 2=\textdir.. 3=0 lr/1 rl \ifcase#3\relax @@ -15633,6 +15969,12 @@ end end luatexbase.add_to_callback("hpack_filter", Babel.math_box_dir, "Babel.math_box_dir", 0) + if Babel.unset_atdir then + luatexbase.add_to_callback("pre_linebreak_filter", Babel.unset_atdir, + "Babel.unset_atdir") + luatexbase.add_to_callback("hpack_filter", Babel.unset_atdir, + "Babel.unset_atdir") + end }}% \fi % \end{macrocode} @@ -15650,7 +15992,7 @@ end % Unlike \xetex{}, \luatex{} requires only minimal changes for % right-to-left layouts, particularly in monolingual documents (the % engine itself reverses boxes -- including column order or headings -% --, margins, etc.) with |bidi=basic|, without having to patch +% --, margins, etc.)\ with |bidi=basic|, without having to patch % almost any macro where text direction is relevant. % % Still, there are three areas deserving special attention, namely, @@ -15827,6 +16169,115 @@ end \fi\fi} \fi \def\bbl@provide@extra#1{% + % == onchar == + \ifx\bbl@KVP@onchar\@nnil\else + \bbl@luahyphenate + \bbl@exp{% + \\\AddToHook{env/document/before}{{\\\select@language{#1}{}}}}% + \directlua{ + if Babel.locale_mapped == nil then + Babel.locale_mapped = true + Babel.linebreaking.add_before(Babel.locale_map, 1) + Babel.loc_to_scr = {} + Babel.chr_to_loc = Babel.chr_to_loc or {} + end + Babel.locale_props[\the\localeid].letters = false + }% + \bbl@xin@{ letters }{ \bbl@KVP@onchar\space}% + \ifin@ + \directlua{ + Babel.locale_props[\the\localeid].letters = true + }% + \fi + \bbl@xin@{ ids }{ \bbl@KVP@onchar\space}% + \ifin@ + \ifx\bbl@starthyphens\@undefined % Needed if no explicit selection + \AddBabelHook{babel-onchar}{beforestart}{{\bbl@starthyphens}}% + \fi + \bbl@exp{\\\bbl@add\\\bbl@starthyphens + {\\\bbl@patterns@lua{\languagename}}}% + \directlua{ + if Babel.script_blocks['\bbl@cl{sbcp}'] then + Babel.loc_to_scr[\the\localeid] = Babel.script_blocks['\bbl@cl{sbcp}'] + Babel.locale_props[\the\localeid].lg = \the\@nameuse{l@\languagename}\space + end + }% + \fi + \bbl@xin@{ fonts }{ \bbl@KVP@onchar\space}% + \ifin@ + \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% + \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}% + \directlua{ + if Babel.script_blocks['\bbl@cl{sbcp}'] then + Babel.loc_to_scr[\the\localeid] = + Babel.script_blocks['\bbl@cl{sbcp}'] + end}% + \ifx\bbl@mapselect\@undefined % TODO. almost the same as mapfont + \AtBeginDocument{% + \bbl@patchfont{{\bbl@mapselect}}% + {\selectfont}}% + \def\bbl@mapselect{% + \let\bbl@mapselect\relax + \edef\bbl@prefontid{\fontid\font}}% + \def\bbl@mapdir##1{% + \begingroup + \setbox\z@\hbox{% Force text mode + \def\languagename{##1}% + \let\bbl@ifrestoring\@firstoftwo % To avoid font warning + \bbl@switchfont + \ifnum\fontid\font>\z@ % A hack, for the pgf nullfont hack + \directlua{ + Babel.locale_props[\the\csname bbl@id@@##1\endcsname]% + ['/\bbl@prefontid'] = \fontid\font\space}% + \fi}% + \endgroup}% + \fi + \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}% + \fi + % TODO - catch non-valid values + \fi + % == mapfont == + % For bidi texts, to switch the font based on direction + \ifx\bbl@KVP@mapfont\@nnil\else + \bbl@ifsamestring{\bbl@KVP@mapfont}{direction}{}% + {\bbl@error{unknown-mapfont}{}{}{}}% + \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% + \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}% + \ifx\bbl@mapselect\@undefined % TODO. See onchar. + \AtBeginDocument{% + \bbl@patchfont{{\bbl@mapselect}}% + {\selectfont}}% + \def\bbl@mapselect{% + \let\bbl@mapselect\relax + \edef\bbl@prefontid{\fontid\font}}% + \def\bbl@mapdir##1{% + {\def\languagename{##1}% + \let\bbl@ifrestoring\@firstoftwo % avoid font warning + \bbl@switchfont + \directlua{Babel.fontmap + [\the\csname bbl@wdir@##1\endcsname]% + [\bbl@prefontid]=\fontid\font}}}% + \fi + \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}% + \fi + % == Line breaking: CJK quotes == + \ifcase\bbl@engine\or + \bbl@xin@{/c}{/\bbl@cl{lnbrk}}% + \ifin@ + \bbl@ifunset{bbl@quote@\languagename}{}% + {\directlua{ + Babel.locale_props[\the\localeid].cjk_quotes = {} + local cs = 'op' + for c in string.utfvalues(% + [[\csname bbl@quote@\languagename\endcsname]]) do + if Babel.cjk_characters[c].c == 'qu' then + Babel.locale_props[\the\localeid].cjk_quotes[c] = cs + end + cs = ( cs == 'op') and 'cl' or 'op' + end + }}% + \fi + \fi % == Counters: mapdigits == % Native digits \ifx\bbl@KVP@mapdigits\@nnil\else @@ -15834,7 +16285,6 @@ end {\RequirePackage{luatexbase}% \bbl@activate@preotf \directlua{ - Babel = Babel or {} %%% -> presets in luababel Babel.digits_mapped = true Babel.digits = Babel.digits or {} Babel.digits[\the\localeid] = @@ -15871,10 +16321,29 @@ end \bbl@replace\bbl@tempa{transforms.}{}% \bbl@carg\bbl@transforms{babel\bbl@tempa}{##2}{##3}% \fi}% + \bbl@exp{% + \\\bbl@ifblank{\bbl@cl{dgnat}}% + {\let\\\bbl@tempa\relax}% + {\def\\\bbl@tempa{% + \\\bbl@elt{transforms.prehyphenation}% + {digits.native.1.0}{([0-9])}% + \\\bbl@elt{transforms.prehyphenation}% + {digits.native.1.1}{string={1\string|0123456789\string|\bbl@cl{dgnat}}}}}}% + \ifx\bbl@tempa\relax\else + \toks@\expandafter\expandafter\expandafter{% + \csname bbl@inidata@\languagename\endcsname}% + \bbl@csarg\edef{inidata@\languagename}{% + \unexpanded\expandafter{\bbl@tempa}% + \the\toks@}% + \fi \csname bbl@inidata@\languagename\endcsname \bbl@release@transforms\relax % \relax closes the last item. \fi} +% \end{macrocode} +% % Start tabular here: +% +% \begin{macrocode} \def\localerestoredirs{% \ifcase\bbl@thetextdir \ifnum\textdirection=\z@\else\textdir TLT\fi @@ -15892,7 +16361,9 @@ end {\chardef\bbl@tabular@mode\z@}% {\chardef\bbl@tabular@mode\@ne}}% Mixed, with LTR cols \ifnum\bbl@bidimode>\@ne % Any lua bidi= except default=1 - \ifcase\bbl@tabular@mode\or % 1 + % Redefine: vrules mess up dirs. TODO: why? + \def\@arstrut{\relax\copy\@arstrutbox}% + \ifcase\bbl@tabular@mode\or % 1 = Mixed - default \let\bbl@parabefore\relax \AddToHook{para/before}{\bbl@parabefore} \AtBeginDocument{% @@ -15917,7 +16388,7 @@ end {\\\do@row@strut\<fi>}{\\\do@row@strut\<fi>\egroup}}}% {}}% \fi}% - \or % 2 + \or % 2 = All RTL - tabular \let\bbl@parabefore\relax \AddToHook{para/before}{\bbl@parabefore}% \AtBeginDocument{% @@ -15957,14 +16428,14 @@ end % removed it without an alternative. Also, |\hangindent| does not % honour direction changes by default, so we need to redefine % |\@hangfrom|. -% +% % \begin{macrocode} \ifnum\bbl@bidimode>\z@ % Any bidi= \def\bbl@nextfake#1{% non-local changes, use always inside a group! \bbl@exp{% - \def\\\bbl@insidemath{0}% - \mathdir\the\bodydir + \mathdir\the\bodydir #1% Once entered in math, set boxes to restore values + \def\\\bbl@insidemath{0}% \<ifmmode>% \everyvbox{% \the\everyvbox @@ -16063,7 +16534,7 @@ end \raise\@tempdimc\hb@xt@\z@{% \@defaultunitsset\@tempdimc{#1}\unitlength \kern\@tempdimc - {\ifnum\bbl@tempc>\z@\bbl@pictresetdir\fi#3}\hss}% + {\ifnum\bbl@tempc>\z@\bbl@pictresetdir\fi#3}\hss}% \ignorespaces}% \MakeRobust\put}% \AtBeginDocument @@ -16077,6 +16548,7 @@ end \AddToHook{env/tikzpicture/begin}{\bbl@pictsetdir\tw@}% \bbl@add\tikz@atbegin@node{\bbl@pictresetdir}% \bbl@sreplace\tikz{\begingroup}{\begingroup\bbl@pictsetdir\tw@}% + \bbl@sreplace\tikzpicture{\begingroup}{\begingroup\bbl@pictsetdir\tw@}% \fi \ifx\tcolorbox\@undefined\else \def\tcb@drawing@env@begin{% @@ -16094,10 +16566,10 @@ end {} % \end{macrocode} % -% Implicitly reverses sectioning labels in bidi=basic-r, because -% the full stop is not in contact with L numbers any more. I -% think there must be a better way. Assumes |bidi=basic|, but -% there are some additional readjustments for |bidi=default|. +% Implicitly reverses sectioning labels in bidi=basic-r, because the +% full stop is not in contact with L numbers any more. I think there +% must be a better way. Assumes |bidi=basic|, but there are some +% additional readjustments for |bidi=default|. % % \begin{macrocode} \IfBabelLayout{counters*}% @@ -16178,23 +16650,20 @@ Babel.linebreaking.replacements = {} Babel.linebreaking.replacements[0] = {} -- pre Babel.linebreaking.replacements[1] = {} -- post --- Discretionaries contain strings as nodes -function Babel.str_to_nodes(fn, matches, base) - local n, head, last - if fn == nil then return nil end - for s in string.utfvalues(fn(matches)) do - if base.id == 7 then - base = base.replace - end - n = node.copy(base) - n.char = s - if not head then - head = n - else - last.next = n - end - last = n - end +function Babel.tovalue(v) + if type(v) == 'table' then + return Babel.locale_props[v[1]].vars[v[2]] or v[3] + else + return v + end +end + +Babel.attr_hboxed = luatexbase.registernumber'bbl@attr@hboxed' + +function Babel.set_hboxed(head, gc) + for item in node.traverse(head) do + node.set_attribute(item, Babel.attr_hboxed, 1) + end return head end @@ -16227,10 +16696,14 @@ Babel.fetch_subtext[0] = function(head) if lang == locale or lang == nil then lang = lang or locale - if Babel.ignore_pre_char(item) then + if Babel.ignore_pre_char(item) then word_string = word_string .. Babel.us_char else - word_string = word_string .. unicode.utf8.char(item.char) + if node.has_attribute(item, Babel.attr_hboxed) then + word_string = word_string .. Babel.us_char + else + word_string = word_string .. unicode.utf8.char(item.char) + end end word_nodes[#word_nodes+1] = item else @@ -16238,12 +16711,16 @@ Babel.fetch_subtext[0] = function(head) end elseif item.id == 12 and item.subtype == 13 then - word_string = word_string .. ' ' + if node.has_attribute(item, Babel.attr_hboxed) then + word_string = word_string .. Babel.us_char + else + word_string = word_string .. ' ' + end word_nodes[#word_nodes+1] = item -- Ignore leading unrecognized nodes, too. elseif word_string ~= '' then - word_string = word_string .. Babel.us_char + word_string = word_string .. Babel.us_char word_nodes[#word_nodes+1] = item -- Will be ignored end @@ -16279,7 +16756,11 @@ Babel.fetch_subtext[1] = function(head) if item.lang == lang or lang == nil then if (item.char ~= 124) and (item.char ~= 61) then -- not =, not | lang = lang or item.lang - word_string = word_string .. unicode.utf8.char(item.char) + if node.has_attribute(item, Babel.attr_hboxed) then + word_string = word_string .. Babel.us_char + else + word_string = word_string .. unicode.utf8.char(item.char) + end word_nodes[#word_nodes+1] = item end else @@ -16287,11 +16768,19 @@ Babel.fetch_subtext[1] = function(head) end elseif item.id == 7 and item.subtype == 2 then - word_string = word_string .. '=' + if node.has_attribute(item, Babel.attr_hboxed) then + word_string = word_string .. Babel.us_char + else + word_string = word_string .. '=' + end word_nodes[#word_nodes+1] = item elseif item.id == 7 and item.subtype == 3 then - word_string = word_string .. '|' + if node.has_attribute(item, Babel.attr_hboxed) then + word_string = word_string .. Babel.us_char + else + word_string = word_string .. '|' + end word_nodes[#word_nodes+1] = item -- (1) Go to next word if nothing was found, and (2) implicitly @@ -16304,7 +16793,7 @@ Babel.fetch_subtext[1] = function(head) break else - word_string = word_string .. Babel.us_char + word_string = word_string .. Babel.us_char word_nodes[#word_nodes+1] = item -- Will be ignored end @@ -16328,6 +16817,7 @@ Babel.us_char = string.char(31) function Babel.hyphenate_replace(head, mode) local u = unicode.utf8 local lbkr = Babel.linebreaking.replacements[mode] + local tovalue = Babel.tovalue local word_head = head @@ -16448,7 +16938,7 @@ function Babel.hyphenate_replace(head, mode) if crep then step = crep.step or step end - + if crep and crep.after then crep.insert = true if dummy_node then @@ -16459,7 +16949,7 @@ function Babel.hyphenate_replace(head, mode) dummy_node = item end end - + if crep and not crep.after and dummy_node then node.remove(head, dummy_node) dummy_node = nil @@ -16480,7 +16970,7 @@ function Babel.hyphenate_replace(head, mode) sc = sc - 1 -- Nothing has been inserted. last_match = utf8.offset(w, sc+1+step) goto next - + elseif crep and crep.kashida then -- Experimental node.set_attribute(item, Babel.attr_kashida, @@ -16531,9 +17021,9 @@ function Babel.hyphenate_replace(head, mode) d.replace = Babel.str_to_nodes(crep.no, matches, item_base) d.attr = item_base.attr if crep.pre == nil then -- TeXbook p96 - d.penalty = crep.penalty or tex.hyphenpenalty + d.penalty = tovalue(crep.penalty) or tex.hyphenpenalty else - d.penalty = crep.penalty or tex.exhyphenpenalty + d.penalty = tovalue(crep.penalty) or tex.exhyphenpenalty end placeholder = '|' head, new = node.insert_before(head, item, d) @@ -16544,37 +17034,37 @@ function Babel.hyphenate_replace(head, mode) elseif crep and crep.penalty then d = node.new(14, 0) -- (penalty, userpenalty) d.attr = item_base.attr - d.penalty = crep.penalty + d.penalty = tovalue(crep.penalty) head, new = node.insert_before(head, item, d) elseif crep and crep.space then -- 655360 = 10 pt = 10 * 65536 sp d = node.new(12, 13) -- (glue, spaceskip) local quad = font.getfont(item_base.font).size or 655360 - node.setglue(d, crep.space[1] * quad, - crep.space[2] * quad, - crep.space[3] * quad) + node.setglue(d, tovalue(crep.space[1]) * quad, + tovalue(crep.space[2]) * quad, + tovalue(crep.space[3]) * quad) if mode == 0 then placeholder = ' ' end head, new = node.insert_before(head, item, d) - + elseif crep and crep.norule then -- 655360 = 10 pt = 10 * 65536 sp d = node.new(2, 3) -- (rule, empty) = \no*rule local quad = font.getfont(item_base.font).size or 655360 - d.width = crep.norule[1] * quad - d.height = crep.norule[2] * quad - d.depth = crep.norule[3] * quad + d.width = tovalue(crep.norule[1]) * quad + d.height = tovalue(crep.norule[2]) * quad + d.depth = tovalue(crep.norule[3]) * quad head, new = node.insert_before(head, item, d) elseif crep and crep.spacefactor then d = node.new(12, 13) -- (glue, spaceskip) local base_font = font.getfont(item_base.font) node.setglue(d, - crep.spacefactor[1] * base_font.parameters['space'], - crep.spacefactor[2] * base_font.parameters['space_stretch'], - crep.spacefactor[3] * base_font.parameters['space_shrink']) + tovalue(crep.spacefactor[1]) * base_font.parameters['space'], + tovalue(crep.spacefactor[2]) * base_font.parameters['space_stretch'], + tovalue(crep.spacefactor[3]) * base_font.parameters['space_shrink']) if mode == 0 then placeholder = ' ' end @@ -16582,20 +17072,20 @@ function Babel.hyphenate_replace(head, mode) elseif mode == 0 and crep and crep.space then -- ERROR - + elseif crep and crep.kern then d = node.new(13, 1) -- (kern, user) local quad = font.getfont(item_base.font).size or 655360 d.attr = item_base.attr - d.kern = crep.kern * quad + d.kern = tovalue(crep.kern) * quad head, new = node.insert_before(head, item, d) - + elseif crep and crep.node then - d = node.new(crep.node[1], crep.node[2]) + d = node.new(crep.node[1], crep.node[2]) d.attr = item_base.attr head, new = node.insert_before(head, item, d) - end -- ie replacement cases + end -- i.e., replacement cases -- Shared by disc, space(factor), kern, node and penalty. if sc == 1 then @@ -16621,7 +17111,7 @@ function Babel.hyphenate_replace(head, mode) print('.....', '/') Babel.debug_hyph(w, w_nodes, sc, first, last, last_match) end - + if dummy_node then node.remove(head, dummy_node) dummy_node = nil @@ -16732,7 +17222,7 @@ function Babel.string_prehyphenation(str, locale) last.next = n last = n end - head = Babel.hyphenate_replace(head, 0) + head = Babel.hyphenate_replace(head, 0) res = '' for n in node.traverse(head) do if n.id == 12 then @@ -16768,24 +17258,25 @@ end %<*bididata> -- Data from Unicode and ConTeXt -Babel = Babel or {} - Babel.ranges = { {0x0590, 0x05FF, 'r'}, {0x0600, 0x07BF, 'al'}, {0x07C0, 0x085F, 'r'}, {0x0860, 0x086F, 'al'}, {0x08A0, 0x08FF, 'al'}, - {0xE000, 0xF8FF, 'on'}, -- PUA {0xFB1D, 0xFB4F, 'r'}, {0xFB50, 0xFDFF, 'al'}, {0xFE70, 0xFEFF, 'al'}, - {0x10800, 0x10C4F, 'r'}, - {0x1E800, 0x1E8DF, 'r'}, - {0x1E900, 0x1E95F, 'r'}, - {0x1F300, 0x1F9FF, 'on'}, - {0xF0000, 0xFFFFD, 'on'}, -- PUA - {0x100000, 0x10FFFD, 'on'} -- PUA + {0x10800, 0x10CFF, 'r'}, + {0x10D00, 0x10D3F, 'al'}, + {0x10D40, 0x10EBF, 'r'}, + {0x10EC0, 0x10EFF, 'al'}, + {0x10F00, 0x10F2F, 'r'}, + {0x10F30, 0x10F6F, 'al'}, + {0x10F70, 0x10FFF, 'r'}, + {0x1E800, 0x1E95F, 'r'}, + {0x1EE00, 0x1EEFF, 'al'}, + {0x1F300, 0x1F9FF, 'on'} } Babel.characters = { @@ -21551,114 +22042,6 @@ Babel.characters = { [0x10B3D]={d='on'}, [0x10B3E]={d='on'}, [0x10B3F]={d='on'}, - [0x10C80]={d='r'}, - [0x10C81]={d='r'}, - [0x10C82]={d='r'}, - [0x10C83]={d='r'}, - [0x10C84]={d='r'}, - [0x10C85]={d='r'}, - [0x10C86]={d='r'}, - [0x10C87]={d='r'}, - [0x10C88]={d='r'}, - [0x10C89]={d='r'}, - [0x10C8A]={d='r'}, - [0x10C8B]={d='r'}, - [0x10C8C]={d='r'}, - [0x10C8D]={d='r'}, - [0x10C8E]={d='r'}, - [0x10C8F]={d='r'}, - [0x10C90]={d='r'}, - [0x10C91]={d='r'}, - [0x10C92]={d='r'}, - [0x10C93]={d='r'}, - [0x10C94]={d='r'}, - [0x10C95]={d='r'}, - [0x10C96]={d='r'}, - [0x10C97]={d='r'}, - [0x10C98]={d='r'}, - [0x10C99]={d='r'}, - [0x10C9A]={d='r'}, - [0x10C9B]={d='r'}, - [0x10C9C]={d='r'}, - [0x10C9D]={d='r'}, - [0x10C9E]={d='r'}, - [0x10C9F]={d='r'}, - [0x10CA0]={d='r'}, - [0x10CA1]={d='r'}, - [0x10CA2]={d='r'}, - [0x10CA3]={d='r'}, - [0x10CA4]={d='r'}, - [0x10CA5]={d='r'}, - [0x10CA6]={d='r'}, - [0x10CA7]={d='r'}, - [0x10CA8]={d='r'}, - [0x10CA9]={d='r'}, - [0x10CAA]={d='r'}, - [0x10CAB]={d='r'}, - [0x10CAC]={d='r'}, - [0x10CAD]={d='r'}, - [0x10CAE]={d='r'}, - [0x10CAF]={d='r'}, - [0x10CB0]={d='r'}, - [0x10CB1]={d='r'}, - [0x10CB2]={d='r'}, - [0x10CC0]={d='r'}, - [0x10CC1]={d='r'}, - [0x10CC2]={d='r'}, - [0x10CC3]={d='r'}, - [0x10CC4]={d='r'}, - [0x10CC5]={d='r'}, - [0x10CC6]={d='r'}, - [0x10CC7]={d='r'}, - [0x10CC8]={d='r'}, - [0x10CC9]={d='r'}, - [0x10CCA]={d='r'}, - [0x10CCB]={d='r'}, - [0x10CCC]={d='r'}, - [0x10CCD]={d='r'}, - [0x10CCE]={d='r'}, - [0x10CCF]={d='r'}, - [0x10CD0]={d='r'}, - [0x10CD1]={d='r'}, - [0x10CD2]={d='r'}, - [0x10CD3]={d='r'}, - [0x10CD4]={d='r'}, - [0x10CD5]={d='r'}, - [0x10CD6]={d='r'}, - [0x10CD7]={d='r'}, - [0x10CD8]={d='r'}, - [0x10CD9]={d='r'}, - [0x10CDA]={d='r'}, - [0x10CDB]={d='r'}, - [0x10CDC]={d='r'}, - [0x10CDD]={d='r'}, - [0x10CDE]={d='r'}, - [0x10CDF]={d='r'}, - [0x10CE0]={d='r'}, - [0x10CE1]={d='r'}, - [0x10CE2]={d='r'}, - [0x10CE3]={d='r'}, - [0x10CE4]={d='r'}, - [0x10CE5]={d='r'}, - [0x10CE6]={d='r'}, - [0x10CE7]={d='r'}, - [0x10CE8]={d='r'}, - [0x10CE9]={d='r'}, - [0x10CEA]={d='r'}, - [0x10CEB]={d='r'}, - [0x10CEC]={d='r'}, - [0x10CED]={d='r'}, - [0x10CEE]={d='r'}, - [0x10CEF]={d='r'}, - [0x10CF0]={d='r'}, - [0x10CF1]={d='r'}, - [0x10CF2]={d='r'}, - [0x10CFA]={d='r'}, - [0x10CFB]={d='r'}, - [0x10CFC]={d='r'}, - [0x10CFD]={d='r'}, - [0x10CFE]={d='r'}, - [0x10CFF]={d='r'}, [0x10E60]={d='an'}, [0x10E61]={d='an'}, [0x10E62]={d='an'}, @@ -22365,147 +22748,6 @@ Babel.characters = { [0x1E948]={d='nsm'}, [0x1E949]={d='nsm'}, [0x1E94A]={d='nsm'}, - [0x1EE00]={d='al'}, - [0x1EE01]={d='al'}, - [0x1EE02]={d='al'}, - [0x1EE03]={d='al'}, - [0x1EE05]={d='al'}, - [0x1EE06]={d='al'}, - [0x1EE07]={d='al'}, - [0x1EE08]={d='al'}, - [0x1EE09]={d='al'}, - [0x1EE0A]={d='al'}, - [0x1EE0B]={d='al'}, - [0x1EE0C]={d='al'}, - [0x1EE0D]={d='al'}, - [0x1EE0E]={d='al'}, - [0x1EE0F]={d='al'}, - [0x1EE10]={d='al'}, - [0x1EE11]={d='al'}, - [0x1EE12]={d='al'}, - [0x1EE13]={d='al'}, - [0x1EE14]={d='al'}, - [0x1EE15]={d='al'}, - [0x1EE16]={d='al'}, - [0x1EE17]={d='al'}, - [0x1EE18]={d='al'}, - [0x1EE19]={d='al'}, - [0x1EE1A]={d='al'}, - [0x1EE1B]={d='al'}, - [0x1EE1C]={d='al'}, - [0x1EE1D]={d='al'}, - [0x1EE1E]={d='al'}, - [0x1EE1F]={d='al'}, - [0x1EE21]={d='al'}, - [0x1EE22]={d='al'}, - [0x1EE24]={d='al'}, - [0x1EE27]={d='al'}, - [0x1EE29]={d='al'}, - [0x1EE2A]={d='al'}, - [0x1EE2B]={d='al'}, - [0x1EE2C]={d='al'}, - [0x1EE2D]={d='al'}, - [0x1EE2E]={d='al'}, - [0x1EE2F]={d='al'}, - [0x1EE30]={d='al'}, - [0x1EE31]={d='al'}, - [0x1EE32]={d='al'}, - [0x1EE34]={d='al'}, - [0x1EE35]={d='al'}, - [0x1EE36]={d='al'}, - [0x1EE37]={d='al'}, - [0x1EE39]={d='al'}, - [0x1EE3B]={d='al'}, - [0x1EE42]={d='al'}, - [0x1EE47]={d='al'}, - [0x1EE49]={d='al'}, - [0x1EE4B]={d='al'}, - [0x1EE4D]={d='al'}, - [0x1EE4E]={d='al'}, - [0x1EE4F]={d='al'}, - [0x1EE51]={d='al'}, - [0x1EE52]={d='al'}, - [0x1EE54]={d='al'}, - [0x1EE57]={d='al'}, - [0x1EE59]={d='al'}, - [0x1EE5B]={d='al'}, - [0x1EE5D]={d='al'}, - [0x1EE5F]={d='al'}, - [0x1EE61]={d='al'}, - [0x1EE62]={d='al'}, - [0x1EE64]={d='al'}, - [0x1EE67]={d='al'}, - [0x1EE68]={d='al'}, - [0x1EE69]={d='al'}, - [0x1EE6A]={d='al'}, - [0x1EE6C]={d='al'}, - [0x1EE6D]={d='al'}, - [0x1EE6E]={d='al'}, - [0x1EE6F]={d='al'}, - [0x1EE70]={d='al'}, - [0x1EE71]={d='al'}, - [0x1EE72]={d='al'}, - [0x1EE74]={d='al'}, - [0x1EE75]={d='al'}, - [0x1EE76]={d='al'}, - [0x1EE77]={d='al'}, - [0x1EE79]={d='al'}, - [0x1EE7A]={d='al'}, - [0x1EE7B]={d='al'}, - [0x1EE7C]={d='al'}, - [0x1EE7E]={d='al'}, - [0x1EE80]={d='al'}, - [0x1EE81]={d='al'}, - [0x1EE82]={d='al'}, - [0x1EE83]={d='al'}, - [0x1EE84]={d='al'}, - [0x1EE85]={d='al'}, - [0x1EE86]={d='al'}, - [0x1EE87]={d='al'}, - [0x1EE88]={d='al'}, - [0x1EE89]={d='al'}, - [0x1EE8B]={d='al'}, - [0x1EE8C]={d='al'}, - [0x1EE8D]={d='al'}, - [0x1EE8E]={d='al'}, - [0x1EE8F]={d='al'}, - [0x1EE90]={d='al'}, - [0x1EE91]={d='al'}, - [0x1EE92]={d='al'}, - [0x1EE93]={d='al'}, - [0x1EE94]={d='al'}, - [0x1EE95]={d='al'}, - [0x1EE96]={d='al'}, - [0x1EE97]={d='al'}, - [0x1EE98]={d='al'}, - [0x1EE99]={d='al'}, - [0x1EE9A]={d='al'}, - [0x1EE9B]={d='al'}, - [0x1EEA1]={d='al'}, - [0x1EEA2]={d='al'}, - [0x1EEA3]={d='al'}, - [0x1EEA5]={d='al'}, - [0x1EEA6]={d='al'}, - [0x1EEA7]={d='al'}, - [0x1EEA8]={d='al'}, - [0x1EEA9]={d='al'}, - [0x1EEAB]={d='al'}, - [0x1EEAC]={d='al'}, - [0x1EEAD]={d='al'}, - [0x1EEAE]={d='al'}, - [0x1EEAF]={d='al'}, - [0x1EEB0]={d='al'}, - [0x1EEB1]={d='al'}, - [0x1EEB2]={d='al'}, - [0x1EEB3]={d='al'}, - [0x1EEB4]={d='al'}, - [0x1EEB5]={d='al'}, - [0x1EEB6]={d='al'}, - [0x1EEB7]={d='al'}, - [0x1EEB8]={d='al'}, - [0x1EEB9]={d='al'}, - [0x1EEBA]={d='al'}, - [0x1EEBB]={d='al'}, [0x1EEF0]={d='on'}, [0x1EEF1]={d='on'}, [0x1F000]={d='on'}, @@ -22895,8 +23137,6 @@ Babel.characters = { % % \begin{macrocode} %<*basic-r> -Babel = Babel or {} - Babel.bidi_enabled = true require('babel-data-bidi.lua') @@ -22907,7 +23147,7 @@ local ranges = Babel.ranges local DIR = node.id("dir") local function dir_mark(head, from, to, outer) - dir = (outer == 'r') and 'TLT' or 'TRT' -- ie, reverse + dir = (outer == 'r') and 'TLT' or 'TRT' -- i.e., reverse local d = node.new(DIR) d.dir = '+' .. dir node.insert_before(head, from, d) @@ -22970,13 +23210,13 @@ function Babel.bidi(head, ispar) if inmath then dir = ('TRT' == tex.mathdir) and 'r' or 'l' end % \end{macrocode} % -% Next is based on the assumption babel sets the language AND -% switches the script with its dir. We treat a language block as -% a separate Unicode sequence. The following piece of code is -% executed at the first glyph after a `dir' node. We don't know -% the current language until then. This is not exactly true, as -% the math mode may insert explicit dirs in the node list, so, for -% the moment there is a hack by brute force (just above). +% Next is based on the assumption \babel{} sets the language +% \textit{and} switches the script with its dir. We treat a language +% block as a separate Unicode sequence. The following piece of code is +% executed at the first glyph after a `dir' node. We don't know the +% current language until then. This is not exactly true, as the math +% mode may insert explicit dirs in the node list, so, for the moment +% there is a hack by brute force (just above). % % \begin{macrocode} if new_dir then @@ -23038,7 +23278,7 @@ function Babel.bidi(head, ispar) % Numbers in R mode. A sequence of <en>, <et>, <an>, <es> and <cs> is % typeset (with some rules) in L mode. We store the starting and % ending points, and only when anything different is found (including -% nil, ie, a non-char), the textdir is set. This means you cannot +% nil, i.e., a non-char), the textdir is set. This means you cannot % insert, say, a whatsit, but this is what I would expect (with % \textsf{luacolor} you may colorize some digits). Anyway, this % behavior could be changed with a switch in the future. Note in the @@ -23085,7 +23325,7 @@ function Babel.bidi(head, ispar) elseif first_d and dir ~= strong_lr then dir_mark(head, first_d, last_d, outer) first_d, last_d = nil, nil - end + end end % \end{macrocode} % @@ -23094,10 +23334,8 @@ function Babel.bidi(head, ispar) % clearly <r> and <l>, resptly, but with other combinations depends on % outer. From all these, we select only those resolving <on> $\to$ % <r>. At the beginning (when |last_lr| is nil) of an R text, they are -% mirrored directly. -% -% TODO - numbers in R mode are processed. It doesn't hurt, but should -% not be done. +% mirrored directly. Numbers in R mode are processed. It should not be +% done, but it doesn't hurt. % % \begin{macrocode} if dir and not last_lr and dir ~= 'l' and outer == 'r' then @@ -23163,9 +23401,7 @@ end % % \begin{macrocode} %<*basic> -Babel = Babel or {} - --- eg, Babel.fontmap[1][<prefontid>]=<dirfontid> +-- e.g., Babel.fontmap[1][<prefontid>]=<dirfontid> Babel.fontmap = Babel.fontmap or {} Babel.fontmap[0] = {} -- l @@ -23193,7 +23429,7 @@ local GLYPH = node.id('glyph') local function insert_implicit(head, state, outer) local new_state = state if state.sim and state.eim and state.sim ~= state.eim then - dir = ((outer == 'r') and 'TLT' or 'TRT') -- ie, reverse + dir = ((outer == 'r') and 'TLT' or 'TRT') -- i.e., reverse local d = node.new(DIR) d.dir = '+' .. dir node.insert_before(head, state.sim, d) @@ -23232,7 +23468,7 @@ end -- TODO - \hbox with an explicit dir can lead to wrong results -- <R \hbox dir TLT{<R>}> and <L \hbox dir TRT{<L>}>. A small attempt --- was s made to improve the situation, but the problem is the 3-dir +-- was made to improve the situation, but the problem is the 3-dir -- model in babel/Unicode and the 2-dir model in LuaTeX don't fit -- well. @@ -23254,6 +23490,7 @@ function Babel.bidi(head, ispar, hdir) local has_hyperlink = false local ATDIR = Babel.attr_dir + local attr_d local save_outer local temp = node.get_attribute(head, ATDIR) @@ -23288,6 +23525,8 @@ function Babel.bidi(head, ispar, hdir) if glyph_not_symbol_font(item) or (item.id == 7 and item.subtype == 2) then + if node.get_attribute(item, ATDIR) == 128 then goto nextnode end + local d_font = nil local item_r if item.id == 7 and item.subtype == 2 then @@ -23295,6 +23534,7 @@ function Babel.bidi(head, ispar, hdir) else item_r = item end + local chardata = characters[item_r.char] d = chardata and chardata.d or nil if not d or d == 'nsm' then @@ -23365,7 +23605,7 @@ function Babel.bidi(head, ispar, hdir) d = nil elseif item.id == node.id'math' then - inmath = (item.subtype == 0) + inmath = (item.subtype == 0) elseif item.id == 8 and item.subtype == 19 then has_hyperlink = true @@ -23422,6 +23662,7 @@ function Babel.bidi(head, ispar, hdir) -- Force mathdir in math if ON (currently works as expected only -- with 'l') + if inmath and d == 'on' then d = ('TRT' == tex.mathdir) and 'r' or 'l' end @@ -23437,9 +23678,12 @@ function Babel.bidi(head, ispar, hdir) table.insert(nodes, {item, d, outer_first}) end + node.set_attribute(item, ATDIR, 128) outer_first = nil - end + ::nextnode:: + + end -- for each node -- TODO -- repeated here in case EN/ET is the last node. Find a -- better way of doing things: @@ -23569,9 +23813,16 @@ function Babel.bidi(head, ispar, hdir) end head = node.prev(head) or head - - -------------- FIX HYPERLINKS ---------------- - +% \end{macrocode} +% +% Now direction nodes has been distributed with relation to characters +% and spaces, we need to take into account \TeX\-specific elements in +% the node list, to move them at an appropriate place. Firstly, with +% hyperlinks. Secondly, we avoid them between penalties and spaces, so +% that the latter are still discardable. +% +% \begin{macrocode} + --- FIXES --- if has_hyperlink then local flag, linking = 0, 0 for item in node.traverse(head) do @@ -23598,6 +23849,28 @@ function Babel.bidi(head, ispar, hdir) end end + for item in node.traverse_id(10, head) do + local p = item + local flag = false + while p.prev and p.prev.id == 14 do + flag = true + p = p.prev + end + if flag then + node.insert_before(head, p, node.copy(item)) + node.remove(head,item) + end + end + + return head +end +-- Make sure anything is marked as 'bidi done' (including nodes inserted +-- after the babel algorithm). 128 = 1000 0000. +function Babel.unset_atdir(head) + local ATDIR = Babel.attr_dir + for item in node.traverse(head) do + node.set_attribute(item, ATDIR, 128) + end return head end %</basic> @@ -23620,14 +23893,12 @@ end %\iffalse % \begin{macrocode} %<*cjkdata> -Babel = Babel or {} - Babel.cjk_characters = { [0x0021]={c='ex'}, - [0x0022]={c='qu'}, + [0x0022]={c='qu'}, [0x0024]={c='pr'}, [0x0025]={c='po'}, - [0x0027]={c='qu'}, + [0x0027]={c='qu'}, [0x0028]={c='op'}, [0x0029]={c='cp'}, [0x002B]={c='pr'}, @@ -23648,18 +23919,18 @@ Babel.cjk_characters = { [0x00A3]={c='pr'}, [0x00A4]={c='pr'}, [0x00A5]={c='pr'}, - [0x00AB]={c='qu'}, + [0x00AB]={c='qu'}, [0x00B0]={c='po'}, [0x00B1]={c='pr'}, - [0x00BB]={c='qu'}, - [0x2018]={c='qu'}, - [0x2019]={c='qu'}, + [0x00BB]={c='qu'}, + [0x2018]={c='qu'}, + [0x2019]={c='qu'}, [0x201A]={c='op'}, - [0x201B]={c='qu'}, - [0x201C]={c='qu'}, - [0x201D]={c='qu'}, + [0x201B]={c='qu'}, + [0x201C]={c='qu'}, + [0x201D]={c='qu'}, [0x201E]={c='op'}, - [0x201F]={c='qu'}, + [0x201F]={c='qu'}, [0x2024]={c='in'}, [0x2025]={c='in'}, [0x2026]={c='in'}, @@ -23671,8 +23942,8 @@ Babel.cjk_characters = { [0x2035]={c='po'}, [0x2036]={c='po'}, [0x2037]={c='po'}, - [0x2039]={c='qu'}, - [0x203A]={c='qu'}, + [0x2039]={c='qu'}, + [0x203A]={c='qu'}, [0x203C]={c='ns'}, [0x203D]={c='ns'}, [0x2044]={c='is'}, @@ -23731,22 +24002,22 @@ Babel.cjk_characters = { [0x29FD]={c='cl'}, [0x2CF9]={c='ex'}, [0x2CFE]={c='ex'}, - [0x2E02]={c='qu'}, - [0x2E03]={c='qu'}, - [0x2E04]={c='qu'}, - [0x2E05]={c='qu'}, - [0x2E06]={c='qu'}, - [0x2E07]={c='qu'}, - [0x2E08]={c='qu'}, - [0x2E09]={c='qu'}, - [0x2E0A]={c='qu'}, - [0x2E0B]={c='qu'}, - [0x2E0C]={c='qu'}, - [0x2E0D]={c='qu'}, + [0x2E02]={c='qu'}, + [0x2E03]={c='qu'}, + [0x2E04]={c='qu'}, + [0x2E05]={c='qu'}, + [0x2E06]={c='qu'}, + [0x2E07]={c='qu'}, + [0x2E08]={c='qu'}, + [0x2E09]={c='qu'}, + [0x2E0A]={c='qu'}, + [0x2E0B]={c='qu'}, + [0x2E0C]={c='qu'}, + [0x2E0D]={c='qu'}, [0x2E18]={c='op'}, - [0x2E1C]={c='qu'}, - [0x2E1D]={c='qu'}, - [0x2E20]={c='qu'}, + [0x2E1C]={c='qu'}, + [0x2E1D]={c='qu'}, + [0x2E20]={c='qu'}, [0x2E21]={c='qu'}, [0x2E22]={c='op'}, [0x2E23]={c='cl'}, @@ -23783,14 +24054,39 @@ Babel.cjk_characters = { [0x301D]={c='op'}, [0x301E]={c='cl'}, [0x301F]={c='cl'}, + [0x3043]={c='cj'}, + [0x3045]={c='cj'}, + [0x3047]={c='cj'}, + [0x3049]={c='cj'}, + [0x3063]={c='cj'}, + [0x3083]={c='cj'}, + [0x3085]={c='cj'}, + [0x3087]={c='cj'}, + [0x308E]={c='cj'}, + [0x3095]={c='cj'}, + [0x3096]={c='cj'}, [0x303B]={c='ns'}, [0x303C]={c='ns'}, + [0x3041]={c='cj'}, [0x309B]={c='ns'}, [0x309C]={c='ns'}, [0x309D]={c='ns'}, [0x309E]={c='ns'}, [0x30A0]={c='ns'}, + [0x30A1]={c='cj'}, + [0x30A3]={c='cj'}, + [0x30A5]={c='cj'}, + [0x30A7]={c='cj'}, + [0x30A9]={c='cj'}, + [0x30C3]={c='cj'}, + [0x30E3]={c='cj'}, + [0x30E5]={c='cj'}, + [0x30E7]={c='cj'}, + [0x30EE]={c='cj'}, + [0x30F5]={c='cj'}, + [0x30F6]={c='cj'}, [0x30FB]={c='ns'}, + [0x30FC]={c='cj'}, [0x30FD]={c='ns'}, [0x30FE]={c='ns'}, [0xA015]={c='ns'}, @@ -23860,25 +24156,33 @@ Babel.cjk_characters = { [0xFF61]={c='cl', w='h'}, [0xFF62]={c='op', w='h'}, [0xFF63]={c='cl', w='h'}, - [0xFF64]={c='cl', w='h'} + [0xFF64]={c='cl', w='h'}, + [0xFF70]={c='cj'} } Babel.cjk_class = setmetatable ( Babel.cjk_characters, { __index = function(_, k) if (k >= 0xAC00 and k <= 0xD7A3) -- H2/H3 - or (k >= 0x2E80 and k <= 0x9FFF) + or (k >= 0x2E80 and k <= 0x31E9) -- Skip small + or (k >= 0x3200 and k <= 0x9FFF) or (k >= 0xA000 and k <= 0xA48F) -- Yi or (k >= 0xA490 and k <= 0xA4CF) -- Yi or (k >= 0xF900 and k <= 0xFAFF) or (k >= 0xFE10 and k <= 0xFE1F) or (k >= 0xFE30 and k <= 0xFE6F) - or (k >= 0xFF00 and k <= 0xFFEF) + or (k >= 0xFF00 and k <= 0xFF66) -- Skip small + or (k >= 0xFF70 and k <= 0xFFEF) or (k >= 0x1F000 and k <= 0x1FFFD) or (k >= 0x20000 and k <= 0x2FFFD) or (k >= 0x30000 and k <= 0x3FFFD) then return {c='I'} elseif (k >= 0x20A0 and k <= 0x20CF) then return {c='pr'} + elseif (k >= 0x31F0 and k <= 0x31FF) + or (k >= 0xFF67 and k <= 0xFF6F) + or (k >= 0x1B150 and k <= 0x1B152) + or (k >= 0x1B164 and k <= 0x1B167) then + return {c='cj'} else return {c='O'} end @@ -23911,15 +24215,13 @@ Babel.cjk_breaks = { % % \section{The `nil' language} % -% This `language' does nothing, except setting the hyphenation patterns to -% nohyphenation. +% This `language' does nothing, except setting the hyphenation patterns +% to nohyphenation. For this language currently no special definitions +% are needed or available. % -% For this language currently no special definitions are needed or -% available. -% -% The macro |\LdfInit| takes care of preventing that this file is -% loaded more than once, checking the category code of the -% \texttt{@} sign, etc. +% The macro |\LdfInit| takes care of preventing that this file is +% loaded more than once, checking the category code of the \texttt{@} +% sign, etc. % % \begin{macrocode} %<*nil> @@ -23927,9 +24229,9 @@ Babel.cjk_breaks = { \LdfInit{nil}{datenil} % \end{macrocode} % -% When this file is read as an option, i.e. by the |\usepackage| -% command, \texttt{nil} could be an `unknown' language in which -% case we have to make it known. +% When this file is read as an option, i.e., by the |\usepackage| +% command, \texttt{nil} could be an `unknown' language in which case we +% have to make it known. % % \begin{macrocode} \ifx\l@nil\@undefined @@ -23941,26 +24243,23 @@ Babel.cjk_breaks = { \fi % \end{macrocode} % -% This macro is used to store the values of the hyphenation -% parameters |\lefthyphenmin| and |\righthyphenmin|. +% This macro is used to store the values of the hyphenation parameters +% |\lefthyphenmin| and |\righthyphenmin|. % % \begin{macrocode} \providehyphenmins{\CurrentOption}{\m@ne\m@ne} % \end{macrocode} % -% The next step consists of defining commands to switch to (and -% from) the `nil' language. -% \begin{macro}{\captionnil} -% \begin{macro}{\datenil} +% The next step consists of defining commands to switch to (and from) +% the `nil' language. +% \macro{\captionnil} +% \macro{\datenil} % % \begin{macrocode} \let\captionsnil\@empty \let\datenil\@empty % \end{macrocode} % -% \end{macro} -% \end{macro} -% % There is no locale file for this pseudo-language, so the % corresponding fields are defined here. % @@ -23995,10 +24294,10 @@ Babel.cjk_breaks = { \@namedef{bbl@sotf@nil}{latn} % \end{macrocode} % -% The macro |\ldf@finish| takes care of looking for a -% configuration file, setting the main language to be switched on -% at |\begin{document}| and resetting the category code of -% \texttt{@} to its original value. +% The macro |\ldf@finish| takes care of looking for a configuration +% file, setting the main language to be switched on at +% |\begin{document}| and resetting the category code of \texttt{@} to +% its original value. % % \begin{macrocode} \ldf@finish{nil} @@ -24306,7 +24605,7 @@ Babel.cjk_breaks = { #2=\bbl@cntcommon} \def\bbl@hebrdayspriormonths#1#2#3{% {\countdef\tmpf= 14 - #3=\ifcase #1\relax + #3=\ifcase #1 0 \or 0 \or 30 \or @@ -24488,7 +24787,7 @@ Babel.cjk_breaks = { %</ca-buddhist> % % \subsection{Chinese} -% +% % Brute force, with the Julian day of first day of each month. The % table has been computed with the help of \textsf{python-lunardate} by % Ricky Yeung, GPLv2 (but the code itself has not been used). The range @@ -24498,7 +24797,7 @@ Babel.cjk_breaks = { %<*ca-chinese> \ExplSyntaxOn <@Compute Julian day@> -\def\bbl@ca@chinese#1-#2-#3\@@#4#5#6{% +\def\bbl@ca@chinese#1-#2-#3\@@#4#5#6{% \edef\bbl@tempd{\fp_eval:n{% \bbl@cs@jd{#1}{#2}{#3} - 2457072.5 }}% \count@\z@ @@ -24677,7 +24976,7 @@ Babel.cjk_breaks = { % % \subsection{General tools} % -% A number of \LaTeX\ macro's that are needed later on. +% A number of \LaTeX\ macro's that are needed later on. % % \begin{macrocode} \long\def\@firstofone#1{#1} @@ -24752,8 +25051,8 @@ Babel.cjk_breaks = { \@onlypreamble\@onlypreamble % \end{macrocode} % -% Mimic \LaTeX's |\AtBeginDocument|; for this to work the user -% needs to add |\begindocument| to his file. +% Mimic \LaTeX's |\AtBeginDocument|; for this to work the user needs to +% add |\begindocument| to his file. % % \begin{macrocode} \def\begindocument{% @@ -24772,9 +25071,8 @@ Babel.cjk_breaks = { \def\AtBeginDocument{\g@addto@macro\@begindocumenthook} % \end{macrocode} % -% We also have to mimic \LaTeX's |\AtEndOfPackage|. Our -% replacement macro is much simpler; it stores its argument in -% |\@endofldf|. +% We also have to mimic \LaTeX's |\AtEndOfPackage|. Our replacement +% macro is much simpler; it stores its argument in |\@endofldf|. % % \begin{macrocode} \def\AtEndOfPackage#1{\g@addto@macro\@endofldf{#1}} @@ -24785,10 +25083,10 @@ Babel.cjk_breaks = { \chardef\bbl@opt@hyphenmap\z@ % \end{macrocode} % -% \LaTeX\ needs to be able to switch off writing to its auxiliary -% files; plain doesn't have them by default. There is a trick to -% hide some conditional commands from the outer |\ifx|. The same -% trick is applied below. +% \LaTeX\ needs to be able to switch off writing to its auxiliary +% files; plain doesn't have them by default. There is a trick to hide +% some conditional commands from the outer |\ifx|. The same trick is +% applied below. % % \begin{macrocode} \catcode`\&=\z@ @@ -24799,7 +25097,7 @@ Babel.cjk_breaks = { \catcode`\&=4 % \end{macrocode} % -% Mimic \LaTeX's commands to define control sequences. +% Mimic \LaTeX's commands to define control sequences. % % \begin{macrocode} \def\newcommand{\@star@or@long\new@command} @@ -24867,11 +25165,11 @@ Babel.cjk_breaks = { \def\@x@protect#1&fi#2#3{&fi\protect#1} % \end{macrocode} % -% The following little macro |\in@| is taken from \file{latex.ltx}; -% it checks whether its first argument is part of its second -% argument. It uses the boolean |\in@|; allocating a new boolean -% inside conditionally executed code is not possible, hence the -% construct with the temporary definition of |\bbl@tempa|. +% The following little macro |\in@| is taken from \file{latex.ltx}; it +% checks whether its first argument is part of its second argument. It +% uses the boolean |\in@|; allocating a new boolean inside +% conditionally executed code is not possible, hence the construct with +% the temporary definition of |\bbl@tempa|. % % \begin{macrocode} \def\bbl@tempa{\csname newif\endcsname&ifin@} @@ -24887,32 +25185,31 @@ Babel.cjk_breaks = { \bbl@tempa % \end{macrocode} % -% \LaTeX\ has a macro to check whether a certain package was loaded -% with specific options. The command has two extra arguments which -% are code to be executed in either the true or false case. -% This is used to detect whether the document needs one of the -% accents to be activated (\Lopt{activegrave} and -% \Lopt{activeacute}). For plain \TeX\ we assume that the user -% wants them to be active by default. Therefore the only thing we -% do is execute the third argument (the code for the true case). +% \LaTeX\ has a macro to check whether a certain package was loaded +% with specific options. The command has two extra arguments which are +% code to be executed in either the true or false case. This is used to +% detect whether the document needs one of the accents to be activated +% (\Lopt{activegrave} and \Lopt{activeacute}). For plain \TeX\ we +% assume that the user wants them to be active by default. Therefore +% the only thing we do is execute the third argument (the code for the +% true case). % % \begin{macrocode} \def\@ifpackagewith#1#2#3#4{#3} % \end{macrocode} % -% The \LaTeX\ macro |\@ifl@aded| checks whether a file was -% loaded. This functionality is not needed for plain \TeX\ but we -% need the macro to be defined as a no-op. +% The \LaTeX\ macro |\@ifl@aded| checks whether a file was loaded. This +% functionality is not needed for plain \TeX\ but we need the macro to +% be defined as a no-op. % % \begin{macrocode} \def\@ifl@aded#1#2#3#4{} % \end{macrocode} % -% For the following code we need to make sure that the commands -% |\newcommand| and |\providecommand| exist with some sensible -% definition. They are not fully equivalent to their \LaTeXe\ -% versions; just enough to make things work in plain~\TeX -% environments. +% For the following code we need to make sure that the commands +% |\newcommand| and |\providecommand| exist with some sensible +% definition. They are not fully equivalent to their \LaTeXe\ versions; +% just enough to make things work in plain~\TeX environments. % % \begin{macrocode} \ifx\@tempcnta\@undefined @@ -24923,9 +25220,9 @@ Babel.cjk_breaks = { \fi % \end{macrocode} % -% To prevent wasting two counters in \LaTeX\ (because -% counters with the same name are allocated later by it) we reset -% the counter that holds the next free counter (|\count10|). +% To prevent wasting two counters in \LaTeX\ (because counters with the +% same name are allocated later by it) we reset the counter that holds +% the next free counter (|\count10|). % % \begin{macrocode} \ifx\bye\@undefined @@ -24966,8 +25263,8 @@ Babel.cjk_breaks = { % % \subsection{Encoding related macros} % -% Code from \file{ltoutenc.dtx}, adapted for use in the plain \TeX\ -% environment. +% Code from \file{ltoutenc.dtx}, adapted for use in the plain \TeX\ +% environment. % % \begin{macrocode} \def\DeclareTextCommand{% @@ -25090,9 +25387,8 @@ Babel.cjk_breaks = { \def\cf@encoding{OT1} % \end{macrocode} % -% Currently we only use the \LaTeXe\ method for accents for those -% that are known to be made active in \emph{some} language -% definition file. +% Currently we only use the \LaTeXe\ method for accents for those that +% are known to be made active in \emph{some} language definition file. % % \begin{macrocode} \DeclareTextAccent{\"}{OT1}{127} @@ -25102,8 +25398,8 @@ Babel.cjk_breaks = { \DeclareTextAccent{\~}{OT1}{126} % \end{macrocode} % -% The following control sequences are used in \file{babel.def} -% but are not defined for \textsc{plain} \TeX. +% The following control sequences are used in \file{babel.def} but are +% not defined for \textsc{plain} \TeX. % % \begin{macrocode} \DeclareTextSymbol{\textquotedblleft}{OT1}{92} @@ -25125,7 +25421,7 @@ Babel.cjk_breaks = { \fi % \end{macrocode} % -% And a few more “dummy” definitions. +% And a few more “dummy” definitions. % % \begin{macrocode} \def\languagename{english}% @@ -25162,7 +25458,6 @@ Babel.cjk_breaks = { \input babel.def %</plain> % \end{macrocode} -% % \Finale % \endinput diff --git a/macros/latex/required/babel/base/babel.ins b/macros/latex/required/babel/base/babel.ins index 9c640a94cb..ac7b809ba4 100644 --- a/macros/latex/required/babel/base/babel.ins +++ b/macros/latex/required/babel/base/babel.ins @@ -3,7 +3,7 @@ %% driver files from the doc files in this package when run through %% LaTeX or TeX. %% -%% Copyright 2012-2024 Javier Bezos and Johannes L. Braams. +%% Copyright 2012-2025 Javier Bezos and Johannes L. Braams. %% Copyright 1989-2008 Johannes L. Braams and any individual authors %% listed elsewhere in this file. All rights reserved. %% @@ -26,7 +26,7 @@ %% and covered by LPPL is defined by the unpacking scripts (with %% extension .ins) which are part of the distribution. %% -\def\filedate{2024/06/26} +\def\filedate{2025/02/14} \def\batchfile{babel.ins} \input docstrip.tex @@ -105,32 +105,6 @@ \expandafter\gdef\csname #1Var\endcsname{#2}% \fi} -% The following is somewhat hackish, but it does the job for babel, and -% must be used in the following way: <-name> starts a block to be -% ignored if 'name' is active, and <+name> ends the block (in this -% order). Used to exclude some parts from babel.def. With the original -% definitions, some code goes 'visually' in comments/documentation, but -% with this change they are in the real code. However, it must be -% considered temporal, because the solution must be to reorganize the -% code. - -\let\bblMinus\minusOption -\def\minusOption-#1>#2\endLine{% - \global\let\bblactivefiles\activefiles - \def\tempa{}% - \def\do##1##2##3{% - \def\tempb{#1}\def\tempc{##2}% - \ifx\tempb\tempc\else - \expandafter\def\expandafter\tempa\expandafter{% - \tempa\do##1{##2}##3}% - \fi}% - \activefiles - \let\activefiles\tempa} - -\let\bblPlus\plusOption -\def\plusOption+#1>#2\endLine{% - \let\activefiles\bblactivefiles} - % Preambles \declarepreamble\mainpreamble @@ -179,11 +153,27 @@ \file{bplain.tex}{\from{babel.dtx}{bplain}} \file{blplain.tex}{\from{babel.dtx}{blplain}} } + +% MakeIndex style files + +\usedir{makeindex/babel} -% compatibility files +\generate{\file{bbind.ist}{\from{bbidxglo.dtx}{idx}} + \file{bbglo.ist}{\from{bbidxglo.dtx}{glo}}} + +% lua code + +\def\MetaPrefix{--} +\usepreamble\luapreamble +\nopostamble +\generate{\file{babel-transforms.lua}{\from{babel.dtx}{transforms}}} +\generate{\file{babel-data-bidi.lua}{\from{babel.dtx}{bididata}}} +\generate{\file{babel-data-cjk.lua}{\from{babel.dtx}{cjkdata}}} +\generate{\file{babel-bidi-basic-r.lua}{\from{babel.dtx}{basic-r}}} +\generate{\file{babel-bidi-basic.lua}{\from{babel.dtx}{basic}}} + +% Compatibility files -\let\minusOption\bblMinus -\let\plusOption\bblPlus \def\compatfile#1{\file{#1.sty}{\from{bbcompat.dtx}{styfile,#1}}} \generate{% @@ -246,23 +236,6 @@ \compatfile{bahasam} } -% MakeIndex style files - -\usedir{makeindex/babel} - -\generate{\file{bbind.ist}{\from{bbidxglo.dtx}{idx}} - \file{bbglo.ist}{\from{bbidxglo.dtx}{glo}}} - -% lua code - -\def\MetaPrefix{--} -\usepreamble\luapreamble -\nopostamble -\generate{\file{babel-transforms.lua}{\from{babel.dtx}{transforms}}} -\generate{\file{babel-data-bidi.lua}{\from{babel.dtx}{bididata}}} -\generate{\file{babel-data-cjk.lua}{\from{babel.dtx}{cjkdata}}} -\generate{\file{babel-bidi-basic-r.lua}{\from{babel.dtx}{basic-r}}} -\generate{\file{babel-bidi-basic.lua}{\from{babel.dtx}{basic}}} \Msg{***********************************************************} \Msg{*} diff --git a/macros/latex/required/babel/base/babel.pdf b/macros/latex/required/babel/base/babel.pdf Binary files differindex 8d3e32fbc8..2e51c65464 100644 --- a/macros/latex/required/babel/base/babel.pdf +++ b/macros/latex/required/babel/base/babel.pdf diff --git a/macros/latex/required/babel/base/bbcompat.dtx b/macros/latex/required/babel/base/bbcompat.dtx index d88b690b23..67e666e83a 100644 --- a/macros/latex/required/babel/base/bbcompat.dtx +++ b/macros/latex/required/babel/base/bbcompat.dtx @@ -30,7 +30,7 @@ % % \iffalse %<*dtx> -\ProvidesFile{bbcompat.dtx}[2024/06/26 v24.7] +\ProvidesFile{bbcompat.dtx}[2025/02/14 v25.4] %</dtx> % %% File 'bbcompat.dtx' diff --git a/macros/latex/required/firstaid/changes.txt b/macros/latex/required/firstaid/changes.txt index cbabfcbb72..9df9304805 100644 --- a/macros/latex/required/firstaid/changes.txt +++ b/macros/latex/required/firstaid/changes.txt @@ -1,3 +1,20 @@ +2024-11-24 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + + * latex2e-first-aid-for-external-files.dtx: add iftag@-test to cleveref firstaid for issue #1560 + +2024-11-08 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + + * latex2e-first-aid-for-external-files.dtx: add missing \expandafter for issue #1544 + +2024-11-04 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + + * latex2e-first-aid-for-external-files.dtx: correct spurious space + +2024-10-16 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + + * latex2e-first-aid-for-external-files.dtx: extend firstaid for cleveref + for issue #1393 and longtable. + 2024-06-25 David Carlisle <David.Carlisle@latex-project.org> * latex2e-first-aid-for-external-files.dtx: add firstaid for arydshln diff --git a/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.dtx b/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.dtx index 5615d3f697..650c69fa5b 100644 --- a/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.dtx +++ b/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.dtx @@ -111,8 +111,8 @@ % \end{macrocode} % % \begin{macrocode} -\def\LaTeXFirstAidDate{2024/06/25} -\def\LaTeXFirstAidVersion{v1.1f} +\def\LaTeXFirstAidDate{2024/11/24} +\def\LaTeXFirstAidVersion{v1.1j} % \end{macrocode} % % \begin{macrocode} @@ -343,7 +343,7 @@ % It will be replaced when the ``configuration points'' interface % for \LaTeX{} becomes available. At that point the package will be % able to set up a different strategy for doing shipouts and -% without the need to overrite a primitive (which it did in the +% without the need to overwrite a primitive (which it did in the % past and which we do below) and then this code here can be taken % out again. % \begin{macrocode} @@ -446,7 +446,7 @@ % the classic \TeX{} implementation but with the extended % allocation possibilities of all modern engines is no longer the % case and there is a point where the allocations take a ``jump'' -% breaking the odering assumption. These days we are fairly close +% breaking the ordering assumption. These days we are fairly close % to that point and depending on how many packages are loaded % before \pkg{bigfoot} the package breaks. % @@ -717,6 +717,39 @@ {[\@tempb][\arabic{page}][\cref@result]\thepage}{}{}{}}}% <------- five \@esphack}% } +% \end{macrocode} +% \changes{v1.1g}{2024/10/16}{update cleveref data in label hook} +% cleveref patches and redefines \cs{refstepcounter} so that a call updates its data. +% This fails if like e.g. in \pkg{longtable} the counter is stepped with +% \cs{@kernel@refstepcounter}. We therefore move the data setup into the label hook. +% As the hook is in a group we have to smuggle the data out of it. +% \url{https://tex.stackexchange.com/a/722909/2388} and issue \#1393 +% \begin{macrocode} + \newcommand\firstaid@cref@smugglelabel{\let\cref@currentlabel\cref@gcurrentlabel@temp} + \newcommand\firstaid@cref@updatelabeldata[1]{% + \cref@constructprefix{#1}{\cref@result}% + \@ifundefined{cref@#1@alias}% + {\def\@tempa{#1}}% + {\def\@tempa{\csname cref@#1@alias\endcsname}}% + \protected@xdef\cref@gcurrentlabel@temp{% + [\@tempa][\arabic{#1}][\cref@result]% + \csname p@#1\endcsname\csname the#1\endcsname}% + \aftergroup\firstaid@cref@smugglelabel + } +% \end{macrocode} +% we test if \cs{@currentcounter} is empty for unnumbered sections +% \changes{v1.1h}{2024/11/01}{fix spurious space} +% \changes{v1.1j}{2024/11/24}{add \cs{iftag@} test, issue \#1560} +% \begin{macrocode} + \newif\iftag@ + \AddToHook{label}[firstaid/cleveref] + {\ifx + \@currentcounter\@empty + \else + \iftag@\else + \firstaid@cref@updatelabeldata{\@currentcounter}% + \fi + \fi} }% } % \end{macrocode} diff --git a/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.pdf b/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.pdf Binary files differindex 789de4f3e2..1f2d9c251e 100644 --- a/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.pdf +++ b/macros/latex/required/firstaid/latex2e-first-aid-for-external-files.pdf diff --git a/macros/latex/required/graphics/README.md b/macros/latex/required/graphics/README.md index bcab2e8f31..27ae99fe5a 100644 --- a/macros/latex/required/graphics/README.md +++ b/macros/latex/required/graphics/README.md @@ -1,7 +1,7 @@ The LaTeX `graphics` bundle =========================== -Release 2024-06-01 patch level 0 +Release 2024-11-01 Overview -------- diff --git a/macros/latex/required/graphics/changes.txt b/macros/latex/required/graphics/changes.txt index face90b342..d437358079 100644 --- a/macros/latex/required/graphics/changes.txt +++ b/macros/latex/required/graphics/changes.txt @@ -9,7 +9,16 @@ All changes above are only part of the development branch for the next release. ================================================================================ ######################### -# 2023-11-01 Release +# 2024-11-01 Release +######################### + +2024-06-24 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * color.dtx (section{Extra Groups}): + Support new @endpe mechanism + +######################### +# 2024-06-01 Release ######################### 2024-05-23 Frank Mittelbach <Frank.Mittelbach@latex-project.org> diff --git a/macros/latex/required/graphics/color.dtx b/macros/latex/required/graphics/color.dtx index 130a960d09..b14c148f2f 100644 --- a/macros/latex/required/graphics/color.dtx +++ b/macros/latex/required/graphics/color.dtx @@ -21,7 +21,7 @@ %<driver> \ProvidesFile{color.drv} % \fi % \ProvidesFile{color.dtx} - [2024/01/14 v1.3d Standard LaTeX Color (DPC)] + [2024/06/23 v1.3e Standard LaTeX Color (DPC)] % % \iffalse %<*driver> @@ -877,10 +877,15 @@ % commands. The |\endgraf| in its definition is required in the case % of groups of text in vertical `par' mode, but doesn't do any harm in % horizontal `LR' contexts. +% The |\@endpefalse| is required for the newer \texttt{@endpe} +% handling, again it is harmless if an older kernel is used +% (because there it was a local assignment). % \changes{v0.2d}{1994/05/13} % {New definition, was previously just \cs{endgroup}} +% \changes{v1.3e}{2024/06/23} +% {Support new \texttt{@endpe} mechanism} % \begin{macrocode} -\def\color@endgroup{\endgraf\endgroup} +\def\color@endgroup{\endgraf\@endpefalse\endgroup} % \end{macrocode} % \end{macro} % diff --git a/macros/latex/required/graphics/color.pdf b/macros/latex/required/graphics/color.pdf Binary files differindex 8f4c2e2128..d67d0cff53 100644 --- a/macros/latex/required/graphics/color.pdf +++ b/macros/latex/required/graphics/color.pdf diff --git a/macros/latex/required/graphics/drivers.pdf b/macros/latex/required/graphics/drivers.pdf Binary files differindex d4f9e82581..44ad5cb376 100644 --- a/macros/latex/required/graphics/drivers.pdf +++ b/macros/latex/required/graphics/drivers.pdf diff --git a/macros/latex/required/graphics/epsfig.pdf b/macros/latex/required/graphics/epsfig.pdf Binary files differindex d37c0d912d..352c104fd0 100644 --- a/macros/latex/required/graphics/epsfig.pdf +++ b/macros/latex/required/graphics/epsfig.pdf diff --git a/macros/latex/required/graphics/graphics.dtx b/macros/latex/required/graphics/graphics.dtx index 2392ac09d1..86556ea40a 100644 --- a/macros/latex/required/graphics/graphics.dtx +++ b/macros/latex/required/graphics/graphics.dtx @@ -27,7 +27,7 @@ %<driver> \ProvidesFile{graphics.drv} % \fi % \ProvidesFile{graphics.dtx} - [2024/05/23 v1.4g Standard LaTeX Graphics (DPC,SPQR)] + [2024/08/06 v1.4g Standard LaTeX Graphics (DPC,SPQR)] % % \iffalse %<*driver> @@ -1050,7 +1050,8 @@ % % \begin{macrocode} \edef\Gin@gzext{\detokenize{gz}} -% \edef{macrocode} +% \end{macrocode} +% \end{macro} % \end{macro} % % \begin{macro}{\Gin@set@curr@file} diff --git a/macros/latex/required/graphics/graphics.pdf b/macros/latex/required/graphics/graphics.pdf Binary files differindex f7191c9f48..98722554e9 100644 --- a/macros/latex/required/graphics/graphics.pdf +++ b/macros/latex/required/graphics/graphics.pdf diff --git a/macros/latex/required/graphics/graphicx.pdf b/macros/latex/required/graphics/graphicx.pdf Binary files differindex f33d34a4bd..82c183bca7 100644 --- a/macros/latex/required/graphics/graphicx.pdf +++ b/macros/latex/required/graphics/graphicx.pdf diff --git a/macros/latex/required/graphics/grfguide.pdf b/macros/latex/required/graphics/grfguide.pdf Binary files differindex 8e0bc91ce7..d01c625f72 100644 --- a/macros/latex/required/graphics/grfguide.pdf +++ b/macros/latex/required/graphics/grfguide.pdf diff --git a/macros/latex/required/graphics/keyval.pdf b/macros/latex/required/graphics/keyval.pdf Binary files differindex a53bbf67a3..c2e2eeef47 100644 --- a/macros/latex/required/graphics/keyval.pdf +++ b/macros/latex/required/graphics/keyval.pdf diff --git a/macros/latex/required/graphics/lscape.pdf b/macros/latex/required/graphics/lscape.pdf Binary files differindex 465c1e5ea6..6f3e937971 100644 --- a/macros/latex/required/graphics/lscape.pdf +++ b/macros/latex/required/graphics/lscape.pdf diff --git a/macros/latex/required/graphics/mathcolor.pdf b/macros/latex/required/graphics/mathcolor.pdf Binary files differindex f88db97f8f..92ee1382e7 100644 --- a/macros/latex/required/graphics/mathcolor.pdf +++ b/macros/latex/required/graphics/mathcolor.pdf diff --git a/macros/latex/required/graphics/rotating.pdf b/macros/latex/required/graphics/rotating.pdf Binary files differindex 3acb6b72fc..3305acbe6e 100644 --- a/macros/latex/required/graphics/rotating.pdf +++ b/macros/latex/required/graphics/rotating.pdf diff --git a/macros/latex/required/graphics/rotex.pdf b/macros/latex/required/graphics/rotex.pdf Binary files differindex 8df385137b..bc01792df0 100644 --- a/macros/latex/required/graphics/rotex.pdf +++ b/macros/latex/required/graphics/rotex.pdf diff --git a/macros/latex/required/graphics/trig.pdf b/macros/latex/required/graphics/trig.pdf Binary files differindex b901f23572..7ab4d2e20f 100644 --- a/macros/latex/required/graphics/trig.pdf +++ b/macros/latex/required/graphics/trig.pdf diff --git a/macros/latex/required/l3kernel/CHANGELOG.md b/macros/latex/required/l3kernel/CHANGELOG.md index c58c1a6188..3778678162 100644 --- a/macros/latex/required/l3kernel/CHANGELOG.md +++ b/macros/latex/required/l3kernel/CHANGELOG.md @@ -7,6 +7,110 @@ this project uses date-based 'snapshot' version identifiers. ## [Unreleased] +## [2025-01-18] + +### Changed +- Use a dedicated internal marker for `fp` and `int` expressions, allowing use + with LuaMetaTeX (see \#1518) + +### Fixed +- Missing trailing period in `\tl_analysis_log:(N|n)` output (see \#1663) +- Some state variables weren't correctly reset by `\keys_define:nn` and + `\keys_set:nn` breaking some nested usages in edge cases + +## [2025-01-14] + +### Added +- `\int_step_tokens:nn`, `\int_step_tokens:nnn`, and `\int_step_tokens:nnnn` + +### Fixed +- Check conditionals are defined when creating variants (see \#1189) + +## [2024-12-25] + +### Added +- `\file_forget:n` + +### Changed +- Expand 'value(s)' arg. to `\color_select:nn`, `\color_set:nnn`, etc. (see + \#1640) + +### Fixed +- Initialize color `.` properly (see \#1642) + +## [2024-12-09] + +### Added +- `\bitset_use:N` and `\clist_use:N`: this clarifies that bitsets and clists + can be used with `V`-type expansion +- `\sys_if_engine_opentype:(TF)` +- Add equivalent interfaces for regex functions: + - `\int_(g)set_regex_count:Nnn`, `\int_(g)set_regex_count:NNn` + - `\seq_(g)set_regex_extract_once:Nnn`, `\seq_(g)set_regex_extract_once:NNn` + - `\seq_(g)set_regex_extract_all:Nnn`, `\seq_(g)set_regex_extract_all:NNn` + - `\seq_(g)set_regex_split:Nnn`, `\seq_(g)set_regex_split:NNn` + - `\tl_if_regex_match:nn(TF)`, `\tl_if_regex_match:nN(TF)` + - `\tl_regex_(g)replace_once:Nnn`, `\tl_regex_(g)replace_once:NNn` + - `\tl_regex_(g)replace_all:Nnn`, `\tl_regex_(g)replace_all:NNn` + +### Fixed +- `\prop_item:Nn` result not returned in `\exp_not:n` for linked properties + (see \#1630) + +### Removed +- `\c_catcode_active_tl`: was missing a `_`, always intended to be internal + +## [2024-11-02] + +### Added +- `V`-type variant for all `\<var>_set:Nn` functions + +### Fixed +- Error detection in coffin code (see \#1580) + +## [2024-10-09] + +### Added +- `\coffin_ht_plus_dp:(N|c)` + +### Fixed +- Use TU-encoding with lualatex and xelatex in `l3doc` +- Inconsistent local/global assignments in `l3doc` (see \#1593) + +## [2024-09-10] + +### Changed +- Increase outdent of long function names in `l3doc` (issue \#1585) + +### Fixed +- `\seq_map_pairwise_function:NNN` not work with `\seq_map_break:(n)` (issue \#1587) + +## [2024-08-30] + +### Changed +- Reduce memory usage when building Unicode data storage +- Avoid recursive doc for `\file_if_exist:n(TF)` (issue \#1573) + +### Fixed +- Handling of `ltcmd` newlines (`\obeyedline`) in `l3doc` (issue \#1577) + +## [2024-08-16] + +### Added +- Add quark (`\q_`) and scan mark (`\s_`) prefixes to naming scheme + (issue \#1565) + +## [2024-07-20] + +### Fixed +- Implementation of deprecated `\tl_mixed_case:n(n)` +- Redo the fix for LaTeX2e key properties (issue latex3/latex2e\#1415) + +## [2024-06-19] + +### Fixed +- Avoid a low-level error when LaTeX2e key properties are given without a value + ## [2024-05-27] ### Added @@ -324,6 +428,7 @@ this project uses date-based 'snapshot' version identifiers. - `\file_input_raw:n` - `\int_if_zero:n(TF)` - `\str_mdfive_hash:n` + ### Changed - Remove `\noexpand` inside math mode in `\text_expand:n` - Re-implement `\dim_to_decimal_in_bp:n` and @@ -476,14 +581,14 @@ this project uses date-based 'snapshot' version identifiers. ### Added - Complete list of pdfTeX primitives +### Changed +- Leave catcode of `&` unchanged in code environment + ### Fixed - Allow for multi-part BCP47 strings in case changing - Loading with plain TeX due to `\outer` status of `^^L` issue ([\#1161](https://github.com/latex3/latex3/issues/1161)) -### Changed -- Leave catcode of `&` unchanged in code environment - ## [2023-01-16] ### Added @@ -573,9 +678,8 @@ this project uses date-based 'snapshot' version identifiers. ### Changed - Replace `LaTeX3` in message text by `LaTeX` - -### Changed - Approach to setting current color data from LaTeX2e + ## [2022-08-05] ### Added @@ -1112,7 +1216,7 @@ this project uses date-based 'snapshot' version identifiers. also *expandable* ### Fixed -- Make `expl3` reload-safe for `latexrelease` (see latex3/latex2e#295) +- Make `expl3` reload-safe for `latexrelease` (see latex3/latex2e\#295) ## [2020-02-25] @@ -1742,7 +1846,18 @@ this project uses date-based 'snapshot' version identifiers. - Step functions have been added for dim variables, e.g. `\dim_step_inline:nnnn` -[Unreleased]: https://github.com/latex3/latex3/compare/2024-05-27...HEAD +[Unreleased]: https://github.com/latex3/latex3/compare/2025-01-18...HEAD +[2025-01-18]: https://github.com/latex3/latex3/compare/2025-01-14...2025-01-18 +[2025-01-14]: https://github.com/latex3/latex3/compare/2024-12-25...2025-01-14 +[2024-12-25]: https://github.com/latex3/latex3/compare/2024-12-09...2024-12-25 +[2024-12-09]: https://github.com/latex3/latex3/compare/2024-11-02...2024-12-09 +[2024-11-02]: https://github.com/latex3/latex3/compare/2024-10-09...2024-11-02 +[2024-10-09]: https://github.com/latex3/latex3/compare/2024-09-10...2024-10-09 +[2024-09-10]: https://github.com/latex3/latex3/compare/2024-08-30...2024-09-10 +[2024-08-30]: https://github.com/latex3/latex3/compare/2024-08-16...2024-08-30 +[2024-08-16]: https://github.com/latex3/latex3/compare/2024-07-20...2024-08-16 +[2024-07-20]: https://github.com/latex3/latex3/compare/2024-06-19...2024-07-20 +[2024-06-19]: https://github.com/latex3/latex3/compare/2024-05-27...2024-06-19 [2024-05-27]: https://github.com/latex3/latex3/compare/2024-05-08...2024-05-27 [2024-05-08]: https://github.com/latex3/latex3/compare/2024-04-11...2024-05-08 [2024-04-11]: https://github.com/latex3/latex3/compare/2024-03-14...2024-04-11 diff --git a/macros/latex/required/l3kernel/README.md b/macros/latex/required/l3kernel/README.md index 8946af1293..db98f70515 100644 --- a/macros/latex/required/l3kernel/README.md +++ b/macros/latex/required/l3kernel/README.md @@ -1,7 +1,7 @@ LaTeX3 Programming Conventions ============================== -Release 2024-05-27 +Release 2025-01-18 Overview -------- @@ -91,6 +91,6 @@ by e-mail: <latex-team@latex-project.org>. ----- -<p>Copyright (C) 1998-2012,2015-2024 The LaTeX Project <br /> +<p>Copyright (C) 1998-2012,2015-2025 The LaTeX Project <br /> <a href="http://latex-project.org/">http://latex-project.org/</a> <br /> All rights reserved.</p> diff --git a/macros/latex/required/l3kernel/expl3.dtx b/macros/latex/required/l3kernel/expl3.dtx index 4b4e61d3c8..f84b346c05 100644 --- a/macros/latex/required/l3kernel/expl3.dtx +++ b/macros/latex/required/l3kernel/expl3.dtx @@ -2,7 +2,7 @@ % %% File: expl3.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -24,7 +24,7 @@ % %<*driver|generic|package|2ekernel> %</driver|generic|package|2ekernel> -\def\ExplFileDate{2024-05-27}% +\def\ExplFileDate{2025-01-18}% %<*driver> \documentclass[full]{l3doc} \usepackage{graphicx} @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -454,6 +454,15 @@ % implementation in \LaTeX3 means that |toks| are not required, and that % all operations for storing tokens can use the |tl| variable type. % +% There are two more special types of constants: +% \begin{arg-description} +% \item[q] constants of quark type; +% \item[s] constants of scan mark type. +% \end{arg-description} +% The \meta{type} part of quark and scan mark constants is omitted, and +% the \meta{module} part of general quarks and scan marks is often +% omitted too. +% % Experienced \TeX{} programmers will notice that some of the variable % types listed are native \TeX{} registers whilst others are not. In % general, the underlying \TeX{} implementation for a data structure may diff --git a/macros/latex/required/l3kernel/expl3.pdf b/macros/latex/required/l3kernel/expl3.pdf Binary files differindex a6eca24ce4..48ae5f7db1 100644 --- a/macros/latex/required/l3kernel/expl3.pdf +++ b/macros/latex/required/l3kernel/expl3.pdf diff --git a/macros/latex/required/l3kernel/interface3.pdf b/macros/latex/required/l3kernel/interface3.pdf Binary files differindex 5c72322e35..686e509dd7 100644 --- a/macros/latex/required/l3kernel/interface3.pdf +++ b/macros/latex/required/l3kernel/interface3.pdf diff --git a/macros/latex/required/l3kernel/interface3.tex b/macros/latex/required/l3kernel/interface3.tex index 62501cfa53..f13ec99d5f 100644 --- a/macros/latex/required/l3kernel/interface3.tex +++ b/macros/latex/required/l3kernel/interface3.tex @@ -2,7 +2,7 @@ File: interface3.tex -Copyright (C) 1990-2011,2017-2024 The LaTeX Project +Copyright (C) 1990-2011,2017-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -58,7 +58,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2024-05-27} +\date{Released 2025-01-18} \pagenumbering{roman} \maketitle diff --git a/macros/latex/required/l3kernel/l3.ins b/macros/latex/required/l3kernel/l3.ins index bf7a75381d..eafa8dcc33 100644 --- a/macros/latex/required/l3kernel/l3.ins +++ b/macros/latex/required/l3kernel/l3.ins @@ -2,7 +2,7 @@ File l3.ins -Copyright (C) 2011,2012,2014-2024 The LaTeX Project +Copyright (C) 2011,2012,2014-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -35,7 +35,7 @@ license information is placed in the derived files. \preamble -Copyright (C) 1990-2024 The LaTeX Project +Copyright (C) 1990-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of @@ -156,7 +156,7 @@ and all files in that bundle must be distributed together. \def\MetaPrefix{--} \preamble -Copyright (C) 1990-2024 The LaTeX Project +Copyright (C) 1990-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/macros/latex/required/l3kernel/l3basics.dtx b/macros/latex/required/l3kernel/l3basics.dtx index 69e4441580..552ead9f5a 100644 --- a/macros/latex/required/l3kernel/l3basics.dtx +++ b/macros/latex/required/l3kernel/l3basics.dtx @@ -2,7 +2,7 @@ % %% File: l3basics.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -1151,10 +1151,9 @@ % argument (a single token denoted by |N|) is still free for definition. % It would be used in constructions like % \begin{quote} -% |\bool_if:nTF {| \\ -% \verb" \cs_if_free_p:N \l_tmpz_tl || \cs_if_free_p:N \g_tmpz_tl " \\ -% |}| -% \Arg{true code} \Arg{false code} +% "\bool_if:nTF" \\ +% " { \cs_if_free_p:N \l_tmpz_tl || \cs_if_free_p:N \g_tmpz_tl }" \\ +% " "\Arg{true code} \Arg{false code} % \end{quote} % % For each predicate defined, a \enquote{branching conditional} @@ -1171,7 +1170,7 @@ % % \subsection{Tests on control sequences} % -% \begin{function}[EXP,pTF]{\cs_if_eq:NN} +% \begin{function}[EXP,pTF]{\cs_if_eq:NN, \cs_if_eq:Nc, \cs_if_eq:cN, \cs_if_eq:cc} % \begin{syntax} % \cs{cs_if_eq_p:NN} \meta{cs_1} \meta{cs_2} % \cs{cs_if_eq:NNTF} \meta{cs_1} \meta{cs_2} \Arg{true code} \Arg{false code} @@ -1187,9 +1186,10 @@ % \cs{cs_if_exist:NTF} \meta{control sequence} \Arg{true code} \Arg{false code} % \end{syntax} % Tests whether the \meta{control sequence} is currently defined -% (whether as a function or another control sequence type). Any -% definition of \meta{control sequence} other than \tn{relax} -% evaluates as \texttt{true}. +% (whether as a function or another control sequence type), +% and its meaning is not the primitive \tn{relax} token. +% This is different from \cs{if_cs_exist:N}, which evaluates to +% \texttt{true} if passed the token \tn{relax} as an argument. % \end{function} % % \begin{function}[EXP,pTF]{\cs_if_free:N, \cs_if_free:c} @@ -1197,10 +1197,7 @@ % \cs{cs_if_free_p:N} \meta{control sequence} % \cs{cs_if_free:NTF} \meta{control sequence} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests whether the \meta{control sequence} is currently free to -% be defined. This test is \texttt{false} if the -% \meta{control sequence} currently exists (as defined by -% \cs{cs_if_exist:NTF}). +% This test is the negation of the above \cs{cs_if_exist:NTF}. % \end{function} % % \subsection{Primitive conditionals} @@ -1282,7 +1279,7 @@ % Check if <cs> appears in the hash table or if the control sequence % that can be formed from <tokens> appears in the hash table. The % latter function does not turn the control sequence in question into -% "\scan_stop:"! This can be useful when dealing with control +% the primitive \tn{relax} token. This can be useful when dealing with control % sequences which cannot be entered as a single token. % \begin{texnote} % These are the \TeX{} primitives \tn{ifdefined} and \tn{ifcsname}. @@ -1327,8 +1324,8 @@ % % \begin{function}[added = 2017-07-16, updated = 2023-05-23]{\debug_on:n, \debug_off:n} % \begin{syntax} -% \cs{debug_on:n} |{| \meta{comma-separated list} |}| -% \cs{debug_off:n} |{| \meta{comma-separated list} |}| +% \cs{debug_on:n} \Arg{comma-separated list} +% \cs{debug_off:n} \Arg{comma-separated list} % \end{syntax} % Turn on and off within a group various debugging code, some of which % is also available as \pkg{expl3} load-time options. The items that @@ -2458,7 +2455,7 @@ % % \subsection{Exist or free} % -% A control sequence is said to \emph{exist} (to be used) if has an entry in +% A control sequence is said to \emph{exist} (to be used) if it has an entry in % the hash table and its meaning is different from the primitive % \tn{relax} token. A control sequence is said to be \emph{free} % (to be defined) if it does not already exist. diff --git a/macros/latex/required/l3kernel/l3bitset.dtx b/macros/latex/required/l3kernel/l3bitset.dtx index 4559b56fd3..16a0fd7aac 100644 --- a/macros/latex/required/l3kernel/l3bitset.dtx +++ b/macros/latex/required/l3kernel/l3bitset.dtx @@ -2,7 +2,7 @@ % %% File: l3bitset.dtx % -% Copyright (C) 2020-2024 The LaTeX Project +% Copyright (C) 2020-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -240,6 +240,16 @@ % implementation based on \cs{fp_eval:n} otherwise. % \end{function} % +% \begin{function}[EXP, added = 2024-11-12]{\bitset_use:N, \bitset_use:c} +% \begin{syntax} +% \cs{bitset_use:N} \meta{bitset var} +% \end{syntax} +% This leaves the current value of the bitset expressed as +% a binary (string) number in the input stream. +% If no bit has been set yet, the output is zero. This is +% functionally equivalent to \cs{bitset_to_bin:N}. +% \end{function} +% % \begin{function}[added = 2023-11-15] % {\bitset_show:N, \bitset_show:c} % \begin{syntax} @@ -524,6 +534,13 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\bitset_use:N, \bitset_use:c} +% \begin{macrocode} +\cs_new_eq:NN \bitset_use:N \tl_use:N +\cs_generate_variant:Nn \bitset_use:N { c } +% \end{macrocode} +% \end{macro} +% % \begin{macro} % { % \bitset_item:Nn, \bitset_item:cn diff --git a/macros/latex/required/l3kernel/l3bootstrap.dtx b/macros/latex/required/l3kernel/l3bootstrap.dtx index 861f0bb5a6..a1b36c6074 100644 --- a/macros/latex/required/l3kernel/l3bootstrap.dtx +++ b/macros/latex/required/l3kernel/l3bootstrap.dtx @@ -2,7 +2,7 @@ % %% File: l3bootstrap.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -70,14 +70,14 @@ % \cs{ExplSyntaxOn} \meta{code} \cs{ExplSyntaxOff} % \end{syntax} % The \cs{ExplSyntaxOn} function switches to a category code -% regime in which spaces and new lines are ignored, and in which the colon (|:|) +% régime in which spaces and new lines are ignored, and in which the colon (|:|) % and underscore (|_|) are treated as \enquote{letters}, thus allowing % access to the names of code functions and variables. Within this % environment, |~| is used to input a space. The \cs{ExplSyntaxOff} -% reverts to the document category code regime. +% reverts to the document category code régime. % \begin{texnote} % Spaces introduced by~|~| behave much in the same way as normal -% space characters in the standard category code regime: they are +% space characters in the standard category code régime: they are % ignored after a control word or at the start of a line, and % multiple consecutive~|~| are equivalent to a single one. However, % |~|~is \emph{not} ignored at the end of a line. diff --git a/macros/latex/required/l3kernel/l3box.dtx b/macros/latex/required/l3kernel/l3box.dtx index 808d22da23..136af6afc0 100644 --- a/macros/latex/required/l3kernel/l3box.dtx +++ b/macros/latex/required/l3kernel/l3box.dtx @@ -2,7 +2,7 @@ % %% File: l3box.dtx % -% Copyright (C) 2005-2024 The LaTeX Project +% Copyright (C) 2005-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -906,9 +906,9 @@ % \begin{syntax} % \cs{box_set_trim:Nnnnn} \meta{box} \Arg{left} \Arg{bottom} \Arg{right} \Arg{top} % \end{syntax} -% Adjusts the bounding box of the \meta{box} \meta{left} is removed from +% Adjusts the bounding box of the \meta{box}: \meta{left} is removed from % the left-hand edge of the bounding box, \meta{right} from the right-hand -% edge and so fourth. All adjustments are \meta{dim exprs}. +% edge, and so forth. All adjustments are \meta{dim exprs}. % Material outside of the bounding box is still displayed in the output % unless \cs{box_set_clipped:N} is subsequently applied. % The updated \meta{box} is an diff --git a/macros/latex/required/l3kernel/l3cctab.dtx b/macros/latex/required/l3kernel/l3cctab.dtx index 4bf8db41a6..012c0489e6 100644 --- a/macros/latex/required/l3kernel/l3cctab.dtx +++ b/macros/latex/required/l3kernel/l3cctab.dtx @@ -2,7 +2,7 @@ % %% File: l3cctab.dtx % -% Copyright (C) 2018-2024 The LaTeX Project +% Copyright (C) 2018-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -117,7 +117,7 @@ % Ends the scope of a \meta{category code table} started using % \cs{cctab_begin:N}, returning the codes to those in force before the % matching \cs{cctab_begin:N} was used. This must be used within the -% same \TeX{} group (and at the same \TeX{} group level) as the +% same \TeX{} group and at the same \TeX{} group level as the % matching \cs{cctab_begin:N}. % \end{function} % @@ -866,8 +866,7 @@ \group_begin: \int_set:Nn \tex_endlinechar:D { 32 } \char_set_catcode_invalid:n { 0 } - \bool_lazy_or:nnTF - { \sys_if_engine_xetex_p: } { \sys_if_engine_luatex_p: } + \sys_if_engine_opentype:TF { \int_step_function:nN { 31 } \char_set_catcode_invalid:n } { \int_step_function:nN { 31 } \char_set_catcode_active:n } \int_step_function:nnN { 33 } { 64 } \char_set_catcode_other:n @@ -892,8 +891,7 @@ \char_set_catcode_group_end:n { 125 } % right brace \char_set_catcode_space:n { 126 } % tilde \char_set_catcode_invalid:n { 127 } % ^^? - \bool_lazy_or:nnF - { \sys_if_engine_xetex_p: } { \sys_if_engine_luatex_p: } + \sys_if_engine_opentype:F { \int_step_function:nnN { 128 } { 255 } \char_set_catcode_active:n } \@@_gset:n { \c_code_cctab } \group_end: diff --git a/macros/latex/required/l3kernel/l3clist.dtx b/macros/latex/required/l3kernel/l3clist.dtx index 5adb01cffb..0e1666076d 100644 --- a/macros/latex/required/l3kernel/l3clist.dtx +++ b/macros/latex/required/l3kernel/l3clist.dtx @@ -3,7 +3,7 @@ %% File: l3clist.dtx % % Copyright (C) 2004-2011 Frank Mittelbach, The LaTeX Project -% (C) 2012-2024 The LaTeX Project +% (C) 2012-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -324,8 +324,10 @@ % { % \clist_remove_all:Nn, \clist_remove_all:cn, % \clist_remove_all:NV, \clist_remove_all:cV, +% \clist_remove_all:Ne, \clist_remove_all:ce, % \clist_gremove_all:Nn, \clist_gremove_all:cn, -% \clist_gremove_all:NV, \clist_gremove_all:cV +% \clist_gremove_all:NV, \clist_gremove_all:cV, +% \clist_gremove_all:Ne, \clist_gremove_all:ce % } % \begin{syntax} % \cs{clist_remove_all:Nn} \meta{clist~var} \Arg{item} @@ -350,7 +352,7 @@ % Reverses the order of items stored in the \meta{clist~var}. % \end{function} % -% \begin{function}[added = 2014-07-18]{\clist_reverse:n} +% \begin{function}[added = 2014-07-18, EXP]{\clist_reverse:n} % \begin{syntax} % \cs{clist_reverse:n} \Arg{comma list} % \end{syntax} @@ -391,7 +393,7 @@ % \cs{clist_if_empty_p:n} \Arg{comma list} % \cs{clist_if_empty:nTF} \Arg{comma list} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests if the \meta{clist~var} is empty (containing no items). +% Tests if the \meta{comma~list} is empty (containing no items). % The rules for space trimming are as for other \texttt{n}-type % comma-list functions, hence the comma list |{~,~,,~}| (without % outer braces) is empty, while |{~,{},}| (without outer braces) @@ -562,7 +564,8 @@ % % \begin{function}[EXP, added = 2013-05-26]{\clist_use:Nnnn, \clist_use:cnnn} % \begin{syntax} -% \cs{clist_use:Nnnn} \meta{clist~var} \Arg{separator~between~two} \Arg{separator~between~more~than~two} \Arg{separator~between~final~two} +% \cs{clist_use:Nnnn} \meta{clist~var} \Arg{separator~between~two} \\ +% ~~\Arg{separator~between~more~than~two} \Arg{separator~between~final~two} % \end{syntax} % Places the contents of the \meta{clist~var} in the input stream, % with the appropriate \meta{separator} between the items. Namely, if @@ -616,10 +619,27 @@ % \end{texnote} % \end{function} % +% \begin{function}[EXP, added = 2024-11-12]{\clist_use:N, \clist_use:c} +% \begin{syntax} +% \cs{clist_use:N} \meta{clist~var} +% \end{syntax} +% Places the contents of the \meta{clist~var} in the input stream, +% with a comma between each item. The result is exaclty the stored +% \meta{clist}, which will include braces around (for example) +% entries with retained spaces at the ends. +% \begin{texnote} +% The result is returned as-is, in the same way as \cs{tl_use:N} +% and \emph{without} protection from expansion, +% cf.~\cs{clist_use:Nnnnn}, etc. It is equivalent to \texttt{V}-type +% expansion of a \texttt{clist}. +% \end{texnote} +% \end{function} +% % \begin{function}[EXP, added = 2021-05-10]{\clist_use:nnnn, \clist_use:nn} % \begin{syntax} -% \cs{clist_use:nnnn} \meta{comma~list} \Arg{separator~between~two} \Arg{separator~between~more~than~two} \Arg{separator~between~final~two} -% \cs{clist_use:nn} \meta{comma~list} \Arg{separator} +% \cs{clist_use:nnnn} \Arg{comma~list} \Arg{separator~between~two} \\ +% ~~\Arg{separator~between~more~than~two} \Arg{separator~between~final~two} +% \cs{clist_use:nn} \Arg{comma~list} \Arg{separator} % \end{syntax} % Places the contents of the \meta{comma~list} in the input stream, % with the appropriate \meta{separator} between the items. As for @@ -648,60 +668,60 @@ % \begin{function}[noTF, added = 2012-05-14, updated = 2019-02-16] % {\clist_get:NN, \clist_get:cN} % \begin{syntax} -% \cs{clist_get:NN} \meta{clist~var} \meta{token list variable} +% \cs{clist_get:NN} \meta{clist~var} \meta{tl~var} % \end{syntax} % Stores the left-most item from a \meta{clist~var} in the -% \meta{token list variable} without removing it from the -% \meta{clist~var}. The \meta{token list variable} is assigned locally. +% \meta{tl~var} without removing it from the +% \meta{clist~var}. The \meta{tl~var} is assigned locally. % In the non-branching version, if the \meta{clist~var} is empty the -% \meta{token list variable} is set to the marker value \cs{q_no_value}. +% \meta{tl~var} is set to the marker value \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2011-09-06]{\clist_pop:NN, \clist_pop:cN} % \begin{syntax} -% \cs{clist_pop:NN} \meta{clist~var} \meta{token list variable} +% \cs{clist_pop:NN} \meta{clist~var} \meta{tl~var} % \end{syntax} % Pops the left-most item from a \meta{clist~var} into the -% \meta{token list variable}, \emph{i.e.}~removes the item from the -% comma list and stores it in the \meta{token list variable}. +% \meta{tl~var}, \emph{i.e.}~removes the item from the +% comma list and stores it in the \meta{tl~var}. % Both of the variables are assigned locally. % \end{function} % % \begin{function}{\clist_gpop:NN, \clist_gpop:cN} % \begin{syntax} -% \cs{clist_gpop:NN} \meta{clist~var} \meta{token list variable} +% \cs{clist_gpop:NN} \meta{clist~var} \meta{tl~var} % \end{syntax} % Pops the left-most item from a \meta{clist~var} into the -% \meta{token list variable}, \emph{i.e.}~removes the item from the -% comma list and stores it in the \meta{token list variable}. +% \meta{tl~var}, \emph{i.e.}~removes the item from the +% comma list and stores it in the \meta{tl~var}. % The \meta{clist~var} is modified globally, while the assignment of -% the \meta{token list variable} is local. +% the \meta{tl~var} is local. % \end{function} % % \begin{function}[TF, added = 2012-05-14]{\clist_pop:NN, \clist_pop:cN} % \begin{syntax} -% \cs{clist_pop:NNTF} \meta{clist~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{clist_pop:NNTF} \meta{clist~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{clist~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{clist~var} is non-empty, pops the top item from the -% \meta{clist~var} in the \meta{token list variable}, \emph{i.e.}~removes +% \meta{clist~var} in the \meta{tl~var}, \emph{i.e.}~removes % the item from the \meta{clist~var}. Both the \meta{clist~var} and the -% \meta{token list variable} are assigned locally. +% \meta{tl~var} are assigned locally. % \end{function} % % \begin{function}[TF, added = 2012-05-14]{\clist_gpop:NN, \clist_gpop:cN} % \begin{syntax} -% \cs{clist_gpop:NNTF} \meta{clist~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{clist_gpop:NNTF} \meta{clist~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{clist~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{clist~var} is non-empty, pops the top item from the -% \meta{clist~var} in the \meta{token list variable}, \emph{i.e.}~removes +% \meta{clist~var} in the \meta{tl~var}, \emph{i.e.}~removes % the item from the \meta{clist~var}. The \meta{clist~var} is modified -% globally, while the \meta{token list variable} is assigned locally. +% globally, while the \meta{tl~var} is assigned locally. % \end{function} % % \begin{function} @@ -1429,13 +1449,15 @@ % \begin{macro} % { % \clist_remove_all:Nn, \clist_remove_all:cn, -% \clist_remove_all:NV, \clist_remove_all:cV +% \clist_remove_all:NV, \clist_remove_all:cV, +% \clist_remove_all:Ne, \clist_remove_all:ce % } % \UnitTested % \begin{macro} % { % \clist_gremove_all:Nn, \clist_gremove_all:cn, -% \clist_gremove_all:NV, \clist_gremove_all:cV +% \clist_gremove_all:NV, \clist_gremove_all:cV, +% \clist_gremove_all:Ne, \clist_gremove_all:ce % } % \UnitTested % \begin{macro}{\@@_remove_all:NNNn} @@ -1509,8 +1531,8 @@ \cs_new:Npn \@@_remove_all: { \exp_after:wN \@@_remove_all:w \@@_tmp:w , } \cs_new:Npn \@@_remove_all:w #1 , \s_@@_mark , #2 , { \exp_not:n {#1} } -\cs_generate_variant:Nn \clist_remove_all:Nn { c , NV , cV } -\cs_generate_variant:Nn \clist_gremove_all:Nn { c , NV , cV } +\cs_generate_variant:Nn \clist_remove_all:Nn { c , NV , cV , Ne , ce } +\cs_generate_variant:Nn \clist_gremove_all:Nn { c , NV , cV , Ne , ce } % \end{macrocode} % \end{macro} % \end{macro} @@ -2002,6 +2024,13 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\clist_use:N, \clist_use:c} +% \begin{macrocode} +\cs_new_eq:NN \clist_use:N \tl_use:N +\cs_generate_variant:Nn \clist_use:N { c } +% \end{macrocode} +% \end{macro} +% % \begin{macro} % { % \clist_use:nnnn, \clist_use:nn, \@@_use:Nw, diff --git a/macros/latex/required/l3kernel/l3coffins.dtx b/macros/latex/required/l3kernel/l3coffins.dtx index 62dc5f92ad..2d1d86a75c 100644 --- a/macros/latex/required/l3kernel/l3coffins.dtx +++ b/macros/latex/required/l3kernel/l3coffins.dtx @@ -2,7 +2,7 @@ % %% File: l3coffins.dtx % -% Copyright (C) 2010-2024 The LaTeX Project +% Copyright (C) 2010-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -327,6 +327,14 @@ % in a form suitable for use in a \meta{dim expr}. % \end{function} % +% \begin{function}[added = 2024-10-01]{\coffin_ht_plus_dp:N, \coffin_ht_plus_dp:c} +% \begin{syntax} +% \cs{coffin_ht_plus_dp:N} \meta{coffin} +% \end{syntax} +% Calculates the total vertical size (height plus depth) of the \meta{coffin} +% in a form suitable for use in a \meta{dim expr}. +% \end{function} +% % \begin{function}{\coffin_wd:N, \coffin_wd:c} % \begin{syntax} % \cs{coffin_wd:N} \meta{coffin} @@ -866,7 +874,7 @@ % \begin{macrocode} \cs_new_protected:Npn \coffin_set_eq:NN #1#2 { - \@@_if_exist:NT #1 + \@@_if_exist:NT #2 { \box_set_eq:NN #1 #2 \prop_set_eq:cc { coffin ~ \@@_to_value:N #1 ~ corners } @@ -878,7 +886,7 @@ \cs_generate_variant:Nn \coffin_set_eq:NN { c , Nc , cc } \cs_new_protected:Npn \coffin_gset_eq:NN #1#2 { - \@@_if_exist:NT #1 + \@@_if_exist:NT #2 { \box_gset_eq:NN #1 #2 \prop_gset_eq:cc { coffin ~ \@@_to_value:N #1 ~ corners } @@ -924,7 +932,8 @@ % \begin{macro} % { % \coffin_dp:N, \coffin_dp:c, \coffin_ht:N, \coffin_ht:c, -% \coffin_wd:N, \coffin_wd:c +% \coffin_ht_plus_dp:N, \coffin_ht_plus_dp:c, +% \coffin_wd:N, \coffin_wd:c, % } % Coffins are just boxes when it comes to measurement. However, semantically % a separate set of functions are required. @@ -933,6 +942,8 @@ \cs_new_eq:NN \coffin_dp:c \box_dp:c \cs_new_eq:NN \coffin_ht:N \box_ht:N \cs_new_eq:NN \coffin_ht:c \box_ht:c +\cs_new_eq:NN \coffin_ht_plus_dp:N \box_ht_plus_dp:N +\cs_new_eq:NN \coffin_ht_plus_dp:c \box_ht_plus_dp:c \cs_new_eq:NN \coffin_wd:N \box_wd:N \cs_new_eq:NN \coffin_wd:c \box_wd:c % \end{macrocode} diff --git a/macros/latex/required/l3kernel/l3color.dtx b/macros/latex/required/l3kernel/l3color.dtx index b56fb9e0ac..bbfec94de4 100644 --- a/macros/latex/required/l3kernel/l3color.dtx +++ b/macros/latex/required/l3kernel/l3color.dtx @@ -2,7 +2,7 @@ % %% File: l3color.dtx % -% Copyright (C) 2017-2024 The LaTeX Project +% Copyright (C) 2017-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -103,7 +103,7 @@ % \begin{itemize} % \item \texttt{Gray} Grayscale color, with a single axis running from % $0$ (fully black) to $15$ (fully white) -% \item \texttt{hsb} Hue-saturation-brightness color, with three axes,all +% \item \texttt{hsb} Hue-saturation-brightness color, with three axes, all % real values in the range $[0,1]$ for hue saturation and brightness % \item \texttt{Hsb} Hue-saturation-brightness color, with three axes, integer % in the range $[0,360]$ for hue, real values in the range $[0,1]$ for @@ -142,7 +142,7 @@ % Section~\ref{l3color:sec:new-models} for more detail of color support % for additional models. % -% When color is selected by model, the \meta{values} given are specified as +% When color is selected by model, the \meta{value(s)} given are specified as % a comma-separated list. The length of the list will therefore be determined % by the detail of the model involved. % @@ -233,19 +233,20 @@ % color specification as the \meta{name}. % \end{function} % -% \begin{function}{\color_set:nnn} +% \begin{function}[updated = 2024-12-24]{\color_set:nnn} % \begin{syntax} % \cs{color_set:nnn} \Arg{name} \Arg{model(s)} \Arg{value(s)} % \end{syntax} % Stores the color specification equivalent to the \meta{model(s)} and -% \meta{values} as the \meta{name}. +% \meta{value(s)} as the \meta{name}. The \meta{value(s)} are expanded before +% parsing. % \end{function} % % \begin{function}{\color_set_eq:nn} % \begin{syntax} -% \cs{color_set_eq:nn} \Arg{name1} \Arg{name2} +% \cs{color_set_eq:nn} \Arg{name_1} \Arg{name_2} % \end{syntax} -% Copies the color specification in \meta{name2} to \meta{name1}. The +% Copies the color specification in \meta{name_2} to \meta{name_1}. The % special name |.| may be used to represent the current color, allowing % it to be saved to a name. % \end{function} @@ -276,7 +277,7 @@ % These commands set the current color (|.|): other more specialised functions % such as fill and stroke selectors do \emph{not} adjust this value. % -% \begin{function}{\color_select:n} +% \begin{function}[updated = 2024-12-24]{\color_select:n} % \begin{syntax} % \cs{color_select:n} \Arg{color expression} % \end{syntax} @@ -289,7 +290,8 @@ % \cs{color_select:nn} \Arg{model(s)} \Arg{value(s)} % \end{syntax} % Activates the color specification equivalent to the \meta{model(s)} and -% \meta{value(s)} for typeset material. +% \meta{value(s)} for typeset material. The \meta{value(s)} are fully +% expanded before parsing. % \end{function} % % \begin{variable}{\l_color_fixed_model_tl} @@ -316,16 +318,17 @@ % color specification for filling or stroking. % \end{function} % -% \begin{function}{\color_fill:nn, \color_stroke:nn} +% \begin{function}[updated = 2024-12-24]{\color_fill:nn, \color_stroke:nn} % \begin{syntax} % \cs{color_fill:nn} \Arg{model(s)} \Arg{value(s)} % \end{syntax} % Activates the color specification equivalent to the \meta{model(s)} and -% \meta{value(s)} for filling or stroking. +% \meta{value(s)} for filling or stroking. The \meta{value(s)} are fully +% expanded before parsing. % \end{function} % % \begin{variable}[module = color]{color.sc} -% When using \texttt{dvips}, this PostScript variables hold the stroke color. +% When using \texttt{dvips}, this PostScript variable holds the stroke color. % \end{variable} % % \subsection{Coloring math mode material} @@ -336,13 +339,15 @@ % required needs careful handling. The functionality here covers this important % use case. % -% \begin{function}[added = 2022-01-26]{\color_math:nn, \color_math:nnn} +% \begin{function}[added = 2022-01-26, updated = 2024-12-24] +% {\color_math:nn, \color_math:nnn} % \begin{syntax} -% \cs{color_math:nn} \Arg{color expression}\Arg{content} +% \cs{color_math:nn} \Arg{color expression} \Arg{content} % \cs{color_math:nnn} \Arg{model(s)} \Arg{value(s)} \Arg{content} % \end{syntax} % Works as for \cs[no-index]{color_select:n(n)} but applies color only to the math mode -% \meta{content}. The function does not generate a group and the \meta{content} +% \meta{content}. The \meta{value(s)} are fully expanded before parsing. +% The function does not generate a group and the \meta{content} % therefore retains its math atom states. Sub/superscripts are also properly % handled. % \end{function} @@ -406,20 +411,21 @@ % % \begin{function}{\color_export:nnN} % \begin{syntax} -% \cs{color_export:nnN} \Arg{color expression} \Arg{format} \Arg{tl} +% \cs{color_export:nnN} \Arg{color expression} \Arg{format} \meta{tl var} % \end{syntax} % Parses the \meta{color expression} as described earlier, % then converts to the \meta{format} specified and assigns the data to the -% \meta{tl}. +% \meta{tl var}. % \end{function} % -% \begin{function}{\color_export:nnnN} +% \begin{function}[updated = 2024-12-24]{\color_export:nnnN} % \begin{syntax} -% \cs{color_export:nnnN} \Arg{model} \Arg{value(s)} \Arg{format} \Arg{tl} +% \cs{color_export:nnnN} \Arg{model} \Arg{value(s)} \Arg{format} \meta{tl var} % \end{syntax} % Expresses the combination of \meta{model} and \meta{value(s)} in an % internal representation, then converts to the \meta{format} specified and -% assigns the data to the \meta{tl}. +% assigns the data to the \meta{tl var}. The \meta{value(s)} are fully +% expanded before parsing. % \end{function} % % \section{Creating new color models} @@ -495,7 +501,7 @@ % % Color profiles are used to ensure color accuracy by linking to collaboration. % Applying a profile can be used to standardise color which is otherwise -% device-dependence. +% device-dependent. % % \begin{function}[added = 2021-02-23]{\color_profile_apply:nn} % \begin{syntax} @@ -697,14 +703,14 @@ % \begin{macro}{\@@_convert:nnnN, \@@_convert:nVnN, \@@_convert:nnVN} % \begin{macro}[EXP] % { -% \@@_convert_gray_gray:w -% \@@_convert_gray_rgb:w -% \@@_convert_gray_cmyk:w -% \@@_convert_cmyk_gray:w -% \@@_convert_cmyk_rgb:w -% \@@_convert_cmyk_cmyk:w -% \@@_convert_rgb_gray:w -% \@@_convert_rgb_rgb:w +% \@@_convert_gray_gray:w, +% \@@_convert_gray_rgb:w, +% \@@_convert_gray_cmyk:w, +% \@@_convert_cmyk_gray:w, +% \@@_convert_cmyk_rgb:w, +% \@@_convert_cmyk_cmyk:w, +% \@@_convert_rgb_gray:w, +% \@@_convert_rgb_rgb:w, % \@@_convert_rgb_cmyk:w % } % \begin{macro}[EXP]{\@@_convert_rgb_cmyk:nnn} @@ -1433,6 +1439,7 @@ % % \begin{macro}{\color_select:n} % \begin{macro}{\color_select:nn} +% \begin{macro}{\@@_select_main:Nnn} % \begin{macro}{\@@_select_main:Nw, \@@_select_loop:Nw} % \begin{macro}{\@@_select:nnN} % \begin{macro}{\@@_select_swap:Nnn} @@ -1449,8 +1456,7 @@ } \cs_new_protected:Npn \color_select:nn #1#2 { - \@@_select_main:Nw \l_@@_current_tl - #1 / / \s_@@_mark #2 / / \s_@@_stop + \@@_select_main:Nnn \l_@@_current_tl {#1} {#2} \@@_finalise_current: \@@_select:N \l_@@_current_tl } @@ -1459,6 +1465,15 @@ % model, we don't need most of the data: just set up and apply the backend % function. % \begin{macrocode} +\cs_new_protected:Npn \@@_select_main:Nnn #1#2#3 + { + \use:e + { + \exp_not:N \@@_select_main:Nw \exp_not:N #1 + \exp_not:n {#2} / / \exp_not:N \s_@@_mark + #3 / / \exp_not:N \s_@@_stop + } + } \cs_new_protected:Npn \@@_select_main:Nw #1 #2 / #3 / #4 \s_@@_mark #5 / #6 / #7 \s_@@_stop { @@ -1505,6 +1520,7 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \subsection{Math color} % @@ -1545,10 +1561,7 @@ \cs_new_protected:Npn \color_math:nnn #1#2#3 { \@@_math:nn {#3} - { - \@@_select_main:Nw \l_@@_current_tl - #1 / / \s_@@_mark #2 / / \s_@@_stop - } + { \@@_select_main:Nnn \l_@@_current_tl {#1} {#2} } } \cs_new_protected:Npn \@@_math:nn #1#2 { @@ -1720,14 +1733,12 @@ } \cs_new_protected:Npn \color_fill:nn #1#2 { - \@@_select_main:Nw \l_@@_current_tl - #1 / / \s_@@_mark #2 / / \s_@@_stop + \@@_select_main:Nnn \l_@@_current_tl {#1} {#2} \exp_after:wN \@@_draw:nnn \l_@@_current_tl { fill } } \cs_new_protected:Npn \color_stroke:nn #1#2 { - \@@_select_main:Nw \l_@@_current_tl - #1 / / \s_@@_mark #2 / / \s_@@_stop + \@@_select_main:Nnn \l_@@_current_tl {#1} {#2} \exp_after:wN \@@_draw:nnn \l_@@_current_tl { stroke } } \cs_new_protected:Npn \@@_draw:nnn #1#2#3 @@ -1910,6 +1921,8 @@ \prop_new:c { l_@@_named_._prop } \tl_new:c { l_@@_named_._tl } \tl_set:ce { l_@@_named_._tl } { \@@_model:N \l_@@_current_tl } +\prop_put:cve { l_@@_named_._prop } { l_@@_named_._tl } + { \@@_values:N \l_@@_current_tl } % \end{macrocode} % \end{variable} % @@ -1932,8 +1945,7 @@ } \cs_new_protected:Npn \color_export:nnnN #1#2#3#4 { - \@@_select_main:Nw #4 - #1 / / \s_@@_mark #2 / / \s_@@_stop + \@@_select_main:Nnn #4 {#1} {#2} \@@_export:nN {#3} #4 } \cs_new_protected:Npn \@@_export:nN #1#2 diff --git a/macros/latex/required/l3kernel/l3debug.dtx b/macros/latex/required/l3kernel/l3debug.dtx index 21e6747a84..3c8f60341e 100644 --- a/macros/latex/required/l3kernel/l3debug.dtx +++ b/macros/latex/required/l3kernel/l3debug.dtx @@ -2,7 +2,7 @@ % %% File: l3debug.dtx % -% Copyright (C) 2019-2024 The LaTeX Project +% Copyright (C) 2019-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -69,7 +69,7 @@ % % Standard file identification. % \begin{macrocode} -\ProvidesExplFile{l3debug.def}{2024-05-27}{}{L3 Debugging support} +\ProvidesExplFile{l3debug.def}{2025-01-18}{}{L3 Debugging support} % \end{macrocode} % % \begin{variable}{\s_@@_stop} diff --git a/macros/latex/required/l3kernel/l3deprecation.dtx b/macros/latex/required/l3kernel/l3deprecation.dtx index 5852205ddc..3f41595f56 100644 --- a/macros/latex/required/l3kernel/l3deprecation.dtx +++ b/macros/latex/required/l3kernel/l3deprecation.dtx @@ -2,7 +2,7 @@ % %% File: l3deprecation.dtx % -% Copyright (C) 2017-2024 The LaTeX Project +% Copyright (C) 2017-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -505,10 +505,10 @@ { \text_uppercase:nn {#1} {#2} } \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_titlecase_first:n } \cs_new:Npn \tl_mixed_case:n #1 - { \text_titlecase_first:n {#1} } + { \text_titlecase_first:n { \text_lowercase:n {#1} } } \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_titlecase_first:nn } \cs_new:Npn \tl_mixed_case:nn #1#2 - { \text_titlecase_first:nn {#1} {#2} } + { \text_titlecase_first:nn {#1} { \text_lowercase:n {#2} } } % \end{macrocode} % \end{macro} % @@ -571,7 +571,7 @@ % \char_lower_case:N, \char_upper_case:N, % \char_mixed_case:Nn, \char_fold_case:N, % \char_str_lower_case:N, \char_str_upper_case:N, -% \char_str_mixed_case:Nn, \char_str_fold_case:N, +% \char_str_mixed_case:N, \char_str_fold_case:N, % } % \begin{macrocode} \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_lowercase:n } diff --git a/macros/latex/required/l3kernel/l3doc.dtx b/macros/latex/required/l3kernel/l3doc.dtx index 43b719ce59..84245e202c 100644 --- a/macros/latex/required/l3kernel/l3doc.dtx +++ b/macros/latex/required/l3kernel/l3doc.dtx @@ -2,7 +2,7 @@ % %% File: l3doc.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -31,7 +31,7 @@ \askforoverwritefalse \preamble -Copyright (C) 1990-2024 The LaTeX Project +Copyright (C) 1990-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of @@ -71,7 +71,7 @@ and all files in that bundle must be distributed together. % This isn't included in the typeset documentation because it's a bit % ugly: %<*class> -\ProvidesExplClass{l3doc}{2024-05-27}{} +\ProvidesExplClass{l3doc}{2025-01-18}{} {L3 Experimental documentation class} %</class> % \fi @@ -84,7 +84,7 @@ and all files in that bundle must be distributed together. % require you to do updates, if the class changes.}} % % \author{\Team} -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % \maketitle % \tableofcontents % @@ -471,7 +471,7 @@ and all files in that bundle must be distributed together. % \cs{tl_if_empty_p:N} \meta{tl~var} % \cs{tl_if_empty:NTF} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests if the \meta{token list variable} is entirely empty +% Tests if the \meta{tl~var} is entirely empty % (\emph{i.e.}~contains no tokens at all). % \end{function} % \end{verbatim} @@ -484,7 +484,7 @@ and all files in that bundle must be distributed together. % \cs{tl_if_empty_p:N} \meta{tl~var} % \cs{tl_if_empty:NTF} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests if the \meta{token list variable} is entirely empty +% Tests if the \meta{tl~var} is entirely empty % (\emph{i.e.}~contains no tokens at all). % \end{function} % \end{minipage} @@ -959,8 +959,8 @@ and all files in that bundle must be distributed together. % \begin{macrocode} \bool_new:N \g_@@_typeset_documentation_bool \bool_new:N \g_@@_typeset_implementation_bool -\bool_set_true:N \g_@@_typeset_documentation_bool -\bool_set_true:N \g_@@_typeset_implementation_bool +\bool_gset_true:N \g_@@_typeset_documentation_bool +\bool_gset_true:N \g_@@_typeset_implementation_bool % \end{macrocode} % \end{variable} % @@ -1531,12 +1531,22 @@ and all files in that bundle must be distributed together. % \begin{macrocode} \bool_if:NT \g_@@_lmodern_bool { - \RequirePackage[T1]{fontenc} - \RequirePackage{lmodern} - \group_begin: - \ttfamily - \DeclareFontShape{T1}{lmtt}{m}{it}{<->ec-lmtto10}{} - \group_end: + \sys_if_engine_opentype:TF + { + \group_begin: + \ttfamily + \DeclareFontShape{TU}{lmtt}{m}{it} + {<-> \UnicodeFontFile{lmmonoslant10-regular}{}}{} + \group_end: + } + { + \RequirePackage[T1]{fontenc} + \RequirePackage{lmodern} + \group_begin: + \ttfamily + \DeclareFontShape{T1}{lmtt}{m}{it}{<->ec-lmtto10}{} + \group_end: + } } % \end{macrocode} % @@ -1618,7 +1628,7 @@ and all files in that bundle must be distributed together. % % \subsection{Design} % -% Increase the text width slightly so that width the standard fonts +% Increase the text width slightly so that with the standard fonts % 72~columns of code may appear in a \env{macrocode} environment. % Increase the marginpar width slightly, for long command names. And % increase the left margin by a similar amount. @@ -2160,10 +2170,18 @@ and all files in that bundle must be distributed together. % % \begin{macro}{\@@_names_get_seq:nN} % The argument~|#1| (argument of a |function| or |macro| environment) -% has catcodes $10$ (space), $12$ (other) and $13$ (active). Sanitize -% catcodes. If the |verb| option was used, output a one-item -% sequence. Otherwise, remove any \enquote{\%} character at the -% beginning of a line. Remove tabs and newlines. Finally, convert +% has catcodes $10$ (space), $12$ (other) and $13$ (active), and +% since \LaTeX{} 2024-06-01 also macro \cs{obeyedline} in replacement +% of active |^^M| tokens (due to the revised behavior of |+v| +% argument type in |ltcmd|). +% If the |verb| option was used, sanitize catcodes and output +% a one-item sequence. +% Otherwise, remove any \enquote{\%} character at the beginning of +% a line using new end-of-line marker \cs{obeyedline}. Remove any +% remaining \cs{obeyedline}. Then sanitize catcodes so we keep those +% verbatim \cs{obeyedline} typed in by user. Remove remaining +% \enquote{\%} character at the beginning of a line using traditional +% |^^M| marker. Remove tabs and newlines. Finally, convert % |_@@| and |@@| to |__|\meta{module name} (if it is non-empty). At % this point, \cs{l_@@_tmpa_tl} contains a comma-delimited list of % names, where |@| and~|_| have category code letter. Turn it to a @@ -2172,17 +2190,20 @@ and all files in that bundle must be distributed together. % \begin{macrocode} \cs_new_protected:Npn \@@_names_get_seq:nN #1#2 { - \__kernel_tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:n {#1} } \bool_if:NTF \l_@@_names_verb_bool { \seq_clear:N #2 - \seq_put_right:NV #2 \l_@@_tmpa_tl + \seq_put_right:No #2 { \tl_to_str:n {#1} } } { + \tl_set:Nn \l_@@_tmpa_tl {#1} \tl_remove_all:Ne \l_@@_tmpa_tl - { \iow_char:N \^^M \c_percent_str } + { \exp_not:N \obeyedline \c_percent_str } \tl_remove_all:Ne \l_@@_tmpa_tl - { \token_to_str:N \obeyedline \c_space_tl \c_percent_str } + { \exp_not:N \obeyedline } + \__kernel_tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:N \l_@@_tmpa_tl } + \tl_remove_all:Ne \l_@@_tmpa_tl + { \iow_char:N \^^M \c_percent_str } \tl_remove_all:Ne \l_@@_tmpa_tl { \tl_to_str:n { ^ ^ A } } \tl_remove_all:Ne \l_@@_tmpa_tl { \iow_char:N \^^I } \tl_remove_all:Ne \l_@@_tmpa_tl { \iow_char:N \^^M } @@ -2529,7 +2550,7 @@ and all files in that bundle must be distributed together. \cs_new_protected:Npn \@@_function_typeset_stop: { \par - \dim_set:Nn \prevdepth { \box_dp:N \l_@@_descr_coffin } + \dim_set:Nn \prevdepth { \coffin_dp:N \l_@@_descr_coffin } \allowbreak } % \end{macrocode} @@ -2594,7 +2615,7 @@ and all files in that bundle must be distributed together. \dim_zero:N \l_@@_trial_width_dim \hcoffin_set:Nn \l_@@_functions_coffin { \@@_typeset_functions: } \dim_set:Nn \l_@@_trial_width_dim - { \box_wd:N \l_@@_functions_coffin } + { \coffin_wd:N \l_@@_functions_coffin } \bool_set:Nn \l_@@_long_name_bool { \dim_compare_p:nNn \l_@@_trial_width_dim > \marginparwidth } } @@ -2643,7 +2664,7 @@ and all files in that bundle must be distributed together. \coffin_join:NnnNnnnn \l_@@_output_coffin {l} {b} \l_@@_descr_coffin {l} {t} - {0.75\marginparwidth + \marginparsep} {-\medskipamount} + {\marginparwidth + \marginparsep} {-\medskipamount} \coffin_typeset:Nnnnn \l_@@_output_coffin {\l_@@_descr_coffin-l} {\l_@@_descr_coffin-t} {0pt} {0pt} @@ -2695,8 +2716,7 @@ and all files in that bundle must be distributed together. % \end{macro} % % ^^A TODO: collect all index targets from a given function environment in a box and stick it at the top. -% \begin{macro} -% {\@@_typeset_function_block:nN, \@@_typeset_function_block:eN} +% \begin{macro}{\@@_typeset_function_block:nN} % \begin{macro}{\@@_function_index:n, \@@_function_index:e} % |#1| is a csname, |#2| a boolean indicating whether to add |TF| or not. % \begin{macrocode} @@ -2712,7 +2732,6 @@ and all files in that bundle must be distributed together. { \@@_typeset_variant_list:nN {#1} #2 } \\ } -\cs_generate_variant:Nn \@@_typeset_function_block:nN { e } \cs_new_protected:Npn \@@_function_index:n #1 { \seq_gput_right:Nn \g_doc_functions_seq {#1} @@ -2840,7 +2859,7 @@ and all files in that bundle must be distributed together. { \textwidth \bool_if:NT \l_@@_long_name_bool - { + 0.75 \marginparwidth - \l_@@_trial_width_dim } + { + \marginparwidth - \l_@@_trial_width_dim } } \hbox_gset:Nw \g_@@_syntax_box \small \ttfamily @@ -3213,7 +3232,7 @@ and all files in that bundle must be distributed together. % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_print_macroname_aux:nn} +% \begin{macro}{\@@_print_macroname_aux:nn, \@@_print_macroname_aux:on} % |#1| is prefix, |#2| is optional |TF| suffix. % \begin{macrocode} \cs_new_protected:Npn \@@_print_macroname_aux:nn #1#2 @@ -3589,7 +3608,7 @@ and all files in that bundle must be distributed together. % \begin{macrocode} \newenvironment{TemplateInterfaceDescription}[1] { - \subsection{The~object~type~`#1'} + \subsection{The~template~type~`#1'} \begingroup \@beginparpenalty\@M \description @@ -3608,7 +3627,7 @@ and all files in that bundle must be distributed together. % \begin{macrocode} \newenvironment{TemplateDescription}[2] { - \subsection{The~template~`#2'~(object~type~#1)} + \subsection{The~template~`#2'~(template~type~#1)} \subsubsection*{Attributes:} \begingroup \@beginparpenalty\@M @@ -3714,7 +3733,7 @@ and all files in that bundle must be distributed together. { \clist_map_inline:nn {#1} { - \clist_put_right:Nn \g_docinput_clist {##1} + \clist_gput_right:Nn \g_docinput_clist {##1} \@@_input:n {##1} } } @@ -3839,7 +3858,7 @@ and all files in that bundle must be distributed together. { MMMMV - \filesep \int_use:N \c@CodelineNo } } } -\tl_gclear:N \filesep +\tl_clear_new:N \filesep \cs_new_protected:Npn \@@_index_page_hc:nn #1#2 { \protected@write \@indexfile {} @@ -4254,7 +4273,6 @@ and all files in that bundle must be distributed together. {#2} \l_@@_index_internal_bool } -\cs_generate_variant:Nn \@@_special_index:nn { o } % \end{macrocode} % \end{macro} % @@ -4698,7 +4716,7 @@ and all files in that bundle must be distributed together. % \begin{macrocode} \tl_const:Nn \Team { - The~\LaTeX3~Project\thanks + The~\LaTeX~Project~team\thanks {\url{https://www.latex-project.org/latex3/}} } % \end{macrocode} @@ -4712,7 +4730,7 @@ and all files in that bundle must be distributed together. } \author { - The~\LaTeX3~Project\thanks{E-mail:~ + The~\LaTeX~Project~team\thanks{E-mail:~ \href{mailto:latex-l@listserv.uni-heidelberg.de} {latex-l@listserv.uni-heidelberg.de}} } diff --git a/macros/latex/required/l3kernel/l3doc.pdf b/macros/latex/required/l3kernel/l3doc.pdf Binary files differindex 42960f5e6f..e368761eb8 100644 --- a/macros/latex/required/l3kernel/l3doc.pdf +++ b/macros/latex/required/l3kernel/l3doc.pdf diff --git a/macros/latex/required/l3kernel/l3docstrip.dtx b/macros/latex/required/l3kernel/l3docstrip.dtx index fecb228324..4c6592789b 100644 --- a/macros/latex/required/l3kernel/l3docstrip.dtx +++ b/macros/latex/required/l3kernel/l3docstrip.dtx @@ -2,7 +2,7 @@ % %% File l3dosctrip.dtx % -% Copyright (C) 2012-2024 The LaTeX Project +% Copyright (C) 2012-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -63,7 +63,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3docstrip.pdf b/macros/latex/required/l3kernel/l3docstrip.pdf Binary files differindex efc8882c36..90f0bb5ac4 100644 --- a/macros/latex/required/l3kernel/l3docstrip.pdf +++ b/macros/latex/required/l3kernel/l3docstrip.pdf diff --git a/macros/latex/required/l3kernel/l3expan.dtx b/macros/latex/required/l3kernel/l3expan.dtx index d13578bde1..ee5ad95896 100644 --- a/macros/latex/required/l3kernel/l3expan.dtx +++ b/macros/latex/required/l3kernel/l3expan.dtx @@ -2,7 +2,7 @@ % %% File: l3expan.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -75,8 +75,8 @@ % If \cs{seq_gpush:No} was not defined it could be coded in the following way: % \begin{verbatim} % \exp_args:NNo \seq_gpush:Nn -% \g_file_name_stack -% { \l_tmpa_tl } +% \g_file_name_stack +% { \l_tmpa_tl } % \end{verbatim} % In other words, the first argument to \cs{exp_args:NNo} is the base % function and the other arguments are preprocessed and then passed to @@ -2203,6 +2203,7 @@ % \@@_generate_variant_T_form:nnn, % \@@_generate_variant_F_form:nnn, % \@@_generate_variant_TF_form:nnn, +% \@@_generate_variant_check:nn % } % \begin{macrocode} \cs_new_protected:Npn \prg_generate_conditional_variant:Nnn #1 @@ -2244,13 +2245,23 @@ \@@_generate_variant:w #2 \s_@@_mark {#3} {#4} {#5} } \cs_new_protected:Npn \@@_generate_variant_p_form:nnn #1#2 - { \cs_generate_variant:cn { #1 _p : #2 } } + { \@@_generate_variant_check:nn { #1 _p : #2 } } \cs_new_protected:Npn \@@_generate_variant_T_form:nnn #1#2 - { \cs_generate_variant:cn { #1 : #2 T } } + { \@@_generate_variant_check:nn { #1 : #2 T } } \cs_new_protected:Npn \@@_generate_variant_F_form:nnn #1#2 - { \cs_generate_variant:cn { #1 : #2 F } } + { \@@_generate_variant_check:nn { #1 : #2 F } } \cs_new_protected:Npn \@@_generate_variant_TF_form:nnn #1#2 - { \cs_generate_variant:cn { #1 : #2 TF } } + { \@@_generate_variant_check:nn { #1 : #2 TF } } +\cs_new_protected:Npn \@@_generate_variant_check:nn #1#2 + { + \cs_if_exist:cTF {#1} + { \cs_generate_variant:cn {#1} {#2} } + { + \msg_error:nne + { kernel } { conditional-base-undefined } + { \token_to_str:c {#1} } + } + } % \end{macrocode} % \end{macro} % diff --git a/macros/latex/required/l3kernel/l3file.dtx b/macros/latex/required/l3kernel/l3file.dtx index 546222711e..460d8794d8 100644 --- a/macros/latex/required/l3kernel/l3file.dtx +++ b/macros/latex/required/l3kernel/l3file.dtx @@ -2,7 +2,7 @@ % %% File: l3file.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -225,8 +225,8 @@ % % \begin{function}[noTF, added = 2012-06-24, updated = 2019-03-23]{\ior_get:NN} % \begin{syntax} -% \cs{ior_get:NN} \meta{stream} \meta{token list variable} -% \cs{ior_get:NNTF} \meta{stream} \meta{token list variable} \meta{true code} \meta{false code} +% \cs{ior_get:NN} \meta{stream} \meta{tl~var} +% \cs{ior_get:NNTF} \meta{stream} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % Function that reads one or more lines (until an equal number of left % and right braces are found) from the file input \meta{stream} and stores @@ -243,7 +243,7 @@ % converted to the token \cs{par}. Therefore, blank lines can be % skipped by using a test such as % \begin{verbatim} -% \ior_get:NN \l_my_stream \l_tmpa_tl +% \ior_get:NN \l_my_ior \l_tmpa_tl % \tl_set:Nn \l_tmpb_tl { \par } % \tl_if_eq:NNF \l_tmpa_tl \l_tmpb_tl % ... @@ -267,8 +267,8 @@ % \begin{function}[noTF, added = 2016-12-04, updated = 2019-03-23] % {\ior_str_get:NN} % \begin{syntax} -% \cs{ior_str_get:NN} \meta{stream} \meta{token list variable} -% \cs{ior_str_get:NNTF} \meta{stream} \meta{token list variable} \meta{true code} \meta{false code} +% \cs{ior_str_get:NN} \meta{stream} \meta{tl~var} +% \cs{ior_str_get:NNTF} \meta{stream} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % Function that reads one line from the file input \meta{stream} and stores % the result locally in the \meta{token list} variable. @@ -277,7 +277,7 @@ % characters which are given category code $10$ (space). % Multiple whitespace characters are retained by this process. It % always only reads one line and any blank lines in the input -% result in the \meta{token list variable} being empty. Unlike +% result in the \meta{tl~var} being empty. Unlike % \cs{ior_get:NN}, line ends do not receive any special treatment. Thus % input % \begin{verbatim} @@ -429,7 +429,7 @@ % % \begin{function}[added = 2019-03-23]{\ior_get_term:nN, \ior_str_get_term:nN} % \begin{syntax} -% \cs{ior_get_term:nN} \Arg{prompt} \meta{token list variable} +% \cs{ior_get_term:nN} \Arg{prompt} \meta{tl~var} % \end{syntax} % Function that reads one or more lines (until an equal number of left % and right braces are found) from the terminal and stores @@ -718,8 +718,33 @@ % \cs{file_if_exist_p:n} \Arg{file name} % \cs{file_if_exist:nTF} \Arg{file name} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests if \meta{file name} is found in the path as detailed for -% \cs{file_if_exist:nTF}. +% Expands the argument of the \meta{file name} to give a string, then +% searches for this string using the current \TeX{} search +% path and the additional paths controlled by +% \cs{l_file_search_path_seq}. +% +% Since \TeX{} cannot remove files, only write to them, once a file +% has been found during a \TeX{} run, it will exist until the end of +% the run unless a non-\TeX{} process intervenes. Since file operations +% are relatively slow, \pkg{expl3} therefore internally tracks when a +% file is seen, and uses this information to avoid multiple filesystem +% checks. See \cs{file_forget:n} for how to indicate to \pkg{expl3} that +% a file may have been deleted \emph{during} a \TeX{} run, so that its +% presence in the filesystem can be reasserted with \cs{file_if_exist:nTF} +% and similar commands. +% \end{function} +% +% \begin{function}[added = 2024-12-09]{\file_forget:n} +% \begin{syntax} +% \cs{file_forget:n} \Arg{file name} +% \end{syntax} +% Resets the internal tracker for files such that a subsequent use of +% \cs{file_if_exist:nTF}, \cs{file_size:n}, etc., for the \meta{file name} will +% re-query the filesystem rather than use any cached information. This can +% be used whether or not the file has previously been seen. This function +% is intended to be used where non-\TeX{} processes may result in file +% deletion, for example if \LuaTeX{} is in use, |os.remove()| may be used +% to delete a file part-way through a run. % \end{function} % % \subsection{Information about files and file contents} @@ -844,11 +869,11 @@ % \file_compare_timestamp:VNV % } % \begin{syntax} -% \cs{file_compare_timestamp_p:nNn} \Arg{file-1} \meta{comparator} \Arg{file-2} -% \cs{file_compare_timestamp:nNnTF} \Arg{file-1} \meta{comparator} \Arg{file-2} \Arg{true code} \Arg{false code} +% \cs{file_compare_timestamp_p:nNn} \Arg{file-1} \meta{relation} \Arg{file-2} +% \cs{file_compare_timestamp:nNnTF} \Arg{file-1} \meta{relation} \Arg{file-2} \Arg{true code} \Arg{false code} % \end{syntax} % Compares the file stamps on the two \meta{files} as indicated by -% the \meta{comparator}, and inserts either the \meta{true code} +% the \meta{relation}, and inserts either the \meta{true code} % or \meta{false case} as required. A file which is not found % is treated as older than any file which is found. This allows for % example the construct @@ -865,8 +890,8 @@ % \begin{function}[noTF, updated = 2019-02-16] % {\file_get_full_name:nN, \file_get_full_name:VN} % \begin{syntax} -% \cs{file_get_full_name:nN} \Arg{file name} \meta{tl} -% \cs{file_get_full_name:nNTF} \Arg{file name} \meta{tl} \Arg{true code} \Arg{false code} +% \cs{file_get_full_name:nN} \Arg{file name} \meta{tl var} +% \cs{file_get_full_name:nNTF} \Arg{file name} \meta{tl var} \Arg{true code} \Arg{false code} % \end{syntax} % Searches for \meta{file name} in the path as detailed for % \cs{file_if_exist:nTF}, and if found sets the \meta{tl var} the @@ -941,15 +966,15 @@ % \begin{function}[noTF, added = 2019-01-16, updated = 2019-02-16] % {\file_get:nnN, \file_get:VnN} % \begin{syntax} -% \cs{file_get:nnN} \Arg{file name} \Arg{setup} \meta{tl} -% \cs{file_get:nnNTF} \Arg{file name} \Arg{setup} \meta{tl} \Arg{true code} \Arg{false code} +% \cs{file_get:nnN} \Arg{file name} \Arg{setup} \meta{tl var} +% \cs{file_get:nnNTF} \Arg{file name} \Arg{setup} \meta{tl var} \Arg{true code} \Arg{false code} % \end{syntax} -% Defines \meta{tl} to the contents of \meta{file name}. +% Defines \meta{tl var} to the contents of \meta{file name}. % Category codes may need to be set appropriately via the \meta{setup} % argument. -% The non-branching version sets the \meta{tl} to \cs{q_no_value} if the file is +% The non-branching version sets the \meta{tl var} to \cs{q_no_value} if the file is % not found. The branching version runs the \meta{true code} after the -% assignment to \meta{tl} if the file is found, and \meta{false code} +% assignment to \meta{tl var} if the file is found, and \meta{false code} % otherwise. The file content will be tokenized using the current % category code régime, % \end{function} @@ -3118,6 +3143,15 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\file_forget:n} +% Just a wrapper around a csname: we have to do a lookup here to make +% sure any paths are handled. +% \begin{macrocode} +\cs_new_protected:Npn \file_forget:n #1 + { \cs_undefine:c { @@_seen_ \file_full_name:n {#1} : } } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\file_get_full_name:nN, \file_get_full_name:VN} % \begin{macro}[TF]{\file_get_full_name:nN, \file_get_full_name:VN} % \begin{macro}{\@@_get_full_name_search:nN} diff --git a/macros/latex/required/l3kernel/l3flag.dtx b/macros/latex/required/l3kernel/l3flag.dtx index 88e726df35..2763ccfe25 100644 --- a/macros/latex/required/l3kernel/l3flag.dtx +++ b/macros/latex/required/l3kernel/l3flag.dtx @@ -2,7 +2,7 @@ % %% File: l3flag.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-assign.dtx b/macros/latex/required/l3kernel/l3fp-assign.dtx index e6fa97423e..f7fc361dab 100644 --- a/macros/latex/required/l3kernel/l3fp-assign.dtx +++ b/macros/latex/required/l3kernel/l3fp-assign.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-assign.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % \maketitle % % \begin{documentation} @@ -75,7 +75,9 @@ % \begin{macro} % { % \fp_set:Nn, \fp_set:cn, +% \fp_set:NV, \fp_set:cV, % \fp_gset:Nn, \fp_gset:cn, +% \fp_gset:NV, \fp_gset:cV, % \fp_const:Nn, \fp_const:cn % } % Simply use \cs{@@_parse:n} within various \texttt{f}-expanding @@ -87,8 +89,8 @@ { \__kernel_tl_gset:Nx #1 { \exp_not:f { \@@_parse:n {#2} } } } \cs_new_protected:Npn \fp_const:Nn #1#2 { \tl_const:Ne #1 { \exp_not:f { \@@_parse:n {#2} } } } -\cs_generate_variant:Nn \fp_set:Nn {c} -\cs_generate_variant:Nn \fp_gset:Nn {c} +\cs_generate_variant:Nn \fp_set:Nn { NV , c , cV } +\cs_generate_variant:Nn \fp_gset:Nn { NV , c , cV } \cs_generate_variant:Nn \fp_const:Nn {c} % \end{macrocode} % \end{macro} @@ -202,9 +204,9 @@ { \@@_show_validate:nn { #1 } { - \s_@@ \@@_chk:w ??? ;~ or \iow_newline: - \s_@@_tuple \_@@_tuple_chk:w ? ;~ or \iow_newline: - \s_@@_symbolic \@@_symbolic_chk:w ? , ? ; + \s_@@ \@@_chk:w ??? \@@_sep: or \iow_newline: + \s_@@_tuple \_@@_tuple_chk:w ? \@@_sep: or \iow_newline: + \s_@@_symbolic \@@_symbolic_chk:w ? , ? \@@_sep: } } \cs_new:Npn \@@_show_validate_aux:n #1 @@ -220,46 +222,49 @@ { \s_@@ } { \@@_show_validate:w #1 \s_@@ - \@@_chk:w ??? ; \s_@@_stop + \@@_chk:w ??? \@@_sep: \s_@@_stop } { \s_@@_tuple } { \@@_tuple_show_validate:w #1 - \s_@@_tuple \_@@_tuple_chk:w ?? ; \s_@@_stop + \s_@@_tuple \_@@_tuple_chk:w ?? \@@_sep: \s_@@_stop } { \s_@@_symbolic } { \@@_symbolic_show_validate:w #1 - \s_@@_symbolic \@@_symbolic_chk:w ? , ?? ; \s_@@_stop + \s_@@_symbolic \@@_symbolic_chk:w ? , ?? \@@_sep: \s_@@_stop } } { #2 } } } \cs_new:Npn \@@_show_validate:w - #1 \s_@@ \@@_chk:w #2#3#4#5 ; #6 \s_@@_stop + #1 \s_@@ \@@_chk:w #2#3#4#5 \@@_sep: #6 \s_@@_stop { \str_if_eq:nnF { #2 } {?} { \token_if_eq_meaning:NNTF #2 1 - { \s_@@ \@@_chk:w #2 #3 { #4 } #5 ; } - { \s_@@ \@@_chk:w #2 #3 #4 #5 ; } + { \s_@@ \@@_chk:w #2 #3 { #4 } #5 \@@_sep: } + { \s_@@ \@@_chk:w #2 #3 #4 #5 \@@_sep: } \@@_show_validate_aux:n { #6 } } } \cs_new:Npn \@@_tuple_show_validate:w - #1 \s_@@_tuple \_@@_tuple_chk:w #2#3 ; #4 \s_@@_stop + #1 \s_@@_tuple \_@@_tuple_chk:w #2#3 \@@_sep: #4 \s_@@_stop { \str_if_eq:nnF { #2 } {?} - { \s_@@_tuple \@@_tuple_chk:w { \@@_show_validate_aux:n { #2 } } ; } + { + \s_@@_tuple \@@_tuple_chk:w { \@@_show_validate_aux:n { #2 } } + \@@_sep: + } } \cs_new:Npn \@@_symbolic_show_validate:w - #1 \s_@@_symbolic \@@_symbolic_chk:w #2 , #3#4 ; #5 \s_@@_stop + #1 \s_@@_symbolic \@@_symbolic_chk:w #2 , #3#4 \@@_sep: #5 \s_@@_stop { \str_if_eq:nnF { #2 } {?} { \s_@@_symbolic \@@_symbolic_chk:w \exp_not:n { #2 } , - { \@@_show_validate_aux:n { #3 } }; + { \@@_show_validate_aux:n { #3 } }\@@_sep: \@@_show_validate_aux:n { #5 } } } diff --git a/macros/latex/required/l3kernel/l3fp-aux.dtx b/macros/latex/required/l3kernel/l3fp-aux.dtx index 1ad33e235e..05f514f82e 100644 --- a/macros/latex/required/l3kernel/l3fp-aux.dtx +++ b/macros/latex/required/l3kernel/l3fp-aux.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-aux.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -79,12 +79,27 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_sep:} +% We need a way to stop the expansion in \cs{@@_int_eval:w} and similar with a +% token that isn't absorbed so that it works as a marker for right-delimited +% arguments. Additionally the used token should be impossible to form a valid +% expression for these expression primitives (the otherwise often used +% |;| is turned into a binary operator in some engines for instance). And +% since this is about right-delimiting I think it's funny to use +% \cs{tex_right:D}. An unexpandable primitive is used because it is guaranteed +% to never be a valid token in such an expression and survives all kinds of +% expansion (just like |;| would). +% \begin{macrocode} +\cs_new_eq:NN \@@_sep: \tex_right:D +% \end{macrocode} +% \end{macro} +% % \subsection{Internal representation} % % Internally, a floating point number \meta{X} is a % token list containing % \begin{quote} -% \cs{s_@@} \cs{@@_chk:w} \meta{case} \meta{sign} \meta{body} |;| +% \cs{s_@@} \cs{@@_chk:w} \meta{case} \meta{sign} \meta{body} \cs{@@_sep:} % \end{quote} % Let us explain each piece separately. % @@ -117,15 +132,15 @@ % % Special floating point numbers have the form % \begin{quote} -% \cs{s_@@} \cs{@@_chk:w} \meta{case} \meta{sign} \cs[no-index]{s_@@_\ldots} |;| +% \cs{s_@@} \cs{@@_chk:w} \meta{case} \meta{sign} \cs[no-index]{s_@@_\ldots} \cs{@@_sep:} % \end{quote} -% where \cs[no-index]{s_@@_\ldots} is a scan mark carrying information about how the -% number was formed (useful for debugging). +% where \cs[no-index]{s_@@_\ldots} is a scan mark carrying information about how +% the number was formed (useful for debugging). % % Normal floating point numbers ($\meta{case} = 1$) have the form % \begin{quote} % \cs{s_@@} \cs{@@_chk:w} 1 \meta{sign} \Arg{exponent} -% \Arg{X_1} \Arg{X_2} \Arg{X_3} \Arg{X_4} |;| +% \Arg{X_1} \Arg{X_2} \Arg{X_3} \Arg{X_4} \cs{@@_sep:} % \end{quote} % Here, the \meta{exponent} is an integer, between % $-\ExplSyntaxOn\int_use:N\c__fp_minus_min_exponent_int$ and @@ -135,8 +150,9 @@ % \[ % (-1)^{\meta{sign}/2} \meta{X_1}\meta{X_2}\meta{X_3}\meta{X_4}\cdot 10^{\meta{exponent}-16} % \] -% where we have concatenated the $16$ digits. Currently, floating point numbers are normalized such that -% the \meta{exponent} is minimal, in other words, $1000 \leq \meta{X_1} \leq 9999$. +% where we have concatenated the $16$ digits. Currently, floating point numbers +% are normalized such that the \meta{exponent} is minimal, in other words, +% $1000 \leq \meta{X_1} \leq 9999$. % % \begin{table}\centering % \caption{Internal representation of floating point numbers.} @@ -176,8 +192,8 @@ % Those functions place a semicolon after one or two arguments % (typically digits). % \begin{macrocode} -\cs_new:Npn \@@_use_s:n #1 { #1; } -\cs_new:Npn \@@_use_s:nn #1#2 { #1#2; } +\cs_new:Npn \@@_use_s:n #1 { #1\@@_sep: } +\cs_new:Npn \@@_use_s:nn #1#2 { #1#2\@@_sep: } % \end{macrocode} % \end{macro} % @@ -186,9 +202,9 @@ % Those functions select specific arguments among a set of arguments % delimited by a semicolon. % \begin{macrocode} -\cs_new:Npn \@@_use_none_until_s:w #1; { } -\cs_new:Npn \@@_use_i_until_s:nw #1#2; {#1} -\cs_new:Npn \@@_use_ii_until_s:nnw #1#2#3; {#2} +\cs_new:Npn \@@_use_none_until_s:w #1\@@_sep: { } +\cs_new:Npn \@@_use_i_until_s:nw #1#2\@@_sep: {#1} +\cs_new:Npn \@@_use_ii_until_s:nnw #1#2#3\@@_sep: {#2} % \end{macrocode} % \end{macro} % @@ -196,7 +212,8 @@ % Many internal functions take arguments delimited by semicolons, and % it is occasionally useful to swap two such arguments. % \begin{macrocode} -\cs_new:Npn \@@_reverse_args:Nww #1 #2; #3; { #1 #3; #2; } +\cs_new:Npn \@@_reverse_args:Nww #1 #2\@@_sep: #3\@@_sep: + { #1 #3\@@_sep: #2\@@_sep: } % \end{macrocode} % \end{macro} % @@ -204,7 +221,8 @@ % Rotate three arguments delimited by semicolons. This is the inverse % (or the square) of the Forth primitive |ROT|, hence the name. % \begin{macrocode} -\cs_new:Npn \@@_rrot:www #1; #2; #3; { #2; #3; #1; } +\cs_new:Npn \@@_rrot:www #1\@@_sep: #2\@@_sep: #3\@@_sep: + { #2\@@_sep: #3\@@_sep: #1\@@_sep: } % \end{macrocode} % \end{macro} % @@ -212,8 +230,8 @@ % Many internal functions take arguments delimited by semicolons, and % it is occasionally useful to remove one or two such arguments. % \begin{macrocode} -\cs_new:Npn \@@_use_i:ww #1; #2; { #1; } -\cs_new:Npn \@@_use_i:www #1; #2; #3; { #1; } +\cs_new:Npn \@@_use_i:ww #1\@@_sep: #2\@@_sep: { #1\@@_sep: } +\cs_new:Npn \@@_use_i:www #1\@@_sep: #2\@@_sep: #3\@@_sep: { #1\@@_sep: } % \end{macrocode} % \end{macro} % @@ -241,8 +259,8 @@ % expanded. We define \cs{@@_chk:w} to produce an error. % \begin{macrocode} \scan_new:N \s_@@ -\cs_new_protected:Npn \@@_chk:w #1 ; - { \@@_misused:n { \s_@@ \@@_chk:w #1 ; } } +\cs_new_protected:Npn \@@_chk:w #1 \@@_sep: + { \@@_misused:n { \s_@@ \@@_chk:w #1 \@@_sep: } } % \end{macrocode} % \end{macro} % @@ -287,13 +305,14 @@ % % \begin{variable} % {\c_zero_fp, \c_minus_zero_fp, \c_inf_fp, \c_minus_inf_fp, \c_nan_fp} -% The special floating points. We define the floating points here as \enquote{exact}. +% The special floating points. We define the floating points here as +% \enquote{exact}. % \begin{macrocode} -\tl_const:Nn \c_zero_fp { \s_@@ \@@_chk:w 0 0 \s_@@_exact ; } -\tl_const:Nn \c_minus_zero_fp { \s_@@ \@@_chk:w 0 2 \s_@@_exact ; } -\tl_const:Nn \c_inf_fp { \s_@@ \@@_chk:w 2 0 \s_@@_exact ; } -\tl_const:Nn \c_minus_inf_fp { \s_@@ \@@_chk:w 2 2 \s_@@_exact ; } -\tl_const:Nn \c_nan_fp { \s_@@ \@@_chk:w 3 1 \s_@@_exact ; } +\tl_const:Nn \c_zero_fp { \s_@@ \@@_chk:w 0 0 \s_@@_exact \@@_sep: } +\tl_const:Nn \c_minus_zero_fp { \s_@@ \@@_chk:w 0 2 \s_@@_exact \@@_sep: } +\tl_const:Nn \c_inf_fp { \s_@@ \@@_chk:w 2 0 \s_@@_exact \@@_sep: } +\tl_const:Nn \c_minus_inf_fp { \s_@@ \@@_chk:w 2 2 \s_@@_exact \@@_sep: } +\tl_const:Nn \c_nan_fp { \s_@@ \@@_chk:w 3 1 \s_@@_exact \@@_sep: } % \end{macrocode} % \end{variable} % @@ -343,7 +362,7 @@ { \s_@@ \@@_chk:w 1 0 { \int_eval:n { \c_@@_max_exponent_int + 1 } } - {1000} {0000} {0000} {0000} ; + {1000} {0000} {0000} {0000} \@@_sep: } % \end{macrocode} % \end{variable} @@ -353,9 +372,9 @@ % a zero or infinity with a given sign. % \begin{macrocode} \cs_new:Npn \@@_zero_fp:N #1 - { \s_@@ \@@_chk:w 0 #1 \s_@@_underflow ; } + { \s_@@ \@@_chk:w 0 #1 \s_@@_underflow \@@_sep: } \cs_new:Npn \@@_inf_fp:N #1 - { \s_@@ \@@_chk:w 2 #1 \s_@@_overflow ; } + { \s_@@ \@@_chk:w 2 #1 \s_@@_overflow \@@_sep: } % \end{macrocode} % \end{macro} % @@ -411,7 +430,7 @@ % to $\pm\infty$. The functions \cs{@@_underflow:w} and % \cs{@@_overflow:w} are defined in \pkg{l3fp-traps}. % \begin{macrocode} -\cs_new:Npn \@@_sanitize:Nw #1 #2; +\cs_new:Npn \@@_sanitize:Nw #1 #2\@@_sep: { \if_case:w \if_int_compare:w #2 > \c_@@_max_exponent_int 1 ~ \else: @@ -423,8 +442,8 @@ \fi: \s_@@ \@@_chk:w 1 #1 {#2} } -\cs_new:Npn \@@_sanitize:wN #1; #2 { \@@_sanitize:Nw #2 #1; } -\cs_new:Npn \@@_sanitize_zero:w \s_@@ \@@_chk:w #1 #2 #3; +\cs_new:Npn \@@_sanitize:wN #1\@@_sep: #2 { \@@_sanitize:Nw #2 #1\@@_sep: } +\cs_new:Npn \@@_sanitize_zero:w \s_@@ \@@_chk:w #1 #2 #3\@@_sep: { \c_zero_fp } % \end{macrocode} % \end{macro} @@ -472,19 +491,19 @@ % % \begin{macro}[EXP]{\@@_exp_after_special:nNNw} % \begin{syntax} -% \cs{@@_exp_after_special:nNNw} \Arg{after} \meta{case} \meta{sign} \meta{scan mark} |;| +% \cs{@@_exp_after_special:nNNw} \Arg{after} \meta{case} \meta{sign} \meta{scan mark} \cs{@@_sep:} % \end{syntax} % Special floating point numbers are easy to jump over since they % contain few tokens. % \begin{macrocode} -\cs_new:Npn \@@_exp_after_special:nNNw #1#2#3#4; +\cs_new:Npn \@@_exp_after_special:nNNw #1#2#3#4\@@_sep: { \exp_after:wN \s_@@ \exp_after:wN \@@_chk:w \exp_after:wN #2 \exp_after:wN #3 \exp_after:wN #4 - \exp_after:wN ; + \exp_after:wN \@@_sep: #1 } % \end{macrocode} @@ -496,19 +515,19 @@ % the digits were not braced but instead were delimited arguments (for % instance delimited by |,|). That may be changed some day. % \begin{macrocode} -\cs_new:Npn \@@_exp_after_normal:nNNw #1 1 #2 #3 #4#5#6#7; +\cs_new:Npn \@@_exp_after_normal:nNNw #1 1 #2 #3 #4#5#6#7\@@_sep: { \exp_after:wN \@@_exp_after_normal:Nwwwww \exp_after:wN #2 - \int_value:w #3 \exp_after:wN ; - \int_value:w 1 #4 \exp_after:wN ; - \int_value:w 1 #5 \exp_after:wN ; - \int_value:w 1 #6 \exp_after:wN ; - \int_value:w 1 #7 \exp_after:wN ; #1 + \int_value:w #3 \exp_after:wN \@@_sep: + \int_value:w 1 #4 \exp_after:wN \@@_sep: + \int_value:w 1 #5 \exp_after:wN \@@_sep: + \int_value:w 1 #6 \exp_after:wN \@@_sep: + \int_value:w 1 #7 \exp_after:wN \@@_sep: #1 } \cs_new:Npn \@@_exp_after_normal:Nwwwww - #1 #2; 1 #3 ; 1 #4 ; 1 #5 ; 1 #6 ; - { \s_@@ \@@_chk:w 1 #1 {#2} {#3} {#4} {#5} {#6} ; } + #1 #2\@@_sep: 1 #3 \@@_sep: 1 #4 \@@_sep: 1 #5 \@@_sep: 1 #6 \@@_sep: + { \s_@@ \@@_chk:w 1 #1 {#2} {#3} {#4} {#5} {#6} \@@_sep: } % \end{macrocode} % \end{macro} % @@ -517,17 +536,17 @@ % \begin{macro}{\s_@@_tuple, \@@_tuple_chk:w} % \begin{variable}{\c_@@_empty_tuple_fp} % Floating point tuples take the form \cs{s_@@_tuple} -% \cs{@@_tuple_chk:w} |{| \meta{fp 1} \meta{fp 2} \dots |}| |;| where -% each \meta{fp} is a floating point number or tuple, hence ends with -% |;| itself. When a tuple is typeset, \cs{@@_tuple_chk:w} produces +% \cs{@@_tuple_chk:w} |{| \meta{fp 1} \meta{fp 2} \dots |}| \cs{@@_sep:} +% where each \meta{fp} is a floating point number or tuple, hence ends with +% \cs{@@_sep:} itself. When a tuple is typeset, \cs{@@_tuple_chk:w} produces % an error, just like usual floating point numbers. % Tuples may have zero or one element. % \begin{macrocode} \scan_new:N \s_@@_tuple -\cs_new_protected:Npn \@@_tuple_chk:w #1 ; - { \@@_misused:n { \s_@@_tuple \@@_tuple_chk:w #1 ; } } +\cs_new_protected:Npn \@@_tuple_chk:w #1 \@@_sep: + { \@@_misused:n { \s_@@_tuple \@@_tuple_chk:w #1 \@@_sep: } } \tl_const:Nn \c_@@_empty_tuple_fp - { \s_@@_tuple \@@_tuple_chk:w { } ; } + { \s_@@_tuple \@@_tuple_chk:w { } \@@_sep: } % \end{macrocode} % \end{variable} % \end{macro} @@ -540,15 +559,15 @@ % with the |\use_none:n #1| construction. % \begin{macrocode} \cs_new:Npn \@@_array_count:n #1 - { \@@_tuple_count:w \s_@@_tuple \@@_tuple_chk:w {#1} ; } -\cs_new:Npn \@@_tuple_count:w \s_@@_tuple \@@_tuple_chk:w #1 ; + { \@@_tuple_count:w \s_@@_tuple \@@_tuple_chk:w {#1} \@@_sep: } +\cs_new:Npn \@@_tuple_count:w \s_@@_tuple \@@_tuple_chk:w #1 \@@_sep: { \int_value:w \@@_int_eval:w 0 - \@@_tuple_count_loop:Nw #1 { ? \prg_break: } ; + \@@_tuple_count_loop:Nw #1 { ? \prg_break: } \@@_sep: \prg_break_point: \@@_int_eval_end: } -\cs_new:Npn \@@_tuple_count_loop:Nw #1#2; +\cs_new:Npn \@@_tuple_count_loop:Nw #1#2\@@_sep: { \use_none:n #1 + 1 \@@_tuple_count_loop:Nw } % \end{macrocode} % \end{macro} @@ -570,10 +589,10 @@ % \begin{macrocode} \cs_new:Npn \@@_array_if_all_fp:nTF #1 { - \@@_array_if_all_fp_loop:w #1 { \s_@@ \prg_break: } ; + \@@_array_if_all_fp_loop:w #1 { \s_@@ \prg_break: } \@@_sep: \prg_break_point: \use_i:nn } -\cs_new:Npn \@@_array_if_all_fp_loop:w #1#2 ; +\cs_new:Npn \@@_array_if_all_fp_loop:w #1#2 \@@_sep: { \@@_if_type_fp:NTwFw #1 \@@_array_if_all_fp_loop:w @@ -680,16 +699,16 @@ % item in the tuple and expand it. % \begin{quote} % \cs{@@_exp_after_array_f:w}\\ -% \meta{fp_1} |;|\\ +% \meta{fp_1} \cs{@@_sep:}\\ % \ldots{}\\ -% \meta{fp_n} |;|\\ +% \meta{fp_n} \cs{@@_sep:}\\ % \cs{s_@@_expr_stop} % \end{quote} % \begin{macrocode} \cs_new:Npn \@@_exp_after_tuple_o:w { \@@_exp_after_tuple_f:nw { \exp_after:wN \exp_stop_f: } } \cs_new:Npn \@@_exp_after_tuple_f:nw - #1 \s_@@_tuple \@@_tuple_chk:w #2 ; + #1 \s_@@_tuple \@@_tuple_chk:w #2 \@@_sep: { \exp_after:wN \s_@@_tuple \exp_after:wN \@@_tuple_chk:w @@ -697,7 +716,7 @@ \exp:w \exp_end_continue_f:w \@@_exp_after_array_f:w #2 \s_@@_expr_stop \exp_after:wN } - \exp_after:wN ; + \exp_after:wN \@@_sep: \exp:w \exp_end_continue_f:w #1 } \cs_new:Npn \@@_exp_after_array_f:w @@ -780,7 +799,8 @@ \int_const:Nn \c_@@_leading_shift_int { - 5 0000 } \int_const:Nn \c_@@_middle_shift_int { 5 0000 * 9999 } \int_const:Nn \c_@@_trailing_shift_int { 5 0000 * 10000 } -\cs_new:Npn \@@_pack:NNNNNw #1 #2#3#4#5 #6; { + #1#2#3#4#5 ; {#6} } +\cs_new:Npn \@@_pack:NNNNNw #1 #2#3#4#5 #6\@@_sep: + { + #1#2#3#4#5 \@@_sep: {#6} } % \end{macrocode} % \end{variable} % \end{macro} @@ -802,8 +822,8 @@ \int_const:Nn \c_@@_big_leading_shift_int { - 15 2374 } \int_const:Nn \c_@@_big_middle_shift_int { 15 2374 * 9999 } \int_const:Nn \c_@@_big_trailing_shift_int { 15 2374 * 10000 } -\cs_new:Npn \@@_pack_big:NNNNNNw #1#2 #3#4#5#6 #7; - { + #1#2#3#4#5#6 ; {#7} } +\cs_new:Npn \@@_pack_big:NNNNNNw #1#2 #3#4#5#6 #7\@@_sep: + { + #1#2#3#4#5#6 \@@_sep: {#7} } % \end{macrocode} % \end{variable} % \end{macro} @@ -824,37 +844,37 @@ \int_const:Nn \c_@@_Bigg_leading_shift_int { - 20 0000 } \int_const:Nn \c_@@_Bigg_middle_shift_int { 20 0000 * 9999 } \int_const:Nn \c_@@_Bigg_trailing_shift_int { 20 0000 * 10000 } -\cs_new:Npn \@@_pack_Bigg:NNNNNNw #1#2 #3#4#5#6 #7; - { + #1#2#3#4#5#6 ; {#7} } +\cs_new:Npn \@@_pack_Bigg:NNNNNNw #1#2 #3#4#5#6 #7\@@_sep: + { + #1#2#3#4#5#6 \@@_sep: {#7} } % \end{macrocode} % \end{variable} % \end{macro} % % \begin{macro}[EXP]{\@@_pack_twice_four:wNNNNNNNN} % \begin{syntax} -% \cs{@@_pack_twice_four:wNNNNNNNN} \meta{tokens} |;| \meta{$\geq 8$ digits} +% \cs{@@_pack_twice_four:wNNNNNNNN} \meta{tokens} \cs{@@_sep:} \meta{$\geq 8$ digits} % \end{syntax} % Grabs two sets of $4$ digits and places them before the semi-colon % delimiter. Putting several copies of this function before a % semicolon packs more digits since each takes the digits % packed by the others in its first argument. % \begin{macrocode} -\cs_new:Npn \@@_pack_twice_four:wNNNNNNNN #1; #2#3#4#5 #6#7#8#9 - { #1 {#2#3#4#5} {#6#7#8#9} ; } +\cs_new:Npn \@@_pack_twice_four:wNNNNNNNN #1\@@_sep: #2#3#4#5 #6#7#8#9 + { #1 {#2#3#4#5} {#6#7#8#9} \@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_pack_eight:wNNNNNNNN} % \begin{syntax} -% \cs{@@_pack_eight:wNNNNNNNN} \meta{tokens} |;| \meta{$\geq 8$ digits} +% \cs{@@_pack_eight:wNNNNNNNN} \meta{tokens} \cs{@@_sep:} \meta{$\geq 8$ digits} % \end{syntax} % Grabs one set of $8$ digits and places them before the semi-colon % delimiter as a single group. Putting several copies of this % function before a semicolon packs more digits since each % takes the digits packed by the others in its first argument. % \begin{macrocode} -\cs_new:Npn \@@_pack_eight:wNNNNNNNN #1; #2#3#4#5 #6#7#8#9 - { #1 {#2#3#4#5#6#7#8#9} ; } +\cs_new:Npn \@@_pack_eight:wNNNNNNNN #1\@@_sep: #2#3#4#5 #6#7#8#9 + { #1 {#2#3#4#5#6#7#8#9} \@@_sep: } % \end{macrocode} % \end{macro} % @@ -875,17 +895,17 @@ % % This is used in \pkg{l3fp-basics} and \pkg{l3fp-extended}. % \begin{macrocode} -\cs_new:Npn \@@_basics_pack_low:NNNNNw #1 #2#3#4#5 #6; - { + #1 - 1 ; {#2#3#4#5} {#6} ; } -\cs_new:Npn \@@_basics_pack_high:NNNNNw #1 #2#3#4#5 #6; +\cs_new:Npn \@@_basics_pack_low:NNNNNw #1 #2#3#4#5 #6\@@_sep: + { + #1 - 1 \@@_sep: {#2#3#4#5} {#6} \@@_sep: } +\cs_new:Npn \@@_basics_pack_high:NNNNNw #1 #2#3#4#5 #6\@@_sep: { \if_meaning:w 2 #1 \@@_basics_pack_high_carry:w \fi: - ; {#2#3#4#5} {#6} + \@@_sep: {#2#3#4#5} {#6} } -\cs_new:Npn \@@_basics_pack_high_carry:w \fi: ; #1 - { \fi: + 1 ; {1000} } +\cs_new:Npn \@@_basics_pack_high_carry:w \fi: \@@_sep: #1 + { \fi: + 1 \@@_sep: {1000} } % \end{macrocode} % \end{macro} % @@ -897,16 +917,16 @@ % This is used in \pkg{l3fp-basics} for additions and % divisions. Their syntax is confusing, hence the name. % \begin{macrocode} -\cs_new:Npn \@@_basics_pack_weird_low:NNNNw #1 #2#3#4 #5; +\cs_new:Npn \@@_basics_pack_weird_low:NNNNw #1 #2#3#4 #5\@@_sep: { \if_meaning:w 2 #1 + 1 \fi: \@@_int_eval_end: - #2#3#4; {#5} ; + #2#3#4\@@_sep: {#5} \@@_sep: } \cs_new:Npn \@@_basics_pack_weird_high:NNNNNNNNw - 1 #1#2#3#4 #5#6#7#8 #9; { ; {#1#2#3#4} {#5#6#7#8} {#9} } + 1 #1#2#3#4 #5#6#7#8 #9\@@_sep: { \@@_sep: {#1#2#3#4} {#5#6#7#8} {#9} } % \end{macrocode} % \end{macro} % @@ -922,7 +942,7 @@ % and $1000\leq\meta{X_1}<9999$. The first argument determines % by how much we shift the digits. \meta{f_1} is called as follows: % \begin{syntax} -% \meta{f_1} \meta{rounding} \Arg{X'_1} \Arg{X'_2} \meta{extra-digits} |;| +% \meta{f_1} \meta{rounding} \Arg{X'_1} \Arg{X'_2} \meta{extra-digits} \cs{@@_sep:} % \end{syntax} % where $0\leq\meta{X'_i}<10^{8}-1$ are $8$ digit integers, % forming the truncation of our number. In other words, @@ -972,9 +992,9 @@ % If the \meta{shift} is zero, or too big, life is very easy. % \begin{macrocode} \cs_new:Npn \@@_decimate_:Nnnnn #1 #2#3#4#5 - { #1 0 {#2#3} {#4#5} ; } + { #1 0 {#2#3} {#4#5} \@@_sep: } \cs_new:Npn \@@_decimate_tiny:Nnnnn #1 #2#3#4#5 - { #1 1 { 0000 0000 } { 0000 0000 } 0 #2#3#4#5 ; } + { #1 1 { 0000 0000 } { 0000 0000 } 0 #2#3#4#5 \@@_sep: } % \end{macrocode} % \end{macro} % @@ -1015,8 +1035,8 @@ { \exp_after:wN ##1 \int_value:w - \exp_after:wN \@@_round_digit:Nw #2 ; - \@@_decimate_pack:nnnnnnnnnnw #3 ; + \exp_after:wN \@@_round_digit:Nw #2 \@@_sep: + \@@_decimate_pack:nnnnnnnnnnw #3 \@@_sep: } } \@@_tmp:w {i} {\use_none:nnn #50}{ 0{#2}#3{#4}#5 } @@ -1106,7 +1126,7 @@ % follow, simply anything ending in a semicolon. This, in turn, means % that the \meta{junk} may not contain semicolons. % \begin{macrocode} -\cs_new:Npn \@@_case_return:nw #1#2 \fi: #3 ; { \fi: #1 } +\cs_new:Npn \@@_case_return:nw #1#2 \fi: #3 \@@_sep: { \fi: #1 } % \end{macrocode} % \end{macro} % @@ -1115,7 +1135,7 @@ % point, and returns its first argument (an \meta{fp~var}) then expands % once after it. % \begin{macrocode} -\cs_new:Npn \@@_case_return_o:Nw #1#2 \fi: #3 \s_@@ #4 ; +\cs_new:Npn \@@_case_return_o:Nw #1#2 \fi: #3 \s_@@ #4 \@@_sep: { \fi: \exp_after:wN #1 } % \end{macrocode} % \end{macro} @@ -1133,7 +1153,7 @@ % Same as \cs{@@_case_return_o:Nw} but with two trailing floating % points. % \begin{macrocode} -\cs_new:Npn \@@_case_return_o:Nww #1#2 \fi: #3 \s_@@ #4 ; #5 ; +\cs_new:Npn \@@_case_return_o:Nww #1#2 \fi: #3 \s_@@ #4 \@@_sep: #5 \@@_sep: { \fi: \exp_after:wN #1 } % \end{macrocode} % \end{macro} @@ -1143,9 +1163,10 @@ % or second of two trailing floating point numbers, expanding once % after the result. % \begin{macrocode} -\cs_new:Npn \@@_case_return_i_o:ww #1 \fi: #2 \s_@@ #3 ; \s_@@ #4 ; - { \fi: \@@_exp_after_o:w \s_@@ #3 ; } -\cs_new:Npn \@@_case_return_ii_o:ww #1 \fi: #2 \s_@@ #3 ; +\cs_new:Npn \@@_case_return_i_o:ww + #1 \fi: #2 \s_@@ #3 \@@_sep: \s_@@ #4 \@@_sep: + { \fi: \@@_exp_after_o:w \s_@@ #3 \@@_sep: } +\cs_new:Npn \@@_case_return_ii_o:ww #1 \fi: #2 \s_@@ #3 \@@_sep: { \fi: \@@_exp_after_o:w } % \end{macrocode} % \end{macro} @@ -1157,7 +1178,7 @@ % floating point numbers, this holds if the rounding digit resulting % from \cs{@@_decimate:nNnnnn} is~$0$. % \begin{macrocode} -\prg_new_conditional:Npnn \@@_int:w \s_@@ \@@_chk:w #1 #2 #3 #4; +\prg_new_conditional:Npnn \@@_int:w \s_@@ \@@_chk:w #1 #2 #3 #4\@@_sep: { TF , T , F , p } { \if_case:w #1 \exp_stop_f: @@ -1199,26 +1220,26 @@ \cs_new:Npn \@@_small_int:wTF \s_@@ \@@_chk:w #1#2 { \if_case:w #1 \exp_stop_f: - \@@_case_return:nw { \@@_small_int_true:wTF 0 ; } + \@@_case_return:nw { \@@_small_int_true:wTF 0 \@@_sep: } \or: \exp_after:wN \@@_small_int_normal:NnwTF \or: \@@_case_return:nw { \exp_after:wN \@@_small_int_true:wTF \int_value:w - \if_meaning:w 2 #2 - \fi: 1 0000 0000 ; + \if_meaning:w 2 #2 - \fi: 1 0000 0000 \@@_sep: } \else: \@@_case_return:nw \use_ii:nn \fi: #2 } -\cs_new:Npn \@@_small_int_true:wTF #1; #2#3 { #2 {#1} } -\cs_new:Npn \@@_small_int_normal:NnwTF #1#2#3; +\cs_new:Npn \@@_small_int_true:wTF #1\@@_sep: #2#3 { #2 {#1} } +\cs_new:Npn \@@_small_int_normal:NnwTF #1#2#3\@@_sep: { \@@_decimate:nNnnnn { \c_@@_prec_int - #2 } \@@_small_int_test:NnnwNw #3 #1 } -\cs_new:Npn \@@_small_int_test:NnnwNw #1#2#3#4; #5 +\cs_new:Npn \@@_small_int_test:NnnwNw #1#2#3#4\@@_sep: #5 { \if_meaning:w 0 #1 \exp_after:wN \@@_small_int_true:wTF @@ -1228,7 +1249,7 @@ \else: #3 \fi: - \exp_after:wN ; + \exp_after:wN \@@_sep: \else: \exp_after:wN \use_ii:nn \fi: diff --git a/macros/latex/required/l3kernel/l3fp-basics.dtx b/macros/latex/required/l3kernel/l3fp-basics.dtx index e2d93219b0..25df2952ad 100644 --- a/macros/latex/required/l3kernel/l3fp-basics.dtx +++ b/macros/latex/required/l3kernel/l3fp-basics.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-basics.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -156,7 +156,7 @@ % discarded. % \begin{macrocode} \cs_new:cpn { @@_+_o:ww } - \s_@@ #1 \@@_chk:w #2 #3 ; \s_@@ \@@_chk:w #4 #5 + \s_@@ #1 \@@_chk:w #2 #3 \@@_sep: \s_@@ \@@_chk:w #4 #5 { \if_case:w \if_meaning:w #2 #4 @@ -176,7 +176,7 @@ \else: \exp_after:wN \@@_add_return_ii_o:Nww \int_value:w \fi: #1 #5 - \s_@@ \@@_chk:w #2 #3 ; + \s_@@ \@@_chk:w #2 #3 \@@_sep: \s_@@ \@@_chk:w #4 #5 } % \end{macrocode} @@ -186,7 +186,7 @@ % Ignore the first operand, and return the second, but using the sign % |#1| rather than |#4|. As usual, expand after the floating point. % \begin{macrocode} -\cs_new:Npn \@@_add_return_ii_o:Nww #1 #2 ; \s_@@ \@@_chk:w #3 #4 +\cs_new:Npn \@@_add_return_ii_o:Nww #1 #2 \@@_sep: \s_@@ \@@_chk:w #3 #4 { \@@_exp_after_o:w \s_@@ \@@_chk:w #3 #1 } % \end{macrocode} % \end{macro} @@ -216,7 +216,7 @@ % identical. % \begin{macrocode} \cs_new:Npn \@@_add_inf_o:Nww - #1 \s_@@ \@@_chk:w 2 #2 #3; \s_@@ \@@_chk:w 2 #4 + #1 \s_@@ \@@_chk:w 2 #2 #3\@@_sep: \s_@@ \@@_chk:w 2 #4 { \if_meaning:w #1 #2 \@@_case_return_i_o:ww @@ -227,7 +227,7 @@ { \token_if_eq_meaning:NNTF #1 #4 + - } } \fi: - \s_@@ \@@_chk:w 2 #2 #3; + \s_@@ \@@_chk:w 2 #2 #3\@@_sep: \s_@@ \@@_chk:w 2 #4 } % \end{macrocode} @@ -237,9 +237,9 @@ % \begin{quote} % \cs{@@_add_normal_o:Nww} \meta{sign_2} % \cs{s_@@} \cs{@@_chk:w} |1| \meta{sign_1} -% \meta{exp_1} \meta{body_1} |;| +% \meta{exp_1} \meta{body_1} \cs{@@_sep:} % \cs{s_@@} \cs{@@_chk:w} |1| \meta{initial sign_2} -% \meta{exp_2} \meta{body_2} |;| +% \meta{exp_2} \meta{body_2} \cs{@@_sep:} % \end{quote} % We now have two normal numbers to add, and we have to check signs % and exponents more carefully before performing the addition. @@ -264,8 +264,8 @@ % \begin{macro}[EXP]{\@@_add_npos_o:NnwNnw} % \begin{quote} % \cs{@@_add_npos_o:NnwNnw} \meta{sign_1} \meta{exp_1} \meta{body_1} -% |;| \cs{s_@@} \cs{@@_chk:w} |1| \meta{initial sign_2} \meta{exp_2} -% \meta{body_2} |;| +% \cs{@@_sep:} \cs{s_@@} \cs{@@_chk:w} |1| \meta{initial sign_2} +% \meta{exp_2} \meta{body_2} \cs{@@_sep:} % \end{quote} % Since we are doing an addition, the final sign is \meta{sign_1}. % Start an \cs{@@_int_eval:w}, responsible for computing the exponent: @@ -278,7 +278,7 @@ % the final sign with us in the midst of the calculation to round % properly at the end. % \begin{macrocode} -\cs_new:Npn \@@_add_npos_o:NnwNnw #1#2#3 ; \s_@@ \@@_chk:w 1 #4 #5 +\cs_new:Npn \@@_add_npos_o:NnwNnw #1#2#3 \@@_sep: \s_@@ \@@_chk:w 1 #4 #5 { \exp_after:wN \@@_sanitize:Nw \exp_after:wN #1 @@ -290,7 +290,7 @@ #5 \exp_after:wN \@@_add_big_ii_o:wNww \int_value:w \fi: - \@@_int_eval:w #5 - #2 ; #1 #3; + \@@_int_eval:w #5 - #2 \@@_sep: #1 #3\@@_sep: } % \end{macrocode} % \end{macro} @@ -298,14 +298,14 @@ % \begin{macro}[rEXP]{\@@_add_big_i_o:wNww} % \begin{macro}[rEXP]{\@@_add_big_ii_o:wNww} % \begin{quote} -% \cs{@@_add_big_i_o:wNww} \meta{shift} |;| \meta{final sign} -% \meta{body_1} |;| \meta{body_2} |;| +% \cs{@@_add_big_i_o:wNww} \meta{shift} \cs{@@_sep:} \meta{final sign} +% \meta{body_1} \cs{@@_sep:} \meta{body_2} \cs{@@_sep:} % \end{quote} % Used in \pkg{l3fp-expo}. % Shift the significand of the small number, then add with % \cs{@@_add_significand_o:NnnwnnnnN}. % \begin{macrocode} -\cs_new:Npn \@@_add_big_i_o:wNww #1; #2 #3; #4; +\cs_new:Npn \@@_add_big_i_o:wNww #1\@@_sep: #2 #3\@@_sep: #4\@@_sep: { \@@_decimate:nNnnnn {#1} \@@_add_significand_o:NnnwnnnnN @@ -313,7 +313,7 @@ #3 #2 } -\cs_new:Npn \@@_add_big_ii_o:wNww #1; #2 #3; #4; +\cs_new:Npn \@@_add_big_ii_o:wNww #1\@@_sep: #2 #3\@@_sep: #4\@@_sep: { \@@_decimate:nNnnnn {#1} \@@_add_significand_o:NnnwnnnnN @@ -331,7 +331,7 @@ % \begin{quote}\raggedright % \cs{@@_add_significand_o:NnnwnnnnN} % \meta{rounding digit} -% \Arg{Y'_1} \Arg{Y'_2} \meta{extra-digits} |;| +% \Arg{Y'_1} \Arg{Y'_2} \meta{extra-digits} \cs{@@_sep:} % \Arg{X_1} \Arg{X_2} \Arg{X_3} \Arg{X_4} % \meta{final sign} % \end{quote} @@ -344,19 +344,19 @@ % give an exact power of $10$, for which it is easy to correct % the result at the end. % \begin{macrocode} -\cs_new:Npn \@@_add_significand_o:NnnwnnnnN #1 #2#3 #4; #5#6#7#8 +\cs_new:Npn \@@_add_significand_o:NnnwnnnnN #1 #2#3 #4\@@_sep: #5#6#7#8 { \exp_after:wN \@@_add_significand_test_o:N \int_value:w \@@_int_eval:w 1#5#6 + #2 \exp_after:wN \@@_add_significand_pack:NNNNNNN - \int_value:w \@@_int_eval:w 1#7#8 + #3 ; #1 + \int_value:w \@@_int_eval:w 1#7#8 + #3 \@@_sep: #1 } \cs_new:Npn \@@_add_significand_pack:NNNNNNN #1 #2#3#4#5#6#7 { \if_meaning:w 2 #1 + 1 \fi: - ; #2 #3 #4 #5 #6 #7 ; + \@@_sep: #2 #3 #4 #5 #6 #7 \@@_sep: } \cs_new:Npn \@@_add_significand_test_o:N #1 { @@ -373,7 +373,7 @@ % \begin{macro}[rEXP]{\@@_add_significand_no_carry_o:wwwNN} % \begin{quote} % \cs{@@_add_significand_no_carry_o:wwwNN} -% \meta{8d} |;| \meta{6d} |;| \meta{2d} |;| +% \meta{8d} \cs{@@_sep:} \meta{6d} \cs{@@_sep:} \meta{2d} \cs{@@_sep:} % \meta{rounding digit} \meta{sign} % \end{quote} % If there's no carry, grab all the digits again and round. The @@ -381,14 +381,14 @@ % case where rounding brings a carry. % \begin{macrocode} \cs_new:Npn \@@_add_significand_no_carry_o:wwwNN - #1; #2; #3#4 ; #5#6 + #1\@@_sep: #2\@@_sep: #3#4 \@@_sep: #5#6 { \exp_after:wN \@@_basics_pack_high:NNNNNw \int_value:w \@@_int_eval:w 1 #1 \exp_after:wN \@@_basics_pack_low:NNNNNw \int_value:w \@@_int_eval:w 1 #2 #3#4 + \@@_round:NNN #6 #4 #5 - \exp_after:wN ; + \exp_after:wN \@@_sep: } % \end{macrocode} % \end{macro} @@ -396,14 +396,14 @@ % \begin{macro}[rEXP]{\@@_add_significand_carry_o:wwwNN} % \begin{quote} % \cs{@@_add_significand_carry_o:wwwNN} -% \meta{8d} |;| \meta{6d} |;| \meta{2d} |;| +% \meta{8d} \cs{@@_sep:} \meta{6d} \cs{@@_sep:} \meta{2d} \cs{@@_sep:} % \meta{rounding digit} \meta{sign} % \end{quote} % The case where there is a carry is very similar. Rounding can even % raise the first digit from $1$ to $2$, but we don't care. % \begin{macrocode} \cs_new:Npn \@@_add_significand_carry_o:wwwNN - #1; #2; #3#4; #5#6 + #1\@@_sep: #2\@@_sep: #3#4\@@_sep: #5#6 { + 1 \exp_after:wN \@@_basics_pack_weird_high:NNNNNNNNw @@ -413,8 +413,8 @@ \exp_after:wN \@@_round:NNN \exp_after:wN #6 \exp_after:wN #3 - \int_value:w \@@_round_digit:Nw #4 #5 ; - \exp_after:wN ; + \int_value:w \@@_round_digit:Nw #4 #5 \@@_sep: + \exp_after:wN \@@_sep: } % \end{macrocode} % \end{macro} @@ -425,9 +425,9 @@ % \begin{macro}[EXP]{\@@_sub_eq_o:Nnwnw, \@@_sub_npos_ii_o:Nnwnw} % \begin{quote} % \cs{@@_sub_npos_o:NnwNnw} -% \meta{sign_1} \meta{exp_1} \meta{body_1} |;| +% \meta{sign_1} \meta{exp_1} \meta{body_1} \cs{@@_sep:} % \cs{s_@@} \cs{@@_chk:w} |1| -% \meta{initial sign_2} \meta{exp_2} \meta{body_2} |;| +% \meta{initial sign_2} \meta{exp_2} \meta{body_2} \cs{@@_sep:} % \end{quote} % Rounding properly in some modes requires to know what the sign of % the result will be. Thus, we start by comparing the exponents and @@ -435,23 +435,26 @@ % number is larger, swap the numbers and call % \cs{@@_sub_npos_i_o:Nnwnw} with the opposite of \meta{sign_1}. % \begin{macrocode} -\cs_new:Npn \@@_sub_npos_o:NnwNnw #1#2#3; \s_@@ \@@_chk:w 1 #4#5#6; +\cs_new:Npn \@@_sub_npos_o:NnwNnw + #1#2#3\@@_sep: \s_@@ \@@_chk:w 1 #4#5#6\@@_sep: { - \if_case:w \@@_compare_npos:nwnw {#2} #3; {#5} #6; \exp_stop_f: + \if_case:w + \@@_compare_npos:nwnw {#2} #3\@@_sep: {#5} #6\@@_sep: \exp_stop_f: \exp_after:wN \@@_sub_eq_o:Nnwnw \or: \exp_after:wN \@@_sub_npos_i_o:Nnwnw \else: \exp_after:wN \@@_sub_npos_ii_o:Nnwnw \fi: - #1 {#2} #3; {#5} #6; + #1 {#2} #3\@@_sep: {#5} #6\@@_sep: } -\cs_new:Npn \@@_sub_eq_o:Nnwnw #1#2; #3; { \exp_after:wN \c_zero_fp } -\cs_new:Npn \@@_sub_npos_ii_o:Nnwnw #1 #2; #3; +\cs_new:Npn \@@_sub_eq_o:Nnwnw #1#2\@@_sep: #3\@@_sep: + { \exp_after:wN \c_zero_fp } +\cs_new:Npn \@@_sub_npos_ii_o:Nnwnw #1 #2\@@_sep: #3\@@_sep: { \exp_after:wN \@@_sub_npos_i_o:Nnwnw \int_value:w \@@_neg_sign:N #1 - #3; #2; + #3\@@_sep: #2\@@_sep: } % \end{macrocode} % \end{macro} @@ -460,15 +463,15 @@ % \begin{macro}[EXP]{\@@_sub_npos_i_o:Nnwnw} % After the computation is done, \cs{@@_sanitize:Nw} checks for % overflow/underflow. It expects the \meta{final sign} and the -% \meta{exponent} (delimited by |;|). Start an integer expression for -% the exponent, which starts with the exponent of the largest number, +% \meta{exponent} (delimited by \cs{@@_sep:}). Start an integer expression +% for the exponent, which starts with the exponent of the largest number, % and may be decreased if the two numbers are very close. If the two % numbers have the same exponent, call the \texttt{near} auxiliary. % Otherwise, decimate $y$, then call the \texttt{far} auxiliary to % evaluate the difference between the two significands. Note that we % decimate by $1$ less than one could expect. % \begin{macrocode} -\cs_new:Npn \@@_sub_npos_i_o:Nnwnw #1 #2#3; #4#5; +\cs_new:Npn \@@_sub_npos_i_o:Nnwnw #1 #2#3\@@_sep: #4#5\@@_sep: { \exp_after:wN \@@_sanitize:Nw \exp_after:wN #1 @@ -509,16 +512,16 @@ \exp_after:wN \@@_sub_back_near_after:wNNNNw \int_value:w \@@_int_eval:w 10#5#6 - #1#2 - 11 \exp_after:wN \@@_sub_back_near_pack:NNNNNNw - \int_value:w \@@_int_eval:w 11#7#8 - #3#4 \exp_after:wN ; + \int_value:w \@@_int_eval:w 11#7#8 - #3#4 \exp_after:wN \@@_sep: } -\cs_new:Npn \@@_sub_back_near_pack:NNNNNNw #1#2#3#4#5#6#7 ; - { + #1#2 ; {#3#4#5#6} {#7} ; } -\cs_new:Npn \@@_sub_back_near_after:wNNNNw 10 #1#2#3#4 #5 ; +\cs_new:Npn \@@_sub_back_near_pack:NNNNNNw #1#2#3#4#5#6#7 \@@_sep: + { + #1#2 \@@_sep: {#3#4#5#6} {#7} \@@_sep: } +\cs_new:Npn \@@_sub_back_near_after:wNNNNw 10 #1#2#3#4 #5 \@@_sep: { \if_meaning:w 0 #1 \exp_after:wN \@@_sub_back_shift:wnnnn \fi: - ; {#1#2#3#4} {#5} + \@@_sep: {#1#2#3#4} {#5} } % \end{macrocode} % \end{macro} @@ -532,8 +535,8 @@ % \@@_sub_back_shift_iv:nnnnw % } % \begin{quote} -% \cs{@@_sub_back_shift:wnnnn} |;| -% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} |;| +% \cs{@@_sub_back_shift:wnnnn} \cs{@@_sep:} +% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} \cs{@@_sep:} % \end{quote} % This function is called with $\meta{Z_1}\leq 999$. Act with % \tn{number} to trim leading zeros from \meta{Z_1} \meta{Z_2} (we @@ -547,30 +550,31 @@ % |#2#3| is ignored), get four blocks of $4$~digits and finally clean % up. Trailing zeros are added so that digits can be grabbed safely. % \begin{macrocode} -\cs_new:Npn \@@_sub_back_shift:wnnnn ; #1#2 +\cs_new:Npn \@@_sub_back_shift:wnnnn \@@_sep: #1#2 { \exp_after:wN \@@_sub_back_shift_ii:ww - \int_value:w #1 #2 0 ; + \int_value:w #1 #2 0 \@@_sep: } -\cs_new:Npn \@@_sub_back_shift_ii:ww #1 0 ; #2#3 ; +\cs_new:Npn \@@_sub_back_shift_ii:ww #1 0 \@@_sep: #2#3 \@@_sep: { \if_meaning:w @ #1 @ - 7 - \exp_after:wN \use_i:nnn \exp_after:wN \@@_sub_back_shift_iii:NNNNNNNNw - \int_value:w #2#3 0 ~ 123456789; + \int_value:w #2#3 0 ~ 123456789\@@_sep: \else: - - \@@_sub_back_shift_iii:NNNNNNNNw #1 123456789; + - \@@_sub_back_shift_iii:NNNNNNNNw #1 123456789\@@_sep: \fi: \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_sub_back_shift_iv:nnnnw - \exp_after:wN ; + \exp_after:wN \@@_sep: \int_value:w - #1 ~ #2#3 0 ~ 0000 0000 0000 000 ; + #1 ~ #2#3 0 ~ 0000 0000 0000 000 \@@_sep: } -\cs_new:Npn \@@_sub_back_shift_iii:NNNNNNNNw #1#2#3#4#5#6#7#8#9; {#8} -\cs_new:Npn \@@_sub_back_shift_iv:nnnnw #1 ; #2 ; { ; #1 ; } +\cs_new:Npn \@@_sub_back_shift_iii:NNNNNNNNw #1#2#3#4#5#6#7#8#9\@@_sep: {#8} +\cs_new:Npn \@@_sub_back_shift_iv:nnnnw #1 \@@_sep: #2 \@@_sep: + { \@@_sep: #1 \@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} @@ -578,7 +582,7 @@ % \begin{macro}[rEXP]{\@@_sub_back_far_o:NnnwnnnnN} % \begin{quote}\raggedright % \cs{@@_sub_back_far_o:NnnwnnnnN} -% \meta{rounding} \Arg{Y'_1} \Arg{Y'_2} \meta{extra-digits} |;| +% \meta{rounding} \Arg{Y'_1} \Arg{Y'_2} \meta{extra-digits} \cs{@@_sep:} % \Arg{X_1} \Arg{X_2} \Arg{X_3} \Arg{X_4} % \meta{final sign} % \end{quote} @@ -591,9 +595,9 @@ % and semi-colon delimiters to allow the \texttt{not_far} auxiliary to % grab each piece individually, the \texttt{very_far} auxiliary to use % \cs{@@_pack_eight:wNNNNNNNN}, and the \texttt{quite_far} to ignore -% the significands easily (using the |;| delimiter). +% the significands easily (using the \cs{@@_sep:} delimiter). % \begin{macrocode} -\cs_new:Npn \@@_sub_back_far_o:NnnwnnnnN #1 #2#3 #4; #5#6#7#8 +\cs_new:Npn \@@_sub_back_far_o:NnnwnnnnN #1 #2#3 #4\@@_sep: #5#6#7#8 { \if_case:w \if_int_compare:w 1 #2 = #5#6 \use_i:nnnn #7 \exp_stop_f: @@ -610,7 +614,7 @@ \or: \exp_after:wN \@@_sub_back_very_far_o:wwwwNN \else: \exp_after:wN \@@_sub_back_not_far_o:wwwwNN \fi: - #2 ~ #3 ; #5 #6 ~ #7 #8 ; #1 + #2 ~ #3 \@@_sep: #5 #6 ~ #7 #8 \@@_sep: #1 } % \end{macrocode} % \end{macro} @@ -626,7 +630,7 @@ % (remember that the \meta{rounding} digit is only equal to $5$ if % there was no further non-zero digit). % \begin{macrocode} -\cs_new:Npn \@@_sub_back_quite_far_o:wwNN #1; #2; #3#4 +\cs_new:Npn \@@_sub_back_quite_far_o:wwNN #1\@@_sep: #2\@@_sep: #3#4 { \exp_after:wN \@@_sub_back_quite_far_ii:NN \exp_after:wN #3 @@ -639,8 +643,8 @@ \else: \exp_after:wN \use_ii:nn \fi: - { ; {1000} {0000} {0000} {0000} ; } - { - 1 ; {9999} {9999} {9999} {9999} ; } + { \@@_sep: {1000} {0000} {0000} {0000} \@@_sep: } + { - 1 \@@_sep: {9999} {9999} {9999} {9999} \@@_sep: } } % \end{macrocode} % \end{macro} @@ -661,7 +665,7 @@ % about its parity, which is identical to that of the last digit % of~|#2|. % \begin{macrocode} -\cs_new:Npn \@@_sub_back_not_far_o:wwwwNN #1 ~ #2; #3 ~ #4; #5#6 +\cs_new:Npn \@@_sub_back_not_far_o:wwwwNN #1 ~ #2\@@_sep: #3 ~ #4\@@_sep: #5#6 { - 1 \exp_after:wN \@@_sub_back_near_after:wNNNNw @@ -671,7 +675,7 @@ - \exp_after:wN \@@_round_neg:NNN \exp_after:wN #6 \use_none:nnnnnnn #2 #5 - \exp_after:wN ; + \exp_after:wN \@@_sep: } % \end{macrocode} % \end{macro} @@ -693,9 +697,10 @@ \@@_pack_eight:wNNNNNNNN \@@_sub_back_very_far_ii_o:nnNwwNN { 0 #1#2#3 #4#5#6#7 } - ; + \@@_sep: } -\cs_new:Npn \@@_sub_back_very_far_ii_o:nnNwwNN #1#2 ; #3 ; #4 ~ #5; #6#7 +\cs_new:Npn \@@_sub_back_very_far_ii_o:nnNwwNN + #1#2 \@@_sep: #3 \@@_sep: #4 ~ #5\@@_sep: #6#7 { \exp_after:wN \@@_basics_pack_high:NNNNNw \int_value:w \@@_int_eval:w 1#4 - #1 - 1 @@ -706,8 +711,8 @@ \int_value:w \if_int_odd:w \@@_int_eval:w #5 - #2 \@@_int_eval_end: 1 \else: 2 \fi: - \int_value:w \@@_round_digit:Nw #3 #6 ; - \exp_after:wN ; + \int_value:w \@@_round_digit:Nw #3 #6 \@@_sep: + \exp_after:wN \@@_sep: } % \end{macrocode} % \end{macro} @@ -757,7 +762,7 @@ % argument |#4|, because it differs in the case of divisions. % \begin{macrocode} \cs_new:Npn \@@_mul_cases_o:NnNnww - #1#2#3#4 \s_@@ \@@_chk:w #5#6#7; \s_@@ \@@_chk:w #8#9 + #1#2#3#4 \s_@@ \@@_chk:w #5#6#7\@@_sep: \s_@@ \@@_chk:w #8#9 { \if_case:w \@@_int_eval:w \if_int_compare:w #5 #8 = 11 ~ @@ -791,7 +796,7 @@ \or: \@@_case_return_o:Nww \c_minus_inf_fp #4 \fi: - \s_@@ \@@_chk:w #5 #6 #7; + \s_@@ \@@_chk:w #5 #6 #7\@@_sep: \s_@@ \@@_chk:w #8 #9 } % \end{macrocode} @@ -805,8 +810,8 @@ % \begin{macro}[EXP]{\@@_mul_npos_o:Nww} % \begin{quote} % \cs{@@_mul_npos_o:Nww} \meta{final sign} -% \cs{s_@@} \cs{@@_chk:w} |1| \meta{sign_1} \Arg{exp_1} \meta{body_1} |;| -% \cs{s_@@} \cs{@@_chk:w} |1| \meta{sign_2} \Arg{exp_2} \meta{body_2} |;| +% \cs{s_@@} \cs{@@_chk:w} |1| \meta{sign_1} \Arg{exp_1} \meta{body_1} \cs{@@_sep:} +% \cs{s_@@} \cs{@@_chk:w} |1| \meta{sign_2} \Arg{exp_2} \meta{body_2} \cs{@@_sep:} % \end{quote} % After the computation, \cs{@@_sanitize:Nw} checks for overflow or % underflow. As we did for addition, \cs{@@_int_eval:w} computes the @@ -818,7 +823,8 @@ % This is also used in \pkg{l3fp-convert}. % \begin{macrocode} \cs_new:Npn \@@_mul_npos_o:Nww - #1 \s_@@ \@@_chk:w #2 #3 #4 #5 ; \s_@@ \@@_chk:w #6 #7 #8 #9 ; + #1 \s_@@ \@@_chk:w #2 #3 #4 #5 \@@_sep: + \s_@@ \@@_chk:w #6 #7 #8 #9 \@@_sep: { \exp_after:wN \@@_sanitize:Nw \exp_after:wN #1 @@ -871,13 +877,13 @@ \exp_after:wN \@@_mul_significand_drop:NNNNNw \int_value:w \@@_int_eval:w 99990000 + #3*#9 + #4*#8 + \exp_after:wN \@@_mul_significand_drop:NNNNNw - \int_value:w \@@_int_eval:w 100000000 + #4*#9 ; - ; \exp_after:wN ; + \int_value:w \@@_int_eval:w 100000000 + #4*#9 \@@_sep: + \@@_sep: \exp_after:wN \@@_sep: } -\cs_new:Npn \@@_mul_significand_drop:NNNNNw #1#2#3#4#5 #6; - { #1#2#3#4#5 ; + #6 } -\cs_new:Npn \@@_mul_significand_keep:NNNNNw #1#2#3#4#5 #6; - { #1#2#3#4#5 ; #6 ; } +\cs_new:Npn \@@_mul_significand_drop:NNNNNw #1#2#3#4#5 #6\@@_sep: + { #1#2#3#4#5 \@@_sep: + #6 } +\cs_new:Npn \@@_mul_significand_keep:NNNNNw #1#2#3#4#5 #6\@@_sep: + { #1#2#3#4#5 \@@_sep: #6 \@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} @@ -885,10 +891,10 @@ % \begin{macro}[rEXP]{\@@_mul_significand_test_f:NNN} % \begin{quote} % \cs{@@_mul_significand_test_f:NNN} \meta{sign} |1| -% \meta{digits 1--8} |;| \meta{digits 9--12} |;| \meta{digits 13--16} |;| +% \meta{digits 1--8} \cs{@@_sep:} \meta{digits 9--12} \cs{@@_sep:} \meta{digits 13--16} \cs{@@_sep:} % |+| \meta{digits 17--20} |+| \meta{digits 21--24} -% |+| \meta{digits 25--28} |+| \meta{digits 29--32} |;| -% \cs{exp_after:wN} |;| +% |+| \meta{digits 25--28} |+| \meta{digits 29--32} \cs{@@_sep:} +% \cs{exp_after:wN} \cs{@@_sep:} % \end{quote} % If the \meta{digit 1} is non-zero, then for rounding we only care % about the digits $16$ and $17$, and whether further digits are zero @@ -916,7 +922,8 @@ % integer expression), and replaces it by a \meta{rounding digit}, % suitable for \cs{@@_round:NNN}. % \begin{macrocode} -\cs_new:Npn \@@_mul_significand_large_f:NwwNNNN #1 #2; #3; #4#5#6#7; + +\cs_new:Npn \@@_mul_significand_large_f:NwwNNNN + #1 #2\@@_sep: #3\@@_sep: #4#5#6#7\@@_sep: + { \exp_after:wN \@@_basics_pack_high:NNNNNw \int_value:w \@@_int_eval:w 1#2 @@ -938,7 +945,8 @@ % \texttt{small_pack} auxiliary, by the next digit, to form a $9$ % digit number. % \begin{macrocode} -\cs_new:Npn \@@_mul_significand_small_f:NNwwwN #1 #2#3; #4#5; #6; + #7 +\cs_new:Npn \@@_mul_significand_small_f:NNwwwN + #1 #2#3\@@_sep: #4#5\@@_sep: #6\@@_sep: + #7 { - 1 \exp_after:wN \@@_basics_pack_high:NNNNNw @@ -994,9 +1002,9 @@ % \begin{quote} % \cs{@@_div_npos_o:Nww} \meta{final sign} % \cs{s_@@} \cs{@@_chk:w} |1| \meta{sign_A} \Arg{exp A} -% \Arg{A_1} \Arg{A_2} \Arg{A_3} \Arg{A_4} |;| +% \Arg{A_1} \Arg{A_2} \Arg{A_3} \Arg{A_4} \cs{@@_sep:} % \cs{s_@@} \cs{@@_chk:w} |1| \meta{sign_Z} \Arg{exp Z} -% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} |;| +% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} \cs{@@_sep:} % \end{quote} % We want to compute $A/Z$. As for multiplication, % \cs{@@_sanitize:Nw} checks for overflow or underflow; we provide it @@ -1008,16 +1016,17 @@ % semi-colon, and the \meta{final sign}, used for rounding at the end. % \begin{macrocode} \cs_new:Npn \@@_div_npos_o:Nww - #1 \s_@@ \@@_chk:w 1 #2 #3 #4 ; \s_@@ \@@_chk:w 1 #5 #6 #7#8#9; + #1 \s_@@ \@@_chk:w 1 #2 #3 #4 \@@_sep: + \s_@@ \@@_chk:w 1 #5 #6 #7#8#9\@@_sep: { \exp_after:wN \@@_sanitize:Nw \exp_after:wN #1 \int_value:w \@@_int_eval:w #3 - #6 \exp_after:wN \@@_div_significand_i_o:wnnw - \int_value:w \@@_int_eval:w #7 \use_i:nnnn #8 + 1 ; + \int_value:w \@@_int_eval:w #7 \use_i:nnnn #8 + 1 \@@_sep: #4 - {#7}{#8}#9 ; + {#7}{#8}#9 \@@_sep: #1 } % \end{macrocode} @@ -1196,9 +1205,9 @@ % % \begin{macro}[rEXP]{\@@_div_significand_i_o:wnnw} % \begin{quote} -% \cs{@@_div_significand_i_o:wnnw} \meta{y} |;| +% \cs{@@_div_significand_i_o:wnnw} \meta{y} \cs{@@_sep:} % \Arg{A_1} \Arg{A_2} \Arg{A_3} \Arg{A_4} -% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} |;| \meta{sign} +% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} \cs{@@_sep:} \meta{sign} % \end{quote} % Compute $10^{6} + Q_{A}$ (a $7$~digit number thanks to the shift), % unbrace \meta{A_1} and \meta{A_2}, and prepare the @@ -1208,13 +1217,13 @@ % hence the \cs{int_value:w}. Here, |#4| is six brace groups, which % give the six first |n|-type arguments of the \texttt{calc} function. % \begin{macrocode} -\cs_new:Npn \@@_div_significand_i_o:wnnw #1 ; #2#3 #4 ; +\cs_new:Npn \@@_div_significand_i_o:wnnw #1 \@@_sep: #2#3 #4 \@@_sep: { \exp_after:wN \@@_div_significand_test_o:w \int_value:w \@@_int_eval:w \exp_after:wN \@@_div_significand_calc:wwnnnnnnn - \int_value:w \@@_int_eval:w 999999 + #2 #3 0 / #1 ; - #2 #3 ; + \int_value:w \@@_int_eval:w 999999 + #2 #3 0 / #1 \@@_sep: + #2 #3 \@@_sep: #4 { \exp_after:wN \@@_div_significand_ii:wwn \int_value:w #1 } { \exp_after:wN \@@_div_significand_ii:wwn \int_value:w #1 } @@ -1231,15 +1240,15 @@ % \@@_div_significand_calc_ii:wwnnnnnnn, % } % \begin{quote} -% \cs{@@_div_significand_calc:wwnnnnnnn} \meta{$10^{6}+{}$Q_{A}} |;| -% \meta{A_1} \meta{A_2} |;| \Arg{A_3} \Arg{A_4} +% \cs{@@_div_significand_calc:wwnnnnnnn} \meta{$10^{6}+{}$Q_{A}} \cs{@@_sep:} +% \meta{A_1} \meta{A_2} \cs{@@_sep:} \Arg{A_3} \Arg{A_4} % \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} % \Arg{continuation} % \end{quote} % expands to % \begin{quote} -% \meta{$10^{6}+{}$Q_{A}} \meta{continuation} |;| -% \meta{B_1} \meta{B_2} |;| \Arg{B_3} \Arg{B_4} +% \meta{$10^{6}+{}$Q_{A}} \meta{continuation} \cs{@@_sep:} +% \meta{B_1} \meta{B_2} \cs{@@_sep:} \Arg{B_3} \Arg{B_4} % \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} % \end{quote} % where $B = 10^{4} A - Q_{A} \cdot Z$. This function is also used to @@ -1292,10 +1301,10 @@ \fi: } \cs_new:Npn \@@_div_significand_calc_i:wwnnnnnnn - #1; #2;#3#4 #5#6#7#8 #9 + #1\@@_sep: #2\@@_sep:#3#4 #5#6#7#8 #9 { 1 1 #1 - #9 \exp_after:wN ; + #9 \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w \c_@@_Bigg_leading_shift_int + #2 - #1 * #5 - #5#60 \exp_after:wN \@@_pack_Bigg:NNNNNNw @@ -1306,14 +1315,14 @@ + #4 - #1 * #7 - #80 \exp_after:wN \@@_pack_Bigg:NNNNNNw \int_value:w \@@_int_eval:w \c_@@_Bigg_trailing_shift_int - - #1 * #8 ; + - #1 * #8 \@@_sep: {#5}{#6}{#7}{#8} } \cs_new:Npn \@@_div_significand_calc_ii:wwnnnnnnn - #1; #2;#3#4 #5#6#7#8 #9 + #1\@@_sep: #2\@@_sep:#3#4 #5#6#7#8 #9 { 1 0 #1 - #9 \exp_after:wN ; + #9 \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w \c_@@_Bigg_leading_shift_int + #2 - #1 * #5 \exp_after:wN \@@_pack_Bigg:NNNNNNw @@ -1324,7 +1333,7 @@ + #4 - #1 * #7 \exp_after:wN \@@_pack_Bigg:NNNNNNw \int_value:w \@@_int_eval:w \c_@@_Bigg_trailing_shift_int - - #1 * #8 ; + - #1 * #8 \@@_sep: {#5}{#6}{#7}{#8} } % \end{macrocode} @@ -1333,8 +1342,8 @@ % % \begin{macro}[EXP]{\@@_div_significand_ii:wwn} % \begin{quote} -% \cs{@@_div_significand_ii:wwn} \meta{y} |;| -% \meta{B_1} |;| \Arg{B_2} \Arg{B_3} \Arg{B_4} +% \cs{@@_div_significand_ii:wwn} \meta{y} \cs{@@_sep:} +% \meta{B_1} \cs{@@_sep:} \Arg{B_2} \Arg{B_3} \Arg{B_4} % \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} % \meta{continuations} \meta{sign} % \end{quote} @@ -1347,20 +1356,21 @@ % auxiliary is also used to compute $Q_{C}$ and $Q_{D}$ with the % inputs $C$ and $D$ instead of $B$. % \begin{macrocode} -\cs_new:Npn \@@_div_significand_ii:wwn #1; #2;#3 +\cs_new:Npn \@@_div_significand_ii:wwn #1\@@_sep: #2\@@_sep:#3 { \exp_after:wN \@@_div_significand_pack:NNN \int_value:w \@@_int_eval:w \exp_after:wN \@@_div_significand_calc:wwnnnnnnn - \int_value:w \@@_int_eval:w 999999 + #2 #3 0 / #1 ; #2 #3 ; + \int_value:w \@@_int_eval:w + 999999 + #2 #3 0 / #1 \@@_sep: #2 #3 \@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[rEXP]{\@@_div_significand_iii:wwnnnnn} % \begin{quote} -% \cs{@@_div_significand_iii:wwnnnnn} \meta{y} |;| -% \meta{E_1} |;| \Arg{E_2} \Arg{E_3} \Arg{E_4} +% \cs{@@_div_significand_iii:wwnnnnn} \meta{y} \cs{@@_sep:} +% \meta{E_1} \cs{@@_sep:} \Arg{E_2} \Arg{E_3} \Arg{E_4} % \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} \meta{sign} % \end{quote} % We compute $P \simeq 2E/Z$ by rounding $2 E_{1} E_{2}/Z_{1}Z_{2}$. @@ -1368,12 +1378,12 @@ % add (roughly) $5\cdot P$, which amounts to adding $P/2 \simeq E/Z$ % to $Q_{D}$, the appropriate correction from a hypothetical $Q_{E}$. % \begin{macrocode} -\cs_new:Npn \@@_div_significand_iii:wwnnnnn #1; #2;#3#4#5 #6#7 +\cs_new:Npn \@@_div_significand_iii:wwnnnnn #1\@@_sep: #2\@@_sep:#3#4#5 #6#7 { 0 \exp_after:wN \@@_div_significand_iv:wwnnnnnnn - \int_value:w \@@_int_eval:w ( 2 * #2 #3) / #6 #7 ; % <- P - #2 ; {#3} {#4} {#5} + \int_value:w \@@_int_eval:w ( 2 * #2 #3) / #6 #7 \@@_sep: % <- P + #2 \@@_sep: {#3} {#4} {#5} {#6} {#7} } % \end{macrocode} @@ -1386,8 +1396,8 @@ % \@@_div_significand_vi:Nw % } % \begin{quote} -% \cs{@@_div_significand_iv:wwnnnnnnn} \meta{P} |;| -% \meta{E_1} |;| \Arg{E_2} \Arg{E_3} \Arg{E_4} +% \cs{@@_div_significand_iv:wwnnnnnnn} \meta{P} \cs{@@_sep:} +% \meta{E_1} \cs{@@_sep:} \Arg{E_2} \Arg{E_3} \Arg{E_4} % \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} \meta{sign} % \end{quote} % This adds to the current expression ($10^{7} + 10\cdot Q_{D}$) a @@ -1427,7 +1437,8 @@ % argument of \cs{@@_div_significand_vi:Nw}, a sum of several terms, is % also zero. Otherwise, there was an exact agreement: $T = 0$. % \begin{macrocode} -\cs_new:Npn \@@_div_significand_iv:wwnnnnnnn #1; #2;#3#4#5 #6#7#8#9 +\cs_new:Npn \@@_div_significand_iv:wwnnnnnnn + #1\@@_sep: #2\@@_sep:#3#4#5 #6#7#8#9 { + 5 * #1 \exp_after:wN \@@_div_significand_vi:Nw @@ -1435,17 +1446,17 @@ \exp_after:wN \@@_div_significand_v:NN \int_value:w \@@_int_eval:w 499950 + 2*#4 - #1*#8 + \exp_after:wN \@@_div_significand_v:NN - \int_value:w \@@_int_eval:w 500000 + 2*#5 - #1*#9 ; + \int_value:w \@@_int_eval:w 500000 + 2*#5 - #1*#9 \@@_sep: } \cs_new:Npn \@@_div_significand_v:NN #1#2 { #1#2 \@@_int_eval_end: + } -\cs_new:Npn \@@_div_significand_vi:Nw #1#2; +\cs_new:Npn \@@_div_significand_vi:Nw #1#2\@@_sep: { \if_meaning:w 0 #1 \if_int_compare:w \@@_int_eval:w #2 > 0 + 1 \fi: \else: \if_meaning:w - #1 - \else: + \fi: 1 \fi: - ; + \@@_sep: } % \end{macrocode} % \end{macro} @@ -1459,7 +1470,7 @@ % \cs{@@_div_significand_pack:NNN} $10^{6} + Q_{B}$ % \cs{@@_div_significand_pack:NNN} $10^{6} + Q_{C}$ % \cs{@@_div_significand_pack:NNN} -% $10^{7} + 10\cdot Q_{D} + 5 \cdot P + \varepsilon$ |;| \meta{sign} +% $10^{7} + 10\cdot Q_{D} + 5 \cdot P + \varepsilon$ \cs{@@_sep:} \meta{sign} % \end{quote} % Here, $\varepsilon = \operatorname{sign}(T)$ is $0$ in case $2E=PZ$, % $1$ in case $2E>PZ$, which means that $P$ was the correct value, but @@ -1468,14 +1479,14 @@ % nothing special: it removes the $10^{6}$ and carries two digits (for % the $10^{5}$'s and the $10^{4}$'s). % \begin{macrocode} -\cs_new:Npn \@@_div_significand_pack:NNN 1 #1 #2 { + #1 #2 ; } +\cs_new:Npn \@@_div_significand_pack:NNN 1 #1 #2 { + #1 #2 \@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[rEXP]{\@@_div_significand_test_o:w} % \begin{quote} -% \cs{@@_div_significand_test_o:w} |1| |0| \meta{5d} |;| -% ~~\meta{4d} |;| \meta{4d} |;| \meta{5d} |;| \meta{sign} +% \cs{@@_div_significand_test_o:w} |1| |0| \meta{5d} \cs{@@_sep:} +% ~~\meta{4d} \cs{@@_sep:} \meta{4d} \cs{@@_sep:} \meta{5d} \cs{@@_sep:} \meta{sign} % \end{quote} % The reason we know that the first two digits are |1| and |0| is that % the final result is known to be between $0.1$ (inclusive) and $10$, @@ -1500,30 +1511,30 @@ % % \begin{macro}[EXP]{\@@_div_significand_small_o:wwwNNNNwN} % \begin{quote} -% \cs{@@_div_significand_small_o:wwwNNNNwN} |0| \meta{4d} |;| -% ~~\meta{4d} |;| \meta{4d} |;| \meta{5d} |;| \meta{final sign} +% \cs{@@_div_significand_small_o:wwwNNNNwN} |0| \meta{4d} \cs{@@_sep:} +% ~~\meta{4d} \cs{@@_sep:} \meta{4d} \cs{@@_sep:} \meta{5d} \cs{@@_sep:} \meta{final sign} % \end{quote} % Standard use of the functions \cs{@@_basics_pack_low:NNNNNw} and % \cs{@@_basics_pack_high:NNNNNw}. We finally get to use the % \meta{final sign} which has been sitting there for a while. % \begin{macrocode} \cs_new:Npn \@@_div_significand_small_o:wwwNNNNwN - 0 #1; #2; #3; #4#5#6#7#8; #9 + 0 #1\@@_sep: #2\@@_sep: #3\@@_sep: #4#5#6#7#8\@@_sep: #9 { \exp_after:wN \@@_basics_pack_high:NNNNNw \int_value:w \@@_int_eval:w 1 #1#2 \exp_after:wN \@@_basics_pack_low:NNNNNw \int_value:w \@@_int_eval:w 1 #3#4#5#6#7 + \@@_round:NNN #9 #7 #8 - \exp_after:wN ; + \exp_after:wN \@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[rEXP]{\@@_div_significand_large_o:wwwNNNNwN} % \begin{quote} -% \cs{@@_div_significand_large_o:wwwNNNNwN} \meta{5d} |;| -% ~~\meta{4d} |;| \meta{4d} |;| \meta{5d} |;| \meta{sign} +% \cs{@@_div_significand_large_o:wwwNNNNwN} \meta{5d} \cs{@@_sep:} +% ~~\meta{4d} \cs{@@_sep:} \meta{4d} \cs{@@_sep:} \meta{5d} \cs{@@_sep:} \meta{sign} % \end{quote} % We know that the final result cannot reach $10$, hence |1#1#2|, % together with contributions from the level below, cannot reach @@ -1531,7 +1542,7 @@ % from the last two of our $18$ digits. % \begin{macrocode} \cs_new:Npn \@@_div_significand_large_o:wwwNNNNwN - #1; #2; #3; #4#5#6#7#8; #9 + #1\@@_sep: #2\@@_sep: #3\@@_sep: #4#5#6#7#8\@@_sep: #9 { + 1 \exp_after:wN \@@_basics_pack_weird_high:NNNNNNNNw @@ -1541,8 +1552,8 @@ \exp_after:wN \@@_round:NNN \exp_after:wN #9 \exp_after:wN #6 - \int_value:w \@@_round_digit:Nw #7 #8 ; - \exp_after:wN ; + \int_value:w \@@_round_digit:Nw #7 #8 \@@_sep: + \exp_after:wN \@@_sep: } % \end{macrocode} % \end{macro} @@ -1555,7 +1566,7 @@ % Positive infinity, and \texttt{nan}, are unchanged. Finally, for % normal positive numbers, there is some work to do. % \begin{macrocode} -\cs_new:Npn \@@_sqrt_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_sqrt_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_meaning:w 0 #2 \@@_case_return_same_o:w \fi: \if_meaning:w 2 #3 @@ -1563,7 +1574,7 @@ \fi: \if_meaning:w 1 #2 \else: \@@_case_return_same_o:w \fi: \@@_sqrt_npos_o:w - \s_@@ \@@_chk:w #2 #3 #4; + \s_@@ \@@_chk:w #2 #3 #4\@@_sep: } % \end{macrocode} % \end{macro} @@ -1581,7 +1592,7 @@ % $a_1'\in[10^{6}, 10^{7})$ instead of $[10^{7}, 10^{8})$, then use % Newton's method starting at $17782794 \simeq 10^{7.25}$. % \begin{macrocode} -\cs_new:Npn \@@_sqrt_npos_o:w \s_@@ \@@_chk:w 1 0 #1#2#3#4#5; +\cs_new:Npn \@@_sqrt_npos_o:w \s_@@ \@@_chk:w 1 0 #1#2#3#4#5\@@_sep: { \exp_after:wN \@@_sanitize:Nw \exp_after:wN 0 @@ -1590,18 +1601,18 @@ \exp_after:wN \@@_sqrt_npos_auxi_o:wwnnN \fi: #1 / 2 - \@@_sqrt_Newton_o:wwn 56234133; 0; {#2#3} {#4#5} 0 + \@@_sqrt_Newton_o:wwn 56234133\@@_sep: 0\@@_sep: {#2#3} {#4#5} 0 } -\cs_new:Npn \@@_sqrt_npos_auxi_o:wwnnN #1 / 2 #2; 0; #3#4#5 +\cs_new:Npn \@@_sqrt_npos_auxi_o:wwnnN #1 / 2 #2\@@_sep: 0\@@_sep: #3#4#5 { ( #1 + 1 ) / 2 \@@_pack_eight:wNNNNNNNN \@@_sqrt_npos_auxii_o:wNNNNNNNN - ; + \@@_sep: 0 #3 #4 } -\cs_new:Npn \@@_sqrt_npos_auxii_o:wNNNNNNNN #1; #2#3#4#5#6#7#8#9 - { \@@_sqrt_Newton_o:wwn 17782794; 0; {#1} {#2#3#4#5#6#7#8#9} } +\cs_new:Npn \@@_sqrt_npos_auxii_o:wNNNNNNNN #1\@@_sep: #2#3#4#5#6#7#8#9 + { \@@_sqrt_Newton_o:wwn 17782794\@@_sep: 0\@@_sep: {#1} {#2#3#4#5#6#7#8#9} } % \end{macrocode} % \end{macro} % \end{macro} @@ -1670,7 +1681,7 @@ % |#3 * 100000000 / #1|. In any case, the result is within $[10^{7}, % 10^{8}]$. % \begin{macrocode} -\cs_new:Npn \@@_sqrt_Newton_o:wwn #1; #2; #3 +\cs_new:Npn \@@_sqrt_Newton_o:wwn #1\@@_sep: #2\@@_sep: #3 { \if_int_compare:w #1 = #2 \exp_stop_f: \exp_after:wN \@@_sqrt_auxi_o:NNNNwnnN @@ -1678,16 +1689,16 @@ \exp_after:wN \@@_use_none_until_s:w \fi: \exp_after:wN \@@_sqrt_Newton_o:wwn - \int_value:w \@@_int_eval:w (#1 + #3 * 1 0000 0000 / #1) / 2 ; - #1; {#3} + \int_value:w \@@_int_eval:w (#1 + #3 * 1 0000 0000 / #1) / 2 \@@_sep: + #1\@@_sep: {#3} } % \end{macrocode} % \end{macro} % % \begin{macro}[rEXP]{\@@_sqrt_auxi_o:NNNNwnnN} % This function is followed by $10^{8}+x-1$, which has~$9$ digits -% starting with~$1$, then |;| \Arg{a_1} \Arg{a_2} \meta{a'}. Here, $x -% \simeq \sqrt{10^{8} a_1}$ and we want to estimate the square root of +% starting with~$1$, then \cs{@@_sep:} \Arg{a_1} \Arg{a_2} \meta{a'}. Here, +% $x \simeq \sqrt{10^{8} a_1}$ and we want to estimate the square root of % $a = 10^{-8} a_1 + 10^{-16} a_2 + 10^{-17} a'$. We set up an % initial underestimate % \[ @@ -1708,7 +1719,7 @@ % construction, the underestimates~$y$ are always increasing, $a - y^2 % < 3.2 \cdot 10^{-8}$ for all. Also, $y<1$. % \begin{macrocode} -\cs_new:Npn \@@_sqrt_auxi_o:NNNNwnnN 1 #1#2#3#4#5; +\cs_new:Npn \@@_sqrt_auxi_o:NNNNwnnN 1 #1#2#3#4#5\@@_sep: { \@@_sqrt_auxii_o:NnnnnnnnN \@@_sqrt_auxiii_o:wnnnnnnnn @@ -1794,9 +1805,9 @@ \exp_after:wN \@@_pack_big:NNNNNNw \int_value:w \@@_int_eval:w \c_@@_big_trailing_shift_int - - #6 * #6 ; + - #6 * #6 \@@_sep: % ( - - 257 ) * 5000 0000 / (#2#3 + 1) + 10 0000 0000 ; + - 257 ) * 5000 0000 / (#2#3 + 1) + 10 0000 0000 \@@_sep: {#2}{#3}{#4}{#5}{#6} {#7}{#8}#9 } % \end{macrocode} @@ -1811,8 +1822,8 @@ % \@@_sqrt_auxvii_o:NNNNNw % } % We receive here the difference $a-y^2=d=\sum_i d_i \cdot 10^{-4i}$, -% as \meta{d_2} |;| \Arg{d_3} \ldots{} \Arg{d_{10}}, where each block -% has~$4$ digits, except \meta{d_2}. This function finds the largest +% as \meta{d_2} \cs{@@_sep:} \Arg{d_3} \ldots{} \Arg{d_{10}}, where each +% block has~$4$ digits, except \meta{d_2}. This function finds the largest % $j\leq 6$ such that $10^{4j}(a-y^2) < 2\cdot 10^{8}$, then leaves an % open parenthesis and the integer % $\bigl\lfloor 10^{4j}(a-y^2)\bigr\rfloor$ in an integer @@ -1846,7 +1857,7 @@ % \] % \begin{macrocode} \cs_new:Npn \@@_sqrt_auxiii_o:wnnnnnnnn - #1; #2#3#4#5#6#7#8#9 + #1\@@_sep: #2#3#4#5#6#7#8#9 { \if_int_compare:w #1 > \c_one_int \exp_after:wN \@@_sqrt_auxiv_o:NNNNNw @@ -1866,13 +1877,13 @@ \fi: \fi: } -\cs_new:Npn \@@_sqrt_auxiv_o:NNNNNw 1#1#2#3#4#5#6; +\cs_new:Npn \@@_sqrt_auxiv_o:NNNNNw 1#1#2#3#4#5#6\@@_sep: { \@@_sqrt_auxviii_o:nnnnnnn {#1#2#3#4#5#6} {00000000} } -\cs_new:Npn \@@_sqrt_auxv_o:NNNNNw 1#1#2#3#4#5#6; +\cs_new:Npn \@@_sqrt_auxv_o:NNNNNw 1#1#2#3#4#5#6\@@_sep: { \@@_sqrt_auxviii_o:nnnnnnn {000#1#2#3#4#5} {#60000} } -\cs_new:Npn \@@_sqrt_auxvi_o:NNNNNw 1#1#2#3#4#5#6; +\cs_new:Npn \@@_sqrt_auxvi_o:NNNNNw 1#1#2#3#4#5#6\@@_sep: { \@@_sqrt_auxviii_o:nnnnnnn {0000000#1} {#2#3#4#5#6} } -\cs_new:Npn \@@_sqrt_auxvii_o:NNNNNw 1#1#2#3#4#5#6; +\cs_new:Npn \@@_sqrt_auxvii_o:NNNNNw 1#1#2#3#4#5#6\@@_sep: { \if_int_compare:w #1#2 = \c_zero_int \exp_after:wN \@@_sqrt_auxx_o:Nnnnnnnn @@ -1895,9 +1906,9 @@ \exp_after:wN \@@_basics_pack_low:NNNNNw \int_value:w \@@_int_eval:w #1 + 1#4#5 \exp_after:wN \@@_basics_pack_low:NNNNNw - \int_value:w \@@_int_eval:w #2 + 1#6#7 ; + \int_value:w \@@_int_eval:w #2 + 1#6#7 \@@_sep: } -\cs_new:Npn \@@_sqrt_auxix_o:wnwnw #1; #2#3; #4#5; +\cs_new:Npn \@@_sqrt_auxix_o:wnwnw #1\@@_sep: #2#3\@@_sep: #4#5\@@_sep: { \@@_sqrt_auxii_o:NnnnnnnnN \@@_sqrt_auxiii_o:wnnnnnnnn {#1}{#2}{#3}{#4}{#5} @@ -1942,10 +1953,10 @@ { \exp_after:wN \@@_sqrt_auxxi_o:wwnnN \int_value:w \@@_int_eval:w - (#8 + 2499) / 5000 * 5000 ; - {#4} {#5} {#6} {#7} ; + (#8 + 2499) / 5000 * 5000 \@@_sep: + {#4} {#5} {#6} {#7} \@@_sep: } -\cs_new:Npn \@@_sqrt_auxxi_o:wwnnN #1; #2; #3#4#5 +\cs_new:Npn \@@_sqrt_auxxi_o:wwnnN #1\@@_sep: #2\@@_sep: #3#4#5 { \@@_sqrt_auxii_o:NnnnnnnnN \@@_sqrt_auxxii_o:nnnnnnnnw @@ -1967,7 +1978,7 @@ % \texttt{auxxiv} function with argument~$9998$. For an exact result % call it with~$9999$, and for an overestimate call it with~$10000$. % \begin{macrocode} -\cs_new:Npn \@@_sqrt_auxxii_o:nnnnnnnnw 0; #1#2#3#4#5#6#7#8 #9; +\cs_new:Npn \@@_sqrt_auxxii_o:nnnnnnnnw 0\@@_sep: #1#2#3#4#5#6#7#8 #9\@@_sep: { \if_int_compare:w #1#2 > \c_zero_int \if_int_compare:w #1#2 = \c_one_int @@ -1985,12 +1996,12 @@ \exp_after:wN \@@_sqrt_auxxiv_o:wnnnnnnnN \int_value:w 10000 \fi: - ; + \@@_sep: } -\cs_new:Npn \@@_sqrt_auxxiii_o:w \fi: \fi: \fi: \fi: #1 \fi: ; +\cs_new:Npn \@@_sqrt_auxxiii_o:w \fi: \fi: \fi: \fi: #1 \fi: \@@_sep: { \fi: \fi: \fi: \fi: \fi: - \@@_sqrt_auxxiv_o:wnnnnnnnN 9999 ; + \@@_sqrt_auxxiv_o:wnnnnnnnN 9999 \@@_sep: } % \end{macrocode} % \end{macro} @@ -2016,7 +2027,7 @@ % $0001$, $4999$, $5000$, $5001$, or~$9999$, which it converts to $0$, % $1$, $4$, $5$, $6$, and~$9$, respectively. % \begin{macrocode} -\cs_new:Npn \@@_sqrt_auxxiv_o:wnnnnnnnN #1; #2#3#4#5#6 #7#8#9 +\cs_new:Npn \@@_sqrt_auxxiv_o:wnnnnnnnN #1\@@_sep: #2#3#4#5#6 #7#8#9 { \exp_after:wN \@@_basics_pack_high:NNNNNw \int_value:w \@@_int_eval:w 1 0000 0000 + #2#3 @@ -2030,8 +2041,8 @@ \int_value:w \exp_after:wN \use_i:nn \exp_after:wN \@@_round_digit:Nw - \int_value:w \@@_int_eval:w #6 + 19999 - #1 ; - \exp_after:wN ; + \int_value:w \@@_int_eval:w #6 + 19999 - #1 \@@_sep: + \exp_after:wN \@@_sep: } % \end{macrocode} % \end{macro} @@ -2041,7 +2052,7 @@ % \begin{macro}[EXP]{\@@_logb_o:w, \@@_logb_aux_o:w} % The exponent of a normal number is its \meta{exponent} minus one. % \begin{macrocode} -\cs_new:Npn \@@_logb_o:w ? \s_@@ \@@_chk:w #1#2; @ +\cs_new:Npn \@@_logb_o:w ? \s_@@ \@@_chk:w #1#2\@@_sep: @ { \if_case:w #1 \exp_stop_f: \@@_case_use:nw @@ -2050,9 +2061,9 @@ \or: \@@_case_return_o:Nw \c_inf_fp \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #1 #2; + \s_@@ \@@_chk:w #1 #2\@@_sep: } -\cs_new:Npn \@@_logb_aux_o:w \s_@@ \@@_chk:w #1 #2 #3 #4 ; +\cs_new:Npn \@@_logb_aux_o:w \s_@@ \@@_chk:w #1 #2 #3 #4 \@@_sep: { \exp_after:wN \@@_parse:n \exp_after:wN { \int_value:w \int_eval:w #3 - 1 \exp_after:wN } @@ -2064,7 +2075,7 @@ % \begin{macro}[EXP]{\@@_sign_aux_o:w} % Find the sign of the floating point: \texttt{nan}, |+0|, |-0|, |+1| or |-1|. % \begin{macrocode} -\cs_new:Npn \@@_sign_o:w ? \s_@@ \@@_chk:w #1#2; @ +\cs_new:Npn \@@_sign_o:w ? \s_@@ \@@_chk:w #1#2\@@_sep: @ { \if_case:w #1 \exp_stop_f: \@@_case_return_same_o:w @@ -2072,9 +2083,9 @@ \or: \exp_after:wN \@@_sign_aux_o:w \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #1 #2; + \s_@@ \@@_chk:w #1 #2\@@_sep: } -\cs_new:Npn \@@_sign_aux_o:w \s_@@ \@@_chk:w #1 #2 #3 ; +\cs_new:Npn \@@_sign_aux_o:w \s_@@ \@@_chk:w #1 #2 #3 \@@_sep: { \exp_after:wN \@@_set_sign_o:w \exp_after:wN #2 \c_one_fp @ } % \end{macrocode} % \end{macro} @@ -2088,7 +2099,7 @@ % also expands after itself in the input stream, just like % \cs{@@_+_o:ww}. % \begin{macrocode} -\cs_new:Npn \@@_set_sign_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_set_sign_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \exp_after:wN \@@_exp_after_o:w \exp_after:wN \s_@@ @@ -2096,7 +2107,7 @@ \exp_after:wN #2 \int_value:w \if_case:w #3 \exp_stop_f: #1 \or: 1 \or: 0 \fi: \exp_stop_f: - #4; + #4\@@_sep: } % \end{macrocode} % \end{macro} @@ -2120,11 +2131,11 @@ } \cs_new:Npn \@@_tuple_set_sign_aux_o:Nnw #1#2 { \@@_tuple_map_o:nw \@@_tuple_set_sign_aux_o:w } -\cs_new:Npn \@@_tuple_set_sign_aux_o:w #1#2 ; +\cs_new:Npn \@@_tuple_set_sign_aux_o:w #1#2 \@@_sep: { \@@_change_func_type:NNN #1 \@@_set_sign_o:w \@@_parse_apply_unary_error:NNw - 2 #1 #2 ; @ + 2 #1 #2 \@@_sep: @ } % \end{macrocode} % \end{macro} @@ -2137,12 +2148,18 @@ % Importantly we need to dispatch according to the type, and we make % sure to apply the operator in the correct order. % \begin{macrocode} -\cs_new:cpn { @@_*_tuple_o:ww } #1 ; - { \@@_tuple_map_o:nw { \@@_binary_type_o:Nww * #1 ; } } -\cs_new:cpn { @@_tuple_*_o:ww } #1 ; #2 ; - { \@@_tuple_map_o:nw { \@@_binary_rev_type_o:Nww * #2 ; } #1 ; } -\cs_new:cpn { @@_tuple_/_o:ww } #1 ; #2 ; - { \@@_tuple_map_o:nw { \@@_binary_rev_type_o:Nww / #2 ; } #1 ; } +\cs_new:cpn { @@_*_tuple_o:ww } #1 \@@_sep: + { \@@_tuple_map_o:nw { \@@_binary_type_o:Nww * #1 \@@_sep: } } +\cs_new:cpn { @@_tuple_*_o:ww } #1 \@@_sep: #2 \@@_sep: + { + \@@_tuple_map_o:nw { \@@_binary_rev_type_o:Nww * #2 \@@_sep: } + #1 \@@_sep: + } +\cs_new:cpn { @@_tuple_/_o:ww } #1 \@@_sep: #2 \@@_sep: + { + \@@_tuple_map_o:nw { \@@_binary_rev_type_o:Nww / #2 \@@_sep: } + #1 \@@_sep: + } % \end{macrocode} % \end{macro} % @@ -2154,15 +2171,15 @@ \cs_set_protected:Npn \@@_tmp:w #1 { \cs_new:cpn { @@_tuple_#1_tuple_o:ww } - \s_@@_tuple \@@_tuple_chk:w ##1 ; - \s_@@_tuple \@@_tuple_chk:w ##2 ; + \s_@@_tuple \@@_tuple_chk:w ##1 \@@_sep: + \s_@@_tuple \@@_tuple_chk:w ##2 \@@_sep: { \int_compare:nNnTF { \@@_array_count:n {##1} } = { \@@_array_count:n {##2} } { \@@_tuple_mapthread_o:nww { \@@_binary_type_o:Nww #1 } } { \@@_invalid_operation_o:nww #1 } - \s_@@_tuple \@@_tuple_chk:w {##1} ; - \s_@@_tuple \@@_tuple_chk:w {##2} ; + \s_@@_tuple \@@_tuple_chk:w {##1} \@@_sep: + \s_@@_tuple \@@_tuple_chk:w {##2} \@@_sep: } } \@@_tmp:w + diff --git a/macros/latex/required/l3kernel/l3fp-convert.dtx b/macros/latex/required/l3kernel/l3fp-convert.dtx index 4983a3dd1f..085ebf4028 100644 --- a/macros/latex/required/l3kernel/l3fp-convert.dtx +++ b/macros/latex/required/l3kernel/l3fp-convert.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-convert.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -72,7 +72,7 @@ % representation. We loop through all items, putting |,~| between all % of them and making sure to remove the leading |,~|. % \begin{macrocode} -\cs_new:Npn \@@_tuple_convert:Nw #1 \s_@@_tuple \@@_tuple_chk:w #2 ; +\cs_new:Npn \@@_tuple_convert:Nw #1 \s_@@_tuple \@@_tuple_chk:w #2 \@@_sep: { \int_case:nnF { \@@_array_count:n {#2} } { @@ -81,14 +81,14 @@ } { \@@_tuple_convert_loop:nNw { } #1 - #2 { ? \@@_tuple_convert_end:w } ; + #2 { ? \@@_tuple_convert_end:w } \@@_sep: @ { \use_none:nn } } } -\cs_new:Npn \@@_tuple_convert_loop:nNw #1#2#3#4; #5 @ #6 +\cs_new:Npn \@@_tuple_convert_loop:nNw #1#2#3#4\@@_sep: #5 @ #6 { \use_none:n #3 - \exp_args:Nf \@@_tuple_convert_loop:nNw { #2 #3#4 ; } #2 #5 + \exp_args:Nf \@@_tuple_convert_loop:nNw { #2 #3#4 \@@_sep: } #2 #5 @ { #6 , ~ #1 } } \cs_new:Npn \@@_tuple_convert_end:w #1 @ #2 @@ -108,14 +108,17 @@ % which removes a trailing dot if any. We then clean-up with the % \texttt{end} auxiliary, keeping only the number. % \begin{macrocode} -\cs_new:Npn \@@_trim_zeros:w #1 ; +\cs_new:Npn \@@_trim_zeros:w #1 \@@_sep: { - \@@_trim_zeros_loop:w #1 - ; \@@_trim_zeros_loop:w 0; \@@_trim_zeros_dot:w .; \s_@@_stop + \@@_trim_zeros_loop:w #1 \@@_sep: + \@@_trim_zeros_loop:w 0\@@_sep: + \@@_trim_zeros_dot:w .\@@_sep: + \s_@@_stop } -\cs_new:Npn \@@_trim_zeros_loop:w #1 0; #2 { #2 #1 ; #2 } -\cs_new:Npn \@@_trim_zeros_dot:w #1 .; { \@@_trim_zeros_end:w #1 ; } -\cs_new:Npn \@@_trim_zeros_end:w #1 ; #2 \s_@@_stop { #1 } +\cs_new:Npn \@@_trim_zeros_loop:w #1 0\@@_sep: #2 { #2 #1 \@@_sep: #2 } +\cs_new:Npn \@@_trim_zeros_dot:w #1 .\@@_sep: + { \@@_trim_zeros_end:w #1 \@@_sep: } +\cs_new:Npn \@@_trim_zeros_end:w #1 \@@_sep: #2 \s_@@_stop { #1 } % \end{macrocode} % \end{macro} % \end{macro} @@ -148,9 +151,9 @@ #1 \@@_to_scientific:w \@@_to_scientific_recover:w #1 } -\cs_new:Npn \@@_to_scientific_recover:w #1 #2 ; +\cs_new:Npn \@@_to_scientific_recover:w #1 #2 \@@_sep: { - \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 ; } } { } { } + \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 \@@_sep: } } { } { } nan } \cs_new:Npn \@@_tuple_to_scientific:w @@ -201,14 +204,14 @@ \s_@@ \@@_chk:w #1 #2 } \cs_new:Npn \@@_to_scientific_normal:wnnnnn - \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ; + \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 \@@_sep: { \exp_after:wN \@@_to_scientific_normal:wNw \exp_after:wN e \int_value:w \@@_int_eval:w #2 - 1 - ; #3 #4 #5 #6 ; + \@@_sep: #3 #4 #5 #6 \@@_sep: } -\cs_new:Npn \@@_to_scientific_normal:wNw #1 ; #2#3; +\cs_new:Npn \@@_to_scientific_normal:wNw #1 \@@_sep: #2#3\@@_sep: { #2.#3 #1 } % \end{macrocode} % \end{macro} @@ -242,9 +245,9 @@ #1 \@@_to_decimal:w \@@_to_decimal_recover:w #1 } -\cs_new:Npn \@@_to_decimal_recover:w #1 #2 ; +\cs_new:Npn \@@_to_decimal_recover:w #1 #2 \@@_sep: { - \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 ; } } { } { } + \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 \@@_sep: } } { } { } nan } \cs_new:Npn \@@_tuple_to_decimal:w @@ -297,7 +300,7 @@ \s_@@ \@@_chk:w #1 #2 } \cs_new:Npn \@@_to_decimal_normal:wnnnnn - \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ; + \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 \@@_sep: { \int_compare:nNnTF {#2} > 0 { @@ -309,7 +312,7 @@ { \exp_after:wN \exp_after:wN \exp_after:wN \@@_to_decimal_huge:wnnnn - \prg_replicate:nn { #2 - \c_@@_prec_int } { 0 } ; + \prg_replicate:nn { #2 - \c_@@_prec_int } { 0 } \@@_sep: } {#3} {#4} {#5} {#6} } @@ -318,19 +321,19 @@ \exp_after:wN 0 \exp_after:wN . \exp:w \exp_end_continue_f:w \prg_replicate:nn { - #2 } { 0 } - #3#4#5#6 ; + #3#4#5#6 \@@_sep: } } -\cs_new:Npn \@@_to_decimal_large:Nnnw #1#2#3#4; +\cs_new:Npn \@@_to_decimal_large:Nnnw #1#2#3#4\@@_sep: { \exp_after:wN \@@_trim_zeros:w \int_value:w \if_int_compare:w #2 > \c_zero_int #2 \fi: \exp_stop_f: - #3.#4 ; + #3.#4 \@@_sep: } -\cs_new:Npn \@@_to_decimal_huge:wnnnn #1; #2#3#4#5 { #2#3#4#5 #1 } +\cs_new:Npn \@@_to_decimal_huge:wnnnn #1\@@_sep: #2#3#4#5 { #2#3#4#5 #1 } % \end{macrocode} % \end{macro} % @@ -355,9 +358,9 @@ % \begin{macrocode} \cs_new:Npn \@@_to_tl_dispatch:w #1 { \@@_change_func_type:NNN #1 \@@_to_tl:w \@@_to_tl_recover:w #1 } -\cs_new:Npn \@@_to_tl_recover:w #1 #2 ; +\cs_new:Npn \@@_to_tl_recover:w #1 #2 \@@_sep: { - \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 ; } } { } { } + \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 \@@_sep: } } { } { } nan } \cs_new:Npn \@@_tuple_to_tl:w @@ -395,15 +398,15 @@ \s_@@ \@@_chk:w 1 0 {#1} } \cs_new:Npn \@@_to_tl_scientific:wnnnnn - \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ; + \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 \@@_sep: { \exp_after:wN \@@_to_tl_scientific:wNw \exp_after:wN e \int_value:w \@@_int_eval:w #2 - 1 - ; #3 #4 #5 #6 ; + \@@_sep: #3 #4 #5 #6 \@@_sep: } -\cs_new:Npn \@@_to_tl_scientific:wNw #1 ; #2#3; - { \@@_trim_zeros:w #2.#3 ; #1 } +\cs_new:Npn \@@_to_tl_scientific:wNw #1 \@@_sep: #2#3\@@_sep: + { \@@_trim_zeros:w #2.#3 \@@_sep: #1 } % \end{macrocode} % \end{macro} % @@ -431,14 +434,14 @@ \exp_after:wN \@@_to_dim_dispatch:w \exp:w \exp_end_continue_f:w \@@_parse:n } -\cs_new:Npn \@@_to_dim_dispatch:w #1#2 ; +\cs_new:Npn \@@_to_dim_dispatch:w #1#2 \@@_sep: { \@@_change_func_type:NNN #1 \@@_to_dim:w \@@_to_dim_recover:w - #1 #2 ; + #1 #2 \@@_sep: } \cs_new:Npn \@@_to_dim_recover:w #1 { \@@_invalid_operation:nnw { 0pt } { fp_to_dim } } -\cs_new:Npn \@@_to_dim:w #1 ; { \@@_to_decimal:w #1 ; pt } +\cs_new:Npn \@@_to_dim:w #1 \@@_sep: { \@@_to_decimal:w #1 \@@_sep: pt } % \end{macrocode} % \end{macro} % \end{macro} @@ -459,17 +462,17 @@ \exp_after:wN \@@_to_int_dispatch:w \exp:w \exp_end_continue_f:w \@@_parse:n } -\cs_new:Npn \@@_to_int_dispatch:w #1#2 ; +\cs_new:Npn \@@_to_int_dispatch:w #1#2 \@@_sep: { \@@_change_func_type:NNN #1 \@@_to_int:w \@@_to_int_recover:w - #1 #2 ; + #1 #2 \@@_sep: } \cs_new:Npn \@@_to_int_recover:w #1 { \@@_invalid_operation:nnw { 0 } { fp_to_int } } -\cs_new:Npn \@@_to_int:w #1; +\cs_new:Npn \@@_to_int:w #1\@@_sep: { \exp_after:wN \@@_to_decimal:w \exp:w \exp_end_continue_f:w - \@@_round:Nwn \@@_round_to_nearest:NNN #1; { 0 } + \@@_round:Nwn \@@_round_to_nearest:NNN #1\@@_sep: { 0 } } % \end{macrocode} % \end{macro} @@ -490,7 +493,7 @@ % points), then multiplied by $2^{-16} = 0.0000152587890625$ to give a % value expressed in points. The auxiliary \cs{@@_mul_npos_o:Nww} % expects the desired \meta{final sign} and two floating point -% operands (of the form \cs{s_@@} \ldots{} |;|) as arguments. +% operands (of the form \cs{s_@@} \ldots{} \cs{@@_sep:}) as arguments. % This set of functions is also used to convert dimension registers to % floating points while parsing expressions: in this context there is % an additional exponent, which is the first argument of @@ -504,7 +507,7 @@ \exp_after:wN \@@_from_dim_test:ww \exp_after:wN 0 \exp_after:wN , - \int_value:w \tex_glueexpr:D #1 ; + \int_value:w \tex_glueexpr:D #1 \@@_sep: } \cs_new:Npn \@@_from_dim_test:ww #1, #2 { @@ -520,18 +523,18 @@ \fi: \fi: } -\cs_new:Npn \@@_from_dim:wNw #1,#2#3; +\cs_new:Npn \@@_from_dim:wNw #1,#2#3\@@_sep: { - \@@_pack_twice_four:wNNNNNNNN \@@_from_dim:wNNnnnnnn ; - #3 000 0000 00 {10}987654321; #2 {#1} + \@@_pack_twice_four:wNNNNNNNN \@@_from_dim:wNNnnnnnn \@@_sep: + #3 000 0000 00 {10}987654321\@@_sep: #2 {#1} } -\cs_new:Npn \@@_from_dim:wNNnnnnnn #1; #2#3#4#5#6#7#8#9 - { \@@_from_dim:wnnnnwNn #1 {#2#300} {0000} ; } -\cs_new:Npn \@@_from_dim:wnnnnwNn #1; #2#3#4#5#6; #7#8 +\cs_new:Npn \@@_from_dim:wNNnnnnnn #1\@@_sep: #2#3#4#5#6#7#8#9 + { \@@_from_dim:wnnnnwNn #1 {#2#300} {0000} \@@_sep: } +\cs_new:Npn \@@_from_dim:wnnnnwNn #1\@@_sep: #2#3#4#5#6\@@_sep: #7#8 { \@@_mul_npos_o:Nww #7 - \s_@@ \@@_chk:w 1 #7 {#5} #1 ; - \s_@@ \@@_chk:w 1 0 {#8} {1525} {8789} {0625} {0000} ; + \s_@@ \@@_chk:w 1 #7 {#5} #1 \@@_sep: + \s_@@ \@@_chk:w 1 0 {#8} {1525} {8789} {0625} {0000} \@@_sep: \prg_do_nothing: } % \end{macrocode} @@ -603,16 +606,16 @@ { \exp_last_unbraced:Ne \use_ii:nn { - \@@_array_to_clist_loop:Nw #1 { ? \prg_break: } ; + \@@_array_to_clist_loop:Nw #1 { ? \prg_break: } \@@_sep: \prg_break_point: } } } -\cs_new:Npn \@@_array_to_clist_loop:Nw #1#2; +\cs_new:Npn \@@_array_to_clist_loop:Nw #1#2\@@_sep: { \use_none:n #1 , ~ - \exp_not:f { \@@_to_tl_dispatch:w #1 #2 ; } + \exp_not:f { \@@_to_tl_dispatch:w #1 #2 \@@_sep: } \@@_array_to_clist_loop:Nw } % \end{macrocode} diff --git a/macros/latex/required/l3kernel/l3fp-expo.dtx b/macros/latex/required/l3kernel/l3fp-expo.dtx index 7577f640d4..39fd6e3dc9 100644 --- a/macros/latex/required/l3kernel/l3fp-expo.dtx +++ b/macros/latex/required/l3kernel/l3fp-expo.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-expo.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -135,15 +135,24 @@ % Those are needed in the implementation. It turns out that we don't % need the value of $\ln(5)$. % \begin{macrocode} -\tl_const:Nn \c_@@_ln_i_fixed_tl { {0000}{0000}{0000}{0000}{0000}{0000};} -\tl_const:Nn \c_@@_ln_ii_fixed_tl { {6931}{4718}{0559}{9453}{0941}{7232};} -\tl_const:Nn \c_@@_ln_iii_fixed_tl {{10986}{1228}{8668}{1096}{9139}{5245};} -\tl_const:Nn \c_@@_ln_iv_fixed_tl {{13862}{9436}{1119}{8906}{1883}{4464};} -\tl_const:Nn \c_@@_ln_vi_fixed_tl {{17917}{5946}{9228}{0550}{0081}{2477};} -\tl_const:Nn \c_@@_ln_vii_fixed_tl {{19459}{1014}{9055}{3133}{0510}{5353};} -\tl_const:Nn \c_@@_ln_viii_fixed_tl{{20794}{4154}{1679}{8359}{2825}{1696};} -\tl_const:Nn \c_@@_ln_ix_fixed_tl {{21972}{2457}{7336}{2193}{8279}{0490};} -\tl_const:Nn \c_@@_ln_x_fixed_tl {{23025}{8509}{2994}{0456}{8401}{7991};} +\tl_const:Nn \c_@@_ln_i_fixed_tl + { {0000}{0000}{0000}{0000}{0000}{0000}\@@_sep:} +\tl_const:Nn \c_@@_ln_ii_fixed_tl + { {6931}{4718}{0559}{9453}{0941}{7232}\@@_sep:} +\tl_const:Nn \c_@@_ln_iii_fixed_tl + {{10986}{1228}{8668}{1096}{9139}{5245}\@@_sep:} +\tl_const:Nn \c_@@_ln_iv_fixed_tl + {{13862}{9436}{1119}{8906}{1883}{4464}\@@_sep:} +\tl_const:Nn \c_@@_ln_vi_fixed_tl + {{17917}{5946}{9228}{0550}{0081}{2477}\@@_sep:} +\tl_const:Nn \c_@@_ln_vii_fixed_tl + {{19459}{1014}{9055}{3133}{0510}{5353}\@@_sep:} +\tl_const:Nn \c_@@_ln_viii_fixed_tl + {{20794}{4154}{1679}{8359}{2825}{1696}\@@_sep:} +\tl_const:Nn \c_@@_ln_ix_fixed_tl + {{21972}{2457}{7336}{2193}{8279}{0490}\@@_sep:} +\tl_const:Nn \c_@@_ln_x_fixed_tl + {{23025}{8509}{2994}{0456}{8401}{7991}\@@_sep:} % \end{macrocode} % \end{variable} % @@ -156,7 +165,7 @@ % $+\infty$ or a \texttt{nan} is itself. Positive normal numbers call % \cs{@@_ln_npos_o:w}. % \begin{macrocode} -\cs_new:Npn \@@_ln_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_ln_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_meaning:w 2 #3 \@@_case_use:nw { \@@_invalid_operation_o:nw { ln } } @@ -168,7 +177,7 @@ \else: \@@_case_return_same_o:w \fi: - \@@_ln_npos_o:w \s_@@ \@@_chk:w #2#3#4; + \@@_ln_npos_o:w \s_@@ \@@_chk:w #2#3#4\@@_sep: } % \end{macrocode} % \end{macro} @@ -180,7 +189,7 @@ % In all other cases, the final result is at least $10^{-4}$, and % then an error of $0.5\cdot 10^{-20}$ is acceptable. % \begin{macrocode} -\cs_new:Npn \@@_ln_npos_o:w \s_@@ \@@_chk:w 10#1#2#3; +\cs_new:Npn \@@_ln_npos_o:w \s_@@ \@@_chk:w 10#1#2#3\@@_sep: { %^^A todo: ln(1) should be "exact zero", not "underflow" \exp_after:wN \@@_sanitize:Nw \int_value:w % for the overall sign @@ -203,7 +212,7 @@ % \end{syntax} % This function expands to % \begin{syntax} -% \meta{continuation} \Arg{Y_1} \Arg{Y_2} \Arg{Y_3} \Arg{Y_4} \Arg{Y_5} \Arg{Y_6} |;| +% \meta{continuation} \Arg{Y_1} \Arg{Y_2} \Arg{Y_3} \Arg{Y_4} \Arg{Y_5} \Arg{Y_6} \cs{@@_sep:} % \end{syntax} % where $Y = - \ln(X)$ as an extended fixed point. % \begin{macrocode} @@ -225,7 +234,7 @@ \or: 2 \else: 1 \fi: - ; { #1 #2 #3 #4 } + \@@_sep: { #1 #2 #3 #4 } } % \end{macrocode} % \end{macro} @@ -234,7 +243,7 @@ % We have thus found $c \in [1,10]$ such that $0.7\leq ac < 1.4$ % in all cases. Compute $ 1 + x = 1 + ac \in [1.7,2.4)$. % \begin{macrocode} -\cs_new:Npn \@@_ln_x_ii:wnnnn #1; #2#3#4#5 +\cs_new:Npn \@@_ln_x_ii:wnnnn #1\@@_sep: #2#3#4#5 { \exp_after:wN \@@_ln_div_after:Nw \cs:w c_@@_ln_ \@@_int_to_roman:w #1 _fixed_tl \exp_after:wN \cs_end: @@ -244,14 +253,14 @@ \exp_after:wN \@@_ln_x_iii_var:NNNNNw \int_value:w \@@_int_eval:w 9999 9990 + #1*#2#3 + \exp_after:wN \@@_ln_x_iii:NNNNNNw - \int_value:w \@@_int_eval:w 10 0000 0000 + #1*#4#5 ; + \int_value:w \@@_int_eval:w 10 0000 0000 + #1*#4#5 \@@_sep: {20000} {0000} {0000} {0000} } %^^A todo: reoptimize (a generalization attempt failed). -\cs_new:Npn \@@_ln_x_iii:NNNNNNw #1#2 #3#4#5#6 #7; - { #1#2; {#3#4#5#6} {#7} } -\cs_new:Npn \@@_ln_x_iii_var:NNNNNw #1 #2#3#4#5 #6; +\cs_new:Npn \@@_ln_x_iii:NNNNNNw #1#2 #3#4#5#6 #7\@@_sep: + { #1#2\@@_sep: {#3#4#5#6} {#7} } +\cs_new:Npn \@@_ln_x_iii_var:NNNNNw #1 #2#3#4#5 #6\@@_sep: { - #1#2#3#4#5 + 1 ; + #1#2#3#4#5 + 1 \@@_sep: {#1#2#3#4#5} {#6} } % \end{macrocode} @@ -322,16 +331,16 @@ % ^^A todo: doc % % \begin{syntax} -% \cs{@@_ln_x_iv:wnnnnnnnn} \meta{1 or 2} \meta{8d} |;| \Arg{4d} \Arg{4d} \meta{fixed-tl} +% \cs{@@_ln_x_iv:wnnnnnnnn} \meta{1 or 2} \meta{8d} \cs{@@_sep:} \Arg{4d} \Arg{4d} \meta{fixed-tl} % \end{syntax} % The number is $x$. Compute $y$ by adding 1 to the five first digits. % \begin{macrocode} -\cs_new:Npn \@@_ln_x_iv:wnnnnnnnn #1; #2#3#4#5 #6#7#8#9 +\cs_new:Npn \@@_ln_x_iv:wnnnnnnnn #1\@@_sep: #2#3#4#5 #6#7#8#9 { \exp_after:wN \@@_div_significand_pack:NNN \int_value:w \@@_int_eval:w - \@@_ln_div_i:w #1 ; - #6 #7 ; {#8} {#9} + \@@_ln_div_i:w #1 \@@_sep: + #6 #7 \@@_sep: {#8} {#9} {#2} {#3} {#4} {#5} { \exp_after:wN \@@_ln_div_ii:wwn \int_value:w #1 } { \exp_after:wN \@@_ln_div_ii:wwn \int_value:w #1 } @@ -339,23 +348,25 @@ { \exp_after:wN \@@_ln_div_ii:wwn \int_value:w #1 } { \exp_after:wN \@@_ln_div_vi:wwn \int_value:w #1 } } -\cs_new:Npn \@@_ln_div_i:w #1; +\cs_new:Npn \@@_ln_div_i:w #1\@@_sep: { \exp_after:wN \@@_div_significand_calc:wwnnnnnnn - \int_value:w \@@_int_eval:w 999999 + 2 0000 0000 / #1 ; % Q1 + \int_value:w \@@_int_eval:w 999999 + 2 0000 0000 / #1 \@@_sep: % Q1 } -\cs_new:Npn \@@_ln_div_ii:wwn #1; #2;#3 % y; B1;B2 <- for k=1 +\cs_new:Npn \@@_ln_div_ii:wwn + #1\@@_sep: #2\@@_sep:#3 % y\@@_sep: B1\@@_sep:B2 <- for k=1 { \exp_after:wN \@@_div_significand_pack:NNN \int_value:w \@@_int_eval:w \exp_after:wN \@@_div_significand_calc:wwnnnnnnn - \int_value:w \@@_int_eval:w 999999 + #2 #3 / #1 ; % Q2 - #2 #3 ; + \int_value:w \@@_int_eval:w 999999 + #2 #3 / #1 \@@_sep: % Q2 + #2 #3 \@@_sep: } -\cs_new:Npn \@@_ln_div_vi:wwn #1; #2;#3#4#5 #6#7#8#9 %y;F1;F2F3F4x1x2x3x4 +\cs_new:Npn \@@_ln_div_vi:wwn + #1\@@_sep: #2\@@_sep:#3#4#5 #6#7#8#9 %y\@@_sep:F1\@@_sep:F2F3F4x1x2x3x4 { \exp_after:wN \@@_div_significand_pack:NNN - \int_value:w \@@_int_eval:w 1000000 + #2 #3 / #1 ; % Q6 + \int_value:w \@@_int_eval:w 1000000 + #2 #3 / #1 \@@_sep: % Q6 } % \end{macrocode} % We now have essentially @@ -368,8 +379,8 @@ % \cs{@@_div_significand_pack:NNN} $10^6 + Q_{3}$ % \cs{@@_div_significand_pack:NNN} $10^6 + Q_{4}$ % \cs{@@_div_significand_pack:NNN} $10^6 + Q_{5}$ -% \cs{@@_div_significand_pack:NNN} $10^6 + Q_{6}$ |;| -% \meta{exponent} |;| \meta{continuation} +% \cs{@@_div_significand_pack:NNN} $10^6 + Q_{6}$ \cs{@@_sep:} +% \meta{exponent} \cs{@@_sep:} \meta{continuation} % \end{syntax} % where \meta{fixed tl} holds the logarithm of a number % in $[1,10]$, and \meta{exponent} is @@ -378,8 +389,9 @@ % correct order to add the $Q_{i}$ together and put semicolons % between each piece. Once those have been expanded, we get % \begin{syntax} -% \cs{@@_ln_div_after:Nw} \meta{fixed-tl} \meta{1d} |;| \meta{4d} |;| \meta{4d} |;| -% ~~\meta{4d} |;| \meta{4d} |;| \meta{4d} |;| \meta{4d} |;| \meta{exponent} |;| +% \cs{@@_ln_div_after:Nw} \meta{fixed-tl} \meta{1d} \cs{@@_sep:} \meta{4d} \cs{@@_sep:} +% ~~\meta{4d} \cs{@@_sep:} \meta{4d} \cs{@@_sep:} \meta{4d} \cs{@@_sep:} \meta{4d} \cs{@@_sep:} +% ~~\meta{4d} \cs{@@_sep:} \meta{exponent} \cs{@@_sep:} % \end{syntax} % ^^A todo: redoc. % Just as with division, we know that the first two digits @@ -388,7 +400,7 @@ % We then compute $1-2/(x+1)$, after testing whether $2/(x+1)$ is % greater than or smaller than $1$. % \begin{macrocode} -\cs_new:Npn \@@_ln_div_after:Nw #1#2; +\cs_new:Npn \@@_ln_div_after:Nw #1#2\@@_sep: { \if_meaning:w 0 #2 \exp_after:wN \@@_ln_t_small:Nw @@ -398,31 +410,35 @@ \fi: #1 } -\cs_new:Npn \@@_ln_t_small:Nw #1 #2; #3; #4; #5; #6; #7; +\cs_new:Npn \@@_ln_t_small:Nw + #1 #2\@@_sep: #3\@@_sep: #4\@@_sep: #5\@@_sep: #6\@@_sep: #7\@@_sep: { \exp_after:wN \@@_ln_t_large:NNw \exp_after:wN + % <sign> \exp_after:wN #1 - \int_value:w \@@_int_eval:w 9999 - #2 \exp_after:wN ; - \int_value:w \@@_int_eval:w 9999 - #3 \exp_after:wN ; - \int_value:w \@@_int_eval:w 9999 - #4 \exp_after:wN ; - \int_value:w \@@_int_eval:w 9999 - #5 \exp_after:wN ; - \int_value:w \@@_int_eval:w 9999 - #6 \exp_after:wN ; - \int_value:w \@@_int_eval:w 1 0000 - #7 ; + \int_value:w \@@_int_eval:w 9999 - #2 \exp_after:wN \@@_sep: + \int_value:w \@@_int_eval:w 9999 - #3 \exp_after:wN \@@_sep: + \int_value:w \@@_int_eval:w 9999 - #4 \exp_after:wN \@@_sep: + \int_value:w \@@_int_eval:w 9999 - #5 \exp_after:wN \@@_sep: + \int_value:w \@@_int_eval:w 9999 - #6 \exp_after:wN \@@_sep: + \int_value:w \@@_int_eval:w 1 0000 - #7 \@@_sep: } % \end{macrocode} % % \begin{syntax} % \cs{@@_ln_t_large:NNw} \meta{sign} \meta{fixed tl} -% ~~\meta{t_1}|;| \meta{t_2} |;| \meta{t_3}|;| \meta{t_4}|;| \meta{t_5} |;| \meta{t_6}|;| -% ~~\meta{exponent} |;| \meta{continuation} +% ~~\meta{t_1}\cs{@@_sep:} \meta{t_2} \cs{@@_sep:} \meta{t_3}\cs{@@_sep:} \meta{t_4} +% ~~\cs{@@_sep:} \meta{t_5} \cs{@@_sep:} \meta{t_6}\cs{@@_sep:} +% ~~\meta{exponent} \cs{@@_sep:} \meta{continuation} % \end{syntax} % Compute the square $|t|^2$, and keep $|t|$ at the end with its % sign. We know that $|t|<0.1765$, so every piece has at most $4$ % digits. However, since we were not careful in \cs{@@_ln_t_small:w}, % they can have less than $4$ digits. % \begin{macrocode} -\cs_new:Npn \@@_ln_t_large:NNw #1 #2 #3; #4; #5; #6; #7; #8; +\cs_new:Npn \@@_ln_t_large:NNw + #1 #2 + #3\@@_sep: #4\@@_sep: #5\@@_sep: #6\@@_sep: #7\@@_sep: #8\@@_sep: { \exp_after:wN \@@_ln_square_t_after:w \int_value:w \@@_int_eval:w 9999 0000 + #3*#3 @@ -436,7 +452,7 @@ \int_value:w \@@_int_eval:w 1 0000 0000 + 2*#3*#7 + 2*#4*#6 + #5*#5 + (2*#3*#8 + 2*#4*#7 + 2*#5*#6) / 1 0000 - % ; ; ; + % \@@_sep: \@@_sep: \@@_sep: \exp_after:wN \@@_ln_twice_t_after:w \int_value:w \@@_int_eval:w -1 + 2*#3 \exp_after:wN \@@_ln_twice_t_pack:Nw @@ -448,15 +464,16 @@ \exp_after:wN \@@_ln_twice_t_pack:Nw \int_value:w \@@_int_eval:w 9999 + 2*#7 \exp_after:wN \@@_ln_twice_t_pack:Nw - \int_value:w \@@_int_eval:w 10000 + 2*#8 ; ; + \int_value:w \@@_int_eval:w 10000 + 2*#8 \@@_sep: \@@_sep: { \@@_ln_c:NwNw #1 } #2 } -\cs_new:Npn \@@_ln_twice_t_pack:Nw #1 #2; { + #1 ; {#2} } -\cs_new:Npn \@@_ln_twice_t_after:w #1; { ;;; {#1} } -\cs_new:Npn \@@_ln_square_t_pack:NNNNNw #1 #2#3#4#5 #6; - { + #1#2#3#4#5 ; {#6} } -\cs_new:Npn \@@_ln_square_t_after:w 1 0 #1#2#3 #4; +\cs_new:Npn \@@_ln_twice_t_pack:Nw #1 #2\@@_sep: { + #1 \@@_sep: {#2} } +\cs_new:Npn \@@_ln_twice_t_after:w #1\@@_sep: + { \@@_sep:\@@_sep:\@@_sep: {#1} } +\cs_new:Npn \@@_ln_square_t_pack:NNNNNw #1 #2#3#4#5 #6\@@_sep: + { + #1#2#3#4#5 \@@_sep: {#6} } +\cs_new:Npn \@@_ln_square_t_after:w 1 0 #1#2#3 #4\@@_sep: { \@@_ln_Taylor:wwNw {0#1#2#3} {#4} } % \end{macrocode} % \end{macro} @@ -465,10 +482,10 @@ % Denoting $T=t^2$, we get % \begin{syntax} % \cs{@@_ln_Taylor:wwNw} -% ~~\Arg{T_1} \Arg{T_2} \Arg{T_3} \Arg{T_4} \Arg{T_5} \Arg{T_6} |;| |;| -% ~~\Arg{(2t)_1} \Arg{(2t)_2} \Arg{(2t)_3} \Arg{(2t)_4} \Arg{(2t)_5} \Arg{(2t)_6} |;| +% ~~\Arg{T_1} \Arg{T_2} \Arg{T_3} \Arg{T_4} \Arg{T_5} \Arg{T_6} \cs{@@_sep:} \cs{@@_sep:} +% ~~\Arg{(2t)_1} \Arg{(2t)_2} \Arg{(2t)_3} \Arg{(2t)_4} \Arg{(2t)_5} \Arg{(2t)_6} \cs{@@_sep:} % ~~|{| \cs{@@_ln_c:NwNw} \meta{sign} |}| -% ~~\meta{fixed tl} \meta{exponent} |;| \meta{continuation} +% ~~\meta{fixed tl} \meta{exponent} \cs{@@_sep:} \meta{continuation} % \end{syntax} % And we want to compute % \[ @@ -491,26 +508,30 @@ % (${}<10^4$). % \begin{macrocode} \cs_new:Npn \@@_ln_Taylor:wwNw - { \@@_ln_Taylor_loop:www 21 ; {0000}{0000}{0000}{0000}{0000}{0000} ; } -\cs_new:Npn \@@_ln_Taylor_loop:www #1; #2; #3; + { + \@@_ln_Taylor_loop:www + 21 \@@_sep: {0000}{0000}{0000}{0000}{0000}{0000} \@@_sep: + } +\cs_new:Npn \@@_ln_Taylor_loop:www #1\@@_sep: #2\@@_sep: #3\@@_sep: { \if_int_compare:w #1 = \c_one_int \@@_ln_Taylor_break:w \fi: - \exp_after:wN \@@_fixed_div_int:wwN \c_@@_one_fixed_tl #1; - \@@_fixed_add:wwn #2; - \@@_fixed_mul:wwn #3; + \exp_after:wN \@@_fixed_div_int:wwN \c_@@_one_fixed_tl #1\@@_sep: + \@@_fixed_add:wwn #2\@@_sep: + \@@_fixed_mul:wwn #3\@@_sep: { \exp_after:wN \@@_ln_Taylor_loop:www - \int_value:w \@@_int_eval:w #1 - 2 ; + \int_value:w \@@_int_eval:w #1 - 2 \@@_sep: } - #3; + #3\@@_sep: } -\cs_new:Npn \@@_ln_Taylor_break:w \fi: #1 \@@_fixed_add:wwn #2#3; #4 ;; +\cs_new:Npn \@@_ln_Taylor_break:w + \fi: #1 \@@_fixed_add:wwn #2#3\@@_sep: #4 \@@_sep:\@@_sep: { \fi: \exp_after:wN \@@_fixed_mul:wwn - \exp_after:wN { \int_value:w \@@_int_eval:w 10000 + #2 } #3; + \exp_after:wN { \int_value:w \@@_int_eval:w 10000 + #2 } #3\@@_sep: } % \end{macrocode} % \end{macro} @@ -518,8 +539,8 @@ % \begin{macro}{\@@_ln_c:NwNw} % \begin{syntax} % \cs{@@_ln_c:NwNw} \meta{sign} -% ~~\Arg{r_1} \Arg{r_2} \Arg{r_3} \Arg{r_4} \Arg{r_5} \Arg{r_6} |;| -% ~~\meta{fixed tl} \meta{exponent} |;| \meta{continuation} +% ~~\Arg{r_1} \Arg{r_2} \Arg{r_3} \Arg{r_4} \Arg{r_5} \Arg{r_6} \cs{@@_sep:} +% ~~\meta{fixed tl} \meta{exponent} \cs{@@_sep:} \meta{continuation} % \end{syntax} % We are now reduced to finding $\ln(c)$ and $\meta{exponent}\ln(10)$ % in a table, and adding it to the mixture. The first step is to @@ -530,14 +551,14 @@ % is $1$ and $c=1$, we shift to working in units of $\cdot 10^4$, % since the final result is at least $\ln(10/7) \simeq 0.35$. % \begin{macrocode} -\cs_new:Npn \@@_ln_c:NwNw #1 #2; #3 +\cs_new:Npn \@@_ln_c:NwNw #1 #2\@@_sep: #3 { \if_meaning:w + #1 \exp_after:wN \exp_after:wN \exp_after:wN \@@_fixed_sub:wwn \else: \exp_after:wN \exp_after:wN \exp_after:wN \@@_fixed_add:wwn \fi: - #3 #2 ; + #3 #2 \@@_sep: } % \end{macrocode} % \end{macro} @@ -545,7 +566,7 @@ % \begin{macro}{\@@_ln_exponent:wn} % \begin{syntax} % \cs{@@_ln_exponent:wn} -% ~~\Arg{s_1} \Arg{s_2} \Arg{s_3} \Arg{s_4} \Arg{s_5} \Arg{s_6} |;| +% ~~\Arg{s_1} \Arg{s_2} \Arg{s_3} \Arg{s_4} \Arg{s_5} \Arg{s_6} \cs{@@_sep:} % ~~\Arg{exponent} % \end{syntax} % Compute \meta{exponent} times $\ln(10)$. Apart from the cases where @@ -559,7 +580,7 @@ % Besides, we already have addition and subtraction for $24$ digits % fixed point numbers. % \begin{macrocode} -\cs_new:Npn \@@_ln_exponent:wn #1; #2 +\cs_new:Npn \@@_ln_exponent:wn #1\@@_sep: #2 { \if_case:w #2 \exp_stop_f: 0 \@@_case_return:nw { \@@_fixed_to_float_o:Nw 2 } @@ -576,16 +597,16 @@ \exp_after:wN \@@_fixed_add:wwn \int_value:w - \fi: \fi: - #2; #1; + #2\@@_sep: #1\@@_sep: } % \end{macrocode} % Now we painfully write all the cases.\footnote{Bruno: do rounding.} % No overflow nor underflow can happen, except when computing \texttt{ln(1)}. % \begin{macrocode} -\cs_new:Npn \@@_ln_exponent_one:ww 1; #1; +\cs_new:Npn \@@_ln_exponent_one:ww 1\@@_sep: #1\@@_sep: { 0 - \exp_after:wN \@@_fixed_sub:wwn \c_@@_ln_x_fixed_tl #1; + \exp_after:wN \@@_fixed_sub:wwn \c_@@_ln_x_fixed_tl #1\@@_sep: \@@_fixed_to_float_o:wN 0 } % \end{macrocode} @@ -594,14 +615,14 @@ % in the conversion from fixed point to floating point). Note that here % the exponent has been made positive. % \begin{macrocode} -\cs_new:Npn \@@_ln_exponent_small:NNww #1#2#3; #4#5#6#7#8#9; +\cs_new:Npn \@@_ln_exponent_small:NNww #1#2#3\@@_sep: #4#5#6#7#8#9\@@_sep: { 4 \exp_after:wN \@@_fixed_mul:wwn \c_@@_ln_x_fixed_tl - {#3}{0000}{0000}{0000}{0000}{0000} ; + {#3}{0000}{0000}{0000}{0000}{0000} \@@_sep: #2 - {0000}{#4}{#5}{#6}{#7}{#8}; + {0000}{#4}{#5}{#6}{#7}{#8}\@@_sep: \@@_fixed_to_float_o:wN #1 } % \end{macrocode} @@ -613,7 +634,7 @@ % % \begin{macro}[EXP]{\@@_exp_o:w} % \begin{macrocode} -\cs_new:Npn \@@_exp_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_exp_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_return_o:Nw \c_one_fp @@ -630,7 +651,7 @@ \or: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2#3#4; + \s_@@ \@@_chk:w #2#3#4\@@_sep: } % \end{macrocode} % \end{macro} @@ -645,7 +666,7 @@ \@@_exp_pos_o:NNwnw - \@@_fixed_inv_to_float_o:wN \fi: } -\cs_new:Npn \@@_exp_pos_o:NNwnw #1#2#3 \fi: #4#5; +\cs_new:Npn \@@_exp_pos_o:NNwnw #1#2#3 \fi: #4#5\@@_sep: { \fi: \if_int_compare:w #4 > \c_@@_max_exp_exponent_int @@ -696,33 +717,33 @@ % delimited by a semicolon, form a fixed point number, so we pack it % in blocks of $4$ digits. % \begin{macrocode} -\cs_new:Npn \@@_exp_Taylor:Nnnwn #1#2#3 #4; #5 #6 +\cs_new:Npn \@@_exp_Taylor:Nnnwn #1#2#3 #4\@@_sep: #5 #6 { #6 \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_exp_Taylor_ii:ww - ; #2#3#4 0000 0000 ; + \@@_sep: #2#3#4 0000 0000 \@@_sep: } -\cs_new:Npn \@@_exp_Taylor_ii:ww #1; #2; - { \@@_exp_Taylor_loop:www 10 ; #1 ; #1 ; \s_@@_stop } -\cs_new:Npn \@@_exp_Taylor_loop:www #1; #2; #3; +\cs_new:Npn \@@_exp_Taylor_ii:ww #1\@@_sep: #2\@@_sep: + { \@@_exp_Taylor_loop:www 10 \@@_sep: #1 \@@_sep: #1 \@@_sep: \s_@@_stop } +\cs_new:Npn \@@_exp_Taylor_loop:www #1\@@_sep: #2\@@_sep: #3\@@_sep: { \if_int_compare:w #1 = \c_one_int \exp_after:wN \@@_exp_Taylor_break:Nww \fi: - \@@_fixed_div_int:wwN #3 ; #1 ; + \@@_fixed_div_int:wwN #3 \@@_sep: #1 \@@_sep: \@@_fixed_add_one:wN - \@@_fixed_mul:wwn #2 ; + \@@_fixed_mul:wwn #2 \@@_sep: { \exp_after:wN \@@_exp_Taylor_loop:www - \int_value:w \@@_int_eval:w #1 - 1 ; - #2 ; + \int_value:w \@@_int_eval:w #1 - 1 \@@_sep: + #2 \@@_sep: } } -\cs_new:Npn \@@_exp_Taylor_break:Nww #1 #2; #3 \s_@@_stop - { \@@_fixed_add_one:wN #2 ; } +\cs_new:Npn \@@_exp_Taylor_break:Nww #1 #2\@@_sep: #3 \s_@@_stop + { \@@_fixed_add_one:wN #2 \@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} @@ -824,23 +845,23 @@ % on to the Taylor series, eventually multiplied with the mantissa % that we have just computed. % \begin{macrocode} -\cs_new:Npn \@@_exp_pos_large:NnnNwn #1#2#3 #4#5; #6 +\cs_new:Npn \@@_exp_pos_large:NnnNwn #1#2#3 #4#5\@@_sep: #6 { \exp_after:wN \exp_after:wN \exp_after:wN \@@_exp_large:NwN \exp_after:wN \exp_after:wN \exp_after:wN #6 \exp_after:wN \c_@@_one_fixed_tl \int_value:w #3 #4 \exp_stop_f: - #5 00000 ; + #5 00000 \@@_sep: } -\cs_new:Npn \@@_exp_large:NwN #1#2; #3 +\cs_new:Npn \@@_exp_large:NwN #1#2\@@_sep: #3 { \if_case:w #3 ~ \exp_after:wN \@@_fixed_continue:wn \else: \exp_after:wN \@@_exp_intarray:w - \int_value:w \@@_int_eval:w 36 * #1 + 4 * #3 \exp_after:wN ; + \int_value:w \@@_int_eval:w 36 * #1 + 4 * #3 \exp_after:wN \@@_sep: \fi: - #2; + #2\@@_sep: { \if_meaning:w 0 #1 \exp_after:wN \@@_exp_large_after:wwn @@ -850,7 +871,7 @@ \fi: } } -\cs_new:Npn \@@_exp_intarray:w #1 ; +\cs_new:Npn \@@_exp_intarray:w #1 \@@_sep: { + \__kernel_intarray_item:Nn \c_@@_exp_intarray @@ -865,13 +886,15 @@ \int_value:w \__kernel_intarray_item:Nn \c_@@_exp_intarray { \@@_int_eval:w #1 - 1 } \exp_after:wN \@@_exp_intarray_aux:w - \int_value:w \__kernel_intarray_item:Nn \c_@@_exp_intarray {#1} ; ; + \int_value:w \__kernel_intarray_item:Nn + \c_@@_exp_intarray {#1} \@@_sep: \@@_sep: } -\cs_new:Npn \@@_exp_intarray_aux:w 1 #1#2#3#4#5 ; { ; {#1#2#3#4} {#5} } -\cs_new:Npn \@@_exp_large_after:wwn #1; #2; #3 +\cs_new:Npn \@@_exp_intarray_aux:w 1 #1#2#3#4#5 \@@_sep: + { \@@_sep: {#1#2#3#4} {#5} } +\cs_new:Npn \@@_exp_large_after:wwn #1\@@_sep: #2\@@_sep: #3 { - \@@_exp_Taylor:Nnnwn ? { } { } 0 #2; {} #3 - \@@_fixed_mul:wwn #1; + \@@_exp_Taylor:Nnnwn ? { } { } 0 #2\@@_sep: {} #3 + \@@_fixed_mul:wwn #1\@@_sep: } % \end{macrocode} % \end{macro} @@ -921,7 +944,7 @@ % \end{itemize} % \begin{macrocode} \cs_new:cpn { @@_ \iow_char:N \^ _o:ww } - \s_@@ \@@_chk:w #1#2#3; \s_@@ \@@_chk:w #4#5#6; + \s_@@ \@@_chk:w #1#2#3\@@_sep: \s_@@ \@@_chk:w #4#5#6\@@_sep: { \if_meaning:w 0 #4 \@@_case_return_o:Nw \c_one_fp @@ -940,10 +963,10 @@ \else: \exp_after:wN \@@_pow_zero_or_inf:ww \fi: - \s_@@ \@@_chk:w #1#2#3; + \s_@@ \@@_chk:w #1#2#3\@@_sep: } - { \s_@@ \@@_chk:w #4#5#6; \s_@@ \@@_chk:w #1#2#3; } - \s_@@ \@@_chk:w #4#5#6; + { \s_@@ \@@_chk:w #4#5#6\@@_sep: \s_@@ \@@_chk:w #1#2#3\@@_sep: } + \s_@@ \@@_chk:w #4#5#6\@@_sep: } % \end{macrocode} % \end{macro} @@ -959,7 +982,7 @@ % unless $b=-\infty$. % \begin{macrocode} \cs_new:Npn \@@_pow_zero_or_inf:ww - \s_@@ \@@_chk:w #1#2; \s_@@ \@@_chk:w #3#4 + \s_@@ \@@_chk:w #1#2\@@_sep: \s_@@ \@@_chk:w #3#4 { \if_meaning:w 1 #4 \@@_case_return_same_o:w @@ -976,7 +999,7 @@ \@@_case_use:nw { \@@_division_by_zero_o:NNww \c_inf_fp ^ - \s_@@ \@@_chk:w #1 #2 ; + \s_@@ \@@_chk:w #1 #2 \@@_sep: } \fi: \s_@@ \@@_chk:w #3#4 @@ -1000,7 +1023,7 @@ % \end{itemize} % \begin{macrocode} \cs_new:Npn \@@_pow_normal_o:ww - \s_@@ \@@_chk:w 1 #1#2#3; \s_@@ \@@_chk:w #4#5 + \s_@@ \@@_chk:w 1 #1#2#3\@@_sep: \s_@@ \@@_chk:w #4#5 { \if:w 0 \@@_str_if_eq:nn { #2 #3 } { 1 {1000} {0000} {0000} {0000} } \if_int_compare:w #4 #1 = 32 \exp_stop_f: @@ -1024,7 +1047,7 @@ \or: \@@_case_return_ii_o:ww \fi: - \s_@@ \@@_chk:w 1 #1 {#2} #3 ; + \s_@@ \@@_chk:w 1 #1 {#2} #3 \@@_sep: \s_@@ \@@_chk:w #4 #5 } % \end{macrocode} @@ -1069,17 +1092,18 @@ % float. Then comes an exponent and the $4$ brace groups of $x$, % followed by $b$. Compute $-\ln(x)$. % \begin{macrocode} -\cs_new:Npn \@@_pow_npos_aux:NNnww #1#2#3#4#5; \s_@@ \@@_chk:w 1#6#7#8; +\cs_new:Npn \@@_pow_npos_aux:NNnww + #1#2#3#4#5\@@_sep: \s_@@ \@@_chk:w 1#6#7#8\@@_sep: { #1 \@@_int_eval:w \@@_ln_significand:NNNNnnnN #4#5 \@@_pow_exponent:wnN {#3} - \@@_fixed_mul:wwn #8 {0000}{0000} ; - \@@_pow_B:wwN #7; + \@@_fixed_mul:wwn #8 {0000}{0000} \@@_sep: + \@@_pow_B:wwN #7\@@_sep: #1 #2 0 % fixed_to_float_o:wN } -\cs_new:Npn \@@_pow_exponent:wnN #1; #2 +\cs_new:Npn \@@_pow_exponent:wnN #1\@@_sep: #2 { \if_int_compare:w #2 > \c_zero_int \exp_after:wN \@@_pow_exponent:Nwnnnnnw % n\ln(10) - (-\ln(x)) @@ -1088,9 +1112,9 @@ \exp_after:wN \@@_pow_exponent:Nwnnnnnw % -(|n|\ln(10) + (-\ln(x))) \exp_after:wN - \fi: - #2; #1; + #2\@@_sep: #1\@@_sep: } -\cs_new:Npn \@@_pow_exponent:Nwnnnnnw #1#2; #3#4#5#6#7#8; +\cs_new:Npn \@@_pow_exponent:Nwnnnnnw #1#2\@@_sep: #3#4#5#6#7#8\@@_sep: { %^^A todo: use that in ln. \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_leading_shift_int @@ -1109,9 +1133,9 @@ \exp_after:wN \@@_pack:NNNNNw \int_value:w \@@_int_eval:w \c_@@_trailing_shift_int #1 #2*8401 - #1 #7 - #1 ( #2*7991 - #8 ) / 1 0000 ; ; + #1 ( #2*7991 - #8 ) / 1 0000 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_pow_B:wwN #1#2#3#4#5#6; #7; +\cs_new:Npn \@@_pow_B:wwN #1#2#3#4#5#6\@@_sep: #7\@@_sep: { \if_int_compare:w #7 < \c_zero_int \exp_after:wN \@@_pow_C_neg:w \int_value:w - @@ -1122,23 +1146,23 @@ \exp_after:wN \@@_pow_C_overflow:w \int_value:w \fi: \fi: - #7 \exp_after:wN ; + #7 \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w 10 0000 + #1 \@@_int_eval_end: - #2#3#4#5#6 0000 0000 0000 0000 0000 0000 ; %^^A todo: how many 0? + #2#3#4#5#6 0000 0000 0000 0000 0000 0000 \@@_sep: %^^A todo: how many 0? } -\cs_new:Npn \@@_pow_C_overflow:w #1; #2; #3 +\cs_new:Npn \@@_pow_C_overflow:w #1\@@_sep: #2\@@_sep: #3 { + 2 * \c_@@_max_exponent_int \exp_after:wN \@@_fixed_continue:wn \c_@@_one_fixed_tl } -\cs_new:Npn \@@_pow_C_neg:w #1 ; 1 +\cs_new:Npn \@@_pow_C_neg:w #1 \@@_sep: 1 { \exp_after:wN \exp_after:wN \exp_after:wN \@@_pow_C_pack:w \prg_replicate:nn {#1} {0} } -\cs_new:Npn \@@_pow_C_pos:w #1; 1 - { \@@_pow_C_pos_loop:wN #1; } -\cs_new:Npn \@@_pow_C_pos_loop:wN #1; #2 +\cs_new:Npn \@@_pow_C_pos:w #1\@@_sep: 1 + { \@@_pow_C_pos_loop:wN #1\@@_sep: } +\cs_new:Npn \@@_pow_C_pos_loop:wN #1\@@_sep: #2 { \if_meaning:w 0 #1 \exp_after:wN \@@_pow_C_pack:w @@ -1149,7 +1173,7 @@ \else: \exp_after:wN \@@_pow_C_overflow:w \int_value:w \fi: - \@@_int_eval:w #1 - 1 \exp_after:wN ; + \@@_int_eval:w #1 - 1 \exp_after:wN \@@_sep: \fi: } \cs_new:Npn \@@_pow_C_pack:w @@ -1173,20 +1197,21 @@ % called, |(-0.1)**(12345.67)| gives $+0$ rather than complaining % that the sign is not defined. % \begin{macrocode} -\cs_new:Npn \@@_pow_neg:www \s_@@ \@@_chk:w #1#2; #3; #4; +\cs_new:Npn \@@_pow_neg:www + \s_@@ \@@_chk:w #1#2\@@_sep: #3\@@_sep: #4\@@_sep: { - \if_case:w \@@_pow_neg_case:w #4 ; + \if_case:w \@@_pow_neg_case:w #4 \@@_sep: \exp_after:wN \@@_pow_neg_aux:wNN \or: \if_int_compare:w \@@_int_eval:w #1 / 2 = \c_one_int - \@@_invalid_operation_o:Nww ^ #3; #4; + \@@_invalid_operation_o:Nww ^ #3\@@_sep: #4\@@_sep: \exp:w \exp_end_continue_f:w \exp_after:wN \exp_after:wN \exp_after:wN \@@_use_none_until_s:w \fi: \fi: \@@_exp_after_o:w - \s_@@ \@@_chk:w #1#2; + \s_@@ \@@_chk:w #1#2\@@_sep: } \cs_new:Npn \@@_pow_neg_aux:wNN #1 \s_@@ \@@_chk:w #2#3 { @@ -1216,7 +1241,7 @@ % |0|~if and only if the number was an integer, and |#3| is the $8$ % least significant digits of that integer. % \begin{macrocode} -\cs_new:Npn \@@_pow_neg_case:w \s_@@ \@@_chk:w #1#2#3; +\cs_new:Npn \@@_pow_neg_case:w \s_@@ \@@_chk:w #1#2#3\@@_sep: { \if_case:w #1 \exp_stop_f: -1 @@ -1236,7 +1261,7 @@ {#2} {#3} {#4} {#5} \fi: } -\cs_new:Npn \@@_pow_neg_case_aux:Nnnw #1#2#3#4 ; +\cs_new:Npn \@@_pow_neg_case_aux:Nnnw #1#2#3#4 \@@_sep: { \if_meaning:w 0 #1 \if_int_odd:w #3 \exp_stop_f: @@ -1270,7 +1295,7 @@ % with $24$ digits instead of~$16$. It is easy to check that % computing factorials with this precision is enough. % \begin{macrocode} -\cs_new:Npn \@@_fact_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_fact_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_return_o:Nw \c_one_fp @@ -1286,7 +1311,7 @@ \@@_case_use:nw { \@@_invalid_operation_o:fw { fact } } \fi: \@@_fact_pos_o:w - \s_@@ \@@_chk:w #2 #3 #4 ; + \s_@@ \@@_chk:w #2 #3 #4 \@@_sep: } % \end{macrocode} % \end{macro} @@ -1298,11 +1323,11 @@ % \cs{@@_sanitize:Nw} with a positive sign marker~|0| and an integer % expression that will mop up any exponent in the calculation. % \begin{macrocode} -\cs_new:Npn \@@_fact_pos_o:w #1; +\cs_new:Npn \@@_fact_pos_o:w #1\@@_sep: { - \@@_small_int:wTF #1; + \@@_small_int:wTF #1\@@_sep: { \@@_fact_int_o:n } - { \@@_invalid_operation_o:fw { fact } #1; } + { \@@_invalid_operation_o:fw { fact } #1\@@_sep: } } \cs_new:Npn \@@_fact_int_o:n #1 { @@ -1316,7 +1341,7 @@ \exp_after:wN \@@_sanitize:Nw \exp_after:wN 0 \int_value:w \@@_int_eval:w - \@@_fact_loop_o:w #1 . 4 , { 1 } { } { } { } { } { } ; + \@@_fact_loop_o:w #1 . 4 , { 1 } { } { } { } { } { } \@@_sep: } % \end{macrocode} % \end{macro} @@ -1325,7 +1350,7 @@ % The loop receives an integer |#1| whose factorial we want to % compute, which we progressively decrement, and the result so far as % an extended-precision number |#2| in the form -% \meta{exponent}|,|\meta{mantissa}|;|. The loop goes in steps of two +% \meta{exponent}|,|\meta{mantissa}\cs{@@_sep:}. The loop goes in steps of two % because we compute |#1*#1-1| as an integer expression (it must fit % since |#1| is at most $3248$), then multiply with the result so far. % We don't need to fill in most of the mantissa with zeros because @@ -1335,7 +1360,7 @@ % chosen because the normalization step cannot deal with larger % integers. % \begin{macrocode} -\cs_new:Npn \@@_fact_loop_o:w #1 . #2 ; +\cs_new:Npn \@@_fact_loop_o:w #1 . #2 \@@_sep: { \if_int_compare:w #1 < 12 \exp_stop_f: \@@_fact_small_o:w #1 @@ -1343,14 +1368,14 @@ \exp_after:wN \@@_ep_mul:wwwwn \exp_after:wN 4 \exp_after:wN , \exp_after:wN { \int_value:w \@@_int_eval:w #1 * (#1 - 1) } - { } { } { } { } { } ; - #2 ; + { } { } { } { } { } \@@_sep: + #2 \@@_sep: { \exp_after:wN \@@_fact_loop_o:w \int_value:w \@@_int_eval:w #1 - 2 . } } -\cs_new:Npn \@@_fact_small_o:w #1 \fi: #2 ; #3 ; #4 +\cs_new:Npn \@@_fact_small_o:w #1 \fi: #2 \@@_sep: #3 \@@_sep: #4 { \fi: \exp_after:wN \@@_ep_mul:wwwwn @@ -1362,8 +1387,8 @@ 1 \or: 1 \or: 2 \or: 6 \or: 24 \or: 120 \or: 720 \or: 5040 \or: 40320 \or: 362880 \or: 3628800 \or: 39916800 \fi: - } { } { } { } { } { } ; - #3 ; + } { } { } { } { } { } \@@_sep: + #3 \@@_sep: \@@_ep_to_float_o:wwN 0 } % \end{macrocode} diff --git a/macros/latex/required/l3kernel/l3fp-extended.dtx b/macros/latex/required/l3kernel/l3fp-extended.dtx index 596dc86ef2..ce61593e9d 100644 --- a/macros/latex/required/l3kernel/l3fp-extended.dtx +++ b/macros/latex/required/l3kernel/l3fp-extended.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-extended.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -76,7 +76,7 @@ % enough to be rounded away when converting back to a floating point % number. The fixed point numbers are expressed as % \begin{quote} -% \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} |;| +% \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} % \end{quote} % where each \meta{a_i} is exactly $4$ digits (ranging from |0000| to % |9999|), except \meta{a_1}, which may be any \enquote{not-too-large} @@ -89,7 +89,8 @@ % % Most functions we define here have the form % \begin{syntax} -% \cs{@@_fixed_\meta{calculation}:wwn} \meta{operand_1} |;| \meta{operand_2} |;| \Arg{continuation} +% \cs{@@_fixed_\meta{calculation}:wwn} \meta{operand_1} \cs{@@_sep:} +% ~~\meta{operand_2} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % They perform the \meta{calculation} on the two \meta{operands}, then % feed the result ($6$ brace groups followed by a semicolon) to the @@ -97,9 +98,9 @@ % Some functions only accept an \texttt{N}-type \meta{continuation}. % This allows constructions such as % \begin{quote} -% \cs{@@_fixed_add:wwn} \meta{X_1} |;| \meta{X_2} |;| \\ -% \cs{@@_fixed_mul:wwn} \meta{X_3} |;| \\ -% \cs{@@_fixed_add:wwn} \meta{X_4} |;| \\ +% \cs{@@_fixed_add:wwn} \meta{X_1} \cs{@@_sep:} \meta{X_2} \cs{@@_sep:} \\ +% \cs{@@_fixed_mul:wwn} \meta{X_3} \cs{@@_sep:} \\ +% \cs{@@_fixed_add:wwn} \meta{X_4} \cs{@@_sep:} \\ % \end{quote} % to compute $(X_1+X_2)\cdot X_3 + X_4$. This turns out to be very % appropriate for computing continued fractions and Taylor series. @@ -116,29 +117,29 @@ % The fixed-point number~$1$, used in \pkg{l3fp-expo}. % \begin{macrocode} \tl_const:Nn \c_@@_one_fixed_tl - { {10000} {0000} {0000} {0000} {0000} {0000} ; } + { {10000} {0000} {0000} {0000} {0000} {0000} \@@_sep: } % \end{macrocode} % \end{variable} % % \begin{macro}[EXP]{\@@_fixed_continue:wn} % This function simply calls the next function. % \begin{macrocode} -\cs_new:Npn \@@_fixed_continue:wn #1; #2 { #2 #1; } +\cs_new:Npn \@@_fixed_continue:wn #1\@@_sep: #2 { #2 #1\@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_fixed_add_one:wN} % \begin{syntax} -% \cs{@@_fixed_add_one:wN} \meta{a} |;| \meta{continuation} +% \cs{@@_fixed_add_one:wN} \meta{a} \cs{@@_sep:} \meta{continuation} % \end{syntax} % This function adds $1$ to the fixed point \meta{a}, by changing % $a_1$ to $10000+a_1$, then calls the \meta{continuation}. This % requires $a_1 + 10000 < 2^{31}$. % \begin{macrocode} -\cs_new:Npn \@@_fixed_add_one:wN #1#2; #3 +\cs_new:Npn \@@_fixed_add_one:wN #1#2\@@_sep: #3 { \exp_after:wN #3 \exp_after:wN - { \int_value:w \@@_int_eval:w \c_@@_myriad_int + #1 } #2 ; + { \int_value:w \@@_int_eval:w \c_@@_myriad_int + #1 } #2 \@@_sep: } % \end{macrocode} % \end{macro} @@ -151,13 +152,13 @@ % exactly $4$~digits. The choice of shifts allows~|#1| to be in the % range $[0, 5\cdot 10^{8}-1]$. % \begin{macrocode} -\cs_new:Npn \@@_fixed_div_myriad:wn #1#2#3#4#5#6; +\cs_new:Npn \@@_fixed_div_myriad:wn #1#2#3#4#5#6\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_leading_shift_int \exp_after:wN \@@_pack:NNNNNw \int_value:w \@@_int_eval:w \c_@@_trailing_shift_int - + #1 ; {#2}{#3}{#4}{#5}; + + #1 \@@_sep: {#2}{#3}{#4}{#5}\@@_sep: } % \end{macrocode} % \end{macro} @@ -167,7 +168,8 @@ % calling this auxiliary. It braces the last block of digits, and % places the \meta{continuation} |#3| in front. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_after:wwn #1; #2; #3 { #3 {#1} #2; } +\cs_new:Npn \@@_fixed_mul_after:wwn #1\@@_sep: #2\@@_sep: #3 + { #3 {#1} #2\@@_sep: } % \end{macrocode} % \end{macro} % @@ -176,20 +178,20 @@ % \begin{macro}[EXP]{\@@_fixed_mul_short:wwn} % \begin{syntax}\parskip=0pt\obeylines % \cs{@@_fixed_mul_short:wwn} -% | |\Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} |;| -% | |\Arg{b_0} \Arg{b_1} \Arg{b_2} |;| \Arg{continuation} +% | |\Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} +% | |\Arg{b_0} \Arg{b_1} \Arg{b_2} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Computes the product $c=ab$ of $a=\sum_i \meta{a_i} 10^{-4i}$ and % $b=\sum_i \meta{b_i} 10^{-4i}$, rounds it to the closest multiple of % $10^{-24}$, and leaves \meta{continuation} \Arg{c_1} \ldots{} -% \Arg{c_6} |;| in the input stream, where each of the \meta{c_i} are +% \Arg{c_6} \cs{@@_sep:} in the input stream, where each of the \meta{c_i} are % blocks of $4$~digits, except \meta{c_1}, which is any \TeX{} % integer. Note that indices for \meta{b} start at~$0$: for instance % a second operand of |{0001}{0000}{0000}| leaves the first operand % unchanged (rather than dividing it by $10^{4}$, as % \cs{@@_fixed_mul:wwn} would). % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_short:wwn #1#2#3#4#5#6; #7#8#9; +\cs_new:Npn \@@_fixed_mul_short:wwn #1#2#3#4#5#6\@@_sep: #7#8#9\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_leading_shift_int @@ -210,7 +212,7 @@ \int_value:w \@@_int_eval:w \c_@@_trailing_shift_int + #4*#9 + #5*#8 + #6*#7 + ( #5*#9 + #6*#8 + #6*#9 / \c_@@_myriad_int ) - / \c_@@_myriad_int ; ; + / \c_@@_myriad_int \@@_sep: \@@_sep: } % \end{macrocode} % \end{macro} @@ -225,7 +227,7 @@ % \@@_fixed_div_int_after:Nw % } % \begin{syntax} -% \cs{@@_fixed_div_int:wwN} \meta{a} |;| \meta{n} |;| \meta{continuation} +% \cs{@@_fixed_div_int:wwN} \meta{a} \cs{@@_sep:} \meta{n} \cs{@@_sep:} \meta{continuation} % \end{syntax} % Divides the fixed point number \meta{a} by the (small) integer % $0<\meta{n}<10^4$ and feeds the result to the \meta{continuation}. @@ -255,7 +257,7 @@ % \cs{@@_fixed_div_int_pack:Nw} $9999 + Q_{4}$ \\ % \cs{@@_fixed_div_int_pack:Nw} $9999 + Q_{5}$ \\ % \cs{@@_fixed_div_int_pack:Nw} $9999$ \\ -% \cs{@@_fixed_div_int_auxii:wnn} $Q_{6}$ |;| \Arg{n} \Arg{a_{6}} +% \cs{@@_fixed_div_int_auxii:wnn} $Q_{6}$ \cs{@@_sep:} \Arg{n} \Arg{a_{6}} % \end{quote} % where expansion is happening from the last line up. The % \texttt{iii} auxiliary adds $Q_{6} + 2 \simeq a_{6}/n + 1$ to the @@ -268,27 +270,27 @@ % brace group is produced by the \texttt{after} auxiliary, which % places the \meta{continuation} as appropriate. % \begin{macrocode} -\cs_new:Npn \@@_fixed_div_int:wwN #1#2#3#4#5#6 ; #7 ; #8 +\cs_new:Npn \@@_fixed_div_int:wwN #1#2#3#4#5#6 \@@_sep: #7 \@@_sep: #8 { \exp_after:wN \@@_fixed_div_int_after:Nw \exp_after:wN #8 \int_value:w \@@_int_eval:w - 1 \@@_fixed_div_int:wnN - #1; {#7} \@@_fixed_div_int_auxi:wnn - #2; {#7} \@@_fixed_div_int_auxi:wnn - #3; {#7} \@@_fixed_div_int_auxi:wnn - #4; {#7} \@@_fixed_div_int_auxi:wnn - #5; {#7} \@@_fixed_div_int_auxi:wnn - #6; {#7} \@@_fixed_div_int_auxii:wnn ; + #1\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #2\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #3\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #4\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #5\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #6\@@_sep: {#7} \@@_fixed_div_int_auxii:wnn \@@_sep: } -\cs_new:Npn \@@_fixed_div_int:wnN #1; #2 #3 +\cs_new:Npn \@@_fixed_div_int:wnN #1\@@_sep: #2 #3 { \exp_after:wN #3 - \int_value:w \@@_int_eval:w #1 / #2 - 1 ; + \int_value:w \@@_int_eval:w #1 / #2 - 1 \@@_sep: {#2} {#1} } -\cs_new:Npn \@@_fixed_div_int_auxi:wnn #1; #2 #3 +\cs_new:Npn \@@_fixed_div_int_auxi:wnn #1\@@_sep: #2 #3 { + #1 \exp_after:wN \@@_fixed_div_int_pack:Nw @@ -296,9 +298,9 @@ \exp_after:wN \@@_fixed_div_int:wnN \int_value:w \@@_int_eval:w #3 - #1*#2 \@@_int_eval_end: } -\cs_new:Npn \@@_fixed_div_int_auxii:wnn #1; #2 #3 { + #1 + 2 ; } -\cs_new:Npn \@@_fixed_div_int_pack:Nw #1 #2; { + #1; {#2} } -\cs_new:Npn \@@_fixed_div_int_after:Nw #1 #2; { #1 {#2} } +\cs_new:Npn \@@_fixed_div_int_auxii:wnn #1\@@_sep: #2 #3 { + #1 + 2 \@@_sep: } +\cs_new:Npn \@@_fixed_div_int_pack:Nw #1 #2\@@_sep: { + #1\@@_sep: {#2} } +\cs_new:Npn \@@_fixed_div_int_after:Nw #1 #2\@@_sep: { #1 {#2} } % \end{macrocode} % \end{macro} % \end{macro} @@ -314,7 +316,7 @@ % \@@_fixed_add_after:NNNNNwn % } % \begin{syntax} -% \cs{@@_fixed_add:wwn} \meta{a} |;| \meta{b} |;| \Arg{continuation} +% \cs{@@_fixed_add:wwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Computes $a+b$ (resp.\ $a-b$) and feeds the result to the % \meta{continuation}. This function requires $0\leq a_{1},b_{1}\leq @@ -333,7 +335,7 @@ % \begin{macrocode} \cs_new:Npn \@@_fixed_add:wwn { \@@_fixed_add:Nnnnnwnn + } \cs_new:Npn \@@_fixed_sub:wwn { \@@_fixed_add:Nnnnnwnn - } -\cs_new:Npn \@@_fixed_add:Nnnnnwnn #1 #2#3#4#5 #6; #7#8 +\cs_new:Npn \@@_fixed_add:Nnnnnwnn #1 #2#3#4#5 #6\@@_sep: #7#8 { \exp_after:wN \@@_fixed_add_after:NNNNNwn \int_value:w \@@_int_eval:w 9 9999 9998 + #2#3 #1 #7#8 @@ -341,15 +343,16 @@ \int_value:w \@@_int_eval:w 1 9999 9998 + #4#5 \@@_fixed_add:nnNnnnwn #6 #1 } -\cs_new:Npn \@@_fixed_add:nnNnnnwn #1#2 #3 #4#5 #6#7 ; #8 +\cs_new:Npn \@@_fixed_add:nnNnnnwn #1#2 #3 #4#5 #6#7 \@@_sep: #8 { #3 #4#5 \exp_after:wN \@@_fixed_add_pack:NNNNNwn - \int_value:w \@@_int_eval:w 2 0000 0000 #3 #6#7 + #1#2 ; {#8} ; + \int_value:w \@@_int_eval:w + 2 0000 0000 #3 #6#7 + #1#2 \@@_sep: {#8} \@@_sep: } -\cs_new:Npn \@@_fixed_add_pack:NNNNNwn #1 #2#3#4#5 #6; #7 - { + #1 ; {#7} {#2#3#4#5} {#6} } -\cs_new:Npn \@@_fixed_add_after:NNNNNwn 1 #1 #2#3#4#5 #6; #7 +\cs_new:Npn \@@_fixed_add_pack:NNNNNwn #1 #2#3#4#5 #6\@@_sep: #7 + { + #1 \@@_sep: {#7} {#2#3#4#5} {#6} } +\cs_new:Npn \@@_fixed_add_after:NNNNNwn 1 #1 #2#3#4#5 #6\@@_sep: #7 { #7 {#1#2#3#4#5} {#6} } % \end{macrocode} % \end{macro} @@ -361,7 +364,7 @@ % \begin{macro}[EXP]{\@@_fixed_mul:wwn} % \begin{macro}[EXP]{\@@_fixed_mul:nnnnnnnw} % \begin{syntax} -% \cs{@@_fixed_mul:wwn} \meta{a} |;| \meta{b} |;| \Arg{continuation} +% \cs{@@_fixed_mul:wwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Computes $a\times b$ and feeds the result to \meta{continuation}. % This function requires $0\leq a_{1}, b_{1} < 10000$. Once more, we @@ -402,7 +405,7 @@ % is finally placed in front of the $6$ brace groups by % \cs{@@_fixed_mul_after:wwn}. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul:wwn #1#2#3#4 #5; #6#7#8#9 +\cs_new:Npn \@@_fixed_mul:wwn #1#2#3#4 #5\@@_sep: #6#7#8#9 { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_leading_shift_int @@ -424,10 +427,10 @@ + ( #3*#9 + #4*#8 + \@@_fixed_mul:nnnnnnnw #5 {#6}{#7} {#1}{#2} } -\cs_new:Npn \@@_fixed_mul:nnnnnnnw #1#2 #3#4 #5#6 #7#8 ; +\cs_new:Npn \@@_fixed_mul:nnnnnnnw #1#2 #3#4 #5#6 #7#8 \@@_sep: { #1*#4 + #2*#3 + #5*#8 + #6*#7 ) / \c_@@_myriad_int - + #1*#3 + #5*#7 ; ; + + #1*#3 + #5*#7 \@@_sep: \@@_sep: } % \end{macrocode} % \end{macro} @@ -442,9 +445,9 @@ % \@@_fixed_mul_one_minus_mul:wwn, % } % \begin{syntax} -% \cs{@@_fixed_mul_add:wwwn} \meta{a} |;| \meta{b} |;| \meta{c} |;| \Arg{continuation} -% \cs{@@_fixed_mul_sub_back:wwwn} \meta{a} |;| \meta{b} |;| \meta{c} |;| \Arg{continuation} -% \cs{@@_fixed_one_minus_mul:wwn} \meta{a} |;| \meta{b} |;| \Arg{continuation} +% \cs{@@_fixed_mul_add:wwwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{c} \cs{@@_sep:} \Arg{continuation} +% \cs{@@_fixed_mul_sub_back:wwwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{c} \cs{@@_sep:} \Arg{continuation} +% \cs{@@_fixed_one_minus_mul:wwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Sometimes called |FMA| (fused multiply-add), these functions % compute $a\times b + c$, $c - a\times b$, and $1 - a\times b$ and @@ -482,32 +485,33 @@ % Each of the three function starts the first two levels (the first, % corresponding to $10^{-4}$, is empty), with $c_{1} c_{2}$ in the % first level, calls the \texttt{i} auxiliary with arguments described -% later, and adds a trailing ${} + c_{5}c_{6}$ |;| -% \Arg{continuation}~|;|. The ${} + c_{5}c_{6}$ piece, which is +% later, and adds a trailing ${} + c_{5}c_{6}$ \cs{@@_sep:} +% \Arg{continuation}~\cs{@@_sep:}. The ${} + c_{5}c_{6}$ piece, which is % omitted for \cs{@@_fixed_one_minus_mul:wwn}, is taken in the % integer expression for the $10^{-24}$ level. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:wwwn #1; #2; #3#4#5#6#7#8; +\cs_new:Npn \@@_fixed_mul_add:wwwn #1\@@_sep: #2\@@_sep: #3#4#5#6#7#8\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_big_leading_shift_int \exp_after:wN \@@_pack_big:NNNNNNw \int_value:w \@@_int_eval:w \c_@@_big_middle_shift_int + #3 #4 \@@_fixed_mul_add:Nwnnnwnnn + - + #5 #6 ; #2 ; #1 ; #2 ; + - + #7 #8 ; ; + + #5 #6 \@@_sep: #2 \@@_sep: #1 \@@_sep: #2 \@@_sep: + + + #7 #8 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_fixed_mul_sub_back:wwwn #1; #2; #3#4#5#6#7#8; +\cs_new:Npn \@@_fixed_mul_sub_back:wwwn + #1\@@_sep: #2\@@_sep: #3#4#5#6#7#8\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_big_leading_shift_int \exp_after:wN \@@_pack_big:NNNNNNw \int_value:w \@@_int_eval:w \c_@@_big_middle_shift_int + #3 #4 \@@_fixed_mul_add:Nwnnnwnnn - - + #5 #6 ; #2 ; #1 ; #2 ; - - + #7 #8 ; ; + + #5 #6 \@@_sep: #2 \@@_sep: #1 \@@_sep: #2 \@@_sep: - + + #7 #8 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_fixed_one_minus_mul:wwn #1; #2; +\cs_new:Npn \@@_fixed_one_minus_mul:wwn #1\@@_sep: #2\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_big_leading_shift_int @@ -515,17 +519,17 @@ \int_value:w \@@_int_eval:w \c_@@_big_middle_shift_int + 1 0000 0000 \@@_fixed_mul_add:Nwnnnwnnn - - ; #2 ; #1 ; #2 ; - - ; ; + \@@_sep: #2 \@@_sep: #1 \@@_sep: #2 \@@_sep: - + \@@_sep: \@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_fixed_mul_add:Nwnnnwnnn} % \begin{syntax} -% \cs{@@_fixed_mul_add:Nwnnnwnnn} \meta{op} |+| \meta{c_3} \meta{c_4} |;| -% ~~\meta{b} |;| \meta{a} |;| \meta{b} |;| \meta{op} -% ~~|+| \meta{c_5} \meta{c_6} |;| +% \cs{@@_fixed_mul_add:Nwnnnwnnn} \meta{op} |+| \meta{c_3} \meta{c_4} \cs{@@_sep:} +% ~~\meta{b} \cs{@@_sep:} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{op} +% ~~|+| \meta{c_5} \meta{c_6} \cs{@@_sep:} % \end{syntax} % Here, \meta{op} is either |+| or |-|. Arguments |#3|, |#4|, |#5| % are \meta{b_1}, \meta{b_2}, \meta{b_3}; arguments |#7|, |#8|, |#9| @@ -539,7 +543,7 @@ % we've read, but not \meta{b}, since there is another copy later in % the input stream. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:Nwnnnwnnn #1 #2; #3#4#5#6; #7#8#9 +\cs_new:Npn \@@_fixed_mul_add:Nwnnnwnnn #1 #2\@@_sep: #3#4#5#6\@@_sep: #7#8#9 { #1 #7*#3 \exp_after:wN \@@_pack_big:NNNNNNw @@ -557,8 +561,8 @@ % % \begin{macro}[EXP]{\@@_fixed_mul_add:nnnnwnnnn} % \begin{syntax} -% \cs{@@_fixed_mul_add:nnnnwnnnn} \meta{a} |;| \meta{b} |;| \meta{op} -% ~~|+| \meta{c_5} \meta{c_6} |;| +% \cs{@@_fixed_mul_add:nnnnwnnnn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{op} +% ~~|+| \meta{c_5} \meta{c_6} \cs{@@_sep:} % \end{syntax} % Level $10^{-20}$ is $(a_{1} \cdot b_{4} + a_{2} \cdot b_{3} + a_{3} % \cdot b_{2} + a_{4} \cdot b_{1})$, multiplied by the sign, which was @@ -577,7 +581,7 @@ % To do all this, we keep $a_{1}$, $a_{5}$, $a_{6}$, and the % corresponding pieces of \meta{b}. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:nnnnwnnnn #1#2#3#4#5; #6#7#8#9 +\cs_new:Npn \@@_fixed_mul_add:nnnnwnnnn #1#2#3#4#5\@@_sep: #6#7#8#9 { ( #1*#9 + #2*#8 + #3*#7 + #4*#6 ) \exp_after:wN \@@_pack_big:NNNNNNw @@ -585,7 +589,7 @@ \@@_fixed_mul_add:nnnnwnnwN { #6 + #4*#7 + #3*#8 + #2*#9 + #1 } { #7 + #4*#8 + #3*#9 + #2 } - {#1} #5; + {#1} #5\@@_sep: {#6} } % \end{macrocode} @@ -594,8 +598,8 @@ % \begin{macro}[EXP]{\@@_fixed_mul_add:nnnnwnnwN} % \begin{syntax} % \cs{@@_fixed_mul_add:nnnnwnnwN} \Arg{partial_1} \Arg{partial_2} -% ~~\Arg{a_1} \Arg{a_5} \Arg{a_6} |;| \Arg{b_1} \Arg{b_5} \Arg{b_6} |;| -% ~~\meta{op} |+| \meta{c_5} \meta{c_6} |;| +% ~~\Arg{a_1} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} \Arg{b_1} \Arg{b_5} \Arg{b_6} \cs{@@_sep:} +% ~~\meta{op} |+| \meta{c_5} \meta{c_6} \cs{@@_sep:} % \end{syntax} % Complete the \meta{partial_1} and \meta{partial_2} expressions as % explained for the \texttt{ii} auxiliary. The second one is divided @@ -607,7 +611,7 @@ % expected by the packing auxiliaries. See \pkg{l3fp-aux} for the % definition of the shifts and packing auxiliaries. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:nnnnwnnwN #1#2 #3#4#5; #6#7#8; #9 +\cs_new:Npn \@@_fixed_mul_add:nnnnwnnwN #1#2 #3#4#5\@@_sep: #6#7#8\@@_sep: #9 { #9 (#4* #1 *#7) #9 (#5*#6+#4* #2 *#7+#3*#8) / \c_@@_myriad_int @@ -637,21 +641,22 @@ \cs_new:Npn \@@_ep_to_fixed:wwn #1,#2 { \exp_after:wN \@@_ep_to_fixed_auxi:www - \int_value:w \@@_int_eval:w 1 0000 0000 + #2 \exp_after:wN ; + \int_value:w \@@_int_eval:w 1 0000 0000 + #2 \exp_after:wN \@@_sep: \exp:w \exp_end_continue_f:w - \prg_replicate:nn { 4 - \int_max:nn {#1} { -32 } } { 0 } ; + \prg_replicate:nn { 4 - \int_max:nn {#1} { -32 } } { 0 } \@@_sep: } -\cs_new:Npn \@@_ep_to_fixed_auxi:www 1#1; #2; #3#4#5#6#7; +\cs_new:Npn \@@_ep_to_fixed_auxi:www + 1#1\@@_sep: #2\@@_sep: #3#4#5#6#7\@@_sep: { \@@_pack_eight:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN - \@@_ep_to_fixed_auxii:nnnnnnnwn ; + \@@_ep_to_fixed_auxii:nnnnnnnwn \@@_sep: #2 #1#3#4#5#6#7 0000 ! } -\cs_new:Npn \@@_ep_to_fixed_auxii:nnnnnnnwn #1#2#3#4#5#6#7; #8! #9 - { #9 {#1#2}{#3}{#4}{#5}{#6}{#7}; } +\cs_new:Npn \@@_ep_to_fixed_auxii:nnnnnnnwn #1#2#3#4#5#6#7\@@_sep: #8! #9 + { #9 {#1#2}{#3}{#4}{#5}{#6}{#7}\@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} @@ -675,14 +680,14 @@ % any digit that did not make it in the final mantissa (typically only % zeros, unless the original first block has more than~$4$ digits). % \begin{macrocode} -\cs_new:Npn \@@_ep_to_ep:wwN #1,#2#3#4#5#6#7; #8 +\cs_new:Npn \@@_ep_to_ep:wwN #1,#2#3#4#5#6#7\@@_sep: #8 { \exp_after:wN #8 \int_value:w \@@_int_eval:w #1 + 4 \exp_after:wN \use_i:nn \exp_after:wN \@@_ep_to_ep_loop:N \int_value:w \@@_int_eval:w 1 0000 0000 + #2 \@@_int_eval_end: - #3#4#5#6#7 ; ; ! + #3#4#5#6#7 \@@_sep: \@@_sep: ! } \cs_new:Npn \@@_ep_to_ep_loop:N #1 { @@ -694,21 +699,21 @@ \@@_ep_to_ep_loop:N } \cs_new:Npn \@@_ep_to_ep_end:www - #1 \fi: \@@_ep_to_ep_loop:N #2; #3! + #1 \fi: \@@_ep_to_ep_loop:N #2\@@_sep: #3! { \fi: - \if_meaning:w ; #1 + \if_meaning:w \@@_sep: #1 - 2 * \c_@@_max_exponent_int \@@_ep_to_ep_zero:ww \fi: \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN - \@@_use_i:ww , ; - #1 #2 0000 0000 0000 0000 0000 0000 ; + \@@_use_i:ww , \@@_sep: + #1 #2 0000 0000 0000 0000 0000 0000 \@@_sep: } -\cs_new:Npn \@@_ep_to_ep_zero:ww \fi: #1; #2; #3; - { \fi: , {1000}{0000}{0000}{0000}{0000}{0000} ; } +\cs_new:Npn \@@_ep_to_ep_zero:ww \fi: #1\@@_sep: #2\@@_sep: #3\@@_sep: + { \fi: , {1000}{0000}{0000}{0000}{0000}{0000} \@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} @@ -723,12 +728,14 @@ % works if the numbers are normalized so that their first block is % in~$[1000,9999]$. % \begin{macrocode} -\cs_new:Npn \@@_ep_compare:wwww #1,#2#3#4#5#6#7; - { \@@_ep_compare_aux:wwww {#1}{#2}{#3}{#4}{#5}; #6#7; } -\cs_new:Npn \@@_ep_compare_aux:wwww #1;#2;#3,#4#5#6#7#8#9; +\cs_new:Npn \@@_ep_compare:wwww #1,#2#3#4#5#6#7\@@_sep: + { \@@_ep_compare_aux:wwww {#1}{#2}{#3}{#4}{#5}\@@_sep: #6#7\@@_sep: } +\cs_new:Npn \@@_ep_compare_aux:wwww + #1\@@_sep:#2\@@_sep:#3,#4#5#6#7#8#9\@@_sep: { \if_case:w - \@@_compare_npos:nwnw #1; {#3}{#4}{#5}{#6}{#7}; \exp_stop_f: + \@@_compare_npos:nwnw + #1\@@_sep: {#3}{#4}{#5}{#6}{#7}\@@_sep: \exp_stop_f: \if_int_compare:w #2 = #8#9 \exp_stop_f: 0 \else: @@ -749,19 +756,19 @@ % and~|#4| as fixed point numbers, and sum the exponents |#1| % and~|#3|. The result's first block is in $[100,9999]$. % \begin{macrocode} -\cs_new:Npn \@@_ep_mul:wwwwn #1,#2; #3,#4; +\cs_new:Npn \@@_ep_mul:wwwwn #1,#2\@@_sep: #3,#4\@@_sep: { - \@@_ep_to_ep:wwN #3,#4; + \@@_ep_to_ep:wwN #3,#4\@@_sep: \@@_fixed_continue:wn { - \@@_ep_to_ep:wwN #1,#2; + \@@_ep_to_ep:wwN #1,#2\@@_sep: \@@_ep_mul_raw:wwwwN } \@@_fixed_continue:wn } -\cs_new:Npn \@@_ep_mul_raw:wwwwN #1,#2; #3,#4; #5 +\cs_new:Npn \@@_ep_mul_raw:wwwwN #1,#2\@@_sep: #3,#4\@@_sep: #5 { - \@@_fixed_mul:wwn #2; #4; + \@@_fixed_mul:wwn #2\@@_sep: #4\@@_sep: { \exp_after:wN #5 \int_value:w \@@_int_eval:w #1 + #3 , } } % \end{macrocode} @@ -901,12 +908,12 @@ % \meta{denominator} \meta{numerator}, responsible for estimating the % inverse of the denominator. % \begin{macrocode} -\cs_new:Npn \@@_ep_div:wwwwn #1,#2; #3,#4; +\cs_new:Npn \@@_ep_div:wwwwn #1,#2\@@_sep: #3,#4\@@_sep: { - \@@_ep_to_ep:wwN #1,#2; + \@@_ep_to_ep:wwN #1,#2\@@_sep: \@@_fixed_continue:wn { - \@@_ep_to_ep:wwN #3,#4; + \@@_ep_to_ep:wwN #3,#4\@@_sep: \@@_ep_div_esti:wwwwn } } @@ -935,24 +942,25 @@ % $10^{-9}a/(1-\epsilon)$, that is, $1/(10\meta{d})$ and we finally % multiply this by the numerator~|#8|. % \begin{macrocode} -\cs_new:Npn \@@_ep_div_esti:wwwwn #1,#2#3; #4, +\cs_new:Npn \@@_ep_div_esti:wwwwn #1,#2#3\@@_sep: #4, { \exp_after:wN \@@_ep_div_estii:wwnnwwn \int_value:w \@@_int_eval:w 10 0000 0000 / ( #2 + 1 ) - \exp_after:wN ; + \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w #4 - #1 + 1 , - {#2} #3; + {#2} #3\@@_sep: } -\cs_new:Npn \@@_ep_div_estii:wwnnwwn #1; #2,#3#4#5; #6; #7 +\cs_new:Npn \@@_ep_div_estii:wwnnwwn + #1\@@_sep: #2,#3#4#5\@@_sep: #6\@@_sep: #7 { \exp_after:wN \@@_ep_div_estiii:NNNNNwwwn \int_value:w \@@_int_eval:w 10 0000 0000 - 1750 - + #1 000 + (10 0000 0000 / #3 - #1) * (1000 - #4 / 10) ; - {#3}{#4}#5; #6; { #7 #2, } + + #1 000 + (10 0000 0000 / #3 - #1) * (1000 - #4 / 10) \@@_sep: + {#3}{#4}#5\@@_sep: #6\@@_sep: { #7 #2, } } -\cs_new:Npn \@@_ep_div_estiii:NNNNNwwwn 1#1#2#3#4#5#6; #7; +\cs_new:Npn \@@_ep_div_estiii:NNNNNwwwn 1#1#2#3#4#5#6\@@_sep: #7\@@_sep: { - \@@_fixed_mul_short:wwn #7; {#1}{#2#3#4#5}{#6}; + \@@_fixed_mul_short:wwn #7\@@_sep: {#1}{#2#3#4#5}{#6}\@@_sep: \@@_ep_div_epsi:wnNNNNNn {#1#2#3#4}#5#6 \@@_fixed_mul:wwn } @@ -978,28 +986,29 @@ % combination of \texttt{short_mul} and \texttt{div_myriad} is both % faster and more precise than a simple \texttt{mul}. % \begin{macrocode} -\cs_new:Npn \@@_ep_div_epsi:wnNNNNNn #1#2#3#4#5#6; +\cs_new:Npn \@@_ep_div_epsi:wnNNNNNn #1#2#3#4#5#6\@@_sep: { \exp_after:wN \@@_ep_div_epsii:wwnNNNNNn \int_value:w \@@_int_eval:w 1 9998 - #2 \exp_after:wN \@@_ep_div_eps_pack:NNNNNw \int_value:w \@@_int_eval:w 1 9999 9998 - #3#4 \exp_after:wN \@@_ep_div_eps_pack:NNNNNw - \int_value:w \@@_int_eval:w 2 0000 0000 - #5#6 ; ; + \int_value:w \@@_int_eval:w 2 0000 0000 - #5#6 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_ep_div_eps_pack:NNNNNw #1#2#3#4#5#6; - { + #1 ; {#2#3#4#5} {#6} } -\cs_new:Npn \@@_ep_div_epsii:wwnNNNNNn 1#1; #2; #3#4#5#6#7#8 +\cs_new:Npn \@@_ep_div_eps_pack:NNNNNw #1#2#3#4#5#6\@@_sep: + { + #1 \@@_sep: {#2#3#4#5} {#6} } +\cs_new:Npn \@@_ep_div_epsii:wwnNNNNNn 1#1\@@_sep: #2\@@_sep: #3#4#5#6#7#8 { - \@@_fixed_mul:wwn {0000}{#1}#2; {0000}{#1}#2; + \@@_fixed_mul:wwn {0000}{#1}#2\@@_sep: {0000}{#1}#2\@@_sep: \@@_fixed_add_one:wN - \@@_fixed_mul:wwn {10000} {#1} #2 ; + \@@_fixed_mul:wwn {10000} {#1} #2 \@@_sep: { - \@@_fixed_mul_short:wwn {0000}{#1}#2; {#3}{#4#5#6#7}{#8000}; + \@@_fixed_mul_short:wwn + {0000}{#1}#2\@@_sep: {#3}{#4#5#6#7}{#8000}\@@_sep: \@@_fixed_div_myriad:wn \@@_fixed_mul:wwn } - \@@_fixed_add:wwn {#3}{#4#5#6#7}{#8000}{0000}{0000}{0000}; + \@@_fixed_add:wwn {#3}{#4#5#6#7}{#8000}{0000}{0000}{0000}\@@_sep: } % \end{macrocode} % \end{macro} @@ -1047,9 +1056,9 @@ % mantissa and an altered continuation where we have stored the % result's exponent. % \begin{macrocode} -\cs_new:Npn \@@_ep_isqrt:wwn #1,#2; +\cs_new:Npn \@@_ep_isqrt:wwn #1,#2\@@_sep: { - \@@_ep_to_ep:wwN #1,#2; + \@@_ep_to_ep:wwN #1,#2\@@_sep: \@@_ep_isqrt_auxi:wwn } \cs_new:Npn \@@_ep_isqrt_auxi:wwn #1, @@ -1060,10 +1069,10 @@ { (1 - #1) / 2 , 535 , { 0 } { } } { 1 - #1 / 2 , 168 , { } { 0 } } } -\cs_new:Npn \@@_ep_isqrt_auxii:wwnnnwn #1, #2, #3#4 #5#6; #7 +\cs_new:Npn \@@_ep_isqrt_auxii:wwnnnwn #1, #2, #3#4 #5#6\@@_sep: #7 { \@@_ep_isqrt_esti:wwwnnwn #2, 0, #5, {#3} {#4} - {#5} #6 ; { #7 #1 , } + {#5} #6 \@@_sep: { #7 #1 , } } % \end{macrocode} % \end{macro} @@ -1106,13 +1115,14 @@ { \exp_after:wN \@@_ep_isqrt_estiii:NNNNNwwwn \int_value:w \@@_int_eval:w 1000 0000 + #2 * #2 #5 * 5 - \exp_after:wN , \int_value:w \@@_int_eval:w 10000 + #2 ; + \exp_after:wN , \int_value:w \@@_int_eval:w 10000 + #2 \@@_sep: } -\cs_new:Npn \@@_ep_isqrt_estiii:NNNNNwwwn 1#1#2#3#4#5#6, 1#7#8; #9; +\cs_new:Npn \@@_ep_isqrt_estiii:NNNNNwwwn + 1#1#2#3#4#5#6, 1#7#8\@@_sep: #9\@@_sep: { - \@@_fixed_mul_short:wwn #9; {#1} {#2#3#4#5} {#600} ; + \@@_fixed_mul_short:wwn #9\@@_sep: {#1} {#2#3#4#5} {#600} \@@_sep: \@@_ep_isqrt_epsi:wN - \@@_fixed_mul_short:wwn {#7} {#80} {0000} ; + \@@_fixed_mul_short:wwn {#7} {#80} {0000} \@@_sep: } % \end{macrocode} % \end{macro} @@ -1124,19 +1134,19 @@ % multiplications. The \texttt{epsii} auxiliary receives $z$ as~|#1| % and $y$ as~|#2|. % \begin{macrocode} -\cs_new:Npn \@@_ep_isqrt_epsi:wN #1; +\cs_new:Npn \@@_ep_isqrt_epsi:wN #1\@@_sep: { - \@@_fixed_sub:wwn {15000}{0000}{0000}{0000}{0000}{0000}; #1; - \@@_ep_isqrt_epsii:wwN #1; - \@@_ep_isqrt_epsii:wwN #1; - \@@_ep_isqrt_epsii:wwN #1; + \@@_fixed_sub:wwn {15000}{0000}{0000}{0000}{0000}{0000}\@@_sep: #1\@@_sep: + \@@_ep_isqrt_epsii:wwN #1\@@_sep: + \@@_ep_isqrt_epsii:wwN #1\@@_sep: + \@@_ep_isqrt_epsii:wwN #1\@@_sep: } -\cs_new:Npn \@@_ep_isqrt_epsii:wwN #1; #2; +\cs_new:Npn \@@_ep_isqrt_epsii:wwN #1\@@_sep: #2\@@_sep: { - \@@_fixed_mul:wwn #1; #1; - \@@_fixed_mul_sub_back:wwwn #2; - {15000}{0000}{0000}{0000}{0000}{0000}; - \@@_fixed_mul:wwn #1; + \@@_fixed_mul:wwn #1\@@_sep: #1\@@_sep: + \@@_fixed_mul_sub_back:wwwn #2\@@_sep: + {15000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + \@@_fixed_mul:wwn #1\@@_sep: } % \end{macrocode} % \end{macro} @@ -1156,9 +1166,10 @@ % \begin{macrocode} \cs_new:Npn \@@_ep_to_float_o:wwN #1, { + \@@_int_eval:w #1 \@@_fixed_to_float_o:wN } -\cs_new:Npn \@@_ep_inv_to_float_o:wwN #1,#2; +\cs_new:Npn \@@_ep_inv_to_float_o:wwN #1,#2\@@_sep: { - \@@_ep_div:wwwwn 1,{1000}{0000}{0000}{0000}{0000}{0000}; #1,#2; + \@@_ep_div:wwwwn + 1,{1000}{0000}{0000}{0000}{0000}{0000}\@@_sep: #1,#2\@@_sep: \@@_ep_to_float_o:wwN } % \end{macrocode} @@ -1178,9 +1189,9 @@ % a floating point number. This could perhaps remain in % \pkg{l3fp-trig}. % \begin{macrocode} -\cs_new:Npn \@@_fixed_to_float_rad_o:wN #1; +\cs_new:Npn \@@_fixed_to_float_rad_o:wN #1\@@_sep: { - \@@_fixed_mul:wwn #1; {5729}{5779}{5130}{8232}{0876}{7981}; + \@@_fixed_mul:wwn #1\@@_sep: {5729}{5779}{5130}{8232}{0876}{7981}\@@_sep: { \@@_ep_to_float_o:wwN 2, } } % \end{macrocode} @@ -1190,11 +1201,11 @@ % \begin{macro}[rEXP] % {\@@_fixed_to_float_o:wN, \@@_fixed_to_float_o:Nw} % \begin{syntax} -% \ldots{} \cs{@@_int_eval:w} \meta{exponent} \cs{@@_fixed_to_float_o:wN} \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} |;| \meta{sign} +% \ldots{} \cs{@@_int_eval:w} \meta{exponent} \cs{@@_fixed_to_float_o:wN} \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} \meta{sign} % \end{syntax} % yields % \begin{quote} -% \meta{exponent'} |;| \Arg{a'_1} \Arg{a'_2} \Arg{a'_3} \Arg{a'_4} |;| +% \meta{exponent'} \cs{@@_sep:} \Arg{a'_1} \Arg{a'_2} \Arg{a'_3} \Arg{a'_4} \cs{@@_sep:} % \end{quote} % And the \texttt{to_fixed} version gives six brace groups instead of % $4$, ensuring that $1000\leq\meta{a'_1}\leq 9999$. At this stage, we @@ -1204,9 +1215,9 @@ % %^^A todo: round properly when rounding to infinity: I need the sign. % \begin{macrocode} -\cs_new:Npn \@@_fixed_to_float_o:Nw #1#2; - { \@@_fixed_to_float_o:wN #2; #1 } -\cs_new:Npn \@@_fixed_to_float_o:wN #1#2#3#4#5#6; #7 +\cs_new:Npn \@@_fixed_to_float_o:Nw #1#2\@@_sep: + { \@@_fixed_to_float_o:wN #2\@@_sep: #1 } +\cs_new:Npn \@@_fixed_to_float_o:wN #1#2#3#4#5#6\@@_sep: #7 { % for the 8-digit-at-the-start thing + \@@_int_eval:w \c_@@_block_int \exp_after:wN \exp_after:wN @@ -1217,8 +1228,8 @@ \int_value:w 1#2 \exp_after:wN \@@_use_none_stop_f:n \int_value:w 1#3#4 \exp_after:wN \@@_use_none_stop_f:n \int_value:w 1#5#6 - \exp_after:wN ; - \exp_after:wN ; + \exp_after:wN \@@_sep: + \exp_after:wN \@@_sep: } \cs_new:Npn \@@_fixed_to_loop:N #1 { @@ -1230,36 +1241,36 @@ \exp_after:wN #1 \fi: } -\cs_new:Npn \@@_fixed_to_loop_end:w #1 #2 ; +\cs_new:Npn \@@_fixed_to_loop_end:w #1 #2 \@@_sep: { - \if_meaning:w ; #1 + \if_meaning:w \@@_sep: #1 \exp_after:wN \@@_fixed_to_float_zero:w \else: \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_fixed_to_float_pack:ww - \exp_after:wN ; + \exp_after:wN \@@_sep: \fi: - #1 #2 0000 0000 0000 0000 ; + #1 #2 0000 0000 0000 0000 \@@_sep: } -\cs_new:Npn \@@_fixed_to_float_zero:w ; 0000 0000 0000 0000 ; +\cs_new:Npn \@@_fixed_to_float_zero:w \@@_sep: 0000 0000 0000 0000 \@@_sep: { - - 2 * \c_@@_max_exponent_int ; - {0000} {0000} {0000} {0000} ; + - 2 * \c_@@_max_exponent_int \@@_sep: + {0000} {0000} {0000} {0000} \@@_sep: } -\cs_new:Npn \@@_fixed_to_float_pack:ww #1 ; #2#3 ; ; +\cs_new:Npn \@@_fixed_to_float_pack:ww #1 \@@_sep: #2#3 \@@_sep: \@@_sep: { \if_int_compare:w #2 > 4 \exp_stop_f: \exp_after:wN \@@_fixed_to_float_round_up:wnnnnw \fi: - ; #1 ; + \@@_sep: #1 \@@_sep: } -\cs_new:Npn \@@_fixed_to_float_round_up:wnnnnw ; #1#2#3#4 ; +\cs_new:Npn \@@_fixed_to_float_round_up:wnnnnw \@@_sep: #1#2#3#4 \@@_sep: { \exp_after:wN \@@_basics_pack_high:NNNNNw \int_value:w \@@_int_eval:w 1 #1#2 \exp_after:wN \@@_basics_pack_low:NNNNNw - \int_value:w \@@_int_eval:w 1 #3#4 + 1 ; + \int_value:w \@@_int_eval:w 1 #3#4 + 1 \@@_sep: } % \end{macrocode} % \end{macro} diff --git a/macros/latex/required/l3kernel/l3fp-functions.dtx b/macros/latex/required/l3kernel/l3fp-functions.dtx index b9e269b988..2413838ca7 100644 --- a/macros/latex/required/l3kernel/l3fp-functions.dtx +++ b/macros/latex/required/l3kernel/l3fp-functions.dtx @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -138,7 +138,7 @@ \@@_exp_after_array_f:w #2 \s_@@_expr_stop \exp_after:wN } - \exp_after:wN ; + \exp_after:wN \@@_sep: } } % \end{macrocode} @@ -191,7 +191,7 @@ \exp_not:N \@@_symbolic_chk:w \exp_not:N \@@_function_arg_o:w \int_use:N \l_@@_function_arg_int - ########1 , { } ; + ########1 , { } \@@_sep: } } \cs_set:Npn \@@_function_arg_o:w ##1 @ @@ -203,7 +203,7 @@ \@@_exp_after_symbolic_loop:N ##1 { , \tex_romannumeral:D \use_none:nn } \exp_after:wN \c_zero_int - \exp_after:wN { \exp_after:wN } \exp_after:wN ; + \exp_after:wN { \exp_after:wN } \exp_after:wN \@@_sep: } \fp_set:Nn \l_@@_symbolic_fp {#4} \use:e @@ -250,9 +250,9 @@ #2 } \cs_new:Npn \@@_function_arg_few:w #1 @ { \exp_after:wN \c_nan_fp } -\cs_new:Npn \@@_function_arg_get:w #1#2#3; #4 @ +\cs_new:Npn \@@_function_arg_get:w #1#2#3\@@_sep: #4 @ { - \@@_exp_after_array_f:w #3; \s_@@_expr_stop + \@@_exp_after_array_f:w #3\@@_sep: \s_@@_expr_stop \exp_after:wN \exp_stop_f: } % \end{macrocode} diff --git a/macros/latex/required/l3kernel/l3fp-logic.dtx b/macros/latex/required/l3kernel/l3fp-logic.dtx index 486a3bc579..29b149498b 100644 --- a/macros/latex/required/l3kernel/l3fp-logic.dtx +++ b/macros/latex/required/l3kernel/l3fp-logic.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-logic.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -75,8 +75,8 @@ % \subsection{Syntax of internal functions} % % \begin{itemize} -% \item \cs{@@_compare_npos:nwnw} \Arg{expo_1} \meta{body_1} |;| -% \Arg{expo_2} \meta{body_2} |;| +% \item \cs{@@_compare_npos:nwnw} \Arg{expo_1} \meta{body_1} \cs{@@_sep:} +% \Arg{expo_2} \meta{body_2} \cs{@@_sep:} % \item \cs{@@_minmax_o:Nw} \meta{sign} \meta{floating point array} % \item \cs{@@_not_o:w} |?| \meta{floating point array} (with one floating point number only) % \item \cs{@@_&_o:ww} \meta{floating point} \meta{floating point} @@ -123,7 +123,7 @@ \exp_after:wN \@@_compare_return:w \exp:w \exp_end_continue_f:w \@@_parse:n {#1} } -\cs_new:Npn \@@_compare_return:w #1#2#3; +\cs_new:Npn \@@_compare_return:w #1#2#3\@@_sep: { \if_charcode:w 0 \@@_if_type_fp:NTwFw @@ -156,10 +156,10 @@ \prg_return_false: \fi: } -\cs_new:Npn \@@_compare_aux:wn #1; #2 +\cs_new:Npn \@@_compare_aux:wn #1\@@_sep: #2 { \exp_after:wN \@@_compare_back_any:ww - \exp:w \exp_end_continue_f:w \@@_parse:n {#2} #1; + \exp:w \exp_end_continue_f:w \@@_parse:n {#2} #1\@@_sep: } % \end{macrocode} % \end{macro} @@ -167,7 +167,7 @@ % % \begin{macro}[EXP]{\@@_compare_back:ww, \@@_bcmp:ww, \@@_compare_back_any:ww, \@@_compare_nan:w} % \begin{quote} -% \cs{@@_compare_back_any:ww} \meta{y} |;| \meta{x} |;| +% \cs{@@_compare_back_any:ww} \meta{y} \cs{@@_sep:} \meta{x} \cs{@@_sep:} % \end{quote} % Expands (in the same way as \cs{int_eval:n}) to $-1$ if $x<y$, $0$ % if $x=y$, $1$ if $x>y$, and $2$ otherwise (denoted as $x?y$). If @@ -180,7 +180,7 @@ % a different type, the highest type is a larger number. Finally, if % $y\leq 0$, then $x>y$, unless both are zero. % \begin{macrocode} -\cs_new:Npn \@@_compare_back:ww #1#2; #3#4; +\cs_new:Npn \@@_compare_back:ww #1#2\@@_sep: #3#4\@@_sep: { \cs:w @@ @@ -189,9 +189,9 @@ \@@_type_from_scan:N #3 :ww \cs_end: - #1#2; #3#4; + #1#2\@@_sep: #3#4\@@_sep: } -\cs_new:Npn \@@_compare_back_any:ww #1#2; #3 +\cs_new:Npn \@@_compare_back_any:ww #1#2\@@_sep: #3 { \@@_if_type_fp:NTwFw #1 { \@@_if_type_fp:NTwFw #3 \use_i:nn \s_@@ \use_ii:nn \s_@@_stop } @@ -206,11 +206,11 @@ :ww \cs_end: } - #1#2 ; #3 + #1#2 \@@_sep: #3 } \cs_new:Npn \@@_bcmp:ww - \s_@@ \@@_chk:w #1 #2 #3; - \s_@@ \@@_chk:w #4 #5 #6; + \s_@@ \@@_chk:w #1 #2 #3\@@_sep: + \s_@@ \@@_chk:w #4 #5 #6\@@_sep: { \int_value:w \if_meaning:w 3 #1 \exp_after:wN \@@_compare_nan:w \fi: @@ -219,7 +219,7 @@ \if_meaning:w #2 #5 \if_meaning:w #1 #4 \if_meaning:w 1 #1 - \@@_compare_npos:nwnw #6; #3; + \@@_compare_npos:nwnw #6\@@_sep: #3\@@_sep: \else: 0 \fi: @@ -247,30 +247,30 @@ % and if any don't match return~$2$ (as \cs{int_value:w} |02| % \cs{exp_stop_f:}). % \begin{macrocode} -\cs_new:Npn \@@_compare_back_tuple:ww #1; #2; { 2 } -\cs_new:Npn \@@_tuple_compare_back:ww #1; #2; { 2 } +\cs_new:Npn \@@_compare_back_tuple:ww #1\@@_sep: #2\@@_sep: { 2 } +\cs_new:Npn \@@_tuple_compare_back:ww #1\@@_sep: #2\@@_sep: { 2 } \cs_new:Npn \@@_tuple_compare_back_tuple:ww - \s_@@_tuple \@@_tuple_chk:w #1; - \s_@@_tuple \@@_tuple_chk:w #2; + \s_@@_tuple \@@_tuple_chk:w #1\@@_sep: + \s_@@_tuple \@@_tuple_chk:w #2\@@_sep: { \int_compare:nNnTF { \@@_array_count:n {#1} } = { \@@_array_count:n {#2} } { \int_value:w 0 \@@_tuple_compare_back_loop:w - #1 { \s_@@ \prg_break: } ; @ - #2 { \s_@@ \prg_break: } ; + #1 { \s_@@ \prg_break: } \@@_sep: @ + #2 { \s_@@ \prg_break: } \@@_sep: \prg_break_point: \exp_stop_f: } { 2 } } -\cs_new:Npn \@@_tuple_compare_back_loop:w #1#2 ; #3 @ #4#5 ; +\cs_new:Npn \@@_tuple_compare_back_loop:w #1#2 \@@_sep: #3 @ #4#5 \@@_sep: { \use_none:n #1 \use_none:n #4 \if_int_compare:w - \@@_compare_back_any:ww #1 #2 ; #4 #5 ; = \c_zero_int + \@@_compare_back_any:ww #1 #2 \@@_sep: #4 #5 \@@_sep: = \c_zero_int \else: 2 \exp_after:wN \prg_break: \fi: @@ -284,8 +284,8 @@ % \begin{macro}[EXP]{\@@_compare_significand:nnnnnnnn} % \begin{quote} % \cs{@@_compare_npos:nwnw} -% \Arg{expo_1} \meta{body_1} |;| -% \Arg{expo_2} \meta{body_2} |;| +% \Arg{expo_1} \meta{body_1} \cs{@@_sep:} +% \Arg{expo_2} \meta{body_2} \cs{@@_sep:} % \end{quote} % Within an \cs{int_value:w} \ldots{} \cs{exp_stop_f:} construction, % this expands to $0$ if the two numbers are equal, $-1$ if the first @@ -296,7 +296,7 @@ % first $8$ digits coincide, the next $8$ decide. Otherwise, the % first $8$ digits are compared. % \begin{macrocode} -\cs_new:Npn \@@_compare_npos:nwnw #1#2; #3#4; +\cs_new:Npn \@@_compare_npos:nwnw #1#2\@@_sep: #3#4\@@_sep: { \if_int_compare:w #1 = #3 \exp_stop_f: \@@_compare_significand:nnnnnnnn #2 #4 @@ -427,20 +427,22 @@ % progress. Conversion to decimal is done just before calling the % user's function. % \begin{macrocode} -\cs_new:Npn \@@_step:wwwN #1#2; #3#4; #5#6; #7 +\cs_new:Npn \@@_step:wwwN #1#2\@@_sep: #3#4\@@_sep: #5#6\@@_sep: #7 { \@@_if_type_fp:NTwFw #1 { } \s_@@ \prg_break: \s_@@_stop \@@_if_type_fp:NTwFw #3 { } \s_@@ \prg_break: \s_@@_stop \@@_if_type_fp:NTwFw #5 { } \s_@@ \prg_break: \s_@@_stop - \use_i:nnnn { \@@_step_fp:wwwN #1#2; #3#4; #5#6; #7 } + \use_i:nnnn + { \@@_step_fp:wwwN #1#2\@@_sep: #3#4\@@_sep: #5#6\@@_sep: #7 } \prg_break_point: \use:n { - \@@_error:nfff { step-tuple } { \fp_to_tl:n { #1#2 ; } } - { \fp_to_tl:n { #3#4 ; } } { \fp_to_tl:n { #5#6 ; } } + \@@_error:nfff { step-tuple } { \fp_to_tl:n { #1#2 \@@_sep: } } + { \fp_to_tl:n { #3#4 \@@_sep: } } { \fp_to_tl:n { #5#6 \@@_sep: } } } } -\cs_new:Npn \@@_step_fp:wwwN #1 ; \s_@@ \@@_chk:w #2#3#4 ; #5; #6 +\cs_new:Npn \@@_step_fp:wwwN + #1 \@@_sep: \s_@@ \@@_chk:w #2#3#4 \@@_sep: #5\@@_sep: #6 { \token_if_eq_meaning:NNTF #2 1 { @@ -456,11 +458,15 @@ } { \@@_error:nnfn { bad-step } { } - { \fp_to_tl:n { \s_@@ \@@_chk:w #2#3#4 ; } } {#6} + { \fp_to_tl:n { \s_@@ \@@_chk:w #2#3#4 \@@_sep: } } {#6} } \use_none:nnnnn } - { #1 ; } { \c_nan_fp } { \s_@@ \@@_chk:w #2#3#4 ; } { #5 ; } #6 + { #1 \@@_sep: } + { \c_nan_fp } + { \s_@@ \@@_chk:w #2#3#4 \@@_sep: } + { #5 \@@_sep: } + #6 } \cs_new:Npn \@@_step:NnnnnN #1#2#3#4#5#6 { @@ -556,8 +562,8 @@ \exp_after:wN \@@_minmax_loop:Nww \exp_after:wN - \fi: #2 - \s_@@ \@@_chk:w 2 #1 \s_@@_exact ; - \s_@@ \@@_chk:w { 3 \@@_minmax_break_o:w } ; + \s_@@ \@@_chk:w 2 #1 \s_@@_exact \@@_sep: + \s_@@ \@@_chk:w { 3 \@@_minmax_break_o:w } \@@_sep: } % \end{macrocode} % \end{macro} @@ -574,7 +580,7 @@ % maximum; otherwise we keep the first number. Then loop. % \begin{macrocode} \cs_new:Npn \@@_minmax_loop:Nww - #1 \s_@@ \@@_chk:w #2#3; \s_@@ \@@_chk:w #4#5; + #1 \s_@@ \@@_chk:w #2#3\@@_sep: \s_@@ \@@_chk:w #4#5\@@_sep: { \if_meaning:w 3 #4 \if_meaning:w 3 #2 @@ -585,8 +591,8 @@ \else: \if_int_compare:w \@@_compare_back:ww - \s_@@ \@@_chk:w #4#5; - \s_@@ \@@_chk:w #2#3; + \s_@@ \@@_chk:w #4#5\@@_sep: + \s_@@ \@@_chk:w #2#3\@@_sep: = #1 1 \exp_stop_f: \@@_minmax_auxii:ww \else: @@ -594,8 +600,8 @@ \fi: \fi: \@@_minmax_loop:Nww #1 - \s_@@ \@@_chk:w #2#3; - \s_@@ \@@_chk:w #4#5; + \s_@@ \@@_chk:w #2#3\@@_sep: + \s_@@ \@@_chk:w #4#5\@@_sep: } % \end{macrocode} % \end{macro} @@ -603,9 +609,10 @@ % \begin{macro}[EXP]{\@@_minmax_auxi:ww, \@@_minmax_auxii:ww} % Keep the first/second number, and remove the other. % \begin{macrocode} -\cs_new:Npn \@@_minmax_auxi:ww #1 \fi: \fi: #2 \s_@@ #3 ; \s_@@ #4; - { \fi: \fi: #2 \s_@@ #3 ; } -\cs_new:Npn \@@_minmax_auxii:ww #1 \fi: \fi: #2 \s_@@ #3 ; +\cs_new:Npn \@@_minmax_auxi:ww + #1 \fi: \fi: #2 \s_@@ #3 \@@_sep: \s_@@ #4\@@_sep: + { \fi: \fi: #2 \s_@@ #3 \@@_sep: } +\cs_new:Npn \@@_minmax_auxii:ww #1 \fi: \fi: #2 \s_@@ #3 \@@_sep: { \fi: \fi: #2 } % \end{macrocode} % \end{macro} @@ -615,8 +622,8 @@ % to the end of the tests, close the current test with \cs{fi:}, clean % up, and return the appropriate number with one post-expansion. % \begin{macrocode} -\cs_new:Npn \@@_minmax_break_o:w #1 \fi: \fi: #2 \s_@@ #3; #4; - { \fi: \@@_exp_after_o:w \s_@@ #3; } +\cs_new:Npn \@@_minmax_break_o:w #1 \fi: \fi: #2 \s_@@ #3\@@_sep: #4\@@_sep: + { \fi: \@@_exp_after_o:w \s_@@ #3\@@_sep: } % \end{macrocode} % \end{macro} % @@ -627,7 +634,7 @@ % exit the conditional, and one to please \pkg{l3fp-parse}. The first % argument is provided by \pkg{l3fp-parse} and is ignored. % \begin{macrocode} -\cs_new:Npn \@@_not_o:w #1 \s_@@ \@@_chk:w #2#3; @ +\cs_new:Npn \@@_not_o:w #1 \s_@@ \@@_chk:w #2#3\@@_sep: @ { \if_meaning:w 0 #2 \exp_after:wN \exp_after:wN \exp_after:wN \c_one_fp @@ -652,30 +659,31 @@ \group_begin: \char_set_catcode_letter:N & \char_set_catcode_letter:N | - \cs_new:Npn \@@_&_o:ww #1 \s_@@ \@@_chk:w #2#3; + \cs_new:Npn \@@_&_o:ww #1 \s_@@ \@@_chk:w #2#3\@@_sep: { \if_meaning:w 0 #2 #1 - \@@_and_return:wNw \s_@@ \@@_chk:w #2#3; + \@@_and_return:wNw \s_@@ \@@_chk:w #2#3\@@_sep: \fi: \@@_exp_after_o:w } - \cs_new:Npn \@@_&_tuple_o:ww #1 \s_@@ \@@_chk:w #2#3; + \cs_new:Npn \@@_&_tuple_o:ww #1 \s_@@ \@@_chk:w #2#3\@@_sep: { \if_meaning:w 0 #2 #1 - \@@_and_return:wNw \s_@@ \@@_chk:w #2#3; + \@@_and_return:wNw \s_@@ \@@_chk:w #2#3\@@_sep: \fi: \@@_exp_after_tuple_o:w } - \cs_new:Npn \@@_tuple_&_o:ww #1; { \@@_exp_after_o:w } - \cs_new:Npn \@@_tuple_&_tuple_o:ww #1; { \@@_exp_after_tuple_o:w } + \cs_new:Npn \@@_tuple_&_o:ww #1\@@_sep: { \@@_exp_after_o:w } + \cs_new:Npn \@@_tuple_&_tuple_o:ww #1\@@_sep: { \@@_exp_after_tuple_o:w } \cs_new:Npn \@@_|_o:ww { \@@_&_o:ww \else: } \cs_new:Npn \@@_|_tuple_o:ww { \@@_&_tuple_o:ww \else: } - \cs_new:Npn \@@_tuple_|_o:ww #1; #2; { \@@_exp_after_tuple_o:w #1; } - \cs_new:Npn \@@_tuple_|_tuple_o:ww #1; #2; - { \@@_exp_after_tuple_o:w #1; } + \cs_new:Npn \@@_tuple_|_o:ww #1\@@_sep: #2\@@_sep: + { \@@_exp_after_tuple_o:w #1\@@_sep: } + \cs_new:Npn \@@_tuple_|_tuple_o:ww #1\@@_sep: #2\@@_sep: + { \@@_exp_after_tuple_o:w #1\@@_sep: } \group_end: -\cs_new:Npn \@@_and_return:wNw #1; \fi: #2; - { \fi: \@@_exp_after_o:w #1; } +\cs_new:Npn \@@_and_return:wNw #1\@@_sep: \fi: #2\@@_sep: + { \fi: \@@_exp_after_o:w #1\@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} diff --git a/macros/latex/required/l3kernel/l3fp-parse.dtx b/macros/latex/required/l3kernel/l3fp-parse.dtx index 7853c40132..b7fb52e7fd 100644 --- a/macros/latex/required/l3kernel/l3fp-parse.dtx +++ b/macros/latex/required/l3kernel/l3fp-parse.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-parse.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -71,7 +71,7 @@ % % In this file at least, a \meta{floating point object} is a floating % point number or tuple. This can be extended to anything that starts -% with \cs{s_@@} or \cs{s_@@_\meta{type}} and ends with |;| with some +% with \cs{s_@@} or \cs{s_@@_\meta{type}} and ends with \cs{@@_sep:} with some % internal structure that depends on the \meta{type}. % % \begin{macro}[EXP]{\@@_parse:n} @@ -215,12 +215,12 @@ % |\add:ww| 12345 ; 333444 ; % \end{syntax} % which can safely perform the addition by grabbing two arguments -% delimited by~|;|. +% delimited by~\cs{@@_sep:}. % % If we were to continue parsing the expression, then the following % number should also be cleaned up before the next use of a binary % operation such as |\add:ww|. Just like \cs{int_value:w} |12345| -% \cs{exp_after:wN}~|;| expanded what follows once, we need |\add:ww| +% \cs{exp_after:wN}~\cs{@@_sep:} expanded what follows once, we need |\add:ww| % to do the calculation, and in the process to expand the following % once. This is also true in our real application: all the functions of % the form \cs[no-index]{@@_\ldots_o:ww} expand what follows once. This comes at the @@ -643,7 +643,7 @@ % expansion. That turns out to be useful. % \begin{macrocode} \cs_new:Npn \@@_parse_return_semicolon:w - #1 \fi: \@@_parse_expand:w { \fi: ; #1 } + #1 \fi: \@@_parse_expand:w { \fi: \@@_sep: #1 } % \end{macrocode} % \end{macro} % @@ -665,7 +665,7 @@ % stream, until meeting a non-digit, or up to a number of digits equal % to their index. The full expansion is % \begin{syntax} -% \meta{digits} |;| \meta{filling 0} |;| \meta{length} +% \meta{digits} \cs{@@_sep:} \meta{filling 0} \cs{@@_sep:} \meta{length} % \end{syntax} % where \meta{filling 0} is a string of zeros such that \meta{digits} % \meta{filling 0} has the length given by the index of the function, @@ -687,14 +687,14 @@ \@@_parse_expand:w } } -\@@_tmp:w {vii} \@@_parse_digits_vi:N { 0000000 ; 7 } -\@@_tmp:w {vi} \@@_parse_digits_v:N { 000000 ; 6 } -\@@_tmp:w {v} \@@_parse_digits_iv:N { 00000 ; 5 } -\@@_tmp:w {iv} \@@_parse_digits_iii:N { 0000 ; 4 } -\@@_tmp:w {iii} \@@_parse_digits_ii:N { 000 ; 3 } -\@@_tmp:w {ii} \@@_parse_digits_i:N { 00 ; 2 } -\@@_tmp:w {i} \@@_parse_digits_:N { 0 ; 1 } -\cs_new:Npn \@@_parse_digits_:N { ; ; 0 } +\@@_tmp:w {vii} \@@_parse_digits_vi:N { 0000000 \@@_sep: 7 } +\@@_tmp:w {vi} \@@_parse_digits_v:N { 000000 \@@_sep: 6 } +\@@_tmp:w {v} \@@_parse_digits_iv:N { 00000 \@@_sep: 5 } +\@@_tmp:w {iv} \@@_parse_digits_iii:N { 0000 \@@_sep: 4 } +\@@_tmp:w {iii} \@@_parse_digits_ii:N { 000 \@@_sep: 3 } +\@@_tmp:w {ii} \@@_parse_digits_i:N { 00 \@@_sep: 2 } +\@@_tmp:w {i} \@@_parse_digits_:N { 0 \@@_sep: 1 } +\cs_new:Npn \@@_parse_digits_:N { \@@_sep: \@@_sep: 0 } % \end{macrocode} % \end{macro} % @@ -874,26 +874,26 @@ \exp_after:wN \@@_parse_one_register_auxii:wwwNw } \exp_not:N \exp_after:wN { \exp_not:N \tex_the:D #1 } - ; \exp_not:N \@@_parse_one_register_dim:ww - \tl_to_str:n { pt } ; \exp_not:N \@@_parse_one_register_mu:www - . \tl_to_str:n { pt } ; \exp_not:N \@@_parse_one_register_int:www + \@@_sep: \exp_not:N \@@_parse_one_register_dim:ww + \tl_to_str:n { pt } \@@_sep: \exp_not:N \@@_parse_one_register_mu:www + . \tl_to_str:n { pt } \@@_sep: \exp_not:N \@@_parse_one_register_int:www \s_@@_stop } \exp_args:Nno \use:nn { \cs_new:Npn \@@_parse_one_register_auxii:wwwNw #1 . #2 } - { \tl_to_str:n { pt } #3 ; #4#5 \s_@@_stop } - { #4 #1.#2; } + { \tl_to_str:n { pt } #3 \@@_sep: #4#5 \s_@@_stop } + { #4 #1.#2\@@_sep: } \exp_args:Nno \use:nn { \cs_new:Npn \@@_parse_one_register_mu:www #1 } - { \tl_to_str:n { mu } ; #2 ; } - { \@@_parse_one_register_dim:ww #1 ; } -\cs_new:Npn \@@_parse_one_register_int:www #1; #2.; #3; + { \tl_to_str:n { mu } \@@_sep: #2 \@@_sep: } + { \@@_parse_one_register_dim:ww #1 \@@_sep: } +\cs_new:Npn \@@_parse_one_register_int:www #1\@@_sep: #2.\@@_sep: #3\@@_sep: { \@@_parse:n { #1 e #3 } } -\cs_new:Npn \@@_parse_one_register_dim:ww #1; #2; +\cs_new:Npn \@@_parse_one_register_dim:ww #1\@@_sep: #2\@@_sep: { \exp_after:wN \@@_from_dim_test:ww \int_value:w #2 \exp_after:wN , - \int_value:w \dim_to_decimal_in_sp:n { #1 pt } ; + \int_value:w \dim_to_decimal_in_sp:n { #1 pt } \@@_sep: } % \end{macrocode} % \end{macro} @@ -942,11 +942,11 @@ \exp_after:wN \@@_parse_one_register_wd:Nw #4 \@@_parse_expand:w e } -\cs_new:Npn \@@_parse_one_register_wd:Nw #1#2 ; +\cs_new:Npn \@@_parse_one_register_wd:Nw #1#2 \@@_sep: { \exp_after:wN \@@_from_dim_test:ww \exp_after:wN 0 \exp_after:wN , - \int_value:w \dim_to_decimal_in_sp:n { #1 #2 } ; + \int_value:w \dim_to_decimal_in_sp:n { #1 #2 } \@@_sep: } % \end{macrocode} % \end{macro} @@ -1020,7 +1020,7 @@ % mixture of lower and upper case, so we test and use a % differently-named control sequence. % \begin{macrocode} -\cs_new:Npn \@@_parse_word:Nw #1#2; +\cs_new:Npn \@@_parse_word:Nw #1#2\@@_sep: { \cs_if_exist_use:cF { @@_parse_word_#2:N } { @@ -1184,7 +1184,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_zero: { - \exp_after:wN ; \exp_after:wN 1 + \exp_after:wN \@@_sep: \exp_after:wN 1 \int_value:w \@@_parse_exponent:N } % \end{macrocode} @@ -1220,7 +1220,7 @@ % % \begin{macro}[rEXP]{\@@_parse_small_leading:wwNN} % \begin{syntax} -% \cs{@@_parse_small_leading:wwNN} |1| \meta{digits} |;| \meta{zeros} |;| \meta{number~of~zeros} +% \cs{@@_parse_small_leading:wwNN} |1| \meta{digits} \cs{@@_sep:} \meta{zeros} \cs{@@_sep:} \meta{number~of~zeros} % \end{syntax} % We leave \meta{digits} \meta{zeros} in the input stream: the % functions used to grab digits are such that this constitutes digits @@ -1232,7 +1232,7 @@ % Otherwise put $8$~zeros in to complete the significand, then look % for an exponent. % \begin{macrocode} -\cs_new:Npn \@@_parse_small_leading:wwNN 1 #1 ; #2; #3 #4 +\cs_new:Npn \@@_parse_small_leading:wwNN 1 #1 \@@_sep: #2\@@_sep: #3 #4 { #1 #2 \exp_after:wN \@@_parse_pack_trailing:NNNNNNww @@ -1254,7 +1254,7 @@ % % \begin{macro}[rEXP]{\@@_parse_small_trailing:wwNN} % \begin{syntax} -% \cs{@@_parse_small_trailing:wwNN} |1| \meta{digits} |;| \meta{zeros} |;| \meta{number~of~zeros} \meta{next~token} +% \cs{@@_parse_small_trailing:wwNN} |1| \meta{digits} \cs{@@_sep:} \meta{zeros} \cs{@@_sep:} \meta{number~of~zeros} \meta{next~token} % \end{syntax} % Leave digits $10$ to~$15$ (arguments |#1| and |#2|) in the input % stream. If the \meta{next~token} is a digit, it is the $16$th @@ -1264,7 +1264,7 @@ % Otherwise, there is no $16$-th digit, so we put a~$0$, and look for % an exponent. % \begin{macrocode} -\cs_new:Npn \@@_parse_small_trailing:wwNN 1 #1 ; #2; #3 #4 +\cs_new:Npn \@@_parse_small_trailing:wwNN 1 #1 \@@_sep: #2\@@_sep: #3 #4 { #1 #2 \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f: @@ -1301,19 +1301,20 @@ % this is simple because such a carry can only occur to give rise to a % power of~$10$. % \begin{macrocode} -\cs_new:Npn \@@_parse_pack_trailing:NNNNNNww #1 #2 #3#4#5#6 #7; #8 ; +\cs_new:Npn \@@_parse_pack_trailing:NNNNNNww + #1 #2 #3#4#5#6 #7\@@_sep: #8 \@@_sep: { \if_meaning:w 2 #2 + 1 \fi: - ; #8 + #1 ; {#3#4#5#6} {#7}; + \@@_sep: #8 + #1 \@@_sep: {#3#4#5#6} {#7}\@@_sep: } -\cs_new:Npn \@@_parse_pack_leading:NNNNNww #1 #2#3#4#5 #6; #7; +\cs_new:Npn \@@_parse_pack_leading:NNNNNww #1 #2#3#4#5 #6\@@_sep: #7\@@_sep: { + #7 \if_meaning:w 2 #1 \@@_parse_pack_carry:w \fi: - ; 0 {#2#3#4#5} {#6} + \@@_sep: 0 {#2#3#4#5} {#6} } -\cs_new:Npn \@@_parse_pack_carry:w \fi: ; 0 #1 - { \fi: + 1 ; 0 {1000} } +\cs_new:Npn \@@_parse_pack_carry:w \fi: \@@_sep: 0 #1 + { \fi: + 1 \@@_sep: 0 {1000} } % \end{macrocode} % \end{macro} % @@ -1344,7 +1345,7 @@ % % \begin{macro}[rEXP]{\@@_parse_large_leading:wwNN} % \begin{syntax} -% \cs{@@_parse_large_leading:wwNN} |1| \meta{digits} |;| \meta{zeros} |;| \meta{number~of~zeros} \meta{next~token} +% \cs{@@_parse_large_leading:wwNN} |1| \meta{digits} \cs{@@_sep:} \meta{zeros} \cs{@@_sep:} \meta{number~of~zeros} \meta{next~token} % \end{syntax} % We shift the exponent by the number of digits in~|#1|, namely the % target number, $8$, minus the \meta{number of zeros} (number of @@ -1357,7 +1358,7 @@ % complete the $8$~first digits, insert $8$~more, and look for an % exponent. % \begin{macrocode} -\cs_new:Npn \@@_parse_large_leading:wwNN 1 #1 ; #2; #3 #4 +\cs_new:Npn \@@_parse_large_leading:wwNN 1 #1 \@@_sep: #2\@@_sep: #3 #4 { + \c_@@_half_prec_int - #3 \exp_after:wN \@@_parse_pack_leading:NNNNNww @@ -1392,7 +1393,7 @@ % % \begin{macro}[EXP]{\@@_parse_large_trailing:wwNN} % \begin{syntax} -% \cs{@@_parse_large_trailing:wwNN} |1| \meta{digits} |;| \meta{zeros} |;| \meta{number~of~zeros} \meta{next~token} +% \cs{@@_parse_large_trailing:wwNN} |1| \meta{digits} \cs{@@_sep:} \meta{zeros} \cs{@@_sep:} \meta{number~of~zeros} \meta{next~token} % \end{syntax} % We have just read $15$~digits. If the \meta{next token} is a digit, % then the exponent shift caused by this block of $8$~digits is~$8$, @@ -1408,7 +1409,7 @@ % for an exponent after using the \meta{zeros} and providing a $16$-th % digit of~$0$. % \begin{macrocode} -\cs_new:Npn \@@_parse_large_trailing:wwNN 1 #1 ; #2; #3 #4 +\cs_new:Npn \@@_parse_large_trailing:wwNN 1 #1 \@@_sep: #2\@@_sep: #3 #4 { \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f: \exp_after:wN \@@_parse_pack_trailing:NNNNNNww @@ -1488,9 +1489,9 @@ % time, the result |0| or |1| is added to the % surrounding integer expression. % \begin{macrocode} -\cs_new:Npn \@@_parse_round_after:wN #1; #2 +\cs_new:Npn \@@_parse_round_after:wN #1\@@_sep: #2 { - + #2 \exp_after:wN ; + + #2 \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w #1 + \@@_parse_exponent:N } % \end{macrocode} @@ -1500,8 +1501,8 @@ % {\@@_parse_small_round:NN, \@@_parse_round_after:wN} % Here, |#1|~is the digit that we are currently rounding (we only care % whether it is even or odd). If |#2|~is not a digit, then fetch an -% exponent and expand to |;|\meta{exponent} only. Otherwise, we -% expand to |+0| or |+1|, then |;|\meta{exponent}. To +% exponent and expand to \cs{@@_sep:}\meta{exponent} only. Otherwise, we +% expand to |+0| or |+1|, then \cs{@@_sep:}\meta{exponent}. To % decide which, call \cs{@@_round_s:NNNw} to know whether to round up, % giving it as arguments a sign~$0$ (all explicit numbers are % positive), the digit |#1|~to round, the first following digit~|#2|, @@ -1581,7 +1582,7 @@ \fi: \@@_parse_expand:w } -\cs_new:Npn \@@_parse_large_round_aux:wNN #1 ; #2 #3 +\cs_new:Npn \@@_parse_large_round_aux:wNN #1 \@@_sep: #2 #3 { + #2 \exp_after:wN \@@_parse_round_after:wN @@ -1591,7 +1592,7 @@ \exp_after:wN \@@_parse_round_loop:N \exp:w \exp_after:wN \@@_parse_expand:w \else: - \exp_after:wN ; + \exp_after:wN \@@_sep: \exp_after:wN 0 \exp_after:wN #3 \fi: @@ -1618,7 +1619,7 @@ % two tokens ahead completely would break the third example (unpacking % is even worse). Indeed, in the course of reading $3.2$, \cs{c_pi_fp} % is expanded to \cs{s_@@} \cs{@@_chk:w} |1| |0| |{-1}| |{3141}| -% $\cdots$ |;| and \cs{s_@@} stops the expansion. Expanding two tokens +% $\cdots$ \cs{@@_sep:} and \cs{s_@@} stops the expansion. Expanding two tokens % ahead would then force the expansion of \cs{@@_chk:w} (despite it % being protected), and that function tries to produce an error. % @@ -1636,7 +1637,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_exponent:Nw #1 #2 \@@_parse_expand:w { - \exp_after:wN ; + \exp_after:wN \@@_sep: \int_value:w #2 \@@_parse_exponent:N #1 } % \end{macrocode} @@ -1669,7 +1670,7 @@ { \if_int_compare:w \if_catcode:w \scan_stop: \exp_not:N #2 0 \else: `#2 \fi: > `9 \exp_stop_f: - 0 \exp_after:wN ; \exp_after:wN #1 + 0 \exp_after:wN \@@_sep: \exp_after:wN #1 \else: \exp_after:wN \@@_parse_exponent_sign:N \fi: @@ -1708,7 +1709,7 @@ \@@_parse_exponent_keep:NTF #1 { \@@_parse_return_semicolon:w #1 } { - \exp_after:wN ; + \exp_after:wN \@@_sep: \exp:w } \fi: @@ -1820,7 +1821,7 @@ % \begin{macro}[EXP]{\@@_parse_apply_unary_type:NNN, \@@_parse_apply_unary_error:NNw} % In contrast to \cs{@@_parse_apply_function:NNNwN}, this checks that % the operand |#4| is a single argument (namely there is a single -% |;|). We use the fact that any floating point starts with a +% \cs{@@_sep:}). We use the fact that any floating point starts with a % \enquote{safe} token like \cs{s_@@}. If there is no argument % produce the |fp-no-arg| error; if there are at least two produce % |fp-multi-arg|. For the error message extract the mathematical @@ -1834,12 +1835,12 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_apply_unary:NNNwN #1#2#3#4@#5 { - \@@_parse_apply_unary_chk:NwNw #4 @ ; . \s_@@_stop + \@@_parse_apply_unary_chk:NwNw #4 @ \@@_sep: . \s_@@_stop \@@_parse_apply_unary_type:NNN #3 #2 #4 @ \exp:w \exp_end_continue_f:w #5 #1 } -\cs_new:Npn \@@_parse_apply_unary_chk:NwNw #1#2 ; #3#4 \s_@@_stop +\cs_new:Npn \@@_parse_apply_unary_chk:NwNw #1#2 \@@_sep: #3#4 \s_@@_stop { \if_meaning:w @ #3 \else: \token_if_eq_meaning:NNTF . #3 @@ -2043,7 +2044,7 @@ \cs_new:cpn { @@_parse_word_#1:N } { \@@_exp_after_f:nw { \@@_parse_infix:NN } - \s_@@ \@@_chk:w 10 #2 ; + \s_@@ \@@_chk:w 10 #2 \@@_sep: } } \@@_tmp:w {pt} { {1} {1000} {0000} {0000} {0000} } @@ -2070,7 +2071,7 @@ { \exp_after:wN \@@_from_dim_test:ww \exp_after:wN 0 \exp_after:wN , - \int_value:w \dim_to_decimal_in_sp:n { 1 #1 } \exp_after:wN ; + \int_value:w \dim_to_decimal_in_sp:n { 1 #1 } \exp_after:wN \@@_sep: \exp:w \exp_end_continue_f:w \@@_parse_infix:NN } } @@ -2220,7 +2221,7 @@ % according to their types, and expands once after the result. % The |rev| version swaps its arguments before doing this. % \begin{macrocode} -\cs_new:Npn \@@_binary_type_o:Nww #1 #2#3 ; #4 +\cs_new:Npn \@@_binary_type_o:Nww #1 #2#3 \@@_sep: #4 { \exp_after:wN \@@_parse_apply_binary_chk:NN \cs:w @@ -2231,9 +2232,9 @@ _o:ww \cs_end: #1 - #2 #3 ; #4 + #2 #3 \@@_sep: #4 } -\cs_new:Npn \@@_binary_rev_type_o:Nww #1 #2#3 ; #4#5 ; +\cs_new:Npn \@@_binary_rev_type_o:Nww #1 #2#3 \@@_sep: #4#5 \@@_sep: { \exp_after:wN \@@_parse_apply_binary_chk:NN \cs:w @@ -2244,7 +2245,7 @@ _o:ww \cs_end: #1 - #4 #5 ; #2 #3 ; + #4 #5 \@@_sep: #2 #3 \@@_sep: } % \end{macrocode} % \end{macro} @@ -2253,10 +2254,10 @@ % % \begin{macro}[EXP]{\@@_parse_infix_after_operand:NwN} % \begin{macrocode} -\cs_new:Npn \@@_parse_infix_after_operand:NwN #1 #2; +\cs_new:Npn \@@_parse_infix_after_operand:NwN #1 #2\@@_sep: { \@@_exp_after_f:nw { \@@_parse_infix:NN #1 } - #2; + #2\@@_sep: } \cs_new:Npn \@@_parse_infix:NN #1 #2 { @@ -2430,7 +2431,7 @@ \exp_after:wN #1 \exp:w \exp_end_continue_f:w \@@_exp_after_tuple_f:nw { } - \s_@@_tuple \@@_tuple_chk:w { #2 #4 } ; + \s_@@_tuple \@@_tuple_chk:w { #2 #4 } \@@_sep: #5 #1 } % \end{macrocode} @@ -2688,14 +2689,14 @@ \fi: #1 #8 #9 } -\cs_new:Npn \@@_parse_apply_compare_aux:NNwN #1 #2 #3; #4 +\cs_new:Npn \@@_parse_apply_compare_aux:NNwN #1 #2 #3\@@_sep: #4 { \if_meaning:w \@@_parse_compare:NNNNNNN #4 \exp_after:wN \@@_parse_continue_compare:NNwNN \exp_after:wN #1 \exp_after:wN #2 \exp:w \exp_end_continue_f:w - \@@_exp_after_o:w #3; + \@@_exp_after_o:w #3\@@_sep: \exp:w \exp_end_continue_f:w \else: \exp_after:wN \@@_parse_continue:NwN @@ -2725,7 +2726,7 @@ { \@@_error:nffn { bad-args } {#1} - { \fp_to_tl:n { \s_@@_tuple \@@_tuple_chk:w {#3} ; } } + { \fp_to_tl:n { \s_@@_tuple \@@_tuple_chk:w {#3} \@@_sep: } } { } \exp_after:wN \c_nan_fp } @@ -2764,11 +2765,11 @@ { \@@_error:nffn { bad-args } {#2} - { \fp_to_tl:n { \s_@@_tuple \@@_tuple_chk:w {#4} ; } } + { \fp_to_tl:n { \s_@@_tuple \@@_tuple_chk:w {#4} \@@_sep: } } { } \exp_after:wN \c_nan_fp } -\cs_new:Npn \@@_parse_function_one_two_aux:nnw #1#2 #3; #4 +\cs_new:Npn \@@_parse_function_one_two_aux:nnw #1#2 #3\@@_sep: #4 { \@@_if_type_fp:NTwFw #4 { } @@ -2780,14 +2781,14 @@ \@@_parse_function_one_two_error_o:w } \s_@@_stop - \@@_parse_function_one_two_auxii:nnw {#1} {#2} #3; #4 + \@@_parse_function_one_two_auxii:nnw {#1} {#2} #3\@@_sep: #4 } -\cs_new:Npn \@@_parse_function_one_two_auxii:nnw #1#2#3; #4; #5 +\cs_new:Npn \@@_parse_function_one_two_auxii:nnw #1#2#3\@@_sep: #4\@@_sep: #5 { \if_meaning:w @ #5 \else: \exp_after:wN \@@_parse_function_one_two_error_o:w \fi: - \use_ii:nn {#1} { \use_none:n #2 } #3; #4; #5 + \use_ii:nn {#1} { \use_none:n #2 } #3\@@_sep: #4\@@_sep: #5 } % \end{macrocode} % \end{macro} @@ -2798,21 +2799,21 @@ % afterwards. The code |#1| should itself expand once after its % result. % \begin{macrocode} -\cs_new:Npn \@@_tuple_map_o:nw #1 \s_@@_tuple \@@_tuple_chk:w #2 ; +\cs_new:Npn \@@_tuple_map_o:nw #1 \s_@@_tuple \@@_tuple_chk:w #2 \@@_sep: { \exp_after:wN \s_@@_tuple \exp_after:wN \@@_tuple_chk:w \exp_after:wN { \exp:w \exp_end_continue_f:w \@@_tuple_map_loop_o:nw {#1} #2 - { \s_@@ \prg_break: } ; + { \s_@@ \prg_break: } \@@_sep: \prg_break_point: - \exp_after:wN } \exp_after:wN ; + \exp_after:wN } \exp_after:wN \@@_sep: } -\cs_new:Npn \@@_tuple_map_loop_o:nw #1#2#3 ; +\cs_new:Npn \@@_tuple_map_loop_o:nw #1#2#3 \@@_sep: { \use_none:n #2 - #1 #2 #3 ; + #1 #2 #3 \@@_sep: \exp:w \exp_end_continue_f:w \@@_tuple_map_loop_o:nw {#1} } @@ -2824,24 +2825,24 @@ % afterwards. % \begin{macrocode} \cs_new:Npn \@@_tuple_mapthread_o:nww #1 - \s_@@_tuple \@@_tuple_chk:w #2 ; - \s_@@_tuple \@@_tuple_chk:w #3 ; + \s_@@_tuple \@@_tuple_chk:w #2 \@@_sep: + \s_@@_tuple \@@_tuple_chk:w #3 \@@_sep: { \exp_after:wN \s_@@_tuple \exp_after:wN \@@_tuple_chk:w \exp_after:wN { \exp:w \exp_end_continue_f:w \@@_tuple_mapthread_loop_o:nw {#1} - #2 { \s_@@ \prg_break: } ; @ - #3 { \s_@@ \prg_break: } ; + #2 { \s_@@ \prg_break: } \@@_sep: @ + #3 { \s_@@ \prg_break: } \@@_sep: \prg_break_point: - \exp_after:wN } \exp_after:wN ; + \exp_after:wN } \exp_after:wN \@@_sep: } -\cs_new:Npn \@@_tuple_mapthread_loop_o:nw #1#2#3 ; #4 @ #5#6 ; +\cs_new:Npn \@@_tuple_mapthread_loop_o:nw #1#2#3 \@@_sep: #4 @ #5#6 \@@_sep: { \use_none:n #2 \use_none:n #5 - #1 #2 #3 ; #5 #6 ; + #1 #2 #3 \@@_sep: #5 #6 \@@_sep: \exp:w \exp_end_continue_f:w \@@_tuple_mapthread_loop_o:nw {#1} #4 @ } diff --git a/macros/latex/required/l3kernel/l3fp-random.dtx b/macros/latex/required/l3kernel/l3fp-random.dtx index ff999926ab..9ca2d3b3b2 100644 --- a/macros/latex/required/l3kernel/l3fp-random.dtx +++ b/macros/latex/required/l3kernel/l3fp-random.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-random.dtx % -% Copyright (C) 2016-2024 The LaTeX Project +% Copyright (C) 2016-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -266,13 +266,13 @@ % \begin{macro}[EXP] % {\@@_rand_myriads:n, \@@_rand_myriads_loop:w, \@@_rand_myriads_get:w} % Used as \cs{@@_rand_myriads:n} |{XXX}| with one letter |X| -% (specifically) per block of four digit we want; it expands to |;| +% (specifically) per block of four digit we want; it expands to \cs{@@_sep:} % followed by the requested number of brace groups, each containing % four (pseudo-random) digits. Digits are produced as a random number % in $[10000,19999]$ for the usual reason of preserving leading zeros. % \begin{macrocode} \cs_new:Npn \@@_rand_myriads:n #1 - { \@@_rand_myriads_loop:w #1 \prg_break: X \prg_break_point: ; } + { \@@_rand_myriads_loop:w #1 \prg_break: X \prg_break_point: \@@_sep: } \cs_new:Npn \@@_rand_myriads_loop:w #1 X { #1 @@ -281,7 +281,7 @@ \__kernel_randint:n { 10000 } \@@_rand_myriads_loop:w } -\cs_new:Npn \@@_rand_myriads_get:w 1 #1 ; { ; {#1} } +\cs_new:Npn \@@_rand_myriads_get:w 1 #1 \@@_sep: { \@@_sep: {#1} } % \end{macrocode} % \end{macro} % @@ -301,7 +301,7 @@ { \exp_after:wN \@@_rand_o:w \exp:w \exp_end_continue_f:w - \@@_rand_myriads:n { XXXX } { 0000 } { 0000 } ; 0 + \@@_rand_myriads:n { XXXX } { 0000 } { 0000 } \@@_sep: 0 } { \msg_expandable_error:nnnnn @@ -309,7 +309,7 @@ \exp_after:wN \c_nan_fp } } -\cs_new:Npn \@@_rand_o:w ; +\cs_new:Npn \@@_rand_o:w \@@_sep: { \exp_after:wN \@@_sanitize:Nw \exp_after:wN 0 @@ -360,41 +360,41 @@ { \@@_randint_default:w \@@_randint_o:w } } \cs_new:Npn \@@_randint_default:w #1 { \exp_after:wN #1 \c_one_fp } -\cs_new:Npn \@@_randint_badarg:w \s_@@ \@@_chk:w #1#2#3; +\cs_new:Npn \@@_randint_badarg:w \s_@@ \@@_chk:w #1#2#3\@@_sep: { - \@@_int:wTF \s_@@ \@@_chk:w #1#2#3; + \@@_int:wTF \s_@@ \@@_chk:w #1#2#3\@@_sep: { \if_meaning:w 1 #1 \if_int_compare:w - \@@_use_i_until_s:nw #3 ; > \c_@@_prec_int + \@@_use_i_until_s:nw #3 \@@_sep: > \c_@@_prec_int \c_one_int \fi: \fi: } { \c_one_int } } -\cs_new:Npn \@@_randint_o:w #1; #2; @ +\cs_new:Npn \@@_randint_o:w #1\@@_sep: #2\@@_sep: @ { \if_case:w - \@@_randint_badarg:w #1; - \@@_randint_badarg:w #2; - \if:w 1 \@@_compare_back:ww #2; #1; \c_one_int \fi: + \@@_randint_badarg:w #1\@@_sep: + \@@_randint_badarg:w #2\@@_sep: + \if:w 1 \@@_compare_back:ww #2\@@_sep: #1\@@_sep: \c_one_int \fi: \c_zero_int - \@@_randint_auxi_o:ww #1; #2; + \@@_randint_auxi_o:ww #1\@@_sep: #2\@@_sep: \or: \@@_invalid_operation_tl_o:ff - { randint } { \@@_array_to_clist:n { #1; #2; } } + { randint } { \@@_array_to_clist:n { #1\@@_sep: #2\@@_sep: } } \exp:w \fi: \exp_after:wN \exp_end: } -\cs_new:Npn \@@_randint_auxi_o:ww #1 ; #2 ; #3 \exp_end: +\cs_new:Npn \@@_randint_auxi_o:ww #1 \@@_sep: #2 \@@_sep: #3 \exp_end: { \fi: - \@@_randint_auxii:wn #2 ; - { \@@_randint_auxii:wn #1 ; \@@_randint_auxiii_o:ww } + \@@_randint_auxii:wn #2 \@@_sep: + { \@@_randint_auxii:wn #1 \@@_sep: \@@_randint_auxiii_o:ww } } -\cs_new:Npn \@@_randint_auxii:wn \s_@@ \@@_chk:w #1#2#3#4 ; +\cs_new:Npn \@@_randint_auxii:wn \s_@@ \@@_chk:w #1#2#3#4 \@@_sep: { \if_meaning:w 0 #1 \exp_after:wN \use_i:nn @@ -405,7 +405,7 @@ { \exp_after:wN \@@_ep_to_fixed:wwn \int_value:w \@@_int_eval:w - #3 - \c_@@_prec_int , #4 {0000} {0000} ; + #3 - \c_@@_prec_int , #4 {0000} {0000} \@@_sep: { \if_meaning:w 0 #2 \exp_after:wN \use_i:nnnn @@ -416,22 +416,22 @@ \@@_fixed_continue:wn } } -\cs_new:Npn \@@_randint_auxiii_o:ww #1 ; #2 ; +\cs_new:Npn \@@_randint_auxiii_o:ww #1 \@@_sep: #2 \@@_sep: { - \@@_fixed_add:wwn #2 ; - {0000} {0000} {0000} {0001} {0000} {0000} ; - \@@_fixed_sub:wwn #1 ; + \@@_fixed_add:wwn #2 \@@_sep: + {0000} {0000} {0000} {0001} {0000} {0000} \@@_sep: + \@@_fixed_sub:wwn #1 \@@_sep: { \exp_after:wN \use_i:nn \exp_after:wN \@@_fixed_mul_add:wwwn - \exp:w \exp_end_continue_f:w \@@_rand_myriads:n { XXXXXX } ; + \exp:w \exp_end_continue_f:w \@@_rand_myriads:n { XXXXXX } \@@_sep: } - #1 ; + #1 \@@_sep: \@@_randint_auxiv_o:ww - #2 ; - \@@_randint_auxv_o:w #1 ; @ + #2 \@@_sep: + \@@_randint_auxv_o:w #1 \@@_sep: @ } -\cs_new:Npn \@@_randint_auxiv_o:ww #1#2#3#4#5 ; #6#7#8#9 +\cs_new:Npn \@@_randint_auxiv_o:ww #1#2#3#4#5 \@@_sep: #6#7#8#9 { \if_int_compare:w \if_int_compare:w #1#2 > #6#7 \exp_stop_f: 1 \else: @@ -441,7 +441,7 @@ \fi: \@@_randint_auxv_o:w {#1}{#2}{#3}{#4}#5 } -\cs_new:Npn \@@_randint_auxv_o:w #1#2#3#4#5 ; #6 @ +\cs_new:Npn \@@_randint_auxv_o:w #1#2#3#4#5 \@@_sep: #6 @ { \exp_after:wN \@@_sanitize:Nw \int_value:w @@ -453,7 +453,7 @@ \exp_after:wN \@@_reverse_args:Nww \fi: \exp_after:wN \@@_fixed_sub:wwn \c_@@_one_fixed_tl - {#1} {#2} {#3} {#4} {0000} {0000} ; + {#1} {#2} {#3} {#4} {0000} {0000} \@@_sep: { \exp_after:wN \exp_stop_f: \int_value:w \@@_int_eval:w \c_@@_prec_int @@ -480,16 +480,16 @@ \int_eval:n { \exp_after:wN \@@_randint:ww - \int_value:w \int_eval:n {#1} \exp_after:wN ; - \int_value:w \int_eval:n {#2} ; + \int_value:w \int_eval:n {#1} \exp_after:wN \@@_sep: + \int_value:w \int_eval:n {#2} \@@_sep: } } -\cs_new:Npn \@@_randint:ww #1; #2; +\cs_new:Npn \@@_randint:ww #1\@@_sep: #2\@@_sep: { \if_int_compare:w #1 > #2 \exp_stop_f: \msg_expandable_error:nnnn { kernel } { randint-backward-range } {#1} {#2} - \@@_randint:ww #2; #1; + \@@_randint:ww #2\@@_sep: #1\@@_sep: \else: \if_int_compare:w \@@_int_eval:w #2 \if_int_compare:w #1 > \c_zero_int @@ -517,15 +517,15 @@ % } % Any $n\in[-2^{31}+1,2^{31}-1]$ is uniquely written as % $2^{14}n_1+n_2$ with $n_1\in[-2^{17},2^{17}-1]$ and -% $n_2\in[0,2^{14}-1]$. Calling \cs{@@_randint_split_o:Nw} $n$ |;| -% gives $n_1$|;| $n_2$|;| and expands the next token once. We do this +% $n_2\in[0,2^{14}-1]$. Calling \cs{@@_randint_split_o:Nw} $n$ \cs{@@_sep:} +% gives $n_1$\cs{@@_sep:} $n_2$\cs{@@_sep:} and expands the next token once. We do this % for two random numbers and apply \cs{@@_randint_split_o:Nw} twice to % fully decompose the range~$R$. One subtlety is that we compute % $R-2^{31}=\meta{max}-\meta{min}-(2^{31}-1)\in[-2^{31}+1,2^{31}-1]$ % rather than $R$ to avoid overflow. % -% Then we have \cs{@@_randint_wide_aux:w} \meta{X_1}|;|\meta{X_0}|;| -% \meta{Y_1}|;|\meta{Y_0}|;| \meta{R_2}|;|\meta{R_1}|;|\meta{R_0}|;.| +% Then we have \cs{@@_randint_wide_aux:w} \meta{X_1}\cs{@@_sep:}\meta{X_0}\cs{@@_sep:} +% \meta{Y_1}\cs{@@_sep:}\meta{Y_0}\cs{@@_sep:} \meta{R_2}\cs{@@_sep:}\meta{R_1}\cs{@@_sep:}\meta{R_0}|;.| % and we apply the algorithm described earlier. % \begin{macrocode} \cs_new:Npn \__kernel_randint:nn #1#2 @@ -534,46 +534,49 @@ \exp_after:wN \@@_randint_wide_aux:w \int_value:w \exp_after:wN \@@_randint_split_o:Nw - \tex_uniformdeviate:D 268435456 ; + \tex_uniformdeviate:D 268435456 \@@_sep: \int_value:w \exp_after:wN \@@_randint_split_o:Nw - \tex_uniformdeviate:D 268435456 ; + \tex_uniformdeviate:D 268435456 \@@_sep: \int_value:w \exp_after:wN \@@_randint_split_o:Nw \int_value:w \@@_int_eval:w 131072 + \exp_after:wN \@@_randint_split_o:Nw \int_value:w - \__kernel_int_add:nnn {#2} { -#1 } { -\c_max_int } ; + \__kernel_int_add:nnn {#2} { -#1 } { -\c_max_int } \@@_sep: . } -\cs_new:Npn \@@_randint_split_o:Nw #1#2 ; +\cs_new:Npn \@@_randint_split_o:Nw #1#2 \@@_sep: { \if_meaning:w 0 #1 - 0 \exp_after:wN ; \int_value:w 0 + 0 \exp_after:wN \@@_sep: \int_value:w 0 \else: \exp_after:wN \@@_randint_split_aux:w - \int_value:w \@@_int_eval:w (#1#2 - 8192) / 16384 ; + \int_value:w \@@_int_eval:w (#1#2 - 8192) / 16384 \@@_sep: + #1#2 \fi: - \exp_after:wN ; + \exp_after:wN \@@_sep: } -\cs_new:Npn \@@_randint_split_aux:w #1 ; +\cs_new:Npn \@@_randint_split_aux:w #1 \@@_sep: { - #1 \exp_after:wN ; + #1 \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w - #1 * 16384 } -\cs_new:Npn \@@_randint_wide_aux:w #1;#2; #3;#4; #5;#6;#7; . +\cs_new:Npn \@@_randint_wide_aux:w + #1\@@_sep:#2\@@_sep: #3\@@_sep:#4\@@_sep: + #5\@@_sep:#6\@@_sep:#7\@@_sep: . { \exp_after:wN \@@_randint_wide_auxii:w \int_value:w \@@_int_eval:w #5 * #3 + #6 * #1 + (#5 * #4 + #6 * #3 + #7 * #1 + (#5 * #2 + #7 * #3 + (16384 * #6 + #7) * (16384 * #4 + #2) / 268435456) / 16384 - ) / 16384 \exp_after:wN ; - \int_value:w \@@_int_eval:w (#5 + #6) * 16384 + #7 ; - #1 ; #5 ; + ) / 16384 \exp_after:wN \@@_sep: + \int_value:w \@@_int_eval:w (#5 + #6) * 16384 + #7 \@@_sep: + #1 \@@_sep: #5 \@@_sep: } -\cs_new:Npn \@@_randint_wide_auxii:w #1; #2; #3; #4; +\cs_new:Npn \@@_randint_wide_auxii:w + #1\@@_sep: #2\@@_sep: #3\@@_sep: #4\@@_sep: { \if_int_odd:w 0 \if_int_compare:w #1 = #2 \else: \exp_stop_f: \fi: @@ -606,7 +609,7 @@ \if_int_compare:w #1 < \c_one_int \msg_expandable_error:nnnn { kernel } { randint-backward-range } { 1 } {#1} - \@@_randint:ww #1; 1; + \@@_randint:ww #1\@@_sep: 1\@@_sep: \else: \if_int_compare:w #1 > \c__kernel_randint_max_int \__kernel_randint:nn { 1 } {#1} diff --git a/macros/latex/required/l3kernel/l3fp-round.dtx b/macros/latex/required/l3kernel/l3fp-round.dtx index 0d39b8a26a..695b43954c 100644 --- a/macros/latex/required/l3kernel/l3fp-round.dtx +++ b/macros/latex/required/l3kernel/l3fp-round.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-round.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -144,7 +144,7 @@ % \item \cs{@@_round:NNN} \meta{sign} \meta{digit_1} \meta{digit_2} % can expand to |0\exp_stop_f:| or |1\exp_stop_f:|. % \item \cs{@@_round_s:NNNw} \meta{sign} \meta{digit_1} \meta{digit_2} -% \meta{more digits}|;| can expand to |0\exp_stop_f:;| or |1\exp_stop_f:;|. +% \meta{more digits}\cs{@@_sep:} can expand to |0\exp_stop_f:;| or |1\exp_stop_f:;|. % \item \cs{@@_round_neg:NNN} \meta{sign} \meta{digit_1} \meta{digit_2} % can expand to |0\exp_stop_f:| or |1\exp_stop_f:|. % \end{itemize} @@ -267,7 +267,7 @@ % % \begin{macro}[EXP]{\@@_round_s:NNNw} % \begin{syntax} -% \cs{@@_round_s:NNNw} \meta{final sign} \meta{digit} \meta{more digits} |;| +% \cs{@@_round_s:NNNw} \meta{final sign} \meta{digit} \meta{more digits} \cs{@@_sep:} % \end{syntax} % Similar to \cs{@@_round:NNN}, but with an extra semicolon, this % function expands to |0\exp_stop_f:;| if rounding $\meta{final sign} @@ -277,7 +277,7 @@ % \cs{@@_int_eval:w} construction. The only relevant information about % this piece is whether it is zero or not. % \begin{macrocode} -\cs_new:Npn \@@_round_s:NNNw #1 #2 #3 #4; +\cs_new:Npn \@@_round_s:NNNw #1 #2 #3 #4\@@_sep: { \exp_after:wN \@@_round:NNN \exp_after:wN #1 @@ -291,14 +291,14 @@ \fi: \fi: #3 - ; + \@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_round_digit:Nw} % \begin{syntax} -% \cs{int_value:w} \cs{@@_round_digit:Nw} \meta{digit} \meta{int expr} |;| +% \cs{int_value:w} \cs{@@_round_digit:Nw} \meta{digit} \meta{int expr} \cs{@@_sep:} % \end{syntax} % This function should always be called within an \cs{int_value:w} % or \cs{@@_int_eval:w} expansion; it may add an extra @@ -306,7 +306,7 @@ % expression should not be ended with a synonym of \tn{relax}, but % with a semi-colon for instance. % \begin{macrocode} -\cs_new:Npn \@@_round_digit:Nw #1 #2; +\cs_new:Npn \@@_round_digit:Nw #1 #2\@@_sep: { \if_int_odd:w \if_meaning:w 0 #1 1 \else: \if_meaning:w 5 #1 1 \else: @@ -427,7 +427,8 @@ % \cs{@@_round_to_nearest_ninf:NNN}, \cs{@@_round_to_nearest_pinf:NNN} % and act accordingly. % \begin{macrocode} -\cs_new:Npn \@@_round:Nwww #1#2 ; #3 ; \s_@@ \@@_chk:w #4#5#6 ; #7 @ +\cs_new:Npn \@@_round:Nwww + #1#2 \@@_sep: #3 \@@_sep: \s_@@ \@@_chk:w #4#5#6 \@@_sep: #7 @ { \cs_if_eq:NNTF #1 \@@_round_to_nearest:NNN { @@ -440,7 +441,7 @@ \if_case:w #5 \exp_stop_f: _pinf \or: \else: _ninf \fi: \fi: :NNN } - #2 ; #3 ; + #2 \@@_sep: #3 \@@_sep: } { \@@_error:nnnn { num-args } { round () } { 1 } { 3 } @@ -488,11 +489,11 @@ % otherwise invalid as we have something like |round(1,3.14)| where % the number of digits is not an integer. % \begin{macrocode} -\cs_new:Npn \@@_round:Nww #1#2 ; #3 ; +\cs_new:Npn \@@_round:Nww #1#2 \@@_sep: #3 \@@_sep: { - \@@_small_int:wTF #3; { \@@_round:Nwn #1#2; } + \@@_small_int:wTF #3\@@_sep: { \@@_round:Nwn #1#2\@@_sep: } { - \if:w 3 \@@_kind:w #3 ; + \if:w 3 \@@_kind:w #3 \@@_sep: \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn @@ -501,11 +502,11 @@ { \@@_invalid_operation_tl_o:ff { \@@_round_name_from_cs:N #1 } - { \@@_array_to_clist:n { #2; #3; } } + { \@@_array_to_clist:n { #2\@@_sep: #3\@@_sep: } } } } } -\cs_new:Npn \@@_round:Nwn #1 \s_@@ \@@_chk:w #2#3#4; #5 +\cs_new:Npn \@@_round:Nwn #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: #5 { \if_meaning:w 1 #2 \exp_after:wN \@@_round_normal:NwNNnw @@ -514,14 +515,14 @@ \else: \exp_after:wN \@@_exp_after_o:w \fi: - \s_@@ \@@_chk:w #2#3#4; + \s_@@ \@@_chk:w #2#3#4\@@_sep: } -\cs_new:Npn \@@_round_normal:NwNNnw #1#2 \s_@@ \@@_chk:w 1#3#4#5; +\cs_new:Npn \@@_round_normal:NwNNnw #1#2 \s_@@ \@@_chk:w 1#3#4#5\@@_sep: { \@@_decimate:nNnnnn { \c_@@_prec_int - #4 - #2 } \@@_round_normal:NnnwNNnn #5 #1 #3 {#4} {#2} } -\cs_new:Npn \@@_round_normal:NnnwNNnn #1#2#3#4; #5#6 +\cs_new:Npn \@@_round_normal:NnnwNNnn #1#2#3#4\@@_sep: #5#6 { \exp_after:wN \@@_round_normal:NNwNnn \int_value:w \@@_int_eval:w @@ -539,7 +540,7 @@ \use_none:nnnnnnn #3 #1 \@@_int_eval_end: - 0000 0000 0000 0000 ; #6 + 0000 0000 0000 0000 \@@_sep: #6 } \cs_new:Npn \@@_round_pack:Nw #1 { \if_meaning:w 2 #1 + 1 \fi: \@@_int_eval_end: } @@ -552,14 +553,14 @@ \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_round_normal_end:wwNnn - ; #2 + \@@_sep: #2 } -\cs_new:Npn \@@_round_normal_end:wwNnn #1;#2;#3#4#5 +\cs_new:Npn \@@_round_normal_end:wwNnn #1\@@_sep:#2\@@_sep:#3#4#5 { \exp_after:wN \@@_exp_after_o:w \exp:w \exp_end_continue_f:w - \@@_sanitize:Nw #3 #4 ; #1 ; + \@@_sanitize:Nw #3 #4 \@@_sep: #1 \@@_sep: } -\cs_new:Npn \@@_round_special:NwwNnn #1#2;#3;#4#5#6 +\cs_new:Npn \@@_round_special:NwwNnn #1#2\@@_sep:#3\@@_sep:#4#5#6 { \if_meaning:w 0 #1 \@@_case_return:nw @@ -570,12 +571,12 @@ \int_value:w \@@_int_eval:w 1 \if_meaning:w 1 #1 -#6 \else: +#5 \fi: \fi: - ; + \@@_sep: } -\cs_new:Npn \@@_round_special_aux:Nw #1#2; +\cs_new:Npn \@@_round_special_aux:Nw #1#2\@@_sep: { \exp_after:wN \@@_exp_after_o:w \exp:w \exp_end_continue_f:w - \@@_sanitize:Nw #1#2; {1000}{0000}{0000}{0000}; + \@@_sanitize:Nw #1#2\@@_sep: {1000}{0000}{0000}{0000}\@@_sep: } % \end{macrocode} % \end{macro} diff --git a/macros/latex/required/l3kernel/l3fp-symbolic.dtx b/macros/latex/required/l3kernel/l3fp-symbolic.dtx index 88e214f49e..a9cb0ee95e 100644 --- a/macros/latex/required/l3kernel/l3fp-symbolic.dtx +++ b/macros/latex/required/l3kernel/l3fp-symbolic.dtx @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -75,14 +75,14 @@ % % Every symbolic expression has the form \cs{s_@@_symbolic} % \cs{@@_symbolic_chk:w} \meta{operation} |,| \Arg{operands} \meta{junk} -% |;| where the \meta{operation} is a list of \texttt{N}-type tokens, +% \cs{@@_sep:} where the \meta{operation} is a list of \texttt{N}-type tokens, % the \meta{operands} is an array of floating point objects, and the % \meta{junk} is to be discarded. If the outermost operator (last to be % evaluated) is unary, the expression has the form % \begin{quote} % \cs{s_@@_symbolic} \cs{@@_symbolic_chk:w} \\ % \cs{@@_types_unary:NNw} |\__fp_|\meta{op}|_o:w| \meta{token} |,| \\ -% |{| \meta{operand} |}| \meta{junk} |;| +% |{| \meta{operand} |}| \meta{junk} \cs{@@_sep:} % \end{quote} % where the \meta{op} is a unary operation (|set_sign|, |cos|, % \ldots{}), and the \meta{token} and \meta{operand} are used as @@ -92,7 +92,7 @@ % \begin{quote} % \cs{s_@@_symbolic} \cs{@@_symbolic_chk:w} \\ % \cs{@@_types_binary:Nww} |\__fp_|\meta{op}|_o:ww| |,| \\ -% |{| \meta{operand_1} \meta{operand_2} |}| \meta{junk} |;| +% |{| \meta{operand_1} \meta{operand_2} |}| \meta{junk} \cs{@@_sep:} % \end{quote} % where the \meta{op} is an operation (|+|, |&|, \ldots{}), and % |\__fp_|\meta{op}|_o:ww| receives the \meta{operands} as arguments. @@ -100,7 +100,7 @@ % \begin{quote} % \cs{s_@@_symbolic} \cs{@@_symbolic_chk:w} \\ % \cs{@@_variable_o:w} \meta{identifier} |,| \\ -% |{| |}| \meta{junk} |;| +% |{| |}| \meta{junk} \cs{@@_sep:} % \end{quote} % % Symbolic expressions are stored in a prefix form. When encountering a @@ -141,12 +141,12 @@ % \begin{macro}{\@@_symbolic_chk:w} % Analog of \cs{@@_chk:w} for symbolic expressions. % \begin{macrocode} -\cs_new_protected:Npn \@@_symbolic_chk:w #1,#2#3; +\cs_new_protected:Npn \@@_symbolic_chk:w #1,#2#3\@@_sep: { \msg_error:nne { fp } { misused-fp } { \@@_to_tl_dispatch:w - \s_@@_symbolic \@@_symbolic_chk:w #1,{#2}; + \s_@@_symbolic \@@_symbolic_chk:w #1,{#2}\@@_sep: } } % \end{macrocode} @@ -181,7 +181,7 @@ % evaluate all pieces of the expression which can be evaluated. % \begin{macrocode} \cs_new:Npn \@@_exp_after_symbolic_f:nw - #1 \s_@@_symbolic \@@_symbolic_chk:w #2, #3#4; + #1 \s_@@_symbolic \@@_symbolic_chk:w #2, #3#4\@@_sep: { \exp_after:wN \@@_exp_after_symbolic_aux:w \exp:w @@ -193,13 +193,13 @@ \@@_exp_after_array_f:w #3 \s_@@_expr_stop \exp_after:wN } - \exp_after:wN ; + \exp_after:wN \@@_sep: \exp:w \exp_end_continue_f:w #1 } -\cs_new:Npn \@@_exp_after_symbolic_aux:w #1, #2; +\cs_new:Npn \@@_exp_after_symbolic_aux:w #1, #2\@@_sep: { \@@_if_has_symbolic:nTF {#2} - { \s_@@_symbolic \@@_symbolic_chk:w #1, {#2} ; } + { \s_@@_symbolic \@@_symbolic_chk:w #1, {#2} \@@_sep: } { #1 #2 @ \prg_do_nothing: } } \cs_new:Npn \@@_exp_after_symbolic_loop:N #1 @@ -218,11 +218,11 @@ % \begin{macro}[EXP]{\@@_symbolic_binary_o:Nww} % Used when applying infix operators to expressions. % \begin{macrocode} -\cs_new:Npn \@@_symbolic_binary_o:Nww #1 #2; #3; +\cs_new:Npn \@@_symbolic_binary_o:Nww #1 #2\@@_sep: #3\@@_sep: { \@@_exp_after_symbolic_f:nw { \exp_after:wN \exp_stop_f: } \s_@@_symbolic \@@_symbolic_chk:w - \@@_types_binary:Nww #1 , { #2; #3; } ; + \@@_types_binary:Nww #1 , { #2\@@_sep: #3\@@_sep: } \@@_sep: } % \end{macrocode} % \end{macro} @@ -280,11 +280,11 @@ % \begin{macro}[EXP]{\@@_symbolic_unary_o:NNw} % Used when applying infix operators to expressions. % \begin{macrocode} -\cs_new:Npn \@@_symbolic_unary_o:NNw #1#2#3; @ +\cs_new:Npn \@@_symbolic_unary_o:NNw #1#2#3\@@_sep: @ { \@@_exp_after_symbolic_f:nw { \exp_after:wN \exp_stop_f: } \s_@@_symbolic \@@_symbolic_chk:w - \@@_types_unary:NNw #1#2 , { #3; } ; + \@@_types_unary:NNw #1#2 , { #3\@@_sep: } \@@_sep: } % \end{macrocode} % \end{macro} @@ -346,11 +346,11 @@ \@@_tmp:w { decimal } { 0 } \@@_to_decimal_dispatch:w \@@_tmp:w { int } { 0 } \@@_to_int_dispatch:w \@@_tmp:w { scientific } { nan } \@@_to_scientific_dispatch:w -\cs_new:Npn \@@_symbolic_convert:wnnN #1#2; #3#4#5 +\cs_new:Npn \@@_symbolic_convert:wnnN #1#2\@@_sep: #3#4#5 { \str_if_eq:nnTF {#1} { \s_@@_symbolic } - { \@@_invalid_operation:nnw {#3} {#4} #1#2; } - { #5 #1#2; } + { \@@_invalid_operation:nnw {#3} {#4} #1#2\@@_sep: } + { #5 #1#2\@@_sep: } } % \end{macrocode} % \end{macro} @@ -390,7 +390,7 @@ % Converting a symbolic expression to a token list is possible. % \begin{macrocode} \cs_new:Npn \@@_symbolic_to_tl:w - \s_@@_symbolic \@@_symbolic_chk:w #1#2, #3#4; + \s_@@_symbolic \@@_symbolic_chk:w #1#2, #3#4\@@_sep: { \str_case:nnTF {#1} { @@ -409,13 +409,13 @@ ( \@@_to_tl_dispatch:w #3 ) } } -\cs_new:Npn \@@_symbolic_binary_to_tl:Nww #1, #2; #3; @ +\cs_new:Npn \@@_symbolic_binary_to_tl:Nww #1, #2\@@_sep: #3\@@_sep: @ { \use:e { - ( \@@_to_tl_dispatch:w #2; ) + ( \@@_to_tl_dispatch:w #2\@@_sep: ) \@@_types_cs_to_op:N #1 - ( \@@_to_tl_dispatch:w #3; ) + ( \@@_to_tl_dispatch:w #3\@@_sep: ) } } \cs_new:Npn \@@_symbolic_function_to_tl:Nw #1, #2@ @@ -492,7 +492,7 @@ \token_if_eq_meaning:NNTF #2 \prg_do_nothing: { \s_@@_symbolic \@@_symbolic_chk:w - \@@_variable_o:w #1 , { } ; + \@@_variable_o:w #1 , { } \@@_sep: } { \exp_after:wN \s_@@_symbolic @@ -502,7 +502,7 @@ \@@_exp_after_symbolic_loop:N #1 { , \exp:w \use_none:nn } \exp_after:wN \exp_end: - \exp_after:wN { \exp_after:wN } \exp_after:wN ; + \exp_after:wN { \exp_after:wN } \exp_after:wN \@@_sep: #2 } } @@ -519,7 +519,7 @@ { \@@_exp_after_symbolic_f:nw { \@@_parse_infix:NN } \s_@@_symbolic \@@_symbolic_chk:w - \@@_variable_o:w #2 , { } ; + \@@_variable_o:w #2 , { } \@@_sep: } \exp_args:NNc \@@_variable_set_parsing_aux:NNn #1 { @@_parse_word_#2:N } {#2} diff --git a/macros/latex/required/l3kernel/l3fp-traps.dtx b/macros/latex/required/l3kernel/l3fp-traps.dtx index fec48bc163..5fb3d5d08a 100644 --- a/macros/latex/required/l3kernel/l3fp-traps.dtx +++ b/macros/latex/required/l3kernel/l3fp-traps.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-traps.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % \maketitle % % \begin{documentation} @@ -163,19 +163,21 @@ \cs_new_protected:Npn \@@_trap_invalid_operation_set:N #1 { \exp_args:Nno \use:n - { \cs_set:Npn \@@_invalid_operation:nnw ##1##2##3; } + { \cs_set:Npn \@@_invalid_operation:nnw ##1##2##3\@@_sep: } { #1 - \@@_error:nnfn { invalid } {##2} { \fp_to_tl:n { ##3; } } { } + \@@_error:nnfn { invalid } {##2} { \fp_to_tl:n { ##3\@@_sep: } } { } \flag_ensure_raised:N \l_fp_invalid_operation_flag ##1 } \exp_args:Nno \use:n - { \cs_set:Npn \@@_invalid_operation_o:Nww ##1##2; ##3; } + { \cs_set:Npn \@@_invalid_operation_o:Nww ##1##2\@@_sep: ##3\@@_sep: } { #1 \@@_error:nffn { invalid-ii } - { \fp_to_tl:n { ##2; } } { \fp_to_tl:n { ##3; } } {##1} + { \fp_to_tl:n { ##2\@@_sep: } } + { \fp_to_tl:n { ##3\@@_sep: } } + {##1} \flag_ensure_raised:N \l_fp_invalid_operation_flag \exp_after:wN \c_nan_fp } @@ -213,19 +215,23 @@ \cs_new_protected:Npn \@@_trap_division_by_zero_set:N #1 { \exp_args:Nno \use:n - { \cs_set:Npn \@@_division_by_zero_o:Nnw ##1##2##3; } + { \cs_set:Npn \@@_division_by_zero_o:Nnw ##1##2##3\@@_sep: } { #1 - \@@_error:nnfn { zero-div } {##2} { \fp_to_tl:n { ##3; } } { } + \@@_error:nnfn { zero-div } {##2} { \fp_to_tl:n { ##3\@@_sep: } } { } \flag_ensure_raised:N \l_fp_division_by_zero_flag \exp_after:wN ##1 } \exp_args:Nno \use:n - { \cs_set:Npn \@@_division_by_zero_o:NNww ##1##2##3; ##4; } + { + \cs_set:Npn \@@_division_by_zero_o:NNww ##1##2##3\@@_sep: ##4\@@_sep: + } { #1 \@@_error:nffn { zero-div-ii } - { \fp_to_tl:n { ##3; } } { \fp_to_tl:n { ##4; } } {##2} + { \fp_to_tl:n { ##3\@@_sep: } } + { \fp_to_tl:n { ##4\@@_sep: } } + {##2} \flag_ensure_raised:N \l_fp_division_by_zero_flag \exp_after:wN ##1 } @@ -281,12 +287,12 @@ \cs_new_protected:Npn \@@_trap_overflow_set:NnNn #1#2#3#4 { \exp_args:Nno \use:n - { \cs_set:cpn { @@_ #2 :w } \s_@@ \@@_chk:w ##1##2##3; } + { \cs_set:cpn { @@_ #2 :w } \s_@@ \@@_chk:w ##1##2##3\@@_sep: } { #1 \@@_error:nffn { flow \if_meaning:w 1 ##1 -to \fi: } - { \fp_to_tl:n { \s_@@ \@@_chk:w ##1##2##3; } } + { \fp_to_tl:n { \s_@@ \@@_chk:w ##1##2##3\@@_sep: } } { \token_if_eq_meaning:NNF 0 ##2 { - } #4 } {#2} \flag_ensure_raised:c { l_fp_#2_flag } @@ -310,11 +316,11 @@ % division by zero, overflow, and underflow to act silently on their % flag. % \begin{macrocode} -\cs_new:Npn \@@_invalid_operation:nnw #1#2#3; { } -\cs_new:Npn \@@_invalid_operation_o:Nww #1#2; #3; { } +\cs_new:Npn \@@_invalid_operation:nnw #1#2#3\@@_sep: { } +\cs_new:Npn \@@_invalid_operation_o:Nww #1#2\@@_sep: #3\@@_sep: { } \cs_new:Npn \@@_invalid_operation_tl_o:ff #1 #2 { } -\cs_new:Npn \@@_division_by_zero_o:Nnw #1#2#3; { } -\cs_new:Npn \@@_division_by_zero_o:NNww #1#2#3; #4; { } +\cs_new:Npn \@@_division_by_zero_o:Nnw #1#2#3\@@_sep: { } +\cs_new:Npn \@@_division_by_zero_o:NNww #1#2#3\@@_sep: #4\@@_sep: { } \cs_new:Npn \@@_overflow:w { } \cs_new:Npn \@@_underflow:w { } \fp_trap:nn { invalid_operation } { error } diff --git a/macros/latex/required/l3kernel/l3fp-trig.dtx b/macros/latex/required/l3kernel/l3fp-trig.dtx index 7c40c6198f..501a6bf2fa 100644 --- a/macros/latex/required/l3kernel/l3fp-trig.dtx +++ b/macros/latex/required/l3kernel/l3fp-trig.dtx @@ -2,7 +2,7 @@ % %% File: l3fp-trig.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -168,7 +168,7 @@ % result of the series to a floating point directly rather than taking % its inverse, since $\sin(x) = \#3 \sin\lvert x\rvert$. % \begin{macrocode} -\cs_new:Npn \@@_sin_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_sin_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_return_same_o:w @@ -181,7 +181,7 @@ { \@@_invalid_operation_o:fw { #1 { sin } { sind } } } \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3 #4; + \s_@@ \@@_chk:w #2 #3 #4\@@_sep: } % \end{macrocode} % \end{macro} @@ -195,7 +195,7 @@ % sign~|0| regardless of the sign of~$x$, and with an initial octant % of~$2$, because $\cos(x) = + \sin(\pi/2 + \lvert x\rvert)$. % \begin{macrocode} -\cs_new:Npn \@@_cos_o:w #1 \s_@@ \@@_chk:w #2#3; @ +\cs_new:Npn \@@_cos_o:w #1 \s_@@ \@@_chk:w #2#3\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_return_o:Nw \c_one_fp @@ -208,7 +208,7 @@ { \@@_invalid_operation_o:fw { #1 { cos } { cosd } } } \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3; + \s_@@ \@@_chk:w #2 #3\@@_sep: } % \end{macrocode} % \end{macro} @@ -225,7 +225,7 @@ % point sine to the floating point result, because $\csc(x) = \#3 % \big( \sin\lvert x\rvert\big)^{-1}$. % \begin{macrocode} -\cs_new:Npn \@@_csc_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_csc_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_cot_zero_o:Nfw #3 { #1 { csc } { cscd } } @@ -238,7 +238,7 @@ { \@@_invalid_operation_o:fw { #1 { csc } { cscd } } } \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3 #4; + \s_@@ \@@_chk:w #2 #3 #4\@@_sep: } % \end{macrocode} % \end{macro} @@ -251,7 +251,7 @@ % positive sign~$0$, a starting octant of~$2$, and inverting upon % conversion, because $\sec(x) = + 1 / \sin(\pi/2 + \lvert x\rvert)$. % \begin{macrocode} -\cs_new:Npn \@@_sec_o:w #1 \s_@@ \@@_chk:w #2#3; @ +\cs_new:Npn \@@_sec_o:w #1 \s_@@ \@@_chk:w #2#3\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_return_o:Nw \c_one_fp @@ -264,7 +264,7 @@ { \@@_invalid_operation_o:fw { #1 { sec } { secd } } } \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3; + \s_@@ \@@_chk:w #2 #3\@@_sep: } % \end{macrocode} % \end{macro} @@ -278,7 +278,7 @@ % of~$1$ (this shift is somewhat arbitrary). See \cs{@@_cot_o:w} for % an explanation of the $0$~argument. % \begin{macrocode} -\cs_new:Npn \@@_tan_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_tan_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_return_same_o:w @@ -291,7 +291,7 @@ { \@@_invalid_operation_o:fw { #1 { tan } { tand } } } \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3 #4; + \s_@@ \@@_chk:w #2 #3 #4\@@_sep: } % \end{macrocode} % \end{macro} @@ -308,7 +308,7 @@ % sign of the argument: the first of those indicates whether we % compute tangent or cotangent. Those signs are eventually combined. % \begin{macrocode} -\cs_new:Npn \@@_cot_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_cot_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_cot_zero_o:Nfw #3 { #1 { cot } { cotd } } @@ -321,7 +321,7 @@ { \@@_invalid_operation_o:fw { #1 { cot } { cotd } } } \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3 #4; + \s_@@ \@@_chk:w #2 #3 #4\@@_sep: } \cs_new:Npn \@@_cot_zero_o:Nfw #1#2#3 \fi: { @@ -362,7 +362,7 @@ % four \texttt{trig}/\texttt{trigd} auxiliaries receive the operand as % an extended-precision number. % \begin{macrocode} -\cs_new:Npn \@@_trig:NNNNNwn #1#2#3#4#5 \s_@@ \@@_chk:w 1#6#7#8; +\cs_new:Npn \@@_trig:NNNNNwn #1#2#3#4#5 \s_@@ \@@_chk:w 1#6#7#8\@@_sep: { \exp_after:wN #2 \exp_after:wN #3 @@ -374,7 +374,7 @@ \else: #1 \@@_trig_small:ww \@@_trigd_small:ww \fi: - #7,#8{0000}{0000}; + #7,#8{0000}{0000}\@@_sep: } % \end{macrocode} % \end{macro} @@ -390,8 +390,8 @@ % an extended-precision number) rather than the fixed point number. % The period serves to end the integer expression for the octant. % \begin{macrocode} -\cs_new:Npn \@@_trig_small:ww #1,#2; - { \@@_ep_to_fixed:wwn #1,#2; . #1,#2; } +\cs_new:Npn \@@_trig_small:ww #1,#2\@@_sep: + { \@@_ep_to_fixed:wwn #1,#2\@@_sep: . #1,#2\@@_sep: } % \end{macrocode} % \end{macro} % @@ -400,10 +400,10 @@ % \cs{@@_trig_small:ww} to massage it in the form appropriate for the % \texttt{_series} auxiliary. % \begin{macrocode} -\cs_new:Npn \@@_trigd_small:ww #1,#2; +\cs_new:Npn \@@_trigd_small:ww #1,#2\@@_sep: { \@@_ep_mul_raw:wwwwN - -1,{1745}{3292}{5199}{4329}{5769}{2369}; #1,#2; + -1,{1745}{3292}{5199}{4329}{5769}{2369}\@@_sep: #1,#2\@@_sep: \@@_trig_small:ww } % \end{macrocode} @@ -444,34 +444,34 @@ % those are all~$0$ and no precision is lost (|#6| and~|#7| are % four~$0$ each). % \begin{macrocode} -\cs_new:Npn \@@_trigd_large:ww #1, #2#3#4#5#6#7; +\cs_new:Npn \@@_trigd_large:ww #1, #2#3#4#5#6#7\@@_sep: { \exp_after:wN \@@_pack_eight:wNNNNNNNN \exp_after:wN \@@_pack_eight:wNNNNNNNN \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_trigd_large_auxi:nnnnwNNNN - \exp_after:wN ; + \exp_after:wN \@@_sep: \exp:w \exp_end_continue_f:w \prg_replicate:nn { \int_max:nn { 22 - #1 } { 0 } } { 0 } #2#3#4#5#6#7 0000 0000 0000 ! } -\cs_new:Npn \@@_trigd_large_auxi:nnnnwNNNN #1#2#3#4#5; #6#7#8#9 +\cs_new:Npn \@@_trigd_large_auxi:nnnnwNNNN #1#2#3#4#5\@@_sep: #6#7#8#9 { \exp_after:wN \@@_trigd_large_auxii:wNw \int_value:w \@@_int_eval:w #1 + #2 - (#1 + #2 - 4) / 9 * 9 \@@_int_eval_end: - #3; - #4; #5{#6#7#8#9}; + #3\@@_sep: + #4\@@_sep: #5{#6#7#8#9}\@@_sep: } -\cs_new:Npn \@@_trigd_large_auxii:wNw #1; #2#3; +\cs_new:Npn \@@_trigd_large_auxii:wNw #1\@@_sep: #2#3\@@_sep: { + (#1#2 - 4) / 9 * 2 \exp_after:wN \@@_trigd_large_auxiii:www \int_value:w \@@_int_eval:w #1#2 - - (#1#2 - 4) / 9 * 9 \@@_int_eval_end: #3 ; + - (#1#2 - 4) / 9 * 9 \@@_int_eval_end: #3 \@@_sep: } -\cs_new:Npn \@@_trigd_large_auxiii:www #1; #2; #3! +\cs_new:Npn \@@_trigd_large_auxiii:www #1\@@_sep: #2\@@_sep: #3! { \if_int_compare:w #1 < 4500 \exp_stop_f: \exp_after:wN \@@_use_i_until_s:nw @@ -479,8 +479,8 @@ \else: + 1 \fi: - \@@_fixed_sub:wwn {9000}{0000}{0000}{0000}{0000}{0000}; - {#1}#2{0000}{0000}; + \@@_fixed_sub:wwn {9000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + {#1}#2{0000}{0000}\@@_sep: { \@@_trigd_small:ww 2, } } % \end{macrocode} @@ -768,12 +768,12 @@ % between $65$ and $72$ at this point) into groups of~$4$ and the % \texttt{auxv} auxiliary is called. % \begin{macrocode} -\cs_new:Npn \@@_trig_large:ww #1, #2#3#4#5#6; +\cs_new:Npn \@@_trig_large:ww #1, #2#3#4#5#6\@@_sep: { \exp_after:wN \@@_trig_large_auxi:w \int_value:w \@@_int_eval:w (#1 - 4) / 8 \exp_after:wN , - \int_value:w #1 , ; - {#2}{#3}{#4}{#5} ; + \int_value:w #1 , \@@_sep: + {#2}{#3}{#4}{#5} \@@_sep: } \cs_new:Npn \@@_trig_large_auxi:w #1, #2, { @@ -818,7 +818,7 @@ \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN - \@@_trig_large_auxv:www ; + \@@_trig_large_auxv:www \@@_sep: } \cs_new:Npn \@@_trig_large_auxiii:w 1 { \exp_stop_f: } % \end{macrocode} @@ -848,7 +848,7 @@ % more step in the ladder. The last semicolon closes the ladder, and % we return control to the \texttt{auxvii} auxiliary. % \begin{macrocode} -\cs_new:Npn \@@_trig_large_auxv:www #1; #2; #3; +\cs_new:Npn \@@_trig_large_auxv:www #1\@@_sep: #2\@@_sep: #3\@@_sep: { \exp_after:wN \@@_use_i_until_s:nw \exp_after:wN \@@_trig_large_auxvii:w @@ -857,17 +857,17 @@ { \@@_trig_large_auxvi:wnnnnnnnn } + \c_@@_trailing_shift_int - \c_@@_middle_shift_int \@@_use_i_until_s:nw - ; #3 #1 ; ; + \@@_sep: #3 #1 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_trig_large_auxvi:wnnnnnnnn #1; #2#3#4#5#6#7#8#9 +\cs_new:Npn \@@_trig_large_auxvi:wnnnnnnnn #1\@@_sep: #2#3#4#5#6#7#8#9 { \exp_after:wN \@@_trig_large_pack:NNNNNw \int_value:w \@@_int_eval:w \c_@@_middle_shift_int + #2*#9 + #3*#8 + #4*#7 + #5*#6 - #1; {#2}{#3}{#4}{#5} {#7}{#8}{#9} + #1\@@_sep: {#2}{#3}{#4}{#5} {#7}{#8}{#9} } -\cs_new:Npn \@@_trig_large_pack:NNNNNw #1#2#3#4#5#6; - { + #1#2#3#4#5 ; #6 } +\cs_new:Npn \@@_trig_large_pack:NNNNNw #1#2#3#4#5#6\@@_sep: + { + #1#2#3#4#5 \@@_sep: #6 } % \end{macrocode} % \end{macro} % @@ -900,10 +900,10 @@ \cs_new:Npn \@@_trig_large_auxvii:w #1#2#3 { \exp_after:wN \@@_trig_large_auxviii:ww - \int_value:w \@@_int_eval:w (#1#2#3 - 62) / 125 ; + \int_value:w \@@_int_eval:w (#1#2#3 - 62) / 125 \@@_sep: #1#2#3 } -\cs_new:Npn \@@_trig_large_auxviii:ww #1; +\cs_new:Npn \@@_trig_large_auxviii:ww #1\@@_sep: { + #1 \if_int_odd:w #1 \exp_stop_f: @@ -922,20 +922,20 @@ \prg_replicate:nn { 13 } { \@@_trig_large_auxx:wNNNNN } + \c_@@_trailing_shift_int - \c_@@_middle_shift_int - ; + \@@_sep: } -\cs_new:Npn \@@_trig_large_auxx:wNNNNN #1; #2 #3#4#5#6 +\cs_new:Npn \@@_trig_large_auxx:wNNNNN #1\@@_sep: #2 #3#4#5#6 { \exp_after:wN \@@_trig_large_pack:NNNNNw \int_value:w \@@_int_eval:w \c_@@_middle_shift_int #2 8 * #3#4#5#6 - #1; #2 + #1\@@_sep: #2 } -\cs_new:Npn \@@_trig_large_auxxi:w #1; +\cs_new:Npn \@@_trig_large_auxxi:w #1\@@_sep: { \exp_after:wN \@@_ep_mul_raw:wwwwN - \int_value:w \@@_int_eval:w 0 \@@_ep_to_ep_loop:N #1 ; ; ! - 0,{7853}{9816}{3397}{4483}{0961}{5661}; + \int_value:w \@@_int_eval:w 0 \@@_ep_to_ep_loop:N #1 \@@_sep: \@@_sep: ! + 0,{7853}{9816}{3397}{4483}{0961}{5661}\@@_sep: \@@_trig_small:ww } % \end{macrocode} @@ -975,9 +975,9 @@ % floating point number with the given sign, and \cs{@@_sanitize:Nw} % checks for overflow and underflow. % \begin{macrocode} -\cs_new:Npn \@@_sin_series_o:NNwwww #1#2#3. #4; +\cs_new:Npn \@@_sin_series_o:NNwwww #1#2#3. #4\@@_sep: { - \@@_fixed_mul:wwn #4; #4; + \@@_fixed_mul:wwn #4\@@_sep: #4\@@_sep: { \exp_after:wN \@@_sin_series_aux_o:NNnwww \exp_after:wN #1 @@ -990,7 +990,7 @@ {#3} } } -\cs_new:Npn \@@_sin_series_aux_o:NNnwww #1#2#3 #4; #5,#6; +\cs_new:Npn \@@_sin_series_aux_o:NNnwww #1#2#3 #4\@@_sep: #5,#6\@@_sep: { \if_int_odd:w \@@_int_eval:w #3 / 2 \@@_int_eval_end: \exp_after:wN \use_i:nn @@ -998,29 +998,46 @@ \exp_after:wN \use_ii:nn \fi: { % 1/18! - \@@_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0001}{5619}{2070}; - #4;{0000}{0000}{0000}{0477}{9477}{3324}; - \@@_fixed_mul_sub_back:wwwn #4;{0000}{0000}{0011}{4707}{4559}{7730}; - \@@_fixed_mul_sub_back:wwwn #4;{0000}{0000}{2087}{6756}{9878}{6810}; - \@@_fixed_mul_sub_back:wwwn #4;{0000}{0027}{5573}{1922}{3985}{8907}; - \@@_fixed_mul_sub_back:wwwn #4;{0000}{2480}{1587}{3015}{8730}{1587}; - \@@_fixed_mul_sub_back:wwwn #4;{0013}{8888}{8888}{8888}{8888}{8889}; - \@@_fixed_mul_sub_back:wwwn #4;{0416}{6666}{6666}{6666}{6666}{6667}; - \@@_fixed_mul_sub_back:wwwn #4;{5000}{0000}{0000}{0000}{0000}{0000}; - \@@_fixed_mul_sub_back:wwwn#4;{10000}{0000}{0000}{0000}{0000}{0000}; + \@@_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0001}{5619}{2070}\@@_sep: + #4\@@_sep: + {0000}{0000}{0000}{0477}{9477}{3324}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0000}{0000}{0011}{4707}{4559}{7730}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0000}{0000}{2087}{6756}{9878}{6810}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0000}{0027}{5573}{1922}{3985}{8907}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0000}{2480}{1587}{3015}{8730}{1587}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0013}{8888}{8888}{8888}{8888}{8889}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0416}{6666}{6666}{6666}{6666}{6667}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {5000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + \@@_fixed_mul_sub_back:wwwn#4\@@_sep: + {10000}{0000}{0000}{0000}{0000}{0000}\@@_sep: { \@@_fixed_continue:wn 0, } } { % 1/17! - \@@_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0028}{1145}{7254}; - #4;{0000}{0000}{0000}{7647}{1637}{3182}; - \@@_fixed_mul_sub_back:wwwn #4;{0000}{0000}{0160}{5904}{3836}{8216}; - \@@_fixed_mul_sub_back:wwwn #4;{0000}{0002}{5052}{1083}{8544}{1719}; - \@@_fixed_mul_sub_back:wwwn #4;{0000}{0275}{5731}{9223}{9858}{9065}; - \@@_fixed_mul_sub_back:wwwn #4;{0001}{9841}{2698}{4126}{9841}{2698}; - \@@_fixed_mul_sub_back:wwwn #4;{0083}{3333}{3333}{3333}{3333}{3333}; - \@@_fixed_mul_sub_back:wwwn #4;{1666}{6666}{6666}{6666}{6666}{6667}; - \@@_fixed_mul_sub_back:wwwn#4;{10000}{0000}{0000}{0000}{0000}{0000}; - { \@@_ep_mul:wwwwn 0, } #5,#6; + \@@_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0028}{1145}{7254}\@@_sep: + #4\@@_sep: + {0000}{0000}{0000}{7647}{1637}{3182}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0000}{0000}{0160}{5904}{3836}{8216}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0000}{0002}{5052}{1083}{8544}{1719}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0000}{0275}{5731}{9223}{9858}{9065}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0001}{9841}{2698}{4126}{9841}{2698}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {0083}{3333}{3333}{3333}{3333}{3333}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #4\@@_sep: + {1666}{6666}{6666}{6666}{6666}{6667}\@@_sep: + \@@_fixed_mul_sub_back:wwwn#4\@@_sep: + {10000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + { \@@_ep_mul:wwwwn 0, } #5,#6\@@_sep: } { \exp_after:wN \@@_sanitize:Nw @@ -1064,9 +1081,9 @@ % before computing the ratio. Note that this \cs{if_int_odd:w} test % relies on the fact that the octant is at least~$1$. % \begin{macrocode} -\cs_new:Npn \@@_tan_series_o:NNwwww #1#2#3. #4; +\cs_new:Npn \@@_tan_series_o:NNwwww #1#2#3. #4\@@_sep: { - \@@_fixed_mul:wwn #4; #4; + \@@_fixed_mul:wwn #4\@@_sep: #4\@@_sep: { \exp_after:wN \@@_tan_series_aux_o:Nnwww \int_value:w @@ -1077,22 +1094,32 @@ {#3} } } -\cs_new:Npn \@@_tan_series_aux_o:Nnwww #1 #2 #3; #4,#5; +\cs_new:Npn \@@_tan_series_aux_o:Nnwww #1 #2 #3\@@_sep: #4,#5\@@_sep: { - \@@_fixed_mul_sub_back:wwwn {0000}{0000}{1527}{3493}{0856}{7059}; - #3; {0000}{0159}{6080}{0274}{5257}{6472}; - \@@_fixed_mul_sub_back:wwwn #3; {0002}{4571}{2320}{0157}{2558}{8481}; - \@@_fixed_mul_sub_back:wwwn #3; {0115}{5830}{7533}{5397}{3168}{2147}; - \@@_fixed_mul_sub_back:wwwn #3; {1929}{8245}{6140}{3508}{7719}{2982}; - \@@_fixed_mul_sub_back:wwwn #3;{10000}{0000}{0000}{0000}{0000}{0000}; - { \@@_ep_mul:wwwwn 0, } #4,#5; + \@@_fixed_mul_sub_back:wwwn {0000}{0000}{1527}{3493}{0856}{7059}\@@_sep: + #3\@@_sep: + {0000}{0159}{6080}{0274}{5257}{6472}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #3\@@_sep: + {0002}{4571}{2320}{0157}{2558}{8481}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #3\@@_sep: + {0115}{5830}{7533}{5397}{3168}{2147}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #3\@@_sep: + {1929}{8245}{6140}{3508}{7719}{2982}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #3\@@_sep: + {10000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + { \@@_ep_mul:wwwwn 0, } #4,#5\@@_sep: { - \@@_fixed_mul_sub_back:wwwn {0000}{0007}{0258}{0681}{9408}{4706}; - #3;{0000}{2343}{7175}{1399}{6151}{7670}; - \@@_fixed_mul_sub_back:wwwn #3;{0019}{2638}{4588}{9232}{8861}{3691}; - \@@_fixed_mul_sub_back:wwwn #3;{0536}{6357}{0691}{4344}{6852}{4252}; - \@@_fixed_mul_sub_back:wwwn #3;{5263}{1578}{9473}{6842}{1052}{6315}; - \@@_fixed_mul_sub_back:wwwn#3;{10000}{0000}{0000}{0000}{0000}{0000}; + \@@_fixed_mul_sub_back:wwwn {0000}{0007}{0258}{0681}{9408}{4706}\@@_sep: + #3\@@_sep: + {0000}{2343}{7175}{1399}{6151}{7670}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #3\@@_sep: + {0019}{2638}{4588}{9232}{8861}{3691}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #3\@@_sep: + {0536}{6357}{0691}{4344}{6852}{4252}\@@_sep: + \@@_fixed_mul_sub_back:wwwn #3\@@_sep: + {5263}{1578}{9473}{6842}{1052}{6315}\@@_sep: + \@@_fixed_mul_sub_back:wwwn#3\@@_sep: + {10000}{0000}{0000}{0000}{0000}{0000}\@@_sep: { \reverse_if:N \if_int_odd:w \@@_int_eval:w (#2 - 1) / 2 \@@_int_eval_end: @@ -1220,7 +1247,7 @@ % \cs{@@_acotii_o:ww} simply reverses its two arguments. % \begin{macrocode} \cs_new:Npn \@@_atanii_o:Nww - #1 \s_@@ \@@_chk:w #2#3#4; \s_@@ \@@_chk:w #5 #6 @ + #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: \s_@@ \@@_chk:w #5 #6 @ { \if_meaning:w 3 #2 \@@_case_return_i_o:ww \fi: \if_meaning:w 3 #5 \@@_case_return_ii_o:ww \fi: @@ -1236,11 +1263,11 @@ \or: \@@_case_return:nw { \@@_atan_inf_o:NNNw #1 #3 0 } \fi: \@@_atan_normal_o:NNnwNnw #1 - \s_@@ \@@_chk:w #2#3#4; + \s_@@ \@@_chk:w #2#3#4\@@_sep: \s_@@ \@@_chk:w #5 #6 } -\cs_new:Npn \@@_acotii_o:Nww #1#2; #3; - { \@@_atanii_o:Nww #1#3; #2; } +\cs_new:Npn \@@_acotii_o:Nww #1#2\@@_sep: #3\@@_sep: + { \@@_atanii_o:Nww #1#3\@@_sep: #2\@@_sep: } % \end{macrocode} % \end{macro} % @@ -1257,15 +1284,15 @@ % is positive, and $[(7-|#3|)/2]\cdot\pi/4$ for negative~$x$, where % the divisions are rounded up. % \begin{macrocode} -\cs_new:Npn \@@_atan_inf_o:NNNw #1#2#3 \s_@@ \@@_chk:w #4#5#6; +\cs_new:Npn \@@_atan_inf_o:NNNw #1#2#3 \s_@@ \@@_chk:w #4#5#6\@@_sep: { \exp_after:wN \@@_atan_combine_o:NwwwwwN \exp_after:wN #2 \int_value:w \@@_int_eval:w - \if_meaning:w 2 #5 7 - \fi: #3 \exp_after:wN ; + \if_meaning:w 2 #5 7 - \fi: #3 \exp_after:wN \@@_sep: \c_@@_one_fixed_tl - {0000}{0000}{0000}{0000}{0000}{0000}; - 0,{0000}{0000}{0000}{0000}{0000}{0000}; #1 + {0000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + 0,{0000}{0000}{0000}{0000}{0000}{0000}\@@_sep: #1 } % \end{macrocode} % \end{macro} @@ -1279,11 +1306,11 @@ % intermediate rounding errors. % \begin{macrocode} \cs_new_protected:Npn \@@_atan_normal_o:NNnwNnw - #1 \s_@@ \@@_chk:w 1#2#3#4; \s_@@ \@@_chk:w 1#5#6#7; + #1 \s_@@ \@@_chk:w 1#2#3#4\@@_sep: \s_@@ \@@_chk:w 1#5#6#7\@@_sep: { \@@_atan_test_o:NwwNwwN - #2 #3, #4{0000}{0000}; - #5 #6, #7{0000}{0000}; #1 + #2 #3, #4{0000}{0000}\@@_sep: + #5 #6, #7{0000}{0000}\@@_sep: #1 } % \end{macrocode} % \end{macro} @@ -1304,7 +1331,7 @@ % two numbers. The finer test with $0.41421$ is done by % \cs{@@_atan_div:wnwwnw} after the operands have been ordered. % \begin{macrocode} -\cs_new:Npn \@@_atan_test_o:NwwNwwN #1#2,#3; #4#5,#6; +\cs_new:Npn \@@_atan_test_o:NwwNwwN #1#2,#3\@@_sep: #4#5,#6\@@_sep: { \exp_after:wN \@@_atan_combine_o:NwwwwwN \exp_after:wN #1 @@ -1313,11 +1340,11 @@ 7 - \@@_int_eval:w \fi: \if_int_compare:w - \@@_ep_compare:wwww #2,#3; #5,#6; > \c_zero_int + \@@_ep_compare:wwww #2,#3\@@_sep: #5,#6\@@_sep: > \c_zero_int 3 - \exp_after:wN \@@_reverse_args:Nww \fi: - \@@_atan_div:wnwwnw #2,#3; #5,#6; + \@@_atan_div:wnwwnw #2,#3\@@_sep: #5,#6\@@_sep: } % \end{macrocode} % \end{macro} @@ -1337,7 +1364,7 @@ % followed by~$z$, as a comma-delimited exponent and a fixed point % number. % \begin{macrocode} -\cs_new:Npn \@@_atan_div:wnwwnw #1,#2#3; #4,#5#6; +\cs_new:Npn \@@_atan_div:wnwwnw #1,#2#3\@@_sep: #4,#5#6\@@_sep: { \if_int_compare:w \@@_int_eval:w 41421 * #5 < #2 000 @@ -1347,20 +1374,20 @@ \exp_after:wN \@@_atan_near:wwwn \fi: 0 - \@@_ep_div:wwwwn #1,{#2}#3; #4,{#5}#6; + \@@_ep_div:wwwwn #1,{#2}#3\@@_sep: #4,{#5}#6\@@_sep: \@@_atan_auxi:ww } \cs_new:Npn \@@_atan_near:wwwn - 0 \@@_ep_div:wwwwn #1,#2; #3, + 0 \@@_ep_div:wwwwn #1,#2\@@_sep: #3, { 1 - \@@_ep_to_fixed:wwn #1 - #3, #2; + \@@_ep_to_fixed:wwn #1 - #3, #2\@@_sep: \@@_atan_near_aux:wwn } -\cs_new:Npn \@@_atan_near_aux:wwn #1; #2; +\cs_new:Npn \@@_atan_near_aux:wwn #1\@@_sep: #2\@@_sep: { - \@@_fixed_add:wwn #1; #2; - { \@@_fixed_sub:wwn #2; #1; { \@@_ep_div:wwwwn 0, } 0, } + \@@_fixed_add:wwn #1\@@_sep: #2\@@_sep: + { \@@_fixed_sub:wwn #2\@@_sep: #1\@@_sep: { \@@_ep_div:wwwwn 0, } 0, } } % \end{macrocode} % \end{macro} @@ -1372,16 +1399,16 @@ % call to \cs{@@_atan_Taylor_loop:www}, followed by the fixed point % representation of~$z$ and the old representation. % \begin{macrocode} -\cs_new:Npn \@@_atan_auxi:ww #1,#2; - { \@@_ep_to_fixed:wwn #1,#2; \@@_atan_auxii:w #1,#2; } -\cs_new:Npn \@@_atan_auxii:w #1; +\cs_new:Npn \@@_atan_auxi:ww #1,#2\@@_sep: + { \@@_ep_to_fixed:wwn #1,#2\@@_sep: \@@_atan_auxii:w #1,#2\@@_sep: } +\cs_new:Npn \@@_atan_auxii:w #1\@@_sep: { - \@@_fixed_mul:wwn #1; #1; + \@@_fixed_mul:wwn #1\@@_sep: #1\@@_sep: { - \@@_atan_Taylor_loop:www 39 ; - {0000}{0000}{0000}{0000}{0000}{0000} ; + \@@_atan_Taylor_loop:www 39 \@@_sep: + {0000}{0000}{0000}{0000}{0000}{0000} \@@_sep: } - ! #1; + ! #1\@@_sep: } % \end{macrocode} % \end{macro} @@ -1398,22 +1425,22 @@ % computing the octant with a semicolon, and leave the result~|#2| % afterwards. % \begin{macrocode} -\cs_new:Npn \@@_atan_Taylor_loop:www #1; #2; #3; +\cs_new:Npn \@@_atan_Taylor_loop:www #1\@@_sep: #2\@@_sep: #3\@@_sep: { \if_int_compare:w #1 = - \c_one_int \@@_atan_Taylor_break:w \fi: - \exp_after:wN \@@_fixed_div_int:wwN \c_@@_one_fixed_tl #1; - \@@_rrot:www \@@_fixed_mul_sub_back:wwwn #2; #3; + \exp_after:wN \@@_fixed_div_int:wwN \c_@@_one_fixed_tl #1\@@_sep: + \@@_rrot:www \@@_fixed_mul_sub_back:wwwn #2\@@_sep: #3\@@_sep: { \exp_after:wN \@@_atan_Taylor_loop:www - \int_value:w \@@_int_eval:w #1 - 2 ; + \int_value:w \@@_int_eval:w #1 - 2 \@@_sep: } - #3; + #3\@@_sep: } \cs_new:Npn \@@_atan_Taylor_break:w - \fi: #1 \@@_fixed_mul_sub_back:wwwn #2; #3 ! - { \fi: ; #2 ; } + \fi: #1 \@@_fixed_mul_sub_back:wwwn #2\@@_sep: #3 ! + { \fi: \@@_sep: #2 \@@_sep: } % \end{macrocode} % \end{macro} % @@ -1442,7 +1469,8 @@ % both cases, convert to a floating point with % \cs{@@_fixed_to_float_o:wN}. % \begin{macrocode} -\cs_new:Npn \@@_atan_combine_o:NwwwwwN #1 #2; #3; #4; #5,#6; #7 +\cs_new:Npn \@@_atan_combine_o:NwwwwwN + #1 #2\@@_sep: #3\@@_sep: #4\@@_sep: #5,#6\@@_sep: #7 { \exp_after:wN \@@_sanitize:Nw \exp_after:wN #1 @@ -1452,22 +1480,22 @@ \else: \exp_after:wN \use_ii:nn \fi: - { #5 \@@_fixed_mul:wwn #3; #6; } + { #5 \@@_fixed_mul:wwn #3\@@_sep: #6\@@_sep: } { - \@@_fixed_mul:wwn #3; #4; + \@@_fixed_mul:wwn #3\@@_sep: #4\@@_sep: { \exp_after:wN \@@_atan_combine_aux:ww - \int_value:w \@@_int_eval:w #2 / 2 ; #2; + \int_value:w \@@_int_eval:w #2 / 2 \@@_sep: #2\@@_sep: } } { #7 \@@_fixed_to_float_o:wN \@@_fixed_to_float_rad_o:wN } #1 } -\cs_new:Npn \@@_atan_combine_aux:ww #1; #2; +\cs_new:Npn \@@_atan_combine_aux:ww #1\@@_sep: #2\@@_sep: { \@@_fixed_mul_short:wwn - {7853}{9816}{3397}{4483}{0961}{5661}; - {#1}{0000}{0000}; + {7853}{9816}{3397}{4483}{0961}{5661}\@@_sep: + {#1}{0000}{0000}\@@_sep: { \if_int_odd:w #2 \exp_stop_f: \exp_after:wN \@@_fixed_sub:wwn @@ -1491,7 +1519,7 @@ % about what function is being performed (for \enquote{invalid operation} % exceptions). % \begin{macrocode} -\cs_new:Npn \@@_asin_o:w #1 \s_@@ \@@_chk:w #2#3; @ +\cs_new:Npn \@@_asin_o:w #1 \s_@@ \@@_chk:w #2#3\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_return_same_o:w @@ -1504,7 +1532,7 @@ \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3; + \s_@@ \@@_chk:w #2 #3\@@_sep: } % \end{macrocode} % \end{macro} @@ -1517,7 +1545,7 @@ % \texttt{acos} or \texttt{acosd}, and preparing to swap some % arguments down the line. % \begin{macrocode} -\cs_new:Npn \@@_acos_o:w #1 \s_@@ \@@_chk:w #2#3; @ +\cs_new:Npn \@@_acos_o:w #1 \s_@@ \@@_chk:w #2#3\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_use:nw { \@@_atan_inf_o:NNNw #1 0 4 } @@ -1533,7 +1561,7 @@ \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3; + \s_@@ \@@_chk:w #2 #3\@@_sep: } % \end{macrocode} % \end{macro} @@ -1550,7 +1578,7 @@ % outside the domain of arcsine or arccosine. % \begin{macrocode} \cs_new:Npn \@@_asin_normal_o:NfwNnnnnw - #1#2#3 \s_@@ \@@_chk:w 1#4#5#6#7#8#9; + #1#2#3 \s_@@ \@@_chk:w 1#4#5#6#7#8#9\@@_sep: { \if_int_compare:w #5 < \c_one_int \exp_after:wN \@@_use_none_until_s:w @@ -1560,9 +1588,9 @@ \fi: \@@_use_i:ww \@@_invalid_operation_o:fw {#2} - \s_@@ \@@_chk:w 1#4{#5}{#6}{#7}{#8}{#9}; + \s_@@ \@@_chk:w 1#4{#5}{#6}{#7}{#8}{#9}\@@_sep: \@@_asin_auxi_o:NnNww - #1 {#3} #4 #5,{#6}{#7}{#8}{#9}{0000}{0000}; + #1 {#3} #4 #5,{#6}{#7}{#8}{#9}{0000}{0000}\@@_sep: } % \end{macrocode} % \end{macro} @@ -1585,21 +1613,21 @@ % function requires normalized arguments, hence the need for % \texttt{ep_to_ep} and \texttt{continue} after \texttt{ep_mul}. % \begin{macrocode} -\cs_new:Npn \@@_asin_auxi_o:NnNww #1#2#3#4,#5; +\cs_new:Npn \@@_asin_auxi_o:NnNww #1#2#3#4,#5\@@_sep: { - \@@_ep_to_fixed:wwn #4,#5; + \@@_ep_to_fixed:wwn #4,#5\@@_sep: \@@_asin_isqrt:wn - \@@_ep_mul:wwwwn #4,#5; + \@@_ep_mul:wwwwn #4,#5\@@_sep: \@@_ep_to_ep:wwN \@@_fixed_continue:wn { #2 \@@_atan_test_o:NwwNwwN #3 } - 0 1,{1000}{0000}{0000}{0000}{0000}{0000}; #1 + 0 1,{1000}{0000}{0000}{0000}{0000}{0000}\@@_sep: #1 } -\cs_new:Npn \@@_asin_isqrt:wn #1; +\cs_new:Npn \@@_asin_isqrt:wn #1\@@_sep: { - \exp_after:wN \@@_fixed_sub:wwn \c_@@_one_fixed_tl #1; + \exp_after:wN \@@_fixed_sub:wwn \c_@@_one_fixed_tl #1\@@_sep: { - \@@_fixed_add_one:wN #1; + \@@_fixed_add_one:wN #1\@@_sep: \@@_fixed_continue:wn { \@@_ep_mul:wwwwn 0, } 0, } \@@_ep_isqrt:wwn @@ -1619,7 +1647,7 @@ % tests, keeping the function name (\texttt{acsc} or \texttt{acscd}) % as an argument for invalid operation exceptions. % \begin{macrocode} -\cs_new:Npn \@@_acsc_o:w #1 \s_@@ \@@_chk:w #2#3#4; @ +\cs_new:Npn \@@_acsc_o:w #1 \s_@@ \@@_chk:w #2#3#4\@@_sep: @ { \if_case:w \if_meaning:w 2 #2 #3 \fi: #2 \exp_stop_f: \@@_case_use:nw @@ -1630,7 +1658,7 @@ \or: \@@_case_return_same_o:w \else: \@@_case_return_o:Nw \c_minus_zero_fp \fi: - \s_@@ \@@_chk:w #2 #3 #4; + \s_@@ \@@_chk:w #2 #3 #4\@@_sep: } % \end{macrocode} % \end{macro} @@ -1644,7 +1672,7 @@ % \cs{@@_reverse_args:Nww} following precisely that appearing in % \cs{@@_acos_o:w}. % \begin{macrocode} -\cs_new:Npn \@@_asec_o:w #1 \s_@@ \@@_chk:w #2#3; @ +\cs_new:Npn \@@_asec_o:w #1 \s_@@ \@@_chk:w #2#3\@@_sep: @ { \if_case:w #2 \exp_stop_f: \@@_case_use:nw @@ -1658,7 +1686,7 @@ \or: \@@_case_use:nw { \@@_atan_inf_o:NNNw #1 0 4 } \else: \@@_case_return_same_o:w \fi: - \s_@@ \@@_chk:w #2 #3; + \s_@@ \@@_chk:w #2 #3\@@_sep: } % \end{macrocode} % \end{macro} @@ -1672,17 +1700,17 @@ % $\operatorname{acsc}(x)=\operatorname{asin}(1/x)$ and % $\operatorname{asec}(x)=\operatorname{acos}(1/x)$. % \begin{macrocode} -\cs_new:Npn \@@_acsc_normal_o:NfwNnw #1#2#3 \s_@@ \@@_chk:w 1#4#5#6; +\cs_new:Npn \@@_acsc_normal_o:NfwNnw #1#2#3 \s_@@ \@@_chk:w 1#4#5#6\@@_sep: { \int_compare:nNnTF {#5} < 1 { \@@_invalid_operation_o:fw {#2} - \s_@@ \@@_chk:w 1#4{#5}#6; + \s_@@ \@@_chk:w 1#4{#5}#6\@@_sep: } { \@@_ep_div:wwwwn - 1,{1000}{0000}{0000}{0000}{0000}{0000}; - #5,#6{0000}{0000}; + 1,{1000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + #5,#6{0000}{0000}\@@_sep: { \@@_asin_auxi_o:NnNww #1 {#3} #4 } } } diff --git a/macros/latex/required/l3kernel/l3fp-types.dtx b/macros/latex/required/l3kernel/l3fp-types.dtx index e9269e1f03..613890919f 100644 --- a/macros/latex/required/l3kernel/l3fp-types.dtx +++ b/macros/latex/required/l3kernel/l3fp-types.dtx @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -153,7 +153,7 @@ \exp_last_unbraced:Nf \@@_types_binary_auxi:Nww { \@@_types_cs_to_op:N #1 } } -\cs_new:Npn \@@_types_binary_auxi:Nww #1#2#3; #4#5; @ +\cs_new:Npn \@@_types_binary_auxi:Nww #1#2#3\@@_sep: #4#5\@@_sep: @ { \exp_after:wN \@@_types_binary_auxii:NNww \cs:w @@ -163,7 +163,7 @@ \@@_type_from_scan:N #4 _o:ww \cs_end: - #1 #2#3; #4#5; + #1 #2#3\@@_sep: #4#5\@@_sep: } \cs_new:Npn \@@_types_binary_auxii:NNww #1#2 { diff --git a/macros/latex/required/l3kernel/l3fp.dtx b/macros/latex/required/l3kernel/l3fp.dtx index d273b057ea..045f66200a 100644 --- a/macros/latex/required/l3kernel/l3fp.dtx +++ b/macros/latex/required/l3kernel/l3fp.dtx @@ -2,7 +2,7 @@ % %% File: l3fp.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -49,7 +49,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -59,8 +59,8 @@ % separate exponent. The module implements expandably a wide set of % arithmetic, trigonometric, and other operations on decimal floating point % numbers, to be used within floating point expressions. \emph{Floating point -% expressions} (\enquote{\meta{fp expr}}) support the following operations with their usual -% precedence. +% expressions} (\enquote{\meta{fp expr}}) support the following operations with +% their usual precedence. % \begin{itemize} % \item Basic arithmetic: addition $x+y$, subtraction $x-y$, % multiplication $x*y$, division $x/y$, square root~$\sqrt{x}$, @@ -108,7 +108,8 @@ % towards $+\infty$ if $t>0$ and towards $-\infty$ if $t<0$. % \end{itemize} % And \emph{(not yet)} modulo, and \enquote{quantize}. -% \item Random numbers: $\mathop{rand}()$, $\mathop{randint}(m,n)$. +% \item Random numbers: $\operatorname{rand}()$, +% $\operatorname{randint}(m,n)$. % \item Constants: \texttt{pi}, \texttt{deg} (one degree in radians). % \item Dimensions, automatically expressed in points, \emph{e.g.}, % \texttt{pc} is~$12$. @@ -124,9 +125,9 @@ % as |1.234e-34|, or |-.0001|), or as a stored floating point variable, % which is automatically replaced by its current value. % A \enquote{floating point} is a floating point number or a tuple thereof. See -% section~\ref{sec:l3fp:fp-floats} for a description of what a floating point is, -% section~\ref{sec:l3fp:fp-precedence} for details about how an expression is -% parsed, and section~\ref{sec:l3fp:fp-operations} to know what the various +% section~\ref{sec:l3fp:fp-floats} for a description of what a floating point +% is, section~\ref{sec:l3fp:fp-precedence} for details about how an expression +% is parsed, and section~\ref{sec:l3fp:fp-operations} to know what the various % operations do. Some operations may raise exceptions (error messages), % described in section~\ref{sec:l3fp:fp-exceptions}. % @@ -198,7 +199,10 @@ % \section{Setting floating point variables} % % \begin{function}[updated = 2012-05-08, tested = m3fp002] -% {\fp_set:Nn, \fp_set:cn, \fp_gset:Nn, \fp_gset:cn} +% { +% \fp_set:Nn, \fp_set:cn, \fp_set:NV, \fp_set:cV, +% \fp_gset:Nn, \fp_gset:cn, \fp_gset:NV, \fp_gset:cV +% } % \begin{syntax} % \cs{fp_set:Nn} \meta{fp~var} \Arg{fp expr} % \end{syntax} @@ -254,7 +258,8 @@ % integers are expressed without a decimal separator. The values % $\pm\infty$ and \nan{} trigger an \enquote{invalid operation} % exception. -% For a tuple, each item is converted using \cs{fp_eval:n} and they are combined as +% For a tuple, each item is converted using \cs{fp_eval:n} and they are +% combined as % |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)| % if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items. % This function is identical to \cs{fp_to_decimal:n}. @@ -285,7 +290,8 @@ % integers are expressed without a decimal separator. The values % $\pm\infty$ and~\nan{} trigger an \enquote{invalid operation} % exception. -% For a tuple, each item is converted using \cs{fp_to_decimal:n} and they are combined as +% For a tuple, each item is converted using \cs{fp_to_decimal:n} and they are +% combined as % |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)| % if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items. % \end{function} @@ -337,7 +343,8 @@ % The values $\pm\infty$ and~\nan{} trigger an \enquote{invalid % operation} exception. Normal category codes apply: thus the |e| is % category code~$11$ (a letter). -% For a tuple, each item is converted using \cs{fp_to_scientific:n} and they are combined as +% For a tuple, each item is converted using \cs{fp_to_scientific:n} and they +% are combined as % |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)| % if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items. % \end{function} @@ -361,7 +368,8 @@ % |0|, |-0|, \texttt{inf}, \texttt{-inf}, and~\texttt{nan} % respectively. Normal category codes apply and thus \texttt{inf} or % \texttt{nan}, if produced, are made up of letters. -% For a tuple, each item is converted using \cs{fp_to_tl:n} and they are combined as +% For a tuple, each item is converted using \cs{fp_to_tl:n} and they are +% combined as % |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)| % if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items. % \end{function} @@ -377,7 +385,8 @@ % exponent. Non-significant trailing zeros are trimmed. Integers are % expressed without a decimal separator. The values $\pm\infty$ % and~\nan{} trigger an \enquote{invalid operation} exception. -% For a tuple, each item is converted using \cs{fp_to_decimal:n} and they are combined as +% For a tuple, each item is converted using \cs{fp_to_decimal:n} and they are +% combined as % |(|\meta{fp_1}\verb*|, |\meta{fp_2}\verb*|, |\ldots{}\meta{fp_n}|)| % if $n>1$ and |(|\meta{fp_1}|,)| or |()| for fewer items. % This function is identical to \cs{fp_to_decimal:N}. @@ -773,9 +782,9 @@ % The result may contain other functions, which are % then replaced by their results if they have any. For instance, % \begin{quote} -% \cs{fp_new_function:n} |{ foo }| \\ +% \cs{fp_new_function:n} |{ npow }| \\ % \cs{fp_set_function:nnn} |{ npow } { a,b } { a**b }| \\ -% \cs{fp_show:n} |{ npow(16,0.25) } }| +% \cs{fp_show:n} |{ npow(16,0.25) }| % \end{quote} % shows |2|. The names of the \meta{vars} must % consist entirely of Latin letters |[a-zA-Z]|, but are otherwise not @@ -904,7 +913,6 @@ % the \TeX{} run and display some information about the current % operation in the terminal. % \end{itemize} -% \emph{This function is experimental, and may be altered or removed.} % \end{function} % % \begin{variable} @@ -993,7 +1001,8 @@ % valid floating point numbers. Note that the latter could be mistaken % with the difference of \enquote{\texttt{e}} and $1$. To avoid % confusions, the base of natural logarithms cannot be input as |e| and -% should be input as \texttt{exp(1)} or \cs[module = fp]{c_e_fp} (which is faster). +% should be input as \texttt{exp(1)} or \cs[module = fp]{c_e_fp} (which is +% faster). % % Special numbers are input as follows: % \begin{itemize} @@ -1022,7 +1031,8 @@ % \item Unary |+|, |-|, |!|. % \item Implicit multiplication by juxtaposition (\texttt{2pi}) % when neither factor is in parentheses. -% \item Binary |*| and |/|, implicit multiplication by juxtaposition with parentheses (for instance \texttt{3(4+5)}). +% \item Binary |*| and |/|, implicit multiplication by juxtaposition with +% parentheses (for instance \texttt{3(4+5)}). % \item Binary |+| and |-|. % \item Comparisons |>=|, |!=|, |<?|, \emph{etc}. % \item Logical \texttt{and}, denoted by |&&|. @@ -1059,9 +1069,10 @@ % \cs{fp_eval:n} \{ \meta{operand_1} |?| \meta{operand_2} |:| \meta{operand_3} \} % \end{syntax} % The ternary operator |?:| results in \meta{operand_2} if -% \meta{operand_1} is true (not $\pm 0$), and \meta{operand_3} if \meta{operand_1} -% is false ($\pm 0$). All three \meta{operands} are evaluated in all -% cases; they may be tuples. The operator is right associative, hence +% \meta{operand_1} is true (not $\pm 0$), and \meta{operand_3} if +% \meta{operand_1} is false ($\pm 0$). All three \meta{operands} are +% evaluated in all cases; they may be tuples. The operator is right +% associative, hence % \begin{verbatim} % \fp_eval:n % { @@ -1260,11 +1271,11 @@ % \cs{fp_eval:n} \{ |round| |(| \meta{fp expr_1} , \meta{fp expr_2} , \meta{fp expr_3} |)| \} % \end{syntax} % Only |round| accepts a third argument. -% Evaluates $\meta{fp expr_1}=x$ and $\meta{fp expr_2}=n$ and $\meta{fp expr_3}=t$ then rounds -% $x$~to $n$~places. If $n$~is an integer, this rounds~$x$ to a -% multiple of~$10^{-n}$; if $n=+\infty$, this always yields~$x$; if -% $n=-\infty$, this yields one of $\pm 0$, $\pm\infty$, or~\nan{}; if -% $n=\nan{}$, this yields \nan{}; if +% Evaluates $\meta{fp expr_1}=x$ and $\meta{fp expr_2}=n$ and $\meta{fp +% expr_3}=t$ then rounds $x$~to $n$~places. If $n$~is an integer, this +% rounds~$x$ to a multiple of~$10^{-n}$; if $n=+\infty$, this always +% yields~$x$; if $n=-\infty$, this yields one of $\pm 0$, $\pm\infty$, +% or~\nan{}; if $n=\nan{}$, this yields \nan{}; if % $n$~is neither $\pm\infty$ nor an integer, then an \enquote{invalid % operation} exception is raised. When \meta{fp expr_2} is omitted, % $n=0$, \emph{i.e.}, \meta{fp expr_1} is rounded to an integer. The @@ -1275,8 +1286,8 @@ % as follows. If $t$ is \texttt{nan} (or not given) the even % multiple is chosen (\enquote{ties to even}), if $t=\pm 0$ the % multiple closest to $0$ is chosen (\enquote{ties to zero}), -% if $t$ is positive/negative the multiple closest to $\infty$/$-\infty$ is chosen -% (\enquote{ties towards positive/negative infinity}). +% if $t$ is positive/negative the multiple closest to $\infty$/$-\infty$ +% is chosen (\enquote{ties towards positive/negative infinity}). % \item |floor| yields the largest % multiple of~$10^{-n}$ smaller or equal to~$x$ (\enquote{round % towards negative infinity}); @@ -1457,8 +1468,8 @@ % \cs{fp_eval:n} \{ |sqrt(| \meta{fp expr} |)| \} % \end{syntax} % Computes the square root of the \meta{fp expr}. The \enquote{invalid -% operation} is raised when the \meta{fp expr} is negative or is a tuple; no other -% exception can occur. Special values yield $\sqrt{-0} = -0$, +% operation} is raised when the \meta{fp expr} is negative or is a tuple; no +% other exception can occur. Special values yield $\sqrt{-0} = -0$, % $\sqrt{+0} = +0$, $\sqrt{+\infty} = +\infty$ and % $\sqrt{\text{\nan{}}}=\text{\nan{}}$. % \end{function} @@ -1500,8 +1511,9 @@ % % \begin{variable}[tested = m3fp-parse001]{inf, nan} % The special values $+\infty$, $-\infty$, and \nan{} are represented -% as \texttt{inf}, \texttt{-inf} and \texttt{nan} (see \cs[module = fp]{c_inf_fp}, -% \cs[module = fp]{c_minus_inf_fp} and \cs[module = fp]{c_nan_fp}). +% as \texttt{inf}, \texttt{-inf} and \texttt{nan} (see +% \cs[module = fp]{c_inf_fp}, \cs[module = fp]{c_minus_inf_fp} and +% \cs[module = fp]{c_nan_fp}). % \end{variable} % % \begin{variable}[tested = m3fp-parse001]{pi} diff --git a/macros/latex/required/l3kernel/l3fparray.dtx b/macros/latex/required/l3kernel/l3fparray.dtx index f48de27af3..642e75c659 100644 --- a/macros/latex/required/l3kernel/l3fparray.dtx +++ b/macros/latex/required/l3kernel/l3fparray.dtx @@ -2,7 +2,7 @@ % %% File: l3fparray.dtx % -% Copyright (C) 2018-2024 The LaTeX Project +% Copyright (C) 2018-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -63,7 +63,7 @@ % \cs{fparray_new:Nn} \meta{fparray~var} \Arg{size} % \end{syntax} % Evaluates the integer expression \meta{size} and allocates an -% \meta{floating point array variable} with that number of (zero) +% \meta{fparray var} with that number of (zero) % entries. The variable name should start with |\g_| because % assignments are always global. % \end{function} @@ -72,7 +72,7 @@ % \begin{syntax} % \cs{fparray_gzero:N} \meta{fparray~var} % \end{syntax} -% Sets all entries of the \meta{floating point array variable} to +% Sets all entries of the \meta{fparray var} to % $+0$. Assignments are always global. % \end{function} % @@ -83,7 +83,7 @@ % \cs{fparray_gset:Nnn} \meta{fparray~var} \Arg{position} \Arg{value} % \end{syntax} % Stores the result of evaluating the floating point expression -% \meta{value} into the \meta{floating point array variable} at the +% \meta{value} into the \meta{fparray var} at the % (integer expression) \meta{position}. If the \meta{position} is not % between $1$ and the \cs{fparray_count:N}, an error occurs. % Assignments are always global. @@ -95,8 +95,8 @@ % \begin{syntax} % \cs{fparray_count:N} \meta{fparray~var} % \end{syntax} -% Expands to the number of entries in the \meta{floating point array -% variable}. This is performed in constant time. +% Expands to the number of entries in the \meta{fparray +% var}. This is performed in constant time. % \end{function} % % \section{Using a single entry} @@ -111,7 +111,7 @@ % \end{syntax} % Applies \cs{fp_use:N} or \cs{fp_to_tl:N} (respectively) to the % floating point entry stored at the (integer expression) -% \meta{position} in the \meta{floating point array variable}. If the +% \meta{position} in the \meta{fparray var}. If the % \meta{position} is not between $1$ and the % \cs{fparray_count:N} \meta{fparray~var}, an error occurs. % \end{function} @@ -266,25 +266,25 @@ \exp_after:wN \@@_array_gset:NNNNww \exp_after:wN #1 \exp_after:wN #1 - \int_value:w \int_eval:n {#2} \exp_after:wN ; + \int_value:w \int_eval:n {#2} \exp_after:wN \@@_sep: \exp:w \exp_end_continue_f:w \@@_parse:n {#3} } \cs_generate_variant:Nn \fparray_gset:Nnn { c } -\cs_new_protected:Npn \@@_array_gset:NNNNww #1#2#3#4#5 ; #6 ; +\cs_new_protected:Npn \@@_array_gset:NNNNww #1#2#3#4#5 \@@_sep: #6 \@@_sep: { \@@_array_bounds:NNnTF \msg_error:nneee #4 {#5} { \exp_after:wN \@@_change_func_type:NNN - \@@_use_i_until_s:nw #6 ; + \@@_use_i_until_s:nw #6 \@@_sep: \@@_array_gset:w \@@_array_gset_recover:Nw - #6 ; {#5} #1 #2 #3 + #6 \@@_sep: {#5} #1 #2 #3 } { } } -\cs_new_protected:Npn \@@_array_gset_recover:Nw #1#2 ; +\cs_new_protected:Npn \@@_array_gset_recover:Nw #1#2 \@@_sep: { - \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 ; } } { } { } + \@@_error:nffn { unknown-type } { \tl_to_str:n { #2 \@@_sep: } } { } { } \exp_after:wN #1 \c_nan_fp } \cs_new_protected:Npn \@@_array_gset:w \s_@@ \@@_chk:w #1#2 @@ -298,7 +298,7 @@ \s_@@ \@@_chk:w #1 #2 } \cs_new_protected:Npn \@@_array_gset_normal:w - \s_@@ \@@_chk:w 1 #1 #2 #3#4#5 ; #6#7#8#9 + \s_@@ \@@_chk:w 1 #1 #2 #3#4#5 \@@_sep: #6#7#8#9 { \__kernel_intarray_gset:Nnn #7 {#6} {#2} \__kernel_intarray_gset:Nnn #8 {#6} @@ -354,7 +354,7 @@ { \exp_after:wN \@@_array_item:NwN \exp_after:wN #1 - \int_value:w \int_eval:n {#2} ; + \int_value:w \int_eval:n {#2} \@@_sep: \@@_to_decimal:w } \cs_generate_variant:Nn \fparray_item:Nn { c } @@ -362,11 +362,11 @@ { \exp_after:wN \@@_array_item:NwN \exp_after:wN #1 - \int_value:w \int_eval:n {#2} ; + \int_value:w \int_eval:n {#2} \@@_sep: \@@_to_tl:w } \cs_generate_variant:Nn \fparray_item_to_tl:Nn { c } -\cs_new:Npn \@@_array_item:NwN #1#2 ; #3 +\cs_new:Npn \@@_array_item:NwN #1#2 \@@_sep: #3 { \@@_array_bounds:NNnTF \msg_expandable_error:nnfff #1 {#2} { \exp_after:wN \@@_array_item:NNNnN #1 {#2} #3 } @@ -375,22 +375,22 @@ \cs_new:Npn \@@_array_item:NNNnN #1#2#3#4 { \exp_after:wN \@@_array_item:N - \int_value:w \__kernel_intarray_item:Nn #2 {#4} \exp_after:wN ; - \int_value:w \__kernel_intarray_item:Nn #3 {#4} \exp_after:wN ; - \int_value:w \__kernel_intarray_item:Nn #1 {#4} ; + \int_value:w \__kernel_intarray_item:Nn #2 {#4} \exp_after:wN \@@_sep: + \int_value:w \__kernel_intarray_item:Nn #3 {#4} \exp_after:wN \@@_sep: + \int_value:w \__kernel_intarray_item:Nn #1 {#4} \@@_sep: } \cs_new:Npn \@@_array_item:N #1 { \if_meaning:w 0 #1 \exp_after:wN \@@_array_item_special:w \fi: \@@_array_item:w #1 } -\cs_new:Npn \@@_array_item:w #1 #2#3#4#5 #6 ; 1 #7 ; +\cs_new:Npn \@@_array_item:w #1 #2#3#4#5 #6 \@@_sep: 1 #7 \@@_sep: { \exp_after:wN \@@_array_item_normal:w \int_value:w \if_meaning:w #1 1 0 \else: 2 \fi: \exp_stop_f: - #7 ; {#2#3#4#5} {#6} ; + #7 \@@_sep: {#2#3#4#5} {#6} \@@_sep: } -\cs_new:Npn \@@_array_item_special:w #1 ; #2 ; #3 ; #4 +\cs_new:Npn \@@_array_item_special:w #1 \@@_sep: #2 \@@_sep: #3 \@@_sep: #4 { \exp_after:wN #4 \exp:w \exp_end_continue_f:w @@ -402,8 +402,9 @@ \else: \exp_after:wN \c_minus_inf_fp \fi: } -\cs_new:Npn \@@_array_item_normal:w #1 #2#3#4#5 #6 ; #7 ; #8 ; #9 - { #9 \s_@@ \@@_chk:w 1 #1 {#8} #7 {#2#3#4#5} {#6} ; } +\cs_new:Npn \@@_array_item_normal:w + #1 #2#3#4#5 #6 \@@_sep: #7 \@@_sep: #8 \@@_sep: #9 + { #9 \s_@@ \@@_chk:w 1 #1 {#8} #7 {#2#3#4#5} {#6} \@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} diff --git a/macros/latex/required/l3kernel/l3int.dtx b/macros/latex/required/l3kernel/l3int.dtx index 45050964de..120a1b4630 100644 --- a/macros/latex/required/l3kernel/l3int.dtx +++ b/macros/latex/required/l3kernel/l3int.dtx @@ -2,7 +2,7 @@ % %% File: l3int.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -100,21 +100,6 @@ % restricted-expandable functions can both be used, and \cs{exp_not:n} % and its variants have no effect while \cs{exp_not:N} may incorrectly % interrupt the expression. -% \begin{texnote} -% Exactly two expansions are needed to evaluate \cs{int_eval:n}. -% The result is \emph{not} an \meta{internal integer}, and therefore -% should be terminated by a space if used in \cs{int_value:w} or in -% a \TeX{}-style integer assignment. -% -% As all \TeX{} integers, integer operands can also be: -% \tn{value}\Arg{\LaTeXe{} counter}; dimension or skip variables, -% converted to integers in~\texttt{sp}; the character code of some -% character given as \texttt{`}\meta{char} or -% \texttt{`\textbackslash}\meta{char}; octal numbers given as -% \texttt{'} followed by digits from \texttt{0} to \texttt{7}; or -% hexadecimal numbers given as |"| followed by digits and upper case -% letters from \texttt{A} to~\texttt{F}. -% \end{texnote} % % \begin{function}[EXP]{\int_eval:n} % \begin{syntax} @@ -277,11 +262,11 @@ % \begin{function}[EXP, pTF, added=2012-03-03] % {\int_if_exist:N, \int_if_exist:c} % \begin{syntax} -% \cs{int_if_exist_p:N} \meta{int} -% \cs{int_if_exist:NTF} \meta{int} \Arg{true code} \Arg{false code} +% \cs{int_if_exist_p:N} \meta{integer} +% \cs{int_if_exist:NTF} \meta{integer} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests whether the \meta{int} is currently defined. This does not -% check that the \meta{int} really is an integer variable. +% Tests whether the \meta{integer} is currently defined. This does not +% check that the \meta{integer} really is an integer variable. % \end{function} % % \section{Setting and incrementing integers} @@ -310,7 +295,10 @@ % \end{function} % % \begin{function}[updated = 2011-10-22] -% {\int_set:Nn, \int_set:cn, \int_gset:Nn, \int_gset:cn} +% { +% \int_set:Nn, \int_set:cn, \int_set:NV, \int_set:cV, +% \int_gset:Nn, \int_gset:cn, \int_gset:NV, \int_gset:cV +% } % \begin{syntax} % \cs{int_set:Nn} \meta{integer} \Arg{int expr} % \end{syntax} @@ -319,6 +307,37 @@ % \cs{int_eval:n}). % \end{function} % +% \begin{function}[added = 2024-12-08] +% { +% \int_set_regex_count:Nnn, \int_set_regex_count:cnn, +% \int_set_regex_count:NNn, \int_set_regex_count:cNn, +% \int_gset_regex_count:Nnn, \int_gset_regex_count:cnn, +% \int_gset_regex_count:NNn, \int_gset_regex_count:cNn, +% } +% \begin{syntax} +% \cs{int_set_regex_count:Nnn} \meta{integer} \Arg{regex} \Arg{token list} +% \cs{int_set_regex_count:NNn} \meta{integer} \meta{regex~var} \Arg{token list} +% \end{syntax} +% Sets \meta{integer} equal to the number of times +% \meta{regular expression} appears in \meta{token list}. +% The search starts by finding the left-most longest match, +% respecting greedy and lazy (non-greedy) operators. Then the search +% starts again from the character following the last character +% of the previous match, until reaching the end of the token list. +% Infinite loops are prevented in the case where the regular expression +% can match an empty token list: then we count one match between each +% pair of characters. +% For instance, +% \begin{verbatim} +% \int_set_regex_count:Nnn \l_foo_int { (b+|c) } { abbababcbb } +% \end{verbatim} +% results in \cs[no-index]{l_foo_int} taking the value $5$. +% Theses are alternative names for \cs{regex_count:nnN} and friends, +% with arguments re-ordered for \meta{integer} setting; +% see \pkg{l3regex} chapter for more details of the \meta{regex} +% format. +% \end{function} +% % \begin{function}[updated = 2011-10-22] % {\int_sub:Nn, \int_sub:cn, \int_gsub:Nn, \int_gsub:cn} % \begin{syntax} @@ -426,7 +445,8 @@ % \end{syntax} % This function evaluates the \meta{test int expr} and % compares this in turn to each of the -% \meta{int expr cases}. If the two are equal then the +% \meta{int expr case}s until a match is found. +% If the two are equal then the % associated \meta{code} is left in the input stream % and other cases are discarded. If any of the % cases are matched, the \meta{true code} is also inserted into the @@ -445,6 +465,10 @@ % { No idea! } % \end{verbatim} % leaves \enquote{\texttt{Medium}} in the input stream. +% Since evaluation of the test expressions stops at the first +% successful case, the order of possible matches should normally +% be that the most likely are earlier: this will reduce the average +% steps required to complete expansion. % \end{function} % % \begin{function}[EXP,pTF]{\int_if_even:n, \int_if_odd:n} @@ -605,6 +629,32 @@ % $1$. These functions are provided as simple short-cuts for code clarity. % \end{function} % +% \begin{function}[added = 2025-01-13, rEXP] +% {\int_step_tokens:nn, \int_step_tokens:nnn, \int_step_tokens:nnnn} +% \begin{syntax} +% \cs{int_step_tokens:nn} \Arg{final value} \Arg{code} +% \cs{int_step_tokens:nnn} \Arg{initial value} \Arg{final value} \Arg{code} +% \cs{int_step_tokens:nnnn} \Arg{initial value} \Arg{step} \Arg{final value} \Arg{code} +% \end{syntax} +% This function works just like \cs{int_step_function:nnnN} but +% instead of mapping a single function to each stepped \meta{value} +% between \meta{initial value} and \meta{final value} this maps +% the multiple tokens in \meta{code}, so that it gets the current +% \meta{value} as a braced argument following it. For instance +% \begin{verbatim} +% \cs_set:Npn \my_product:nn #1#2 +% { $#1 \times #2 = \int_eval:n { #1 * #2 }$ \quad } +% \int_step_tokens:nnnn { 1 } { 1 } { 4 } { \my_product:nn { 2 } } +% \end{verbatim} +% would print +% \begin{quote} +% $2 \times 1 = 2$ \quad +% $2 \times 2 = 4$ \quad +% $2 \times 3 = 6$ \quad +% $2 \times 4 = 8$ \quad +% \end{quote} +% \end{function} +% % \begin{function}[added = 2012-06-04, updated = 2018-04-22] % {\int_step_inline:nn, \int_step_inline:nnn, \int_step_inline:nnnn} % \begin{syntax} @@ -1132,6 +1182,13 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\@@_sep:} +% See comments in \texttt{l3fp-aux.dtx} for this idea. +% \begin{macrocode} +\cs_new_eq:NN \@@_sep: \tex_right:D +% \end{macrocode} +% \end{macro} +% % \begin{macro}[EXP]{\int_sign:n, \@@_sign:Nw} % See \cs{int_abs:n}. Evaluate the expression once (and when % debugging is enabled, check that the expression is well-formed), @@ -1143,10 +1200,10 @@ \cs_new:Npn \int_sign:n #1 { \int_value:w \exp_after:wN \@@_sign:Nw - \int_value:w \@@_eval:w #1 \@@_eval_end: ; + \int_value:w \@@_eval:w #1 \@@_eval_end: \@@_sep: \exp_stop_f: } -\cs_new:Npn \@@_sign:Nw #1#2 ; +\cs_new:Npn \@@_sign:Nw #1#2 \@@_sep: { \if_meaning:w 0 #1 0 @@ -1180,20 +1237,20 @@ \cs_new:Npn \int_max:nn #1#2 { \int_value:w \exp_after:wN \@@_maxmin:wwN - \int_value:w \@@_eval:w #1 \exp_after:wN ; - \int_value:w \@@_eval:w #2 ; + \int_value:w \@@_eval:w #1 \exp_after:wN \@@_sep: + \int_value:w \@@_eval:w #2 \@@_sep: > \exp_stop_f: } \cs_new:Npn \int_min:nn #1#2 { \int_value:w \exp_after:wN \@@_maxmin:wwN - \int_value:w \@@_eval:w #1 \exp_after:wN ; - \int_value:w \@@_eval:w #2 ; + \int_value:w \@@_eval:w #1 \exp_after:wN \@@_sep: + \int_value:w \@@_eval:w #2 \@@_sep: < \exp_stop_f: } -\cs_new:Npn \@@_maxmin:wwN #1 ; #2 ; #3 +\cs_new:Npn \@@_maxmin:wwN #1 \@@_sep: #2 \@@_sep: #3 { \if_int_compare:w #1 #3 #2 ~ #1 @@ -1233,11 +1290,11 @@ { \int_value:w \@@_eval:w \exp_after:wN \@@_div_truncate:NwNw - \int_value:w \@@_eval:w #1 \exp_after:wN ; - \int_value:w \@@_eval:w #2 ; + \int_value:w \@@_eval:w #1 \exp_after:wN \@@_sep: + \int_value:w \@@_eval:w #2 \@@_sep: \@@_eval_end: } -\cs_new:Npn \@@_div_truncate:NwNw #1#2; #3#4; +\cs_new:Npn \@@_div_truncate:NwNw #1#2 \@@_sep: #3#4 \@@_sep: { \if_meaning:w 0 #1 0 @@ -1261,12 +1318,12 @@ \cs_new:Npn \int_mod:nn #1#2 { \int_value:w \@@_eval:w \exp_after:wN \@@_mod:ww - \int_value:w \@@_eval:w #1 \exp_after:wN ; - \int_value:w \@@_eval:w #2 ; + \int_value:w \@@_eval:w #1 \exp_after:wN \@@_sep: + \int_value:w \@@_eval:w #2 \@@_sep: \@@_eval_end: } -\cs_new:Npn \@@_mod:ww #1; #2; - { #1 - ( \@@_div_truncate:NwNw #1 ; #2 ; ) * #2 } +\cs_new:Npn \@@_mod:ww #1 \@@_sep: #2 \@@_sep: + { #1 - ( \@@_div_truncate:NwNw #1 \@@_sep: #2 \@@_sep: ) * #2 } % \end{macrocode} % \end{macro} % \end{macro} @@ -1483,9 +1540,9 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\int_set:Nn, \int_set:cn} +% \begin{macro}{\int_set:Nn, \int_set:cn, \int_set:NV, \int_set:cV} % \UnitTested -% \begin{macro}{\int_gset:Nn, \int_gset:cn} +% \begin{macro}{\int_gset:Nn, \int_gset:cn, \int_gset:NV, \int_gset:cV} % \UnitTested % As integers are register-based \TeX{} issues an error % if they are not defined. While the |=| sign is optional, this @@ -1496,8 +1553,47 @@ { #1 = \@@_eval:w #2 \@@_eval_end: } \cs_new_protected:Npn \int_gset:Nn #1#2 { \tex_global:D #1 = \@@_eval:w #2 \@@_eval_end: } -\cs_generate_variant:Nn \int_set:Nn { c } -\cs_generate_variant:Nn \int_gset:Nn { c } +\cs_generate_variant:Nn \int_set:Nn { NV , c , cV } +\cs_generate_variant:Nn \int_gset:Nn { NV , c , cV } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { +% \int_set_regex_count:Nnn, \int_set_regex_count:cnn, +% \int_gset_regex_count:Nnn, \int_gset_regex_count:cnn +% } +% \begin{macro} +% { +% \int_set_regex_count:NNn, \int_set_regex_count:cNn, +% \int_gset_regex_count:NNn, \int_set_gregex_count:cNn +% } +% \begin{macrocode} +\cs_new_protected:Npn \int_set_regex_count:Nnn #1#2#3 + { \regex_count:nnN {#2} {#3} #1 } +\cs_generate_variant:Nn \int_set_regex_count:Nnn { c } +\cs_new_protected:Npn \int_gset_regex_count:Nnn #1#2#3 + { + \group_begin: + \int_set_eq:NN \l_@@_internal_a_int #1 + \regex_count:nnN {#2} {#3} \l_@@_internal_a_int + \int_gset_eq:NN #1 \l_@@_internal_a_int + \group_end: + } +\cs_generate_variant:Nn \int_gset_regex_count:Nnn { c } +\cs_new_protected:Npn \int_set_regex_count:NNn #1#2#3 + { \regex_count:NnN #2 {#3} #1 } +\cs_generate_variant:Nn \int_set_regex_count:Nnn { c } +\cs_new_protected:Npn \int_gset_regex_count:NNn #1#2#3 + { + \group_begin: + \int_set_eq:NN \l_@@_internal_a_int #1 + \regex_count:NnN #2 {#3} \l_@@_internal_a_int + \int_gset_eq:NN #1 \l_@@_internal_a_int + \group_end: + } +\cs_generate_variant:Nn \int_gset_regex_count:NNn { c } % \end{macrocode} % \end{macro} % \end{macro} @@ -1881,7 +1977,7 @@ % \subsection{Integer step functions} % % \begin{macro}{\int_step_function:nnnN} -% \begin{macro}{\@@_step:wwwN, \@@_step:NwnnN} +% \begin{macro}{\@@_step:w, \@@_step:Nw} % \begin{macro}{\int_step_function:nN} % \begin{macro}{\int_step_function:nnN} % Before all else, evaluate the initial value, step, and final value. @@ -1889,51 +1985,70 @@ % of the steps. After that, do the function for the start value then % step and loop around. It would be more symmetrical to test for a % step size of zero before checking the sign, but we optimize for the -% most frequent case (positive step). +% most frequent case (positive step). And since when we're doing the +% test the step size is the result of \cs{@@_eval:w} we know that only +% the value $0$ has a leading token |0| which we can use for a faster +% test than \cs{int_compare:nNnTF}. % \begin{macrocode} \cs_new:Npn \int_step_function:nnnN #1#2#3 { - \exp_after:wN \@@_step:wwwN - \int_value:w \@@_eval:w #1 \exp_after:wN ; - \int_value:w \@@_eval:w #2 \exp_after:wN ; - \int_value:w \@@_eval:w #3 ; + \exp_after:wN \@@_step:w + \int_value:w \@@_eval:w #1 \exp_after:wN \@@_sep: + \int_value:w \@@_eval:w #2 \exp_after:wN \@@_sep: + \int_value:w \@@_eval:w #3 \@@_sep: } -\cs_new:Npn \@@_step:wwwN #1; #2; #3; #4 +\cs_new:Npn \@@_step:w #1 \@@_sep: #2 \@@_sep: #3 \@@_sep: #4 { \int_compare:nNnTF {#2} > \c_zero_int - { \@@_step:NwnnN > } + { \@@_step:Nw > } { - \int_compare:nNnTF {#2} = \c_zero_int + \if_meaning:w 0 #2 + \exp_after:wN \use_ii:nn + \fi: + \use_none:n { \msg_expandable_error:nnn { kernel } { zero-step } {#4} \prg_break: } - { \@@_step:NwnnN < } + \@@_step:Nw < } - #1 ; {#2} {#3} #4 + #1 \@@_sep: {#2} {#3} {#4} \prg_break_point: } -\cs_new:Npn \@@_step:NwnnN #1#2 ; #3#4#5 +\cs_new:Npn \@@_step:Nw #1#2 \@@_sep: #3#4#5 { \if_int_compare:w #2 #1 #4 \exp_stop_f: \prg_break:n \fi: #5 {#2} - \exp_after:wN \@@_step:NwnnN + \exp_after:wN \@@_step:Nw \exp_after:wN #1 - \int_value:w \@@_eval:w #2 + #3 ; {#3} {#4} #5 + \int_value:w \@@_eval:w #2 + #3 \@@_sep: {#3} {#4} {#5} } \cs_new:Npn \int_step_function:nN - { \int_step_function:nnnN { 1 } { 1 } } + { \int_step_function:nnnN \c_one_int \c_one_int } \cs_new:Npn \int_step_function:nnN #1 - { \int_step_function:nnnN {#1} { 1 } } + { \int_step_function:nnnN {#1} \c_one_int } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % +% \begin{macro} +% {\int_step_tokens:nn, \int_step_tokens:nnn, \int_step_tokens:nnnn} +% Because the internals \cs{@@_step:wwwn} and \cs{@@_step:Nwnnn} are +% defined in such a way that they work with both a single token or a +% braced group of tokens these are really the same as the |function| +% variants. +% \begin{macrocode} +\cs_new_eq:NN \int_step_tokens:nn \int_step_function:nN +\cs_new_eq:NN \int_step_tokens:nnn \int_step_function:nnN +\cs_new_eq:NN \int_step_tokens:nnnn \int_step_function:nnnN +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\int_step_inline:nn, \int_step_inline:nnn, \int_step_inline:nnnn} % \begin{macro}{\int_step_variable:nNn, \int_step_variable:nnNn, \int_step_variable:nnnNn} % \UnitTested diff --git a/macros/latex/required/l3kernel/l3intarray.dtx b/macros/latex/required/l3kernel/l3intarray.dtx index aa49275e78..94b979956f 100644 --- a/macros/latex/required/l3kernel/l3intarray.dtx +++ b/macros/latex/required/l3kernel/l3intarray.dtx @@ -2,7 +2,7 @@ % %% File: l3intarray.dtx % -% Copyright (C) 2017-2024 The LaTeX Project +% Copyright (C) 2017-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -79,7 +79,7 @@ % \begin{function}[added = 2018-05-04] % {\intarray_const_from_clist:Nn, \intarray_const_from_clist:cn} % \begin{syntax} -% \cs{intarray_const_from_clist:Nn} \meta{intarray~var} \meta{int expr clist} +% \cs{intarray_const_from_clist:Nn} \meta{intarray~var} \Arg{int expr clist} % \end{syntax} % Creates a new constant \meta{integer array variable} or raises an % error if the name is already taken. The \meta{integer array diff --git a/macros/latex/required/l3kernel/l3kernel-functions.dtx b/macros/latex/required/l3kernel/l3kernel-functions.dtx index c3bb838acf..7d38f4a22e 100644 --- a/macros/latex/required/l3kernel/l3kernel-functions.dtx +++ b/macros/latex/required/l3kernel/l3kernel-functions.dtx @@ -2,7 +2,7 @@ % %% File: l3kernel-functions.dtx % -% Copyright (C) 2018-2024 The LaTeX Project +% Copyright (C) 2018-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3keys.dtx b/macros/latex/required/l3kernel/l3keys.dtx index 13772d1781..93c08eb9fa 100644 --- a/macros/latex/required/l3kernel/l3keys.dtx +++ b/macros/latex/required/l3kernel/l3keys.dtx @@ -2,7 +2,7 @@ % %% File: l3keys.dtx % -% Copyright (C) 2006-2024 The LaTeX Project +% Copyright (C) 2006-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -184,12 +184,13 @@ % \begin{function}[updated = 2013-07-08] % {.bool_set:N, .bool_set:c, .bool_gset:N, .bool_gset:c} % \begin{syntax} -% \meta{key} .bool_set:N = \meta{boolean variable} +% \meta{key} .bool_set:N = \meta{boolean} % \end{syntax} -% Defines \meta{key} to set \meta{boolean variable} to \meta{value} (which -% must be either \enquote{\texttt{true}} or \enquote{\texttt{false}}). If the variable -% does not exist, it will be created globally at the point that -% the key is set up. +% Defines \meta{key} to set \meta{boolean} to \meta{value}. If the +% \meta{value} is given, it must be one either \enquote{\texttt{true}} or +% \enquote{\texttt{false}}); it may be omitted, which is equivalent to +% \texttt{true}. If the variable does not exist, it will be created globally +% at the point that the key is set up. % \end{function} % % \begin{function}[added = 2011-08-28, updated = 2013-07-08] @@ -198,12 +199,12 @@ % .bool_gset_inverse:N, .bool_gset_inverse:c % } % \begin{syntax} -% \meta{key} .bool_set_inverse:N = \meta{boolean variable} +% \meta{key} .bool_set_inverse:N = \meta{boolean} % \end{syntax} -% Defines \meta{key} to set \meta{boolean variable} to the logical +% Defines \meta{key} to set \meta{boolean} to the logical % inverse of \meta{value} (which must be either \enquote{\texttt{true}} or % \enquote{\texttt{false}}). -% If the \meta{boolean variable} does not exist, it will be created globally +% If the \meta{boolean} does not exist, it will be created globally % at the point that the key is set up. % \end{function} % @@ -310,9 +311,9 @@ % \begin{function}[updated = 2020-01-17] % {.fp_set:N, .fp_set:c, .fp_gset:N, .fp_gset:c} % \begin{syntax} -% \meta{key} .fp_set:N = \meta{floating point} +% \meta{key} .fp_set:N = \meta{fp var} % \end{syntax} -% Defines \meta{key} to set \meta{floating point} to \meta{value} +% Defines \meta{key} to set \meta{fp var} to \meta{value} % (which must a floating point expression). If the variable does not exist, % it is created globally at the point that the key is set up. The key will % require a value at point-of-use unless a default is set. @@ -367,7 +368,7 @@ % \meta{key} .initial:n = \Arg{value} % \end{syntax} % Initialises the \meta{key} with the \meta{value}, equivalent to -% \begin{quote} +% \begin{quote}\ttfamily % \cs{keys_set:nn} \Arg{module} \{ \meta{key} = \meta{value} \} % \end{quote} % \end{function} @@ -500,9 +501,9 @@ % % \begin{function}{.tl_set:N, .tl_set:c, .tl_gset:N, .tl_gset:c} % \begin{syntax} -% \meta{key} .tl_set:N = \meta{token list variable} +% \meta{key} .tl_set:N = \meta{tl~var} % \end{syntax} -% Defines \meta{key} to set \meta{token list variable} to \meta{value}. +% Defines \meta{key} to set \meta{tl~var} to \meta{value}. % If the variable does not exist, it is created globally % at the point that the key is set up. % \end{function} @@ -510,9 +511,9 @@ % \begin{function}[added = 2023-09-18] % {.tl_set_e:N, .tl_set_e:c, .tl_gset_e:N, .tl_gset_e:c} % \begin{syntax} -% \meta{key} .tl_set_e:N = \meta{token list variable} +% \meta{key} .tl_set_e:N = \meta{tl~var} % \end{syntax} -% Defines \meta{key} to set \meta{token list variable} to \meta{value}, +% Defines \meta{key} to set \meta{tl~var} to \meta{value}, % which will be subjected to an \texttt{e}-type expansion % (\emph{i.e.}~using \cs{tl_set:Ne}). If the variable does not exist, % it is created globally at the point that the key is set up. @@ -649,15 +650,13 @@ % { key } % Name of choice key % { choice-a , choice-b , choice-c } % Valid choices % { \exp_not:n {#1} } % Invalid choice given -% % -% % % } % \end{verbatim} % % Multiple choices are created in a very similar manner to mutually-exclusive % choices, using the properties \texttt{.multichoice:} and % \texttt{.multichoices:nn}. As with mutually exclusive choices, multiple -% choices are define as sub-keys. Thus both +% choices are defined as sub-keys. Thus both % \begin{verbatim} % \keys_define:nn { mymodule } % { @@ -923,7 +922,7 @@ % The correct list is returned by nested calls. % \end{function} % -% \section{Digesting keys} +% \section{Precompiling keys} % % \begin{function}[added = 2022-03-09]{\keys_precompile:nnN} % \begin{syntax} @@ -933,6 +932,14 @@ % resulting code for those which set variables or functions into the % \meta{tl~var}. Thus this function \enquote{precompiles} the keyval list into % a set of results which can be applied rapidly. +% +% It is important to note that when precompiling keys, no expansion of variables +% takes place. This means that any key setting which simply stores variable names, +% rather than variable values, may not work correctly. Most notably, any +% key setting which uses key status variables (\cs{l_keys_key_str}, etc.) +% will yield unpredictable outcomes. As such, keys +% intended to be precompiled should fully expand any values at the point of +% setting. % \end{function} % % \section{Utility functions for keys} @@ -1804,25 +1811,34 @@ % \subsection{The key defining mechanism} % % \begin{macro}{\keys_define:nn, \keys_define:ne, \keys_define:nx} -% \begin{macro}{\@@_define:nnn, \@@_define:onn} % The public function for definitions is just a wrapper for the lower % level mechanism, more or less. The outer function is designed to % keep a track of the current module, to allow safe nesting. The module is set % removing any leading |/| (which is not needed here). % \begin{macrocode} -\cs_new_protected:Npn \keys_define:nn - { \@@_define:onn \l_@@_module_str } -\cs_generate_variant:Nn \keys_define:nn { ne , nx } -\cs_new_protected:Npn \@@_define:nnn #1#2#3 +\cs_new_protected:Npn \keys_define:nn #1#2 { - \str_set:Ne \l_@@_module_str { \@@_trim_spaces:n {#2} } - \keyval_parse:NNn \@@_define:n \@@_define:nn {#3} - \str_set:Nn \l_@@_module_str {#1} + \use:e + { + \exp_not:n + { + \str_set:Ne \l_@@_module_str { \@@_trim_spaces:n {#1} } + \keyval_parse:NNn \@@_define:n \@@_define:nn {#2} + } + \@@_reset_var:N \l_@@_module_str + \@@_reset_var:N \l_@@_inherit_str + \@@_reset_var:N \l_keys_choice_tl + \@@_reset_var:N \l_keys_key_tl + \@@_reset_var:N \l_keys_key_str + \@@_reset_var:N \l_keys_path_tl + \@@_reset_var:N \l_keys_path_str + \@@_reset_var:N \l_keys_value_tl + \int_set:Nn \l_keys_choice_int { \int_use:N \l_keys_choice_int } + } } -\cs_generate_variant:Nn \@@_define:nnn { o } +\cs_generate_variant:Nn \keys_define:nn { ne , nx } % \end{macrocode} % \end{macro} -% \end{macro} % % \begin{macro}{\@@_define:n} % \begin{macro}{\@@_define:nn} @@ -1926,19 +1942,21 @@ % \end{macro} % % \begin{macro}{\@@_define_code:n} +% \begin{macro}[EXP]{\@@_define_code:nnn} % \begin{macro}[EXP]{\@@_define_code:w} % Two possible cases. If there is a value for the key, then just use % the function. If not, then a check to make sure there is no need for % a value with the property. If there should be one then complain, -% otherwise execute it. There is no need to check for a |:| as if it -% was missing the earlier tests would have failed. +% otherwise execute it. For a \LaTeXe{} property like |.code| which +% doesn't contain a |:|, treat it as having arity 1 and pass the +% (empty) value to it. % \begin{macrocode} \cs_new_protected:Npn \@@_define_code:n #1 { \bool_if:NTF \l_@@_no_value_bool { - \exp_after:wN \@@_define_code:w - \l_@@_property_str \s_@@_stop + \@@_define_code:nnn + { \use:c { \c_@@_props_root_str \l_@@_property_str } {#1} } { \use:c { \c_@@_props_root_str \l_@@_property_str } } { \msg_error:nnee { keys } { property-requires-value } @@ -1947,12 +1965,31 @@ } { \use:c { \c_@@_props_root_str \l_@@_property_str } {#1} } } -\exp_last_unbraced:NNNNo - \cs_new:Npn \@@_define_code:w #1 \c_colon_str #2 \s_@@_stop - { \tl_if_empty:nTF {#2} } +\cs_new:Npe \@@_define_code:nnn + { + \exp_not:N \exp_after:wN \exp_not:N \@@_define_code:w + \exp_not:N \l_@@_property_str + \c_colon_str \c_colon_str + \exp_not:N \s_@@_stop + } +\use:e + { + \cs_new:Npn \exp_not:N \@@_define_code:w + #1 \c_colon_str #2 \c_colon_str #3 \exp_not:N \s_@@_stop + } + { + \tl_if_empty:nTF {#3} + { \use_i:nnn } + { + \tl_if_empty:nTF {#2} + { \use_ii:nnn } + { \use_iii:nnn } + } + } % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} % % \subsection{Turning properties into actions} % @@ -2221,14 +2258,8 @@ % function is used here as a meta key should respect the prevailing % filtering, etc. % \begin{macrocode} -\cs_new_protected:Npn \@@_meta_make:n #1 - { - \exp_args:NVo \@@_cmd_set_direct:nn \l_keys_path_str - { - \exp_after:wN \@@_set:nn \exp_after:wN - { \l_@@_module_str } {#1} - } - } +\cs_new_protected:Npn \@@_meta_make:n + { \exp_args:NV \@@_meta_make:nn \l_@@_module_str } \cs_new_protected:Npn \@@_meta_make:nn #1#2 { \exp_args:NV \@@_cmd_set_direct:nn @@ -2813,7 +2844,6 @@ % \subsection{Setting keys} % % \begin{macro}{\@@_set:nnnnNn} -% \begin{macro}{\@@_set:nnnnnnnNn} % \begin{macro}[EXP]{\@@_reset_bool:N, \@@_reset_var:N} % \begin{macro}{\@@_set:nn} % \begin{macro}{\@@_set:nnn} @@ -2830,33 +2860,34 @@ % \item The code to set up the correct selection approach % \end{enumerate} % \begin{macrocode} -\cs_new_protected:Npn \@@_set:nnnnNn - { - \exp_args:Nooo \@@_set:nnnnnnnNn - \l_@@_unused_clist - \l_@@_selective_clist - \l_@@_relative_tl - } -\cs_new_protected:Npn \@@_set:nnnnnnnNn #1#2#3#4#5#6#7#8#9 +\cs_new_protected:Npn \@@_set:nnnnNn #1#2#3#4#5#6 { - \clist_clear:N \l_@@_unused_clist - \clist_set:Ne \l_@@_selective_clist { \tl_to_str:n {#5} } - \tl_set:Nn \l_@@_relative_tl {#7} \use:e { \exp_not:n { - #9 - \@@_set:nn {#4} {#6} + \clist_clear:N \l_@@_unused_clist + \clist_set:Ne \l_@@_selective_clist { \tl_to_str:n {#2} } + \tl_set:Nn \l_@@_relative_tl {#4} + #6 + \@@_set:nn {#1} {#3} + \clist_set_eq:NN #5 \l_@@_unused_clist } \@@_reset_bool:N \l_@@_only_known_bool \@@_reset_bool:N \l_@@_exclude_bool \@@_reset_bool:N \l_@@_selective_bool + \@@_reset_var:N \l_@@_unused_clist + \@@_reset_var:N \l_@@_selective_clist + \@@_reset_var:N \l_@@_relative_tl + \@@_reset_var:N \l_@@_inherit_str + \@@_reset_var:N \l_keys_choice_tl + \@@_reset_var:N \l_keys_key_tl + \@@_reset_var:N \l_keys_key_str + \@@_reset_var:N \l_keys_path_tl + \@@_reset_var:N \l_keys_path_str + \@@_reset_var:N \l_keys_value_tl + \int_set:Nn \l_keys_choice_int { \int_use:N \l_keys_choice_int } } - \clist_set_eq:NN #8 \l_@@_unused_clist - \__kernel_tl_set:Nx \l_@@_unused_clist { \exp_not:n {#1} } - \__kernel_tl_set:Nx \l_@@_selective_clist {#2} - \__kernel_tl_set:Nx \l_@@_relative_tl { \exp_not:n {#3} } } \cs_new:Npn \@@_reset_bool:N #1 { @@ -2864,6 +2895,12 @@ { bool_set_ \bool_if:NTF #1 { true } { false } :N } \exp_not:N #1 } +\cs_new:Npn \@@_reset_var:N #1 + { + \exp_not:n + { \__kernel_tl_set:Nx #1 } + { \exp_not:N \exp_not:n { \exp_not:o { #1 } } } + } \cs_new_protected:Npn \@@_set:nn #1#2 { \exp_args:No \@@_set:nnn \l_@@_module_str {#1} {#2} } \cs_new_protected:Npn \@@_set:nnn #1#2#3 @@ -2877,7 +2914,6 @@ % \end{macro} % \end{macro} % \end{macro} -% \end{macro} % % \begin{macro} % { diff --git a/macros/latex/required/l3kernel/l3legacy.dtx b/macros/latex/required/l3kernel/l3legacy.dtx index 4cfce5c5f1..1f5d582164 100644 --- a/macros/latex/required/l3kernel/l3legacy.dtx +++ b/macros/latex/required/l3kernel/l3legacy.dtx @@ -2,7 +2,7 @@ % %% File: l3legacy.dtx % -% Copyright (C) 2019-2024 The LaTeX Project +% Copyright (C) 2019-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3luatex.dtx b/macros/latex/required/l3kernel/l3luatex.dtx index eb10d5aecc..0e6f1b5967 100644 --- a/macros/latex/required/l3kernel/l3luatex.dtx +++ b/macros/latex/required/l3kernel/l3luatex.dtx @@ -2,7 +2,7 @@ % %% File: l3luatex.dtx % -% Copyright (C) 2010-2024 The LaTeX Project +% Copyright (C) 2010-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -123,7 +123,7 @@ % % \cs{lua_now:n} passes its \Arg{token list} argument to the Lua interpreter % as a single line, with characters interpreted under the current catcode -% regime. These two facts mean that \cs{lua_now:n} rarely behaves as expected +% régime. These two facts mean that \cs{lua_now:n} rarely behaves as expected % for larger pieces of code. Therefore, package authors should \textbf{not} % write significant amounts of Lua code in the arguments to \cs{lua_now:n}. % Instead, it is strongly recommended that they write the majorty of their Lua @@ -567,7 +567,7 @@ ltxutils.filesize = filesize % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{luadef} +% \begin{macro}[int]{luacmd} % An internal function for defining control sequences form Lua which behave % like primitives. This acts as a wrapper around |token.set_lua| which accepts % a function instead of an index into the functions table. diff --git a/macros/latex/required/l3kernel/l3msg.dtx b/macros/latex/required/l3kernel/l3msg.dtx index e901b07c06..817a77e6e9 100644 --- a/macros/latex/required/l3kernel/l3msg.dtx +++ b/macros/latex/required/l3kernel/l3msg.dtx @@ -2,7 +2,7 @@ % %% File: l3msg.dtx % -% Copyright (C) 2009-2024 The LaTeX Project +% Copyright (C) 2009-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -587,8 +587,8 @@ % \begin{function}[EXP, added = 2017-12-04] % {\msg_show_item:n, \msg_show_item_unbraced:n, \msg_show_item:nn, \msg_show_item_unbraced:nn} % \begin{syntax} -% \cs{seq_map_function:NN} \meta{seq} \cs{msg_show_item:n} -% \cs{prop_map_function:NN} \meta{prop} \cs{msg_show_item:nn} +% \cs{seq_map_function:NN} \meta{seq var} \cs{msg_show_item:n} +% \cs{prop_map_function:NN} \meta{property list} \cs{msg_show_item:nn} % \end{syntax} % Used in the text of messages for \cs{msg_show:nnnnnn} to show or log % a list of items or key--value pairs. The output of @@ -647,7 +647,7 @@ % \end{syntax} % Issues an \enquote{Undefined error} message from \TeX{} itself % using the undefined control sequence \cs{???} then prints -% \enquote{! \meta{module}: }\meta{error message}, which should be +% \enquote{! \meta{module}: \meta{error message}}, which should be % short. With default settings, anything beyond approximately $60$ % characters long (or bytes in some engines) is cropped. A leading % space might be removed as well. @@ -2088,6 +2088,13 @@ } \msg_new:nnn { kernel } { randint-backward-range } { Wrong~order~of~bounds~in~\iow_char:N\\int_rand:nn{#1}{#2}. } +\msg_new:nnnn { kernel } { conditional-base-undefined } + { Undefined~conditional~base~function~'#1'. } + { + \c_@@_coding_error_text_tl + LaTeX~has~been~asked~to~define~a~variant~of~the~conditional~'#1',~ + but~the~latter~is~not~defined. + } \msg_new:nnnn { kernel } { conditional-form-unknown } { Conditional~form~'#1'~for~function~'#2'~unknown. } { diff --git a/macros/latex/required/l3kernel/l3names.dtx b/macros/latex/required/l3kernel/l3names.dtx index 5cdd1361e3..cf38ee9254 100644 --- a/macros/latex/required/l3kernel/l3names.dtx +++ b/macros/latex/required/l3kernel/l3names.dtx @@ -2,7 +2,7 @@ % %% File: l3names.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -580,7 +580,6 @@ \@@_primitive:NN \pdfoutline \tex_pdfoutline:D \@@_primitive:NN \pdfoutput \tex_pdfoutput:D \@@_primitive:NN \pdfpageattr \tex_pdfpageattr:D - \@@_primitive:NN \pdfpagesattr \tex_pdfpagesattr:D \@@_primitive:NN \pdfpagebox \tex_pdfpagebox:D \@@_primitive:NN \pdfpageref \tex_pdfpageref:D \@@_primitive:NN \pdfpageresources \tex_pdfpageresources:D @@ -1242,13 +1241,11 @@ % \end{macrocode} % Primitives from \upTeX{}. % \begin{macrocode} - \@@_primitive:NN \currentcjktoken \tex_currentcjktoken:D \@@_primitive:NN \disablecjktoken \tex_disablecjktoken:D \@@_primitive:NN \enablecjktoken \tex_enablecjktoken:D \@@_primitive:NN \forcecjktoken \tex_forcecjktoken:D \@@_primitive:NN \kchar \tex_kchar:D \@@_primitive:NN \kchardef \tex_kchardef:D - \@@_primitive:NN \kuten \tex_kuten:D \@@_primitive:NN \uptexrevision \tex_uptexrevision:D \@@_primitive:NN \uptexversion \tex_uptexversion:D % \end{macrocode} diff --git a/macros/latex/required/l3kernel/l3news.pdf b/macros/latex/required/l3kernel/l3news.pdf Binary files differindex 4b57ef41c8..90e97abb8c 100644 --- a/macros/latex/required/l3kernel/l3news.pdf +++ b/macros/latex/required/l3kernel/l3news.pdf diff --git a/macros/latex/required/l3kernel/l3news01.pdf b/macros/latex/required/l3kernel/l3news01.pdf Binary files differindex b5f45059d3..24a6038dff 100644 --- a/macros/latex/required/l3kernel/l3news01.pdf +++ b/macros/latex/required/l3kernel/l3news01.pdf diff --git a/macros/latex/required/l3kernel/l3news02.pdf b/macros/latex/required/l3kernel/l3news02.pdf Binary files differindex 0ee8ffaf96..e35d0495e9 100644 --- a/macros/latex/required/l3kernel/l3news02.pdf +++ b/macros/latex/required/l3kernel/l3news02.pdf diff --git a/macros/latex/required/l3kernel/l3news03.pdf b/macros/latex/required/l3kernel/l3news03.pdf Binary files differindex fef9bf3a7b..51c23305ec 100644 --- a/macros/latex/required/l3kernel/l3news03.pdf +++ b/macros/latex/required/l3kernel/l3news03.pdf diff --git a/macros/latex/required/l3kernel/l3news04.pdf b/macros/latex/required/l3kernel/l3news04.pdf Binary files differindex 0afbb9591e..01050ed2cc 100644 --- a/macros/latex/required/l3kernel/l3news04.pdf +++ b/macros/latex/required/l3kernel/l3news04.pdf diff --git a/macros/latex/required/l3kernel/l3news05.pdf b/macros/latex/required/l3kernel/l3news05.pdf Binary files differindex 0a44ce6811..c295db48c4 100644 --- a/macros/latex/required/l3kernel/l3news05.pdf +++ b/macros/latex/required/l3kernel/l3news05.pdf diff --git a/macros/latex/required/l3kernel/l3news06.pdf b/macros/latex/required/l3kernel/l3news06.pdf Binary files differindex 10cec7c17f..450c5723af 100644 --- a/macros/latex/required/l3kernel/l3news06.pdf +++ b/macros/latex/required/l3kernel/l3news06.pdf diff --git a/macros/latex/required/l3kernel/l3news07.pdf b/macros/latex/required/l3kernel/l3news07.pdf Binary files differindex 6bfbab4d96..3623d0b448 100644 --- a/macros/latex/required/l3kernel/l3news07.pdf +++ b/macros/latex/required/l3kernel/l3news07.pdf diff --git a/macros/latex/required/l3kernel/l3news08.pdf b/macros/latex/required/l3kernel/l3news08.pdf Binary files differindex a0130195cc..0d1d6a7c34 100644 --- a/macros/latex/required/l3kernel/l3news08.pdf +++ b/macros/latex/required/l3kernel/l3news08.pdf diff --git a/macros/latex/required/l3kernel/l3news09.pdf b/macros/latex/required/l3kernel/l3news09.pdf Binary files differindex 3616cc20ca..1eae2c2e0b 100644 --- a/macros/latex/required/l3kernel/l3news09.pdf +++ b/macros/latex/required/l3kernel/l3news09.pdf diff --git a/macros/latex/required/l3kernel/l3news10.pdf b/macros/latex/required/l3kernel/l3news10.pdf Binary files differindex 00ec553d1c..7f2062d1a6 100644 --- a/macros/latex/required/l3kernel/l3news10.pdf +++ b/macros/latex/required/l3kernel/l3news10.pdf diff --git a/macros/latex/required/l3kernel/l3news11.pdf b/macros/latex/required/l3kernel/l3news11.pdf Binary files differindex 59a672d339..4f37af5b83 100644 --- a/macros/latex/required/l3kernel/l3news11.pdf +++ b/macros/latex/required/l3kernel/l3news11.pdf diff --git a/macros/latex/required/l3kernel/l3news12.pdf b/macros/latex/required/l3kernel/l3news12.pdf Binary files differindex 9c4f937b00..ad15f9c674 100644 --- a/macros/latex/required/l3kernel/l3news12.pdf +++ b/macros/latex/required/l3kernel/l3news12.pdf diff --git a/macros/latex/required/l3kernel/l3pdf.dtx b/macros/latex/required/l3kernel/l3pdf.dtx index 55f49476e3..b9f18324ef 100644 --- a/macros/latex/required/l3kernel/l3pdf.dtx +++ b/macros/latex/required/l3kernel/l3pdf.dtx @@ -2,7 +2,7 @@ % %% File: l3pdf.dtx % -% Copyright(C) 2019-2024 The LaTeX Project +% Copyright(C) 2019-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -70,8 +70,8 @@ % \cs{pdf_object_write:nnn} \Arg{object} \Arg{type} \Arg{content} % \end{syntax} % Writes the \meta{content} as content of the \meta{object}. Depending on the -% \meta{type} declared for the object, the format required for the -% \meta{data} will vary +% \meta{type} declared for the object, the format required for +% \meta{content} will vary: % \begin{itemize} % \item[\texttt{array}] A space-separated list of values % \item[\texttt{dict}] Key--value pairs in the form @@ -112,7 +112,7 @@ % % \begin{function}[added = 2024-04-01]{\pdf_object_new_indexed:nn} % \begin{syntax} -% \cs{pdf_object_new_indexed:nn} \Arg{class} \Arg{index} +% \cs{pdf_object_new_indexed:nn} \Arg{class} \Arg{index} % \end{syntax} % Declares a PDF object of \meta{class} and \meta{index}. The object may be % referenced from this point on, and written later using @@ -122,7 +122,7 @@ % \begin{function}[added = 2024-04-01] % {\pdf_object_write_indexed:nnnn, \pdf_object_write_indexed:nnne} % \begin{syntax} -% \cs{pdf_object_write_indexed:nnnn} \Arg{class} \Arg{index} \Arg{type} \Arg{content} +% \cs{pdf_object_write_indexed:nnnn} \Arg{class} \Arg{index} \Arg{type} \Arg{content} % \end{syntax} % Writes the \meta{content} as content of the object of \meta{class} and % \meta{index}. Depending on the @@ -159,7 +159,7 @@ % \cs{pdf_object_unnamed_write:nn} \Arg{type} \Arg{content} % \end{syntax} % Writes the \meta{content} as content of an anonymous object. Depending on the -% \meta{type}, the format required for the \meta{data} will vary +% \meta{type}, the format required for \meta{content} will vary: % \begin{itemize} % \item[\texttt{array}] A space-separated list of values % \item[\texttt{dict}] Key--value pairs in the form @@ -192,11 +192,11 @@ % % \begin{function}[pTF, EXP, added = 2021-02-10]{\pdf_version_compare:Nn} % \begin{syntax} -% \cs{pdf_version_compare_p:Nn} \meta{comparator} \Arg{version} -% \cs{pdf_version_compare:NnTF} \meta{comparator} \Arg{version} \Arg{true code} \Arg{false code} +% \cs{pdf_version_compare_p:Nn} \meta{relation} \Arg{version} +% \cs{pdf_version_compare:NnTF} \meta{relation} \Arg{version} \Arg{true code} \Arg{false code} % \end{syntax} % Compares the version of the PDF being created with the \meta{version} -% string specified, using the \meta{comparator}. Either the \meta{true code} +% string specified, using the \meta{relation}. Either the \meta{true code} % or \meta{false code} will be left in the output stream. % \end{function} % @@ -251,9 +251,9 @@ % % \section{Destinations} % -% Destinations are the places a link jumped too. -% Unlike the name may suggest they don't described -% an exact location in the PDF. Instead a destination contains a reference to +% Destinations are the places a link jumped to. +% Unlike the name may suggest, they don't describe +% an exact location in the PDF. Instead, a destination contains a reference to % a page along with an instruction how to display this page. % The normally used \enquote{XYZ \textit{top left zoom}} for example instructs % the viewer to show the page with the given \textit{zoom} and diff --git a/macros/latex/required/l3kernel/l3prefixes.csv b/macros/latex/required/l3kernel/l3prefixes.csv index e85412b9d8..4fad000211 100644 --- a/macros/latex/required/l3kernel/l3prefixes.csv +++ b/macros/latex/required/l3kernel/l3prefixes.csv @@ -26,6 +26,7 @@ block,latex2e,The LaTeX Project,https://www.latex-project.org/latex3.html,https: bool,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, box,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, bxjh,BXjaholiday,Takuto Asakura,https://github.com/wtsnjp/BXjaholiday,https://github.com/wtsnjp/BXjaholiday.git,https://github.com/wtsnjp/BXjaholiday/issues,2018-02-02,2019-02-02, +cal,spath3,Andrew Stacey,https://github.com/loopspace/spath3,https://github.com/loopspace/spath3.git,https://github.com/loopspace/spath3/issues,2024-07-18,2024-07-18, cascade,cascade,F. Pantigny,,,,2020-07-21,2020-07-21, catcode,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2018-05-12,2018-05-12, cctab,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-28,2012-09-28, @@ -74,10 +75,12 @@ emoji,emoji,Xiangdong Zeng,https://github.com/stone-zeng/latex-emoji,https://git emojicite,emojicite,Leon Sixt,https://github.com/berleon/emojicite,https://github.com/berleon/emojicite.git,https://github.com/berleon/emojicite/issues/,2020-04-14,2020-04-20, empty,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2018-05-12,2018-05-12, enotez,enotez,Clemens Niederberger,https://github.com/cgnieder/enotez/,https://github.com/cgnieder/enotez.git,https://github.com/cgnieder/enotez/issues,2013-03-16,2020-04-14, +enumext,enumext,Pablo González,https://github.com/pablgonz/enumext,git@github.com:pablgonz/enumext.git,https://github.com/pablgonz/enumext/issues,2024-11-18,2024-11-18, etex,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, etl,etl,Jonathan P. Spratte,https://github.com/Skillmon/ltx_etl,git@github.com:Skillmon/ltx_etl.git,https://github.com/Skillmon/ltx_etl/issues,2021-08-16,2021-08-16, exp,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, expl,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, +expltools,expltools,Vít Starý Novotný,https://github.com/witiko/expltools/,https://github.com/witiko/expltools.git,https://github.com/witiko/expltools/issues,2024-06-26,2024-06-26,Development tools for expl3 programmers exsheets,exsheets,Clemens Niederberger,https://bitbucket.org/cgnieder/exsheets/,git@bitbucket.org:cgnieder/exsheets.git,https://bitbucket.org/cgnieder/exsheets/issues,2013-03-16,2013-03-16, extblx,biblatex-ext,Moritz Wemheuer,https://github.com/moewew/biblatex-ext/,https://github.com/moewew/biblatex-ext.git,https://github.com/moewew/biblatex-ext/issues,2020-02-09,2020-02-09, exwf,exwrapfig,Takuto Asakura,https://github.com/wtsnjp/exwrapfig,https://github.com/wtsnjp/exwrapfig.git,https://github.com/wtsnjp/exwrapfig/issues,2018-06-07,2018-06-07, @@ -132,9 +135,11 @@ job,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https:/ jsonparse,jsonparse,Jasper Habicht,https://github.com/jasperhabicht/jsonparse,https://github.com/jasperhabicht/jsonparse/jsponsparse.git,https://github.com/jasperhabicht/jsonparse/issues,2024-04-14,2024-04-14, kernel,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, keys,"l3kernel,l3keys2e,ltkeys",The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, +keythms,keytheorems,Matthew Bertucci,https://github.com/mbertucci47/keytheorems,https://github.com/mbertucci47/keytheorems,https://github.com/mbertucci47/keytheorems/issues,2024-09-10,2024-09-10, keyval,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, kgl,kantlipsum,Enrico Gregorio,,,,2013-03-16,2013-03-16, kivitendo,"kiviletter, kivitables",Marei Peischl for Kivitendo,https://www.kivitendo.de/,https://github.com/kivitendo/kivitendo-erp,https://forum.kivitendo.de/,2021-05-28,2021-05-28, +knot,spath3,Andrew Stacey,https://github.com/loopspace/spath3,https://github.com/loopspace/spath3.git,https://github.com/loopspace/spath3/issues,2024-07-18,2024-07-18, langsci,langscibook,Language Science Press,https://langsci-press.org,https://github.com/langsci/langscibook,https://github.com/langsci/langscibook/issues,2021-07-20,2021-07-21, left,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2018-05-12,2018-05-12, liftarm,liftarm,Matthias Floré,,,,2024-05-25,2024-05-25, @@ -160,6 +165,7 @@ minibox,minibox,Will Robertson,,https://github.com/wspr/will2e.git,https://githu minus,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2018-05-12,2018-05-12, mix,media9,Alexander Grahn,,https://gitlab.com/agrahn/media9,https://gitlab.com/agrahn/media9/issues,2013-01-18,2020-04-15, mode,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, +moremath,moremath,Marcel Ilg,https://github.com/Mister00X/moremath,https://github.com/Mister00X/moremath.git,https://github.com/Mister00X/moremath/issues,2024-07-27,2024-07-27, morewrites,morewrites,Bruno Le Floch,https://github.com/blefloch/latex-morewrites,https://github.com/blefloch/latex-morewrites.git,https://github.com/blefloch/latex-morewrites/issues,2013-03-16,2015-09-22, msg,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, msvg,media4svg,Alexander Grahn,,https://gitlab.com/agrahn/media4svg,https://gitlab.com/agrahn/media4svg/issues,2020-04-15,2020-04-15, @@ -201,6 +207,7 @@ piton,piton,François Pantigny,,,,29/09/2022,29/09/2022, pkgploader,pkgploader,Michiel Helvensteijn,,,,2014-02-05,2014-02-05, platex,platex,Japanese TeX Development Community,https://github.com/texjporg/platex,https://github.com/texjporg/platex.git,https://github.com/texjporg/platex/issues,2020-09-30,2020-09-30, polyglossia,polyglossia,Arthur Reutenauer,https://www.polyglossia.org/,https://github.com/reutenauer/polyglossia,https://github.com/reutenauer/polyglossia/issues,2019-09-03,, +polyomino,polyomino,Matthias Floré,,,,2024-09-05,2024-09-05, postnotes,postnotes,gusbrs,https://github.com/gusbrs/postnotes,https://github.com/gusbrs/postnotes.git,https://github.com/gusbrs/postnotes/issues,2022-04-23,2022-04-23, prelim,prelim2e,Marei Peischl,https://github.com/TeXhackse/prelim2e,https://github.com/TeXhackse/prelim2e.git,https://github.com/TeXhackse/prelim2e/issues,2020-11-24,2020-11-24, prg,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, @@ -210,6 +217,7 @@ property,latex2e,The LaTeX Project,https://www.latex-project.org/latex3.html,htt pseudo,pseudo,Magnus Lie Hetland,https://github.com/mlhetland/pseudo.sty,https://github.com/mlhetland/pseudo.sty.git,https://github.com/mlhetland/pseudo.sty/issues,2019-06-24,2019-06-24, ptex,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2015-07-28,2015-07-28, ptxcd,ptxcd,Marei Peischl,,,,2020-07-27,2020-07-27,Used for specific corporate design templates +ptxtools,"depp, ptxtools",Marei Peischl,https://gitlab.com/islandoftex/texmf/depp,https://gitlab.com/islandoftex/texmf/depp.git,https://gitlab.com/islandoftex/texmf/depp,2024-07-09,2024-07-09, qrbill,qrbill,Marei Peischl,https://github.com/peiTeX/qrbill,https://github.com/peiTeX/qrbill.git,https://github.com/peiTeX/qrbill/issues,2020-06-27,2020-06-27, quark,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, rainbow,beamertheme-rainbow,samcarter,https://github.com/samcarter/beamertheme-rainbow,https://github.com/samcarter/beamertheme-rainbow,https://github.com/samcarter/beamertheme-rainbow/issues,2023-07-04,2023-07-04, @@ -224,6 +232,7 @@ rivbook,rivbook,Julien Rivaud,,,,2018-06-13,2018-06-14, rivmath,rivmath,Julien Rivaud,,,,2018-06-13,2018-06-13, rpgicons,rpgicons,Jasper Habicht,https://github.com/jasperhabicht/rpgicons,https://github.com/jasperhabicht/rpgicons/rpgicons.git,https://github.com/jasperhabicht/rpgicons/issues,2024-04-29,2024-04-29, sanuml,sanitize-umlaut,Thomas F. Sturm,https://github.com/T-F-S/sanitize-umlaut,https://github.com/T-F-S/sanitize-umlaut.git,https://github.com/T-F-S/sanitize-umlaut/issues,2022-07-19,2022-07-19, +scaletextbullet,scaletextbullet,Oliver Beery,https://github.com/beeryoliver/scaletextbullet,https://github.com/beeryoliver/scaletextbullet/scaletextbullet.git,https://github.com/beeryoliver/scaletextbullet/issues,2024-11-15,2024-11-15, scan,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, schulma,schulmathematik,Keno Wehr,https://ctan.org/pkg/schulmathematik,,,2021-08-23,2021-08-23, scontents,scontents,Pablo González,https://github.com/pablgonz/scontents,git@github.com:pablgonz/scontents.git,https://github.com/pablgonz/scontents/issues,2019-12-05,2019-12-05, @@ -239,6 +248,7 @@ slcd,se2thesis,Stephan Lukasczyk,https://github.com/se2p/se2thesis,https://githu socket,latex2e,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex2e.git,https://github.com/latex3/latex2e/issues,2023-10-17,2023-10-17, sort,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2017-02-13, space,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2018-05-12,2018-05-12, +spath,spath3,Andrew Stacey,https://github.com/loopspace/spath3,https://github.com/loopspace/spath3.git,https://github.com/loopspace/spath3/issues,2024-07-18,2024-07-18, starray,starray,Alceu Frigeri,https://github.com/alceu-frigeri/starray,https://github.com/alceu-frigeri/starray,https://github.com/alceu-frigeri/starray/issues,2023-05-15,2023-05-15, statistics,statistics,Julien Rivaud,https://gitlab.com/frnchfrgg-latex/statistics,https://gitlab.com/frnchfrgg-latex/statistics.git,https://gitlab.com/frnchfrgg-latex/statistics/issues,2018-06-25,2018-06-25, stm,lt3-stm,CV Radhakrishnan,http://www.cvr.cc/,,,2014-02-26,2014-02-26, @@ -258,6 +268,7 @@ tex,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https:/ text,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2020-01-15,2020-01-15, tikzfill,tikzfill,Thomas F. Sturm,https://github.com/T-F-S/tikzfill,https://github.com/T-F-S/tikzfill.git,https://github.com/T-F-S/tikzfill/issues,2022-07-19,2022-07-19, tikzlings,tikzlings,samcarter,https://github.com/samcarter/tikzlings,git@github.com:samcarter/tikzlings.git,https://github.com/samcarter/tikzlings/issues,2023-02-17,2023-02-17, +tikzspath,spath3,Andrew Stacey,https://github.com/loopspace/spath3,https://github.com/loopspace/spath3.git,https://github.com/loopspace/spath3/issues,2024-07-18,2024-07-18, tikzsymbols,tikzsymbols,Ben Vitecek,https://github.com/Vidabe/tikzsymbols,https://github.com/Vidabe/tikzsymbols.git,https://github.com/Vidabe/tikzsymbols/issues,2018-09-26,2018-09-26, tilde,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2018-05-12,2018-05-12, tl,"l3kernel,l3tl-build",The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, @@ -288,6 +299,7 @@ xmarks,latex2e,The LaTeX Project,https://www.latex-project.org/latex3.html,https xparse,xparse,The LaTeX Project,https://www.latex-project.org/latex3.html,https://github.com/latex3/latex3.git,https://github.com/latex3/latex3/issues,2012-09-27,2012-09-27, xpatch,"regexpatch,xpatch",Enrico Gregorio,,,,2013-03-16,2013-03-16, xpeek,xpeek,Joel C. Salomon,,,,2013-03-16,2013-03-16, +xpg,polyglossia,Jürgen Spitzmüller,https://github.com/reutenauer/polyglossia/,https://github.com/reutenauer/polyglossia/,https://github.com/reutenauer/polyglossia/issues,2024-07-02,2024-07-02, xpinyin,xpinyin,Qing Lee,https://github.com/CTeX-org/ctex-kit,https://github.com/CTeX-org/ctex-kit.git,https://github.com/CTeX-org/ctex-kit/issues,2013-03-16,2013-05-26, xsb,xsavebox,Alexander Grahn,,https://gitlab.com/agrahn/xsavebox,https://gitlab.com/agrahn/xsavebox/issues,2016-02-26,2020-04-15, xsim,xsim,Clemens Niederberger,https://github.com/cgnieder/xsim/,https://github.com/cgnieder/xsim.git,https://github.com/cgnieder/xsim/issues,2020-04-14,2020-04-14, @@ -299,4 +311,5 @@ zhnum,zhnumber,Qing Lee,https://github.com/CTeX-org/ctex-kit,https://github.com/ zrefcheck,zref-check,gusbrs,https://github.com/gusbrs/zref-check,https://github.com/gusbrs/zref-check,https://github.com/gusbrs/zref-check/issues,2021-08-05,2021-08-05, zrefclever,zref-clever,gusbrs,https://github.com/gusbrs/zref-clever,https://github.com/gusbrs/zref-clever,https://github.com/gusbrs/zref-clever/issues,2021-11-29,2021-11-29, zrefvario,zref-vario,gusbrs,https://github.com/gusbrs/zref-vario,https://github.com/gusbrs/zref-vario,https://github.com/gusbrs/zref-vario/issues,2022-02-02,2022-02-02, +zugferd,zugferd,Marei Peischl,https://github.com/TeXhackse/LaTeX-ZUGFeRD,https://github.com/TeXhackse/LaTeX-ZUGFeRD.git,https://github.com/TeXhackse/LaTeX-ZUGFeRD/issues,2024-07-09,2024-07-09, zxjt,zxjatype,Takayuki Yato,,,,2013-03-16,2013-03-16, diff --git a/macros/latex/required/l3kernel/l3prefixes.pdf b/macros/latex/required/l3kernel/l3prefixes.pdf Binary files differindex 602ccaaa59..4e850cdf38 100644 --- a/macros/latex/required/l3kernel/l3prefixes.pdf +++ b/macros/latex/required/l3kernel/l3prefixes.pdf diff --git a/macros/latex/required/l3kernel/l3prg.dtx b/macros/latex/required/l3kernel/l3prg.dtx index bec4e3a712..01fcec07cf 100644 --- a/macros/latex/required/l3kernel/l3prg.dtx +++ b/macros/latex/required/l3kernel/l3prg.dtx @@ -2,7 +2,7 @@ % %% File: l3prg.dtx % -% Copyright (C) 2005-2024 The LaTeX Project +% Copyright (C) 2005-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -79,41 +79,28 @@ % \begin{function}[updated = 2022-11-01] % { % \prg_new_conditional:Npnn, \prg_set_conditional:Npnn, \prg_gset_conditional:Npnn, -% \prg_new_conditional:Nnn, \prg_set_conditional:Nnn, \prg_gset_conditional:Nnn +% \prg_new_protected_conditional:Npnn, \prg_set_protected_conditional:Npnn, \prg_gset_protected_conditional:Npnn, +% \prg_new_conditional:Nnn, \prg_set_conditional:Nnn, \prg_gset_conditional:Nnn, +% \prg_new_protected_conditional:Nnn, \prg_set_protected_conditional:Nnn, \prg_gset_protected_conditional:Nnn % } % \begin{syntax} % \cs{prg_new_conditional:Npnn} \cs[no-index]{\meta{name}:\meta{arg spec}} \meta{parameters} \Arg{conditions} \Arg{code} \\ % \cs{prg_new_conditional:Nnn} \cs[no-index]{\meta{name}:\meta{arg spec}} \Arg{conditions} \Arg{code} % \end{syntax} % These functions create a family of conditionals using the same -% \Arg{code} to perform the test created. Those conditionals are -% expandable if \meta{code} is. The \texttt{new} versions check +% \meta{code} to perform the test created. Those non-protected +% conditionals are expandable if \meta{code} is. +% The \texttt{new} versions check % for existing definitions and perform assignments globally % (\emph{cf.}~\cs{cs_new:Npn}) whereas the \texttt{set} versions do no % check and perform assignments locally (\emph{cf.}~\cs{cs_set:Npn}). % The conditionals created are dependent on the comma-separated list -% of \meta{conditions}, which should be one or more of \texttt{p}, -% \texttt{T}, \texttt{F} and \texttt{TF}. -% \end{function} -% -% \begin{function}[updated = 2012-02-06] -% { -% \prg_new_protected_conditional:Npnn, \prg_set_protected_conditional:Npnn, \prg_gset_protected_conditional:Npnn, -% \prg_new_protected_conditional:Nnn, \prg_set_protected_conditional:Nnn, \prg_gset_protected_conditional:Nnn -% } -% \begin{syntax} -% \cs{prg_new_protected_conditional:Npnn} \cs[no-index]{\meta{name}:\meta{arg spec}} \meta{parameters} \Arg{conditions} \Arg{code} \\ -% \cs{prg_new_protected_conditional:Nnn} \cs[no-index]{\meta{name}:\meta{arg spec}} \Arg{conditions} \Arg{code} -% \end{syntax} -% These functions create a family of protected conditionals using the -% same \Arg{code} to perform the test created. The \meta{code} does -% not need to be expandable. The \texttt{new} version check for -% existing definitions and perform assignments globally -% (\emph{cf.}~\cs{cs_new:Npn}) whereas the \texttt{set} version do -% not (\emph{cf.}~\cs{cs_set:Npn}). The conditionals created are -% depended on the comma-separated list of \meta{conditions}, which -% should be one or more of \texttt{T}, \texttt{F} and \texttt{TF} (not -% \texttt{p}). +% of \meta{conditions}, which should be one or more of +% \texttt{T}, \texttt{F} and \texttt{TF}, and for non-protected conditionals +% \texttt{p}. +% For public conditionals, a full set of forms should be provided: +% this contrasts with strictly internal conditionals, where only the +% required subset need be defined. % \end{function} % % The conditionals are defined by \cs{prg_new_conditional:Npnn} and @@ -182,7 +169,7 @@ % \prg_gset_eq_conditional:NNn % } % \begin{syntax} -% \cs{prg_new_eq_conditional:NNn} \cs[no-index]{\meta{name_1}:\meta{arg spec_1}} \cs[no-index]{\meta{name_2}:\meta{arg spec_2}} \Arg{conditions} +% \cs{prg_new_eq_conditional:NNn} \cs[no-index]{\meta{name_1}:\meta{arg spec}} \cs[no-index]{\meta{name_2}:\meta{arg spec}} \Arg{conditions} % \end{syntax} % These functions copy a family of conditionals. The \texttt{new} version % checks for existing definitions (\emph{cf.}~\cs{cs_new_eq:NN}) whereas @@ -338,7 +325,7 @@ % {\bool_to_str:N, \bool_to_str:c, \bool_to_str:n} % \begin{syntax} % \cs{bool_to_str:N} \meta{boolean} -% \cs{bool_to_str:n} \meta{boolean expression} +% \cs{bool_to_str:n} \Arg{boolean expression} % \end{syntax} % Expands to the string \texttt{true} or \texttt{false} depending on % the logical truth of the \meta{boolean} or \meta{boolean @@ -664,7 +651,7 @@ % ~~\Arg{true code} % ~~\Arg{false code} % \end{syntax} -% Evaluates in turn each of the \meta{boolean expression cases} until +% Evaluates in turn each of the \meta{boolean expression case}s until % the first one that evaluates to \texttt{true}. % The \meta{code} associated to this first case is left in the input % stream, followed by the \meta{true code}, and other cases are diff --git a/macros/latex/required/l3kernel/l3prop.dtx b/macros/latex/required/l3kernel/l3prop.dtx index 21b8d03dd6..e2dd1f5bff 100644 --- a/macros/latex/required/l3kernel/l3prop.dtx +++ b/macros/latex/required/l3kernel/l3prop.dtx @@ -2,7 +2,7 @@ % %% File: l3prop.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -181,11 +181,11 @@ % \prop_gset_from_keyval:Nn, \prop_gset_from_keyval:cn, % } % \begin{syntax} -% \cs{prop_set_from_keyval:Nn} \meta{property list} -% \{ -% \meta{key1} |=| \meta{value1} |,| -% \meta{key2} |=| \meta{value2} |,| \ldots{} -% \} +% \cs{prop_set_from_keyval:Nn} \meta{property list} \\ +% ~~\{ \\ +% ~~~~\meta{key_1} |=| \meta{value_1} |,| \\ +% ~~~~\meta{key_2} |=| \meta{value_2} |,| \ldots{} \\ +% ~~\} % \end{syntax} % Sets \meta{property list} to contain key--value pairs given in the second % argument. If duplicate keys appear only the last of the values is kept. @@ -205,11 +205,11 @@ % \begin{function}[added = 2017-11-28, updated = 2021-11-07] % {\prop_const_from_keyval:Nn, \prop_const_from_keyval:cn} % \begin{syntax} -% \cs{prop_const_from_keyval:Nn} \meta{property list} -% \{ -% \meta{key1} |=| \meta{value1} |,| -% \meta{key2} |=| \meta{value2} |,| \ldots{} -% \} +% \cs{prop_const_from_keyval:Nn} \meta{property list} \\ +% ~~\{ \\ +% ~~~~\meta{key_1} |=| \meta{value_1} |,| \\ +% ~~~~\meta{key_2} |=| \meta{value_2} |,| \ldots{} \\ +% ~~\} % \end{syntax} % Creates a new constant \enquote{flat} \meta{property list} or raises % an error if the @@ -224,15 +224,15 @@ % \begin{function}[added = 2024-02-12] % {\prop_const_linked_from_keyval:Nn, \prop_const_linked_from_keyval:cn} % \begin{syntax} -% \cs{prop_const_linked_from_keyval:Nn} \meta{prop~var} -% \{ -% \meta{key1} |=| \meta{value1} |,| -% \meta{key2} |=| \meta{value2} |,| \ldots{} -% \} +% \cs{prop_const_linked_from_keyval:Nn} \meta{property list} \\ +% ~~\{ \\ +% ~~~~\meta{key_1} |=| \meta{value_1} |,| \\ +% ~~~~\meta{key_2} |=| \meta{value_2} |,| \ldots{} \\ +% ~~\} % \end{syntax} -% Creates a new constant \enquote{linked} \meta{prop~var} or raises an +% Creates a new constant \enquote{linked} \meta{property list} or raises an % error if the -% name is already taken. The \meta{prop~var} is set globally to +% name is already taken. The \meta{property list} is set globally to % contain key--value pairs given in the second argument, processed in % the way described for \cs{prop_set_from_keyval:Nn}. If duplicate % keys appear only the last of the values is kept. @@ -332,7 +332,7 @@ % \prop_gconcat:NNN, \prop_gconcat:ccc % } % \begin{syntax} -% \cs{prop_concat:NNN} \meta{property list_1} \meta{property list_2} \meta{property list3} +% \cs{prop_concat:NNN} \meta{property list_1} \meta{property list_2} \meta{property list_3} % \end{syntax} % Combines the key--value pairs of \meta{property list_2} and % \meta{property list_3}, and saves the result in \meta{property list_1}. If a @@ -347,11 +347,11 @@ % \prop_gput_from_keyval:Nn, \prop_gput_from_keyval:cn, % } % \begin{syntax} -% \cs{prop_put_from_keyval:Nn} \meta{property list} -% \{ -% \meta{key1} |=| \meta{value1} |,| -% \meta{key2} |=| \meta{value2} |,| \ldots{} -% \} +% \cs{prop_put_from_keyval:Nn} \meta{property list} \\ +% ~~\{ \\ +% ~~~~\meta{key_1} |=| \meta{value_1} |,| \\ +% ~~~~\meta{key_2} |=| \meta{value_2} |,| \ldots{} \\ +% ~~\} % \end{syntax} % Updates the \meta{property list} by adding entries for each key--value % pair given in the second argument. The addition is done through @@ -384,11 +384,11 @@ % \cs{prop_get:NnN} \meta{property list} \Arg{key} \meta{tl var} % \end{syntax} % Recovers the \meta{value} stored with \meta{key} from the -% \meta{property list}, and places this in the \meta{token list -% variable}. If the \meta{key} is not found in the -% \meta{property list} then the \meta{token list variable} is set -% to the special marker \cs{q_no_value}. The \meta{token list -% variable} is set within the current \TeX{} group. See also +% \meta{property list}, and places this in the \meta{tl +% var}. If the \meta{key} is not found in the +% \meta{property list} then the \meta{tl~var} is set +% to the special marker \cs{q_no_value}. The \meta{tl +% var} is set within the current \TeX{} group. See also % \cs{prop_get:NnNTF}. % \end{function} % @@ -403,9 +403,9 @@ % \cs{prop_pop:NnN} \meta{property list} \Arg{key} \meta{tl var} % \end{syntax} % Recovers the \meta{value} stored with \meta{key} from the -% \meta{property list}, and places this in the \meta{token list -% variable}. If the \meta{key} is not found in the -% \meta{property list} then the \meta{token list variable} is set +% \meta{property list}, and places this in the \meta{tl +% var}. If the \meta{key} is not found in the +% \meta{property list} then the \meta{tl~var} is set % to the special marker \cs{q_no_value}. The \meta{key} and % \meta{value} are then deleted from the property list. Both % assignments are local. See also \cs{prop_pop:NnNTF}. @@ -422,13 +422,13 @@ % \cs{prop_gpop:NnN} \meta{property list} \Arg{key} \meta{tl var} % \end{syntax} % Recovers the \meta{value} stored with \meta{key} from the -% \meta{property list}, and places this in the \meta{token list -% variable}. If the \meta{key} is not found in the -% \meta{property list} then the \meta{token list variable} is set +% \meta{property list}, and places this in the \meta{tl +% var}. If the \meta{key} is not found in the +% \meta{property list} then the \meta{tl~var} is set % to the special marker \cs{q_no_value}. The \meta{key} and % \meta{value} are then deleted from the property list. % The \meta{property list} is modified globally, while the assignment of -% the \meta{token list variable} is local. See also \cs{prop_gpop:NnNTF}. +% the \meta{tl~var} is local. See also \cs{prop_gpop:NnNTF}. % \end{function} % % \begin{function}[EXP, added = 2014-07-17] @@ -553,17 +553,17 @@ % \prop_get:cnc % } % \begin{syntax} -% \cs{prop_get:NnNTF} \meta{property list} \Arg{key} \meta{token list variable} \\ +% \cs{prop_get:NnNTF} \meta{property list} \Arg{key} \meta{tl~var} \\ % ~~\Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{key} is not present in the \meta{property list}, leaves % the \meta{false code} in the input stream. The value of the -% \meta{token list variable} is not defined in this case and should +% \meta{tl~var} is not defined in this case and should % not be relied upon. If the \meta{key} is present in the % \meta{property list}, stores the corresponding \meta{value} in the -% \meta{token list variable} without removing it from the +% \meta{tl~var} without removing it from the % \meta{property list}, then leaves the \meta{true code} in the input -% stream. The \meta{token list variable} is assigned locally. +% stream. The \meta{tl~var} is assigned locally. % \end{function} % % \begin{function}[TF, added = 2011-08-18, updated = 2012-05-19] @@ -574,17 +574,17 @@ % \prop_pop:coN % } % \begin{syntax} -% \cs{prop_pop:NnNTF} \meta{property list} \Arg{key} \meta{token list variable} \\ +% \cs{prop_pop:NnNTF} \meta{property list} \Arg{key} \meta{tl~var} \\ % ~~\Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{key} is not present in the \meta{property list}, leaves % the \meta{false code} in the input stream. The value of the -% \meta{token list variable} is not defined in this case and should +% \meta{tl~var} is not defined in this case and should % not be relied upon. If the \meta{key} is present in % the \meta{property list}, pops the corresponding \meta{value} -% in the \meta{token list variable}, \emph{i.e.}~removes the item from +% in the \meta{tl~var}, \emph{i.e.}~removes the item from % the \meta{property list}. -% Both the \meta{property list} and the \meta{token list variable} +% Both the \meta{property list} and the \meta{tl~var} % are assigned locally. % \end{function} % @@ -596,18 +596,18 @@ % \prop_gpop:coN % } % \begin{syntax} -% \cs{prop_gpop:NnNTF} \meta{property list} \Arg{key} \meta{token list variable} \\ +% \cs{prop_gpop:NnNTF} \meta{property list} \Arg{key} \meta{tl~var} \\ % ~~\Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{key} is not present in the \meta{property list}, leaves % the \meta{false code} in the input stream. The value of the -% \meta{token list variable} is not defined in this case and should +% \meta{tl~var} is not defined in this case and should % not be relied upon. If the \meta{key} is present in % the \meta{property list}, pops the corresponding \meta{value} -% in the \meta{token list variable}, \emph{i.e.}~removes the item from +% in the \meta{tl~var}, \emph{i.e.}~removes the item from % the \meta{property list}. % The \meta{property list} is modified globally, while the -% \meta{token list variable} is assigned locally. +% \meta{tl~var} is assigned locally. % \end{function} % % \section{Mapping over property lists} @@ -1724,7 +1724,7 @@ \exp_after:wN { \tl_to_str:n {#2} } } } - { \exp_after:wN \@@_get_linked:w #1 {#2} \use:n { } { } } + { \exp_after:wN \@@_get_linked:w #1 {#2} \exp_not:n { } { } } } \cs_new:Npn \@@_item:nnn #1#2#3 { diff --git a/macros/latex/required/l3kernel/l3quark.dtx b/macros/latex/required/l3kernel/l3quark.dtx index 136596a3fe..9b90b606f7 100644 --- a/macros/latex/required/l3kernel/l3quark.dtx +++ b/macros/latex/required/l3kernel/l3quark.dtx @@ -2,7 +2,7 @@ % %% File: l3quark.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -32,7 +32,7 @@ % % \title{^^A % The \pkg{l3quark} module\\ Quarks and scan marks^^A -% } +% }\ifdefined\thechapter\label{sec:l3quarks}\fi % % \author{^^A % The \LaTeX{} Project\thanks @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3regex.dtx b/macros/latex/required/l3kernel/l3regex.dtx index 6ca9c8eeed..868f695f3c 100644 --- a/macros/latex/required/l3kernel/l3regex.dtx +++ b/macros/latex/required/l3kernel/l3regex.dtx @@ -2,7 +2,7 @@ % %% File: l3regex.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -469,12 +469,12 @@ % the same category codes as in the original token list. % % By default, the category code of characters inserted by the -% replacement are determined by the prevailing category code regime at +% replacement are determined by the prevailing category code régime at % the time where the replacement is made, with two exceptions: % \begin{itemize} % \item space characters (with character code $32$) inserted with % \verb*|\ | or |\x20| or |\x{20}| have category code~$10$ regardless -% of the prevailing category code regime; +% of the prevailing category code régime; % \item if the category code would be $0$~(escape), $5$~(newline), % $9$~(ignore), $14$~(comment) or $15$~(invalid), it is replaced by % $12$~(other) instead. @@ -541,7 +541,7 @@ % \begin{syntax} % \cs{regex_set:Nn} \meta{regex~var} \Arg{regex} % \end{syntax} -% Stores a compiled version of the \meta{regular expression} in the +% Stores a compiled version of the \meta{regex} in the % \meta{regex~var}. The assignment is local for \cs{regex_set:Nn} and % global for \cs{regex_gset:Nn}. For instance, this function can be % used as @@ -557,7 +557,7 @@ % \end{syntax} % Creates a new constant \meta{regex~var} or raises an error if the name % is already taken. The value of the \meta{regex~var} is set -% globally to the compiled version of the \meta{regular expression}. +% globally to the compiled version of the \meta{regex}. % \end{function} % % \begin{function}[added = 2021-04-26, updated = 2021-04-29] @@ -595,7 +595,7 @@ % \begin{syntax} % \cs{regex_match:nnTF} \Arg{regex} \Arg{token list} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests whether the \meta{regular expression} matches any part +% Tests whether the \meta{regex} matches any part % of the \meta{token list}. For instance, % \begin{verbatim} % \regex_match:nnTF { b [cde]* } { abecdcx } { TRUE } { FALSE } @@ -610,11 +610,11 @@ % \regex_count:NnN, \regex_count:NVN % } % \begin{syntax} -% \cs{regex_count:nnN} \Arg{regex} \Arg{token list} \meta{int var} +% \cs{regex_count:nnN} \Arg{regex} \Arg{token list} \meta{integer} % \end{syntax} -% Sets \meta{int var} within the current \TeX{} group level +% Sets \meta{integer} within the current \TeX{} group level % equal to the number of times -% \meta{regular expression} appears in \meta{token list}. +% \meta{regex} appears in \meta{token list}. % The search starts by finding the left-most longest match, % respecting greedy and lazy (non-greedy) operators. Then the search % starts again from the character following the last character @@ -643,7 +643,7 @@ % \end{syntax} % Determines which of the \meta{regular expressions} matches at the % earliest point in the \meta{token list}, and leaves the -% corresponding \meta{code_i} followed by the \meta{true code} in the +% corresponding \meta{code} followed by the \meta{true code} in the % input stream. If several \meta{regex} match starting at the same % point, then the first one in the list is selected and the others are % discarded. If none of the \meta{regex} match, the \meta{false code} @@ -673,7 +673,7 @@ % \cs{regex_extract_once:nnN} \Arg{regex} \Arg{token list} \meta{seq~var} % \cs{regex_extract_once:nnNTF} \Arg{regex} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} % \end{syntax} -% Finds the first match of the \meta{regular expression} in the +% Finds the first match of the \meta{regex} in the % \meta{token list}. If it exists, the match is stored as the first % item of the \meta{seq~var}, and further items are the contents of % capturing groups, in the order of their opening parenthesis. The @@ -707,7 +707,7 @@ % \cs{regex_extract_all:nnN} \Arg{regex} \Arg{token list} \meta{seq~var} % \cs{regex_extract_all:nnNTF} \Arg{regex} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} % \end{syntax} -% Finds all matches of the \meta{regular expression} +% Finds all matches of the \meta{regex} % in the \meta{token list}, and stores all the submatch information % in a single sequence (concatenating the results of % multiple \cs{regex_extract_once:nnN} calls). @@ -731,15 +731,15 @@ % \regex_split:NnN, \regex_split:NVN, % } % \begin{syntax} -% \cs{regex_split:nnN} \Arg{regular expression} \Arg{token list} \meta{seq~var} -% \cs{regex_split:nnNTF} \Arg{regular expression} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} +% \cs{regex_split:nnN} \Arg{regex} \Arg{token list} \meta{seq~var} +% \cs{regex_split:nnNTF} \Arg{regex} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} % \end{syntax} % Splits the \meta{token list} into a sequence of parts, delimited by -% matches of the \meta{regular expression}. If the \meta{regular expression} +% matches of the \meta{regex}. If the \meta{regex} % has capturing groups, then the token lists that they match are stored as % items of the sequence as well. The assignment to \meta{seq~var} is local. % If no match is found the resulting \meta{seq~var} has the -% \meta{token list} as its sole item. If the \meta{regular expression} +% \meta{token list} as its sole item. If the \meta{regex} % matches the empty token list, then the \meta{token list} is split % into single tokens. % The testing versions insert the \meta{true code} into the input @@ -763,10 +763,10 @@ % \regex_replace_once:NnN,\regex_replace_once:NVN % } % \begin{syntax} -% \cs{regex_replace_once:nnN} \Arg{regular expression} \Arg{replacement} \meta{tl~var} -% \cs{regex_replace_once:nnNTF} \Arg{regular expression} \Arg{replacement} \meta{tl~var} \Arg{true code} \Arg{false code} +% \cs{regex_replace_once:nnN} \Arg{regex} \Arg{replacement} \meta{tl~var} +% \cs{regex_replace_once:nnNTF} \Arg{regex} \Arg{replacement} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} -% Searches for the \meta{regular expression} in the contents of the +% Searches for the \meta{regex} in the contents of the % \meta{tl~var} and replaces the first match with the % \meta{replacement}. In the \meta{replacement}, % |\0| represents the full match, |\1| represent the contents of the @@ -780,10 +780,10 @@ % \regex_replace_all:NnN,\regex_replace_all:NVN % } % \begin{syntax} -% \cs{regex_replace_all:nnN} \Arg{regular expression} \Arg{replacement} \meta{tl~var} -% \cs{regex_replace_all:nnNTF} \Arg{regular expression} \Arg{replacement} \meta{tl~var} \Arg{true code} \Arg{false code} +% \cs{regex_replace_all:nnN} \Arg{regex} \Arg{replacement} \meta{tl~var} +% \cs{regex_replace_all:nnNTF} \Arg{regex} \Arg{replacement} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} -% Replaces all occurrences of the \meta{regular expression} in the +% Replaces all occurrences of the \meta{regex} in the % contents of the \meta{tl~var} % by the \meta{replacement}, where |\0| represents % the full match, |\1| represent the contents of the first capturing @@ -804,8 +804,8 @@ % ~~\Arg{true code} \Arg{false code} % \end{syntax} % Replaces the earliest match of the regular expression -% "(?|"\meta{regex_1}"|"\dots"|"\meta{regex_n}")" in the \meta{token -% list variable} by the \meta{replacement} corresponding to which +% "(?|"\meta{regex_1}"|"\dots"|"\meta{regex_n}")" in the +% \meta{tl var} by the \meta{replacement} corresponding to which % \meta{regex_i} matched, then leaves the \meta{true code} in the % input stream. If none of the \meta{regex} match, then the % \meta{tl~var} is not modified, and the \meta{false code} is left in @@ -5970,8 +5970,8 @@ % corresponding to the initial value of % \cs{l_@@_replacement_category_tl}. % The argument |#1| is a single character (including the case of a catcode-other space). -% In case no specific catcode is requested, we taked into account the -% current catcode regime (at the time the replacement is performed) +% In case no specific catcode is requested, we take into account the +% current catcode régime (at the time the replacement is performed) % as much as reasonable, with all impossible catcodes (escape, % newline, etc.) being mapped to \enquote{other}. % \begin{macrocode} diff --git a/macros/latex/required/l3kernel/l3seq.dtx b/macros/latex/required/l3kernel/l3seq.dtx index 38fc9471a9..b882319b44 100644 --- a/macros/latex/required/l3kernel/l3seq.dtx +++ b/macros/latex/required/l3kernel/l3seq.dtx @@ -2,7 +2,7 @@ % %% File: l3seq.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -108,10 +108,10 @@ % \seq_gset_from_clist:Nn, \seq_gset_from_clist:cn % } % \begin{syntax} -% \cs{seq_set_from_clist:NN} \meta{seq~var} \meta{comma-list} +% \cs{seq_set_from_clist:NN} \meta{seq~var} \meta{clist~var} % \end{syntax} -% Converts the data in the \meta{comma list} into a \meta{seq~var}: -% the original \meta{comma list} is unchanged. +% Converts the data in the \meta{clist~var} into a \meta{seq~var}: +% the original \meta{clist~var} is unchanged. % \end{function} % % \begin{function}[added = 2017-11-28] @@ -145,9 +145,9 @@ % \cs{seq_set_split:Nnn}, and can be removed afterwards using % \cs{seq_remove_all:Nn} \meta{seq~var} |{}|. % The \meta{delimiter} may not contain |{|, |}| or |#| -% (assuming \TeX{}'s normal category code r\'egime). +% (assuming \TeX{}'s normal category code régime). % If the \meta{delimiter} is empty, the \meta{token list} is split -% into \meta{items} as a \meta{token list}. +% into \meta{items} as described for \cs{tl_map_function:nN}. % See also \cs{seq_set_split_keep_spaces:Nnn}, which omits space stripping. % \end{function} % @@ -167,9 +167,10 @@ % \cs{seq_set_split_keep_spaces:Nnn}, and can be removed afterwards using % \cs{seq_remove_all:Nn} \meta{seq~var} |{}|. % The \meta{delimiter} may not contain |{|, |}| or |#| -% (assuming \TeX{}'s normal category code r\'egime). +% (assuming \TeX{}'s normal category code régime). % If the \meta{delimiter} is empty, the \meta{token list} is split -% into \meta{items} as a \meta{token list}. +% into \meta{items} as described for \cs{tl_map_function:nN}; note in this +% case spaces will \emph{not} be preserved. % See also \cs{seq_set_split:Nnn}, which removes spaces around the delimiters. % \end{function} % @@ -189,6 +190,81 @@ % \end{texnote} % \end{function} % +% \begin{function}[added = 2024-12-08] +% { +% \seq_set_regex_extract_once:Nnn, \seq_set_regex_extract_once:cnn, +% \seq_set_regex_extract_once:NNn, \seq_set_regex_extract_once:cNn, +% \seq_gset_regex_extract_once:Nnn, \seq_gset_regex_extract_once:cnn, +% \seq_gset_regex_extract_once:NNn, \seq_gset_regex_extract_once:cNn, +% } +% \begin{syntax} +% \cs{seq_set_regex_extract_once:Nnn} \meta{seq~var} \Arg{regex} \Arg{token list} +% \cs{seq_set_regex_extract_once:NNn} \meta{seq~var} \meta{regex~var} \Arg{token list} +% \end{syntax} +% Finds the first match of the \meta{regex} in the +% \meta{token list}. If it exists, the match is stored as the first +% item of the \meta{seq~var}, and further items are the contents of +% capturing groups, in the order of their opening parenthesis. +% If there is no match, the \meta{seq~var} is cleared. +% Theses are alternative names for \cs{regex_extract_once:nnN} and friends, +% with arguments re-ordered for \meta{seq~var} setting; +% see \pkg{l3regex} chapter for more details of the \meta{regex} +% format. +% \end{function} +% +% \begin{function}[added = 2024-12-08] +% { +% \seq_set_regex_extract_all:Nnn, \seq_set_regex_extract_all:cnn, +% \seq_set_regex_extract_all:NNn, \seq_set_regex_extract_all:cNn, +% \seq_gset_regex_extract_all:Nnn, \seq_gset_regex_extract_all:cnn, +% \seq_gset_regex_extract_all:NNn, \seq_gset_regex_extract_all:cNn, +% } +% \begin{syntax} +% \cs{seq_set_regex_extract_all:Nnn} \meta{seq~var} \Arg{regex} \Arg{token list} +% \cs{seq_set_regex_extract_all:NNn} \meta{seq~var} \meta{regex~var} \Arg{token list} +% \end{syntax} +% Finds all matches of the \meta{regex} in the +% \meta{token list}, and stores all the submatch information +% in a single sequence (concatenating the results of +% multiple \cs{seq_set_regex_extract_all:Nnn} calls). +% If there is no match, the \meta{seq~var} is cleared. +% Theses are alternative names for \cs{regex_extract_all:nnN} and friends, +% with arguments re-ordered for \meta{seq~var} setting; +% see \pkg{l3regex} chapter for more details of the \meta{regex} +% format. +% \end{function} +% +% \begin{function}[added = 2024-12-08] +% { +% \seq_set_regex_split:Nnn, \seq_set_regex_split:cnn, +% \seq_set_regex_split:NNn, \seq_set_regex_split:cNn, +% \seq_gset_regex_split:Nnn, \seq_gset_regex_split:cnn, +% \seq_gset_regex_split:NNn, \seq_gset_regex_split:cNn, +% } +% \begin{syntax} +% \cs{seq_set_regex_split:Nnn} \meta{seq~var} \Arg{regex} \Arg{token list} +% \cs{seq_set_regex_split:NNn} \meta{seq~var} \meta{regex~var} \Arg{token list} +% \end{syntax} +% Splits the \meta{token list} into a sequence of parts, delimited by +% matches of the \meta{regular expression}. If the \meta{regular expression} +% has capturing groups, then the token lists that they match are stored as +% items of the sequence as well. +% If no match is found the resulting \meta{seq~var} has the +% \meta{token list} as its sole item. If the \meta{regular expression} +% matches the empty token list, then the \meta{token list} is split +% into single tokens. +% For example, after +% \begin{verbatim} +% \seq_set_regex_split:Nnn \l_path_seq { / } { the/path/for/this/file.tex } +% \end{verbatim} +% the sequence |\l_path_seq| contains the items |{the}|, |{path}|, +% |{for}|, |{this}|, and |{file.tex}|. +% Theses are alternative names for \cs{regex_split:nnN} and friends, +% with arguments re-ordered for \meta{seq~var} setting; +% see \pkg{l3regex} chapter for more details of the \meta{regex} +% format. +% \end{function} +% % \begin{function} % {\seq_concat:NNN, \seq_concat:ccc, \seq_gconcat:NNN, \seq_gconcat:ccc} % \begin{syntax} @@ -249,78 +325,78 @@ % For implementation reasons, the actions at the left of the sequence are % faster than those acting on the right. These functions all assign the % recovered material locally, \emph{i.e.}~setting the -% \meta{token list variable} used with \cs{tl_set:Nn} and \emph{never} +% \meta{tl~var} used with \cs{tl_set:Nn} and \emph{never} % \cs{tl_gset:Nn}. % % \begin{function}[updated = 2012-05-14]{\seq_get_left:NN, \seq_get_left:cN} % \begin{syntax} -% \cs{seq_get_left:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_get_left:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Stores the left-most item from a \meta{seq~var} in the -% \meta{token list variable} without removing it from the -% \meta{seq~var}. The \meta{token list variable} is assigned locally. -% If \meta{seq~var} is empty the \meta{token list variable} +% \meta{tl~var} without removing it from the +% \meta{seq~var}. The \meta{tl~var} is assigned locally. +% If \meta{seq~var} is empty the \meta{tl~var} % is set to the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2012-05-19]{\seq_get_right:NN, \seq_get_right:cN} % \begin{syntax} -% \cs{seq_get_right:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_get_right:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Stores the right-most item from a \meta{seq~var} in the -% \meta{token list variable} without removing it from the -% \meta{seq~var}. The \meta{token list variable} is assigned locally. -% If \meta{seq~var} is empty the \meta{token list variable} +% \meta{tl~var} without removing it from the +% \meta{seq~var}. The \meta{tl~var} is assigned locally. +% If \meta{seq~var} is empty the \meta{tl~var} % is set to the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2012-05-14]{\seq_pop_left:NN, \seq_pop_left:cN} % \begin{syntax} -% \cs{seq_pop_left:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_pop_left:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Pops the left-most item from a \meta{seq~var} into the -% \meta{token list variable}, \emph{i.e.}~removes the item from the -% sequence and stores it in the \meta{token list variable}. +% \meta{tl~var}, \emph{i.e.}~removes the item from the +% sequence and stores it in the \meta{tl~var}. % Both of the variables are assigned locally. If \meta{seq~var} is -% empty the \meta{token list variable} is set to +% empty the \meta{tl~var} is set to % the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2012-05-14]{\seq_gpop_left:NN, \seq_gpop_left:cN} % \begin{syntax} -% \cs{seq_gpop_left:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_gpop_left:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Pops the left-most item from a \meta{seq~var} into the -% \meta{token list variable}, \emph{i.e.}~removes the item from the -% sequence and stores it in the \meta{token list variable}. +% \meta{tl~var}, \emph{i.e.}~removes the item from the +% sequence and stores it in the \meta{tl~var}. % The \meta{seq~var} is modified globally, while the assignment of -% the \meta{token list variable} is local. -% If \meta{seq~var} is empty the \meta{token list variable} is set to +% the \meta{tl~var} is local. +% If \meta{seq~var} is empty the \meta{tl~var} is set to % the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2012-05-19]{\seq_pop_right:NN, \seq_pop_right:cN} % \begin{syntax} -% \cs{seq_pop_right:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_pop_right:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Pops the right-most item from a \meta{seq~var} into the -% \meta{token list variable}, \emph{i.e.}~removes the item from the -% sequence and stores it in the \meta{token list variable}. +% \meta{tl~var}, \emph{i.e.}~removes the item from the +% sequence and stores it in the \meta{tl~var}. % Both of the variables are assigned locally. If \meta{seq~var} is -% empty the \meta{token list variable} is set to +% empty the \meta{tl~var} is set to % the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2012-05-19]{\seq_gpop_right:NN, \seq_gpop_right:cN} % \begin{syntax} -% \cs{seq_gpop_right:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_gpop_right:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Pops the right-most item from a \meta{seq~var} into the -% \meta{token list variable}, \emph{i.e.}~removes the item from the -% sequence and stores it in the \meta{token list variable}. +% \meta{tl~var}, \emph{i.e.}~removes the item from the +% sequence and stores it in the \meta{tl~var}. % The \meta{seq~var} is modified globally, while the assignment of -% the \meta{token list variable} is local. -% If \meta{seq~var} is empty the \meta{token list variable} is set to +% the \meta{tl~var} is local. +% If \meta{seq~var} is empty the \meta{tl~var} is set to % the special marker \cs{q_no_value}. % \end{function} % @@ -371,92 +447,92 @@ % \begin{function}[TF, added = 2012-05-14, updated = 2012-05-19] % {\seq_get_left:NN, \seq_get_left:cN} % \begin{syntax} -% \cs{seq_get_left:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_get_left:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, stores the left-most item from the % \meta{seq~var} -% in the \meta{token list variable} without removing it from the +% in the \meta{tl~var} without removing it from the % \meta{seq~var}, then leaves the \meta{true code} in the input stream. -% The \meta{token list variable} is assigned locally. +% The \meta{tl~var} is assigned locally. % \end{function} % % \begin{function}[TF, added = 2012-05-19] % {\seq_get_right:NN, \seq_get_right:cN} % \begin{syntax} -% \cs{seq_get_right:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_get_right:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, stores the right-most item from the % \meta{seq~var} -% in the \meta{token list variable} without removing it from the +% in the \meta{tl~var} without removing it from the % \meta{seq~var}, then leaves the \meta{true code} in the input stream. -% The \meta{token list variable} is assigned locally. +% The \meta{tl~var} is assigned locally. % \end{function} % % \begin{function}[TF, added = 2012-05-14, updated = 2012-05-19] % {\seq_pop_left:NN, \seq_pop_left:cN} % \begin{syntax} -% \cs{seq_pop_left:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_pop_left:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, pops the left-most item from the % \meta{seq~var} -% in the \meta{token list variable}, \emph{i.e.}~removes the item from the +% in the \meta{tl~var}, \emph{i.e.}~removes the item from the % \meta{seq~var}, then leaves the \meta{true code} in the input stream. -% Both the \meta{seq~var} and the \meta{token list variable} are assigned +% Both the \meta{seq~var} and the \meta{tl~var} are assigned % locally. % \end{function} % % \begin{function}[TF, added = 2012-05-14, updated = 2012-05-19] % {\seq_gpop_left:NN, \seq_gpop_left:cN} % \begin{syntax} -% \cs{seq_gpop_left:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_gpop_left:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, pops the left-most item from the \meta{seq~var} -% in the \meta{token list variable}, \emph{i.e.}~removes the item from the +% in the \meta{tl~var}, \emph{i.e.}~removes the item from the % \meta{seq~var}, then leaves the \meta{true code} in the input stream. -% The \meta{seq~var} is modified globally, while the \meta{token list variable} +% The \meta{seq~var} is modified globally, while the \meta{tl~var} % is assigned locally. % \end{function} % % \begin{function}[TF, added = 2012-05-19] % {\seq_pop_right:NN, \seq_pop_right:cN} % \begin{syntax} -% \cs{seq_pop_right:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_pop_right:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, pops the right-most item from the \meta{seq~var} -% in the \meta{token list variable}, \emph{i.e.}~removes the item from the +% in the \meta{tl~var}, \emph{i.e.}~removes the item from the % \meta{seq~var}, then leaves the \meta{true code} in the input stream. -% Both the \meta{seq~var} and the \meta{token list variable} are assigned +% Both the \meta{seq~var} and the \meta{tl~var} are assigned % locally. % \end{function} % % \begin{function}[TF, added = 2012-05-19] % {\seq_gpop_right:NN, \seq_gpop_right:cN} % \begin{syntax} -% \cs{seq_gpop_right:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_gpop_right:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, pops the right-most item from the \meta{seq~var} -% in the \meta{token list variable}, \emph{i.e.}~removes the item from the +% in the \meta{tl~var}, \emph{i.e.}~removes the item from the % \meta{seq~var}, then leaves the \meta{true code} in the input stream. % The \meta{seq~var} is modified globally, while the -% \meta{token list variable} is assigned locally. +% \meta{tl~var} is assigned locally. % \end{function} % % \section{Modifying sequences} @@ -672,10 +748,10 @@ % \seq_map_pairwise_function:cNN, \seq_map_pairwise_function:ccN % } % \begin{syntax} -% \cs{seq_map_pairwise_function:NNN} \meta{seq_1} \meta{seq_2} \meta{function} +% \cs{seq_map_pairwise_function:NNN} \meta{seq var_1} \meta{seq var_2} \meta{function} % \end{syntax} % Applies \meta{function} to every pair of items -% \meta{seq_1-item}--\meta{seq_2-item} from the two sequences, returning +% \meta{seq var_1-item}--\meta{seq var_2-item} from the two sequences, returning % items from both sequences from left to right. The \meta{function} % receives two \texttt{n}-type arguments for each iteration. The mapping % terminates when @@ -747,7 +823,7 @@ % Applies \meta{inline function} to every \meta{item} stored % within the \meta{seq~var_2}. The \meta{inline function} should % consist of code which will receive the \meta{item} as |#1|. -% The sequence resulting applying \meta{inline function} to each +% The sequence resulting from applying \meta{inline function} to each % \meta{item} is assigned to \meta{seq~var_1}. % \begin{texnote} % Contrarily to other mapping functions, \cs{seq_map_break:} cannot @@ -852,72 +928,72 @@ % % \begin{function}[updated = 2012-05-14]{\seq_get:NN, \seq_get:cN} % \begin{syntax} -% \cs{seq_get:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_get:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Reads the top item from a \meta{seq~var} into the -% \meta{token list variable} without removing it from the -% \meta{seq~var}. The \meta{token list variable} is assigned locally. -% If \meta{seq~var} is empty the \meta{token list variable} is set to +% \meta{tl~var} without removing it from the +% \meta{seq~var}. The \meta{tl~var} is assigned locally. +% If \meta{seq~var} is empty the \meta{tl~var} is set to % the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2012-05-14]{\seq_pop:NN, \seq_pop:cN} % \begin{syntax} -% \cs{seq_pop:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_pop:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Pops the top item from a \meta{seq~var} into the -% \meta{token list variable}. Both of the variables are assigned -% locally. If \meta{seq~var} is empty the \meta{token list variable} +% \meta{tl~var}. Both of the variables are assigned +% locally. If \meta{seq~var} is empty the \meta{tl~var} % is set to the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[updated = 2012-05-14]{\seq_gpop:NN, \seq_gpop:cN} % \begin{syntax} -% \cs{seq_gpop:NN} \meta{seq~var} \meta{token list variable} +% \cs{seq_gpop:NN} \meta{seq~var} \meta{tl~var} % \end{syntax} % Pops the top item from a \meta{seq~var} into the -% \meta{token list variable}. The \meta{seq~var} is modified globally, -% while the \meta{token list variable} is assigned locally. If -% \meta{seq~var} is empty the \meta{token list variable} is set to +% \meta{tl~var}. The \meta{seq~var} is modified globally, +% while the \meta{tl~var} is assigned locally. If +% \meta{seq~var} is empty the \meta{tl~var} is set to % the special marker \cs{q_no_value}. % \end{function} % % \begin{function}[TF, added = 2012-05-14, updated = 2012-05-19]{\seq_get:NN, \seq_get:cN} % \begin{syntax} -% \cs{seq_get:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_get:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, stores the top item from a -% \meta{seq~var} in the \meta{token list variable} without removing it from -% the \meta{seq~var}. The \meta{token list variable} is assigned locally. +% \meta{seq~var} in the \meta{tl~var} without removing it from +% the \meta{seq~var}. The \meta{tl~var} is assigned locally. % \end{function} % % \begin{function}[TF, added = 2012-05-14, updated = 2012-05-19]{\seq_pop:NN, \seq_pop:cN} % \begin{syntax} -% \cs{seq_pop:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_pop:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, pops the top item from the -% \meta{seq~var} in the \meta{token list variable}, \emph{i.e.}~removes the +% \meta{seq~var} in the \meta{tl~var}, \emph{i.e.}~removes the % item from the \meta{seq~var}. Both the \meta{seq~var} and the -% \meta{token list variable} are assigned locally. +% \meta{tl~var} are assigned locally. % \end{function} % % \begin{function}[TF, added = 2012-05-14, updated = 2012-05-19]{\seq_gpop:NN, \seq_gpop:cN} % \begin{syntax} -% \cs{seq_gpop:NNTF} \meta{seq~var} \meta{token list variable} \Arg{true code} \Arg{false code} +% \cs{seq_gpop:NNTF} \meta{seq~var} \meta{tl~var} \Arg{true code} \Arg{false code} % \end{syntax} % If the \meta{seq~var} is empty, leaves the \meta{false code} in the -% input stream. The value of the \meta{token list variable} is +% input stream. The value of the \meta{tl~var} is % not defined in this case and should not be relied upon. If the % \meta{seq~var} is non-empty, pops the top item from the \meta{seq~var} -% in the \meta{token list variable}, \emph{i.e.}~removes the item from the +% in the \meta{tl~var}, \emph{i.e.}~removes the item from the % \meta{seq~var}. The \meta{seq~var} is modified globally, while the -% \meta{token list variable} is assigned locally. +% \meta{tl~var} is assigned locally. % \end{function} % % \begin{function} @@ -1325,12 +1401,12 @@ % is a repetition of the pattern % \cs{@@_set_split:Nw} \cs{prg_do_nothing:} % \meta{item with spaces} \cs{@@_set_split_end:}. -% Then, \texttt{e}-expansion causes \cs{@@_set_split:Nw} +% Then, \texttt{x}-expansion causes \cs{@@_set_split:Nw} % to trim spaces, and leaves its result as % \cs{@@_set_split:w} \meta{trimmed item} % \cs{@@_set_split_end:}. This is then converted % to the \pkg{l3seq} internal structure by another -% \texttt{e}-expansion. In the first step, we insert +% \texttt{x}-expansion. In the first step, we insert % \cs{prg_do_nothing:} to avoid losing braces too early: % that would cause space trimming to act within those % lost braces. The second step is solely there to strip @@ -1395,7 +1471,7 @@ % and skipping out of that would break horribly. % The \cs{@@_wrap_item:n} function inserts the relevant % \cs{@@_item:n} without expansion in the input stream, -% hence in the \texttt{e}-expanding assignment. +% hence in the \texttt{x}-expanding assignment. % \begin{macrocode} \cs_new_protected:Npn \seq_set_filter:NNn { \@@_set_filter:NNNn \__kernel_tl_set:Nx } @@ -1411,6 +1487,84 @@ % \end{macro} % \end{macro} % +% \begin{macro} +% { +% \seq_set_regex_extract_once:Nnn, \seq_set_regex_extract_once:cnn, +% \seq_gset_regex_extract_once:Nnn, \seq_gset_regex_extract_once:cnn +% } +% \begin{macro} +% { +% \seq_set_regex_extract_all:Nnn, \seq_set_regex_extract_all:cnn, +% \seq_gset_regex_extract_all:Nnn, \seq_gset_regex_extract_all:cnn +% } +% \begin{macro} +% { +% \seq_set_regex_extract_once:NNn, \seq_set_regex_extract_once:cNn, +% \seq_gset_regex_extract_once:NNn, \seq_gset_regex_extract_once:cNn +% } +% \begin{macro} +% { +% \seq_set_regex_extract_all:NNn, \seq_set_regex_extract_all:cNn, +% \seq_gset_regex_extract_all:NNn, \seq_gset_regex_extract_all:cNn +% } +% \begin{macro} +% { +% \seq_set_regex_split:Nnn, \seq_set_regex_split:cnn, +% \seq_gset_regex_split:Nnn, \seq_gset_regex_split:cnn +% } +% \begin{macro} +% { +% \seq_set_regex_split:NNn, \seq_set_regex_split:cNn, +% \seq_gset_regex_split:NNn, \seq_gset_regex_split:cNn +% } +% \begin{macrocode} +\cs_new_protected:Npn \seq_set_regex_extract_once:Nnn #1#2#3 + { \regex_extract_once:nnN {#2} {#3} #1 } +\cs_generate_variant:Nn \seq_set_regex_extract_once:Nnn { c } +\cs_new_protected:Npn \seq_set_regex_extract_once:NNn #1#2#3 + { \regex_extract_once:NnN #2 {#3} #1 } +\cs_generate_variant:Nn \seq_set_regex_extract_once:NNn { c } +\cs_new_protected:Npn \seq_set_regex_extract_all:Nnn #1#2#3 + { \regex_extract_all:nnN {#2} {#3} #1 } +\cs_generate_variant:Nn \seq_set_regex_extract_all:Nnn { c } +\cs_new_protected:Npn \seq_set_regex_extract_all:NNn #1#2#3 + { \regex_extract_all:NnN #2 {#3} #1 } +\cs_generate_variant:Nn \seq_set_regex_extract_all:NNn { c } +\cs_new_protected:Npn \seq_set_regex_split:Nnn #1#2#3 + { \regex_split:nnN {#2} {#3} #1 } +\cs_generate_variant:Nn \seq_set_regex_split:Nnn { c } +\cs_new_protected:Npn \seq_set_regex_split:NNn #1#2#3 + { \regex_split:NnN #2 {#3} #1 } +\cs_generate_variant:Nn \seq_set_regex_split:NNn { c } +\group_begin: + \cs_set_protected:Npn \@@_tmp:w #1#2#3 + { + \cs_new_protected:cpe { seq_gset_regex_ #1 :N #2 n } ##1##2##3 + { + \group_begin: + \seq_set_eq:NN \exp_not:N \l_@@_tmp_seq ##1 + \exp_not:c { regex_ #1 :Nn #2 } + #3 {##2} {##3} \exp_not:N \l_@@_tmp_seq + \seq_gset_eq:NN ##1 \exp_not:N \l_@@_tmp_seq + \group_end: + } + \cs_generate_variant:cn { seq_gset_regex_ #1 :N #2 n } { c } + } + \@@_tmp:w { extract_once } n { } + \@@_tmp:w { extract_once } N \use:n + \@@_tmp:w { extract_all } n { } + \@@_tmp:w { extract_all } N \use:n + \@@_tmp:w { split } n { } + \@@_tmp:w { split } N \use:n +\group_end: +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\seq_concat:NNN, \seq_concat:ccc} % \UnitTested % \begin{macro}{\seq_gconcat:NNN, \seq_gconcat:ccc} @@ -1519,16 +1673,16 @@ % % \begin{macro}{\@@_wrap_item:n} % This function converts its argument to a proper sequence item -% in an \texttt{e}-expansion context. +% in an \texttt{e}- or \texttt{x}-expansion context. % \begin{macrocode} \cs_new:Npn \@@_wrap_item:n #1 { \exp_not:n { \@@_item:n {#1} } } % \end{macrocode} % \end{macro} % -% \begin{variable}{\l_@@_remove_seq} +% \begin{variable}{\l_@@_tmp_seq} % An internal sequence for the removal routines. % \begin{macrocode} -\seq_new:N \l_@@_remove_seq +\seq_new:N \l_@@_tmp_seq % \end{macrocode} % \end{variable} % @@ -1545,13 +1699,13 @@ { \@@_remove_duplicates:NN \seq_gset_eq:NN } \cs_new_protected:Npn \@@_remove_duplicates:NN #1#2 { - \seq_clear:N \l_@@_remove_seq + \seq_clear:N \l_@@_tmp_seq \seq_map_inline:Nn #2 { - \seq_if_in:NnF \l_@@_remove_seq {##1} - { \seq_put_right:Nn \l_@@_remove_seq {##1} } + \seq_if_in:NnF \l_@@_tmp_seq {##1} + { \seq_put_right:Nn \l_@@_tmp_seq {##1} } } - #1 #2 \l_@@_remove_seq + #1 #2 \l_@@_tmp_seq } \cs_generate_variant:Nn \seq_remove_duplicates:N { c } \cs_generate_variant:Nn \seq_gremove_duplicates:N { c } @@ -1581,15 +1735,15 @@ % items one at a time to an intermediate sequence. % The approach taken is therefore similar to % that in \cs{@@_pop_right:NNN}, using a \enquote{flexible} -% \texttt{e}-type expansion to do most of the work. As \cs{tl_if_eq:nnT} +% \texttt{x}-type expansion to do most of the work. As \cs{tl_if_eq:nnT} % is not expandable, a two-part strategy is needed. First, the -% \texttt{e}-type expansion uses \cs{str_if_eq:nnT} to find potential +% \texttt{x}-type expansion uses \cs{str_if_eq:nnT} to find potential % matches. If one is found, the expansion is halted and the necessary -% set up takes place to use the \cs{tl_if_eq:NNT} test. The \texttt{e}-type +% set up takes place to use the \cs{tl_if_eq:NNT} test. The \texttt{x}-type % is started again, including all of the items copied already. This % happens repeatedly until the entire sequence has been scanned. The code % is set up to avoid needing an intermediate scratch list: the lead-off -% \texttt{e}-type expansion (|#1 #2 {#2}|) ensures that nothing is lost. +% \texttt{x}-type expansion (|#1 #2 {#2}|) ensures that nothing is lost. % \begin{macrocode} \cs_new_protected:Npn \seq_remove_all:Nn { \@@_remove_all_aux:NNn \__kernel_tl_set:Nx } @@ -2032,7 +2186,7 @@ % use some of the same ideas as getting from the right. What is needed is a % \enquote{flexible length} way to set a token list variable. This is % supplied by the |{ \if_false: } \fi:| \ldots -% |\if_false: { \fi: }| construct. Using an \texttt{e}-type +% |\if_false: { \fi: }| construct. Using an \texttt{x}-type % expansion and a \enquote{non-expanding} definition for \cs{@@_item:n}, % the left-most $n - 1$ entries in a sequence of $n$ items are stored % back in the sequence. That needs a loop of unknown length, hence using the @@ -2409,6 +2563,7 @@ \exp_after:wN \@@_map_pairwise_function:wNw #2 \s_@@_stop #3 #1 { ? \prg_break: } { } \prg_break_point: + \prg_break_point:Nn \seq_map_break: { } } \cs_new:Npn \@@_map_pairwise_function:wNw \s_@@ #1 \s_@@_stop #2 { diff --git a/macros/latex/required/l3kernel/l3skip.dtx b/macros/latex/required/l3kernel/l3skip.dtx index 6e96b41326..2ae86598cb 100644 --- a/macros/latex/required/l3kernel/l3skip.dtx +++ b/macros/latex/required/l3kernel/l3skip.dtx @@ -3,7 +3,7 @@ %% File: l3skip.dtx % % Copyright (C) 2004-2011 Frank Mittelbach, The LaTeX Project -% (C) 2012-2024 The LaTeX Project +% (C) 2012-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -124,7 +124,10 @@ % \end{function} % % \begin{function}[updated = 2011-10-22] -% {\dim_set:Nn, \dim_set:cn, \dim_gset:Nn, \dim_gset:cn} +% { +% \dim_set:Nn, \dim_set:cn, \dim_set:NV, \dim_set:cV, +% \dim_gset:Nn, \dim_gset:cn, \dim_gset:NV, \dim_gset:cV +% } % \begin{syntax} % \cs{dim_set:Nn} \meta{dimension} \Arg{dim expr} % \end{syntax} @@ -277,7 +280,8 @@ % \end{syntax} % This function evaluates the \meta{test dim expr} and % compares this in turn to each of the -% \meta{dim expr cases}. If the two are equal then the +% \meta{dim expr case}s until a match is found. +% If the two are equal then the % associated \meta{code} is left in the input stream % and other cases are discarded. If any of the % cases are matched, the \meta{true code} is also inserted into the @@ -297,6 +301,10 @@ % { No idea! } % \end{verbatim} % leaves \enquote{\texttt{Medium}} in the input stream. +% Since evaluation of the test expressions stops at the first +% successful case, the order of possible matches should normally +% be that the most likely are earlier: this will reduce the average +% steps required to complete expansion. % \end{function} % % \section{Dimension expression loops} @@ -752,13 +760,16 @@ % \end{function} % % \begin{function}[updated = 2011-10-22] -% {\skip_set:Nn, \skip_set:cn, \skip_gset:Nn, \skip_gset:cn} +% { +% \skip_set:Nn, \skip_set:cn, \skip_set:NV, \skip_set:cV, +% \skip_gset:Nn, \skip_gset:cn, \skip_gset:NV, \skip_gset:cV +% } % \begin{syntax} % \cs{skip_set:Nn} \meta{skip} \Arg{skip expr} % \end{syntax} % Sets \meta{skip} to the value of \meta{skip expr}, which % must evaluate to a length with units and may include a rubber -% component (for example |1 cm plus 0.5 cm|. +% component (for example |1 cm plus 0.5 cm|). % \end{function} % % \begin{function} @@ -988,7 +999,10 @@ % \end{function} % % \begin{function}[updated = 2011-10-22] -% {\muskip_set:Nn, \muskip_set:cn, \muskip_gset:Nn, \muskip_gset:cn} +% { +% \muskip_set:Nn, \muskip_set:cn, \muskip_set:NV, \muskip_set:cV, +% \muskip_gset:Nn, \muskip_gset:cn, \muskip_gset:NV, \muskip_gset:cV +% } % \begin{syntax} % \cs{muskip_set:Nn} \meta{muskip} \Arg{muskip expr} % \end{syntax} @@ -1245,8 +1259,8 @@ % % \subsection{Setting \texttt{dim} variables} % -% \begin{macro}{\dim_set:Nn, \dim_set:cn} -% \begin{macro}{\dim_gset:Nn, \dim_gset:cn} +% \begin{macro}{\dim_set:Nn, \dim_set:cn, \dim_set:NV, \dim_set:cV} +% \begin{macro}{\dim_gset:Nn, \dim_gset:cn, \dim_gset:NV, \dim_gset:cV} % Setting dimensions is easy enough but when debugging we want both to % check that the variable is correctly local/global and to wrap the % expression in some code. The \cs{scan_stop:} deals with the case @@ -1257,8 +1271,8 @@ { #1 = \@@_eval:w #2 \@@_eval_end: \scan_stop: } \cs_new_protected:Npn \dim_gset:Nn #1#2 { \tex_global:D #1 = \@@_eval:w #2 \@@_eval_end: \scan_stop: } -\cs_generate_variant:Nn \dim_set:Nn { c } -\cs_generate_variant:Nn \dim_gset:Nn { c } +\cs_generate_variant:Nn \dim_set:Nn { NV , c , cV } +\cs_generate_variant:Nn \dim_gset:Nn { NV , c , cV } % \end{macrocode} % \end{macro} % \end{macro} @@ -2208,16 +2222,16 @@ % % \subsection{Setting \texttt{skip} variables} % -% \begin{macro}{\skip_set:Nn, \skip_set:cn} -% \begin{macro}{\skip_gset:Nn, \skip_gset:cn} +% \begin{macro}{\skip_set:Nn, \skip_set:cn, \skip_set:NV, \skip_set:cV} +% \begin{macro}{\skip_gset:Nn, \skip_gset:cn, \skip_gset:NV, \skip_gset:cV} % Much the same as for dimensions. % \begin{macrocode} \cs_new_protected:Npn \skip_set:Nn #1#2 { #1 = \tex_glueexpr:D #2 \scan_stop: } \cs_new_protected:Npn \skip_gset:Nn #1#2 { \tex_global:D #1 = \tex_glueexpr:D #2 \scan_stop: } -\cs_generate_variant:Nn \skip_set:Nn { c } -\cs_generate_variant:Nn \skip_gset:Nn { c } +\cs_generate_variant:Nn \skip_set:Nn { NV , c , cV } +\cs_generate_variant:Nn \skip_gset:Nn { NV , c , cV } % \end{macrocode} % \end{macro} % \end{macro} @@ -2459,16 +2473,16 @@ % % \subsection{Setting \texttt{muskip} variables} % -% \begin{macro}{\muskip_set:Nn, \muskip_set:cn} -% \begin{macro}{\muskip_gset:Nn, \muskip_gset:cn} +% \begin{macro}{\muskip_set:Nn, \muskip_set:cn, \muskip_set:NV, \muskip_set:cV} +% \begin{macro}{\muskip_gset:Nn, \muskip_gset:cn, \muskip_gset:NV, \muskip_gset:cV} % This should be pretty familiar. % \begin{macrocode} \cs_new_protected:Npn \muskip_set:Nn #1#2 { #1 = \tex_muexpr:D #2 \scan_stop: } \cs_new_protected:Npn \muskip_gset:Nn #1#2 { \tex_global:D #1 = \tex_muexpr:D #2 \scan_stop: } -\cs_generate_variant:Nn \muskip_set:Nn { c } -\cs_generate_variant:Nn \muskip_gset:Nn { c } +\cs_generate_variant:Nn \muskip_set:Nn { NV , c , cV } +\cs_generate_variant:Nn \muskip_gset:Nn { NV , c , cV } % \end{macrocode} % \end{macro} % \end{macro} diff --git a/macros/latex/required/l3kernel/l3sort.dtx b/macros/latex/required/l3kernel/l3sort.dtx index 47cebcad25..5bbb0d3b34 100644 --- a/macros/latex/required/l3kernel/l3sort.dtx +++ b/macros/latex/required/l3kernel/l3sort.dtx @@ -2,7 +2,7 @@ % %% File l3sort.dtx % -% Copyright (C) 2012-2024 The LaTeX Project +% Copyright (C) 2012-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3str-convert.dtx b/macros/latex/required/l3kernel/l3str-convert.dtx index baf705fe0c..dcb7872132 100644 --- a/macros/latex/required/l3kernel/l3str-convert.dtx +++ b/macros/latex/required/l3kernel/l3str-convert.dtx @@ -2,7 +2,7 @@ % %% File: l3str-convert.dtx % -% Copyright (C) 2013-2024 The LaTeX Project +% Copyright (C) 2013-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -139,10 +139,10 @@ % % \begin{function}{\str_set_convert:Nnnn, \str_gset_convert:Nnnn} % \begin{syntax} -% \cs{str_set_convert:Nnnn} \meta{str~var} \Arg{string} \Arg{name~1} \Arg{name~2} +% \cs{str_set_convert:Nnnn} \meta{str~var} \Arg{string} \Arg{name_1} \Arg{name_2} % \end{syntax} % This function converts the \meta{string} from the encoding given by -% \meta{name~1} to the encoding given by \meta{name~2}, and stores the +% \meta{name_1} to the encoding given by \meta{name_2}, and stores the % result in the \meta{str~var}. Each \meta{name} can have the form % \meta{encoding} or \meta{encoding}\texttt{/}\meta{escaping}, where % the possible values of \meta{encoding} and \meta{escaping} are given @@ -177,14 +177,14 @@ % % \begin{function}[TF]{\str_set_convert:Nnnn, \str_gset_convert:Nnnn} % \begin{syntax} -% \cs{str_set_convert:NnnnTF} \meta{str~var} \Arg{string} \Arg{name~1} \Arg{name~2} \Arg{true code} \Arg{false code} +% \cs{str_set_convert:NnnnTF} \meta{str~var} \Arg{string} \Arg{name_1} \Arg{name_2} \Arg{true code} \Arg{false code} % \end{syntax} % As \cs{str_set_convert:Nnnn}, converts the \meta{string} from the -% encoding given by \meta{name~1} to the encoding given by -% \meta{name~2}, and assigns the result to \meta{str~var}. Contrarily +% encoding given by \meta{name_1} to the encoding given by +% \meta{name_2}, and assigns the result to \meta{str~var}. Contrarily % to \cs{str_set_convert:Nnnn}, the conditional variant does not raise % errors in case the \meta{string} is not valid according to the -% \meta{name~1} encoding, or cannot be expressed in the \meta{name~2} +% \meta{name_1} encoding, or cannot be expressed in the \meta{name_2} % encoding. Instead, the \meta{false code} is performed. % \end{function} % @@ -195,7 +195,7 @@ % % \begin{function}[EXP]{\str_convert_pdfname:n} % \begin{syntax} -% \cs{str_convert_pdfname:n} \meta{string} +% \cs{str_convert_pdfname:n} \Arg{string} % \end{syntax} % As \cs{str_set_convert:Nnnn}, converts the \meta{string} on a byte-by-byte % basis with non-ASCII codepoints escaped using hashes. @@ -2068,7 +2068,7 @@ % % \subsubsection{\textsc{utf-16} support} % -% The definitions are done in a category code regime where the bytes +% The definitions are done in a category code régime where the bytes % $254$ and $255$ used by the byte order mark have catcode~$12$. % \begin{macrocode} \group_begin: @@ -2393,7 +2393,7 @@ % % \subsubsection{\textsc{utf-32} support} % -% The definitions are done in a category code regime where the bytes +% The definitions are done in a category code régime where the bytes % $0$, $254$ and $255$ used by the byte order mark have catcode % \enquote{other}. % \begin{macrocode} @@ -2624,9 +2624,7 @@ \exp_args:Ne \tl_to_str:n { \str_map_function:nN {#1} \@@_convert_pdfname:n } } -\bool_lazy_or:nnTF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } +\sys_if_engine_opentype:TF { \cs_new:Npn \@@_convert_pdfname:n #1 { diff --git a/macros/latex/required/l3kernel/l3str.dtx b/macros/latex/required/l3kernel/l3str.dtx index f4f7b94b88..c6d8c74b80 100644 --- a/macros/latex/required/l3kernel/l3str.dtx +++ b/macros/latex/required/l3kernel/l3str.dtx @@ -2,7 +2,7 @@ % %% File: l3str.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -212,7 +212,7 @@ % \begin{function}[added = 2015-09-18, updated = 2018-07-28] % { % \str_put_right:Nn, \str_put_right:NV, \str_put_right:Ne, -% \str_put_right:cn, \str_put_right:cV, \str_put_right:Ne, +% \str_put_right:cn, \str_put_right:cV, \str_put_right:ce, % \str_gput_right:Nn, \str_gput_right:NV, \str_gput_right:Ne, % \str_gput_right:cn, \str_gput_right:cV, \str_gput_right:ce % } @@ -303,7 +303,8 @@ % ~~\Arg{false code} % \end{syntax} % Compares the \meta{test string} in turn with each -% of the \meta{string case}s (all token lists are converted to strings). +% of the \meta{string case}s until a match is found +% (all token lists are converted to strings). % If the two are equal (as described for % \cs{str_if_eq:nnTF}) then the associated \meta{code} is left in the % input stream and other cases are discarded. If any of the @@ -557,7 +558,7 @@ % \end{function} % % \begin{function}[EXP, added = 2015-09-18] -% {\str_item:Nn, \str_item:nn, \str_item_ignore_spaces:nn} +% {\str_item:Nn, \str_item:cn, \str_item:nn, \str_item_ignore_spaces:nn} % \begin{syntax} % \cs{str_item:nn} \Arg{token list} \Arg{integer expression} % \end{syntax} @@ -757,7 +758,7 @@ % \item Case changing text for typesetting: see the % \cs[index=text_lowercase:n]{text_lowercase:n(n)}, % \cs[index=text_uppercase:n]{text_uppercase:n(n)} and -% \cs[index=text_titlecase_all:n]{text_titlecase_(all|once):n(n)} functions which +% \cs[index=text_titlecase_all:n]{text_titlecase_(all|first):n(n)} functions which % correctly deal with context-dependence and other factors appropriate % to text case changing. % \end{itemize} @@ -789,7 +790,7 @@ % \end{quote} % The folding approach implemented by \cs{str_casefold:n} follows the % \enquote{full} scheme defined by the Unicode Consortium -% (\emph{e.g.}~\SS folds to \texttt{SS}). As case-folding is +% (\emph{e.g.}~\SS{} folds to \texttt{SS}). As case-folding is % a language-insensitive process, there is no special treatment of % Turkic input (\emph{i.e.}~\texttt{I} always folds to \texttt{i} and % not to \texttt{\i}). @@ -797,9 +798,9 @@ % % \begin{function}[added = 2023-05-19, EXP]{\str_mdfive_hash:n, \str_mdfive_hash:e} % \begin{syntax} -% \cs{str_mdfive_hash:n} \Arg{tl} +% \cs{str_mdfive_hash:n} \Arg{tokens} % \end{syntax} -% Expands to the MD5 sum generated from the \meta{tl}, which is converted +% Expands to the MD5 sum generated from the \meta{tokens}, which is converted % to a \meta{string} as described for \cs{tl_to_str:n}. % \end{function} % diff --git a/macros/latex/required/l3kernel/l3styleguide.pdf b/macros/latex/required/l3kernel/l3styleguide.pdf Binary files differindex 0113bac571..881dfbdbff 100644 --- a/macros/latex/required/l3kernel/l3styleguide.pdf +++ b/macros/latex/required/l3kernel/l3styleguide.pdf diff --git a/macros/latex/required/l3kernel/l3styleguide.tex b/macros/latex/required/l3kernel/l3styleguide.tex index bcea3de06e..51b269459f 100644 --- a/macros/latex/required/l3kernel/l3styleguide.tex +++ b/macros/latex/required/l3kernel/l3styleguide.tex @@ -2,7 +2,7 @@ File: l3styleguide.tex -Copyright (C) 2011,2012,2014-2024 The LaTeX Project +Copyright (C) 2011,2012,2014-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2024-05-27} +\date{Released 2025-01-18} \begin{document} diff --git a/macros/latex/required/l3kernel/l3syntax-changes.pdf b/macros/latex/required/l3kernel/l3syntax-changes.pdf Binary files differindex 99e93c2ccc..27409c5e43 100644 --- a/macros/latex/required/l3kernel/l3syntax-changes.pdf +++ b/macros/latex/required/l3kernel/l3syntax-changes.pdf diff --git a/macros/latex/required/l3kernel/l3syntax-changes.tex b/macros/latex/required/l3kernel/l3syntax-changes.tex index 30d8d47747..0abcad3c8e 100644 --- a/macros/latex/required/l3kernel/l3syntax-changes.tex +++ b/macros/latex/required/l3kernel/l3syntax-changes.tex @@ -2,7 +2,7 @@ File: l3syntax-changes.tex -Copyright (C) 2011,2012,2017-2024 The LaTeX Project +Copyright (C) 2011,2012,2017-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2024-05-27} +\date{Released 2025-01-18} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/required/l3kernel/l3sys.dtx b/macros/latex/required/l3kernel/l3sys.dtx index b2228c7fd9..7c6d0e9dc5 100644 --- a/macros/latex/required/l3kernel/l3sys.dtx +++ b/macros/latex/required/l3kernel/l3sys.dtx @@ -2,7 +2,7 @@ % %% File: l3sys.dtx % -% Copyright (C) 2015-2024 The LaTeX Project +% Copyright (C) 2015-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -107,6 +107,26 @@ % |\sys_if_engine_ptex_p:| is true for \epTeX{} but false for \eupTeX{}. % \end{function} % +% \begin{function}[added = 2024-11-05, pTF]{\sys_if_engine_opentype:} +% \begin{syntax} +% \cs{sys_if_engine_opentype_p:} +% \cs{sys_if_engine_opentype:TF} \Arg{true code} \Arg{false code} +% \end{syntax} +% Conditional which allows functionality-specific code to be used. +% The test is true for engines which can use OpenType fonts and +% thus full Unicode typesetting. This tests for features not engine +% name, but currently is equivalent to requiring either +% \XeTeX{} or \LuaTeX{}. +% \begin{texnote} +% The underlying test here checks for \tn{Umathcode}, which +% is used to implement OpenType math font typesetting. Any +% engine which should give a \texttt{true} result here needs +% to provide general Unicode support (accepting the full UTF-8 +% range for character codes), a mechanism to load system fonts +% and a suitable interface for math mode typesetting. +% \end{texnote} +% \end{function} +% % \begin{variable}[added = 2015-09-19]{\c_sys_engine_str} % The current engine given as a lower case string: one of % |luatex|, |pdftex|, |ptex|, |uptex| or |xetex|. @@ -336,9 +356,9 @@ % \begin{function}[added = 2024-03-08, updated = 2024-04-08] % {\sys_get_query:nN, \sys_get_query:nnN, \sys_get_query:nnnN} % \begin{syntax} -% \cs{sys_get_query:nN} \Arg{cmd} \Arg{tl var} -% \cs{sys_get_query:nnN} \Arg{cmd} \Arg{spec} \Arg{tl var} -% \cs{sys_get_query:nnnN} \Arg{cmd} \Arg{options} \Arg{spec} \Arg{tl var} +% \cs{sys_get_query:nN} \Arg{cmd} \meta{tl var} +% \cs{sys_get_query:nnN} \Arg{cmd} \Arg{spec} \meta{tl var} +% \cs{sys_get_query:nnnN} \Arg{cmd} \Arg{options} \Arg{spec} \meta{tl var} % \end{syntax} % Sets the \meta{tl var} to the information returned by the % \texttt{l3sys-query} \meta{cmd}, potentially supplying the \meta{options} @@ -374,11 +394,11 @@ % \begin{function}[added = 2024-03-08] % {\sys_split_query:nN, \sys_split_query:nnN, \sys_split_query:nnnN} % \begin{syntax} -% \cs{sys_split_query:nN} \Arg{cmd} \Arg{seq} -% \cs{sys_split_query:nnN} \Arg{cmd} \Arg{spec} \Arg{seq} -% \cs{sys_split_query:nnnN} \Arg{cmd} \Arg{options} \Arg{spec} \Arg{seq} +% \cs{sys_split_query:nN} \Arg{cmd} \meta{seq var} +% \cs{sys_split_query:nnN} \Arg{cmd} \Arg{spec} \meta{seq var} +% \cs{sys_split_query:nnnN} \Arg{cmd} \Arg{options} \Arg{spec} \meta{seq var} % \end{syntax} -% Works as described for \cs{sys_split_query:nnnN}, but sets the \meta{seq} +% Works as described for \cs{sys_split_query:nnnN}, but sets the \meta{seq var} % to contain one entry for each line returned by \texttt{l3sys-query}. % This function should therefore be preferred where multi-line return is % expected, e.g.~for the \texttt{ls} command. @@ -514,6 +534,14 @@ % \end{variable} % \end{macro} % +% \begin{function}[pTF]{\sys_if_engine_opentype:} +% \begin{macrocode} +\@@_const:nn + { sys_if_engine_opentype } + { \cs_if_exist_p:N \tex_Umathcode:D } +% \end{macrocode} +% \end{function} +% % \begin{variable}{\c_sys_engine_exec_str,\c_sys_engine_format_str} % Take the functions defined above, and set up the engine and format % names. \cs{c_sys_engine_exec_str} differs from \cs{c_sys_engine_str} @@ -1030,7 +1058,7 @@ end % \begin{variable}{\c_sys_timestamp_str} % A simple expansion: Lua\TeX{} chokes if we use \tn{pdffeedback} here, % hence the direct use of Lua. Notice that the function there is in the -% \texttt{pdf} library but isn actually tied to PDF. +% \texttt{pdf} library but isn't actually tied to PDF. % \begin{macrocode} \@@_everyjob:n { diff --git a/macros/latex/required/l3kernel/l3term-glossary.pdf b/macros/latex/required/l3kernel/l3term-glossary.pdf Binary files differindex 01598ca79a..afbdd9d71f 100644 --- a/macros/latex/required/l3kernel/l3term-glossary.pdf +++ b/macros/latex/required/l3kernel/l3term-glossary.pdf diff --git a/macros/latex/required/l3kernel/l3term-glossary.tex b/macros/latex/required/l3kernel/l3term-glossary.tex index 141749aa6b..c907fce097 100644 --- a/macros/latex/required/l3kernel/l3term-glossary.tex +++ b/macros/latex/required/l3kernel/l3term-glossary.tex @@ -2,7 +2,7 @@ File: l3term-glossary.tex -Copyright (C) 2018-2024 The LaTeX Project +Copyright (C) 2018-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2024-05-27} +\date{Released 2025-01-18} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/required/l3kernel/l3text-case.dtx b/macros/latex/required/l3kernel/l3text-case.dtx index 89cdb9e2b1..f8529b1090 100644 --- a/macros/latex/required/l3kernel/l3text-case.dtx +++ b/macros/latex/required/l3kernel/l3text-case.dtx @@ -2,7 +2,7 @@ % %% File: l3text-case.dtx % -% Copyright (C) 2020-2024 The LaTeX Project +% Copyright (C) 2020-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -801,9 +801,7 @@ % the standard catcode. If neither are true, we set as 13 on the grounds that % this will be what is used anyway! % \begin{macrocode} -\bool_lazy_or:nnTF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } +\sys_if_engine_opentype:TF { \cs_new:Npn \@@_change_case_catcode:nn #1#2 { \@@_char_catcode:N #1 } @@ -2319,9 +2317,7 @@ % A few adjustments to case mapping for combining chars: these are not needed % for the Unicode engines % \begin{macrocode} -\bool_lazy_or:nnF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } +\sys_if_engine_opentype:F { \text_declare_uppercase_mapping:nn { "01F0 } { \v { J } } } diff --git a/macros/latex/required/l3kernel/l3text-map.dtx b/macros/latex/required/l3kernel/l3text-map.dtx index 3573002244..accfa0e06e 100644 --- a/macros/latex/required/l3kernel/l3text-map.dtx +++ b/macros/latex/required/l3kernel/l3text-map.dtx @@ -2,7 +2,7 @@ % %% File: l3text-map.dtx % -% Copyright (C) 2022-2024 The LaTeX Project +% Copyright (C) 2022-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3text-purify.dtx b/macros/latex/required/l3kernel/l3text-purify.dtx index 35390811aa..6aa04bf399 100644 --- a/macros/latex/required/l3kernel/l3text-purify.dtx +++ b/macros/latex/required/l3kernel/l3text-purify.dtx @@ -2,7 +2,7 @@ % %% File: l3text-purify.dtx % -% Copyright (C) 2020-2024 The LaTeX Project +% Copyright (C) 2020-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3text.dtx b/macros/latex/required/l3kernel/l3text.dtx index bcfd15cb62..f1f4ecee2f 100644 --- a/macros/latex/required/l3kernel/l3text.dtx +++ b/macros/latex/required/l3kernel/l3text.dtx @@ -2,7 +2,7 @@ % %% File: l3text.dtx % -% Copyright (C) 2020-2024 The LaTeX Project +% Copyright (C) 2020-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -65,11 +65,11 @@ % \end{syntax} % Takes user input \meta{text} and expands the content. % Protected commands (typically -% formatting) are left in place, and no processing takes place of +% formatting) are left in place, and no processing of % math mode material (as delimited by pairs given in % \cs{l_text_math_delims_tl} or as the argument to commands listed -% in \cs{l_text_math_arg_tl}). Commands which are neither engine- -% nor \LaTeX{} protected are expanded exhaustively. +% in \cs{l_text_math_arg_tl}) takes place. Commands which are neither engine- +% nor \LaTeX{}-protected are expanded exhaustively. % Any commands listed in \cs{l_text_expand_exclude_tl} are excluded from % expansion, as are those in \cs{l_text_case_exclude_arg_tl} and % \cs{l_text_math_arg_tl}. @@ -114,8 +114,8 @@ % \end{function} % % Upper- and lowercase have the obvious meanings. Titlecasing may be regarded -% informally as converting the first character of the \meta{tokens} to -% uppercase. However, the process is more complex +% informally as converting the first \emph{non-space} character of the +% \meta{tokens} to uppercase. However, the process is more complex % than this as there are some situations where a single lowercase character % maps to a special form, for example \texttt{ij} in Dutch which becomes % \texttt{IJ}. There are two functions available for titlecasing: one which @@ -214,8 +214,9 @@ % \text_declare_uppercase_mapping:nnn % } % \begin{syntax} -% \cs{text_declare_lowercase_mapping:nn} \Arg{codeppoint} \Arg{replacement} -% \cs{text_declare_lowercase_mapping:nnn} \Arg{BCP-47} \Arg{codeppoint} \Arg{replacement} +% \cs{text_declare_lowercase_mapping:nn} \Arg{codepoint} \Arg{replacement} +% \cs{text_declare_lowercase_mapping:nnn} \Arg{BCP-47} \Arg{codepoint} \\ +% ~~\Arg{replacement} % \end{syntax} % Declares that the \meta{replacement} tokens should be used when case mapping % the \meta{codepoint}, rather than the standard mapping given in the @@ -305,7 +306,7 @@ % % \begin{function}[rEXP, added = 2022-08-04]{\text_map_function:nN} % \begin{syntax} -% \cs{text_map_function:nN} \meta{text} \Arg{function} +% \cs{text_map_function:nN} \Arg{text} \meta{function} % \end{syntax} % Takes user input \meta{text} and expands as described for % \cs{text_expand:n}, then maps over the \emph{graphemes} within the @@ -323,7 +324,7 @@ % % \begin{function}[added = 2022-08-04]{\text_map_inline:nn} % \begin{syntax} -% \cs{text_map_inline:nn} \meta{text} \Arg{inline function} +% \cs{text_map_inline:nn} \Arg{text} \Arg{inline function} % \end{syntax} % Takes user input \meta{text} and expands as described for % \cs{text_expand:n}, then maps over the \emph{graphemes} within the @@ -653,9 +654,7 @@ % Grab a codepoint and apply some code to it: here |#1| should expect one % following \emph{balanced text}. % \begin{macrocode} -\bool_lazy_or:nnTF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } +\sys_if_engine_opentype:TF { \cs_new:Npn \@@_codepoint_process:nN #1#2 { #1 {#2} } } @@ -709,9 +708,7 @@ % Allows comparison for all engines using a first \enquote{character} followed % by a codepoint. % \begin{macrocode} -\bool_lazy_or:nnTF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } +\sys_if_engine_opentype:TF { \prg_new_conditional:Npnn \@@_codepoint_compare:nNn #1#2#3 { TF , p } diff --git a/macros/latex/required/l3kernel/l3tl-analysis.dtx b/macros/latex/required/l3kernel/l3tl-analysis.dtx index 4df9ee68a3..fd162839a8 100644 --- a/macros/latex/required/l3kernel/l3tl-analysis.dtx +++ b/macros/latex/required/l3kernel/l3tl-analysis.dtx @@ -2,7 +2,7 @@ % %% File: l3tl-analysis.dtx % -% Copyright (C) 2011-2024 The LaTeX Project +% Copyright (C) 2011-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -1028,39 +1028,42 @@ % % \subsection{Showing the results} % -% \begin{macro}{\tl_analysis_show:N, \tl_analysis_log:N, \@@_analysis_show:NNN} +% \begin{macro}{\tl_analysis_show:N, \tl_analysis_log:N, \@@_analysis_show:NNnnN} % Add to \cs{@@_analysis:n} a third pass to display tokens to the terminal. % If the token list variable is not defined, throw the same error % as \cs{tl_show:N} by simply calling that function. % \begin{macrocode} \cs_new_protected:Npn \tl_analysis_show:N - { \@@_analysis_show:NNN \msg_show:nneeee \tl_show:N } + { \@@_analysis_show:NNnnN \msg_show:nneeee \tl_show:N {} {} } \cs_new_protected:Npn \tl_analysis_log:N - { \@@_analysis_show:NNN \msg_log:nneeee \tl_log:N } -\cs_new_protected:Npn \@@_analysis_show:NNN #1#2#3 { - \tl_if_exist:NTF #3 + \@@_analysis_show:NNnnN \msg_log:nneeee \tl_log:N + { \iow_newline: >~ . } { . } + } +\cs_new_protected:Npn \@@_analysis_show:NNnnN #1#2#3#4#5 + { + \tl_if_exist:NTF #5 { - \exp_args:No \@@_analysis:n {#3} + \exp_args:No \@@_analysis:n {#5} #1 { tl } { show-analysis } - { \token_to_str:N #3 } { \@@_analysis_show: } { } { } + { \token_to_str:N #5 } { \@@_analysis_show: } {#3} {#4} } { #2 #3 } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\tl_analysis_show:n, \tl_analysis_log:n, \@@_analysis_show:Nn} +% \begin{macro}{\tl_analysis_show:n, \tl_analysis_log:n, \@@_analysis_show:Nnnn} % No existence test needed here. % \begin{macrocode} \cs_new_protected:Npn \tl_analysis_show:n - { \@@_analysis_show:Nn \msg_show:nneeee } + { \@@_analysis_show:Nnnn \msg_show:nneeee {} {} } \cs_new_protected:Npn \tl_analysis_log:n - { \@@_analysis_show:Nn \msg_log:nneeee } -\cs_new_protected:Npn \@@_analysis_show:Nn #1#2 + { \@@_analysis_show:Nnnn \msg_log:nneeee { \iow_newline: >~ . } { . } } +\cs_new_protected:Npn \@@_analysis_show:Nnnn #1#2#3#4 { - \@@_analysis:n {#2} - #1 { tl } { show-analysis } { } { \@@_analysis_show: } { } { } + \@@_analysis:n {#4} + #1 { tl } { show-analysis } { } { \@@_analysis_show: } {#2} {#3} } % \end{macrocode} % \end{macro} @@ -1654,8 +1657,8 @@ { The~token~list~ \tl_if_empty:nF {#1} { #1 ~ } \tl_if_empty:nTF {#2} - { is~empty } - { contains~the~tokens: #2 } + { is~empty #3 } + { contains~the~tokens: #2 #4 } } % \end{macrocode} % diff --git a/macros/latex/required/l3kernel/l3tl-build.dtx b/macros/latex/required/l3kernel/l3tl-build.dtx index 6cd9822ad2..ae38f34583 100644 --- a/macros/latex/required/l3kernel/l3tl-build.dtx +++ b/macros/latex/required/l3kernel/l3tl-build.dtx @@ -2,7 +2,7 @@ % %% File: l3tl-build.dtx % -% Copyright (C) 2018-2024 The LaTeX Project +% Copyright (C) 2018-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3tl.dtx b/macros/latex/required/l3kernel/l3tl.dtx index 71d68d532c..85faa334a9 100644 --- a/macros/latex/required/l3kernel/l3tl.dtx +++ b/macros/latex/required/l3kernel/l3tl.dtx @@ -2,7 +2,7 @@ % %% File: l3tl.dtx % -% Copyright (C) 1990-2024 The LaTeX Project +% Copyright (C) 1990-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -55,7 +55,7 @@ % \begin{verbatim} % \foo:n { a collection of \tokens } % \end{verbatim} -% or may be stored in a so-called \enquote{token list variable}, which +% or may be stored in a so-called \enquote{tl~var} (\meta{tl~var}), which % have the suffix \texttt{tl}: a token list variable can also be used as % the argument to a function, for example % \begin{verbatim} @@ -99,8 +99,8 @@ % % \begin{function} % { -% \tl_const:Nn, \tl_const:Ne, -% \tl_const:cn, \tl_const:ce +% \tl_const:Nn, \tl_const:NV, \tl_const:Ne, +% \tl_const:cn, \tl_const:cV, \tl_const:ce % } % \begin{syntax} % \cs{tl_const:Nn} \meta{tl~var} \Arg{tokens} @@ -333,8 +333,8 @@ % Tests if the \meta{token list} and the special \cs{c_novalue_tl} marker % contain the same list of tokens, both in respect of character codes and % category codes. This means that -% \cs{exp_args:No} \cs{tl_if_novalue:nTF} \{ \cs{c_novalue_tl} \} is -% logically \texttt{true} but \cs{tl_if_novalue:nTF} \{ \cs{c_novalue_tl} \} +% \cs{exp_args:No} \cs{tl_if_novalue:nTF} \texttt\{ \cs{c_novalue_tl} \texttt\} is +% logically \texttt{true} but \cs{tl_if_novalue:nTF} \texttt\{ \cs{c_novalue_tl} \texttt\} % is logically \texttt{false}. % This function is intended to allow construction % of flexible document interface structures in which missing optional @@ -376,6 +376,28 @@ % Token groups (|{|\ldots|}|) are not single tokens. % \end{function} % +% \begin{function}[TF, added = 2024-12-08] +% { +% \tl_if_regex_match:nn, \tl_if_regex_match:Vn, +% \tl_if_regex_match:nN, \tl_if_regex_match:VN, +% } +% \begin{syntax} +% \cs{tl_if_regex_match:nnTF} \Arg{token list} \Arg{regex} \Arg{true code} \Arg{false code} +% \cs{tl_if_regex_match:nNTF} \Arg{token list} \meta{regex~var} \Arg{true code} \Arg{false code} +% \end{syntax} +% Tests whether the \meta{regular expression} matches any part +% of the \meta{token list}. For instance, +% \begin{verbatim} +% \tl_if_regex_match:nnTF { abecdcx } { b [cde]* } { TRUE } { FALSE } +% \tl_if_regex_match:nnTF { example } { [b-dq-w] } { TRUE } { FALSE } +% \end{verbatim} +% leaves \texttt{TRUE} then \texttt{FALSE} in the input stream. +% Theses are alternative names for \cs{regex_match:nnTF} and friends, +% with arguments re-ordered for \meta{token list} testing; +% see \pkg{l3regex} chapter for more details of the \meta{regex} +% format. +% \end{function} +% % \subsection{Testing the first token} % % \begin{function}[updated = 2012-07-09, EXP, pTF] @@ -1110,7 +1132,7 @@ % % Within token lists, replacement takes place at the top level: there is % no recursion into brace groups (more precisely, within a group defined by -% a categroy code $1$/$2$ pair). +% a category code $1$/$2$ pair). % % \begin{function}[updated = 2011-08-11] % { @@ -1158,6 +1180,51 @@ % for an example). % \end{function} % +% \begin{function}[added = 2024-12-08] +% { +% \tl_regex_replace_once:Nnn, \tl_regex_replace_once:cnn, +% \tl_regex_replace_once:NNn, \tl_regex_replace_once:cNn, +% \tl_regex_greplace_once:Nnn, \tl_regex_greplace_once:cnn, +% \tl_regex_greplace_once:NNn, \tl_regex_greplace_once:cNn +% } +% \begin{syntax} +% \cs{tl_regex_replace_once:Nnn} \meta{tl~var} \Arg{regex} \Arg{replacement} +% \cs{tl_regex_replace_once:NNn} \meta{tl~var} \meta{regex~var} \Arg{replacement} +% \end{syntax} +% Searches for the \meta{regular expression} in the contents of the +% \meta{tl~var} and replaces the first match with the +% \meta{replacement}. In the \meta{replacement}, +% |\0| represents the full match, |\1| represent the contents of the +% first capturing group, |\2| of the second, \emph{etc.} +% Theses are alternative names for \cs{regex_replace_once:nnN} and friends, +% with arguments re-ordered for \meta{tl~var} setting; +% See \pkg{l3regex} chapter for more details of the \meta{regex} +% format. +% \end{function} +% +% \begin{function}[added = 2024-12-08] +% { +% \tl_regex_replace_all:Nnn, \tl_regex_replace_all:cnn, +% \tl_regex_replace_all:NNn, \tl_regex_replace_all:cNn, +% \tl_regex_greplace_all:Nnn, \tl_regex_greplace_all:cnn, +% \tl_regex_greplace_all:NNn, \tl_regex_greplace_all:cNn +% } +% \begin{syntax} +% \cs{tl_regex_replace_all:Nnn} \meta{tl~var} \Arg{regex} \Arg{replacement} +% \cs{tl_regex_replace_all:NNn} \meta{tl~var} \meta{regex~var} \Arg{replacement} +% \end{syntax} +% Replaces all occurrences of the \meta{regular expression} in the +% contents of the \meta{tl~var} +% by the \meta{replacement}, where |\0| represents +% the full match, |\1| represent the contents of the first capturing +% group, |\2| of the second, \emph{etc.} Every match is treated +% independently, and matches cannot overlap. +% Theses are alternative names for \cs{regex_replace_all:nnN} and friends, +% with arguments re-ordered for \meta{tl~var} setting; +% see \pkg{l3regex} chapter for more details of the \meta{regex} +% format. +% \end{function} +% % \begin{function}[updated = 2011-08-11] % { % \tl_remove_once:Nn, \tl_remove_once:NV, \tl_remove_once:Ne, @@ -1277,7 +1344,7 @@ % read from a file. % % Contrarily to the \tn{scantokens} \eTeX{} primitive, \cs{tl_rescan:nn} -% tokenizes the whole string in the same category code regime rather +% tokenizes the whole string in the same category code régime rather % than one token at a time, so that directives such as \tn{verb} % that rely on changing category codes will not function properly. % \end{texnote} @@ -1369,8 +1436,8 @@ % % \begin{macro} % { -% \tl_const:Nn, \tl_const:Ne, \tl_const:Nx, -% \tl_const:cn, \tl_const:ce, \tl_const:cx +% \tl_const:Nn, \tl_const:NV, \tl_const:Ne, \tl_const:Nx, +% \tl_const:cn, \tl_const:cV, \tl_const:ce, \tl_const:cx % } % Constants are also easy to generate. They use \cs{cs_gset_nopar:Npe} instead % of \cs{__kernel_tl_gset:Nx} so that the correct scope checking for |c|, @@ -1384,7 +1451,7 @@ \__kernel_chk_if_free_cs:N #1 \cs_gset_nopar:Npe #1 { \__kernel_exp_not:w {#2} } } -\cs_generate_variant:Nn \tl_const:Nn { Ne , c , ce } +\cs_generate_variant:Nn \tl_const:Nn { NV , Ne , c , cV , ce } \cs_generate_variant:Nn \tl_const:Nn { Nx , cx } % \end{macrocode} % \end{macro} @@ -2249,6 +2316,57 @@ % % \begin{macro} % { +% \tl_regex_replace_once:Nnn, \tl_regex_replace_once:cnn, +% \tl_regex_replace_once:NNn, \tl_regex_replace_once:cNn, +% \tl_regex_greplace_once:Nnn, \tl_regex_greplace_once:cnn, +% \tl_regex_greplace_once:NNn, \tl_regex_greplace_once:cNn +% } +% \begin{macro} +% { +% \tl_regex_replace_all:Nnn, \tl_regex_replace_all:cnn, +% \tl_regex_replace_all:NNn, \tl_regex_replace_all:cNn, +% \tl_regex_greplace_all:Nnn, \tl_regex_greplace_all:cnn, +% \tl_regex_greplace_all:NNn, \tl_regex_greplace_all:cNn +% } +% Wrappers. +% \begin{macrocode} +\cs_new_protected:Npn \tl_regex_replace_once:Nnn #1#2#3 + { \regex_replace_once:nnN {#2} {#3} #1 } +\cs_generate_variant:Nn \tl_regex_replace_once:Nnn { c } +\cs_new_protected:Npn \tl_regex_replace_once:NNn #1#2#3 + { \regex_replace_once:NnN #2 {#3} #1 } +\cs_generate_variant:Nn \tl_regex_replace_once:NNn { c } +\cs_new_protected:Npn \tl_regex_replace_all:Nnn #1#2#3 + { \regex_replace_all:nnN {#2} {#3} #1 } +\cs_generate_variant:Nn \tl_regex_replace_all:Nnn { c } +\cs_new_protected:Npn \tl_regex_replace_all:NNn #1#2#3 + { \regex_replace_all:NnN #2 {#3} #1 } +\cs_generate_variant:Nn \tl_regex_replace_all:NNn { c } +\group_begin: + \cs_set_protected:Npn \@@_tmp:w #1#2#3 + { + \cs_new_protected:cpe { tl_regex_greplace_ #1 :N #2 n } ##1##2##3 + { + \group_begin: + \tl_set_eq:NN \exp_not:N \l_@@_internal_a_tl ##1 + \exp_not:c { regex_replace_ #1 :Nn #2 } + #3 {##2} {##3} \exp_not:N \l_@@_internal_a_tl + \tl_gset_eq:NN ##1 \exp_not:N \l_@@_internal_a_tl + \group_end: + } + \cs_generate_variant:cn { tl_regex_greplace_ #1 :N #2 n } { c } + } + \@@_tmp:w { once } n { } + \@@_tmp:w { once } N \use:n + \@@_tmp:w { all } n { } + \@@_tmp:w { all } N \use:n +\group_end: +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro} +% { % \tl_remove_once:Nn, \tl_remove_once:NV, \tl_remove_once:Ne, % \tl_remove_once:cn, \tl_remove_once:cV, \tl_remove_once:ce % } @@ -2611,6 +2729,29 @@ % \end{macrocode} % \end{macro} % +% \begin{macro} +% { +% \tl_if_regex_match:nn, \tl_if_regex_match:Vn, +% \tl_if_regex_match:nN, \tl_if_regex_match:VN, +% } +% \begin{macrocode} +\prg_new_protected_conditional:Npnn \tl_if_regex_match:nn #1#2 { TF , T , F } + { + \regex_match:nnTF {#2} {#1} + \prg_return_true: \prg_return_false: + } +\prg_generate_conditional_variant:Nnn \tl_if_regex_match:nn + { V } { TF , T , F } +\prg_new_protected_conditional:Npnn \tl_if_regex_match:nN #1#2 { TF , T , F } + { + \regex_match:nNTF {#2} #1 + \prg_return_true: \prg_return_false: + } +\prg_generate_conditional_variant:Nnn \tl_if_regex_match:nN + { V } { TF , T , F } +% \end{macrocode} +% \end{macro} +% % \subsection{Mapping over token lists} % % \begin{macro} @@ -2920,7 +3061,7 @@ % } % \begin{macro}{\@@_trim_mark:} % Trimming spaces from around the input is done using delimited -% arguments and quarks, and to get spaces at odd places in the +% arguments and \cs{@@_trim_mark:}, and to get spaces at odd places in the % definitions, we nest those in \cs{@@_tmp:w}, which then receives % a single space as its argument: |#1| is \verb*+ +. % Removing leading spaces is done with \cs{@@_trim_spaces_auxi:w}, diff --git a/macros/latex/required/l3kernel/l3token.dtx b/macros/latex/required/l3kernel/l3token.dtx index 03bf46b101..73d0ec2102 100644 --- a/macros/latex/required/l3kernel/l3token.dtx +++ b/macros/latex/required/l3kernel/l3token.dtx @@ -2,7 +2,7 @@ % %% File: l3token.dtx % -% Copyright (C) 2005-2024 The LaTeX Project +% Copyright (C) 2005-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -151,7 +151,7 @@ % $0$ is not allowed. % Active characters cannot be generated in older versions of \XeTeX{}. % Another way to build token lists with unusual category codes is -% \cs{regex_replace:nnN} |{.*}| \Arg{replacement} \meta{tl~var}. +% \cs{regex_replace_all:nnN} |{.*}| \Arg{replacement} \meta{tl~var}. % \begin{texnote} % Exactly two expansions are needed to produce the character. % \end{texnote} @@ -443,12 +443,6 @@ % not be used other than for category code tests. % \end{variable} % -% \begin{variable}{\c_catcode_active_tl} -% A token list containing an active token. This is used internally -% for test purposes and should not be used other than in -% appropriately-constructed category code tests. -% \end{variable} -% % \section{Converting tokens} % % \begin{function}[EXP]{\token_to_meaning:N, \token_to_meaning:c} @@ -660,7 +654,10 @@ % \cs{token_if_long_macro_p:N} \meta{token} \\ % \cs{token_if_long_macro:NTF} \meta{token} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests if the \meta{token} is a long macro. +% Tests if the \meta{token} is a long macro with no other prefix; to +% test for a macro that is both long and protected, use +% \cs[index = token_if_protected_long_macro:NTF]^^A +% {token_if_protected_long_macro:N(TF)}. % \end{function} % % \begin{function}[EXP,pTF, updated=2012-01-20]{\token_if_protected_macro:N} @@ -668,8 +665,10 @@ % \cs{token_if_protected_macro_p:N} \meta{token} \\ % \cs{token_if_protected_macro:NTF} \meta{token} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests if the \meta{token} is a protected macro: for a macro which -% is both protected and long this returns \texttt{false}. +% Tests if the \meta{token} is a protected macro with no other prefix; to +% test for a macro that is both protected and long, use +% \cs[index = token_if_protected_long_macro:NTF]^^A +% {token_if_protected_long_macro:N(TF)}. % \end{function} % % \begin{function}[EXP,pTF, updated=2012-01-20]{\token_if_protected_long_macro:N} @@ -776,7 +775,7 @@ % ~~\Arg{false code} % \end{syntax} % This function compares the \meta{test token} in turn with each of -% the \meta{token cases}. If the two are equal (as described for +% the \meta{token case}s. If the two are equal (as described for % \cs{token_if_eq_catcode:NNTF}, \cs{token_if_eq_charcode:NNTF} and % \cs{token_if_eq_meaning:NNTF}, respectively) then the associated % \meta{code} is left in the input stream and other cases are @@ -794,7 +793,7 @@ % stream while leaving it in place. This is handled using the % \enquote{peek} functions. The generic \cs{peek_after:Nw} is provided % along with a family of predefined tests for common cases. Peeking -% ahead does \emph{not} skip spaces: rather, \cs{peek_remove_spaces:n}. +% ahead does \emph{not} skip spaces: rather, \cs{peek_remove_spaces:n} % should be used. In addition, using \cs{peek_analysis_map_inline:n}, % one can map through the following tokens in the input stream and % repeatedly perform some tests. @@ -1013,7 +1012,7 @@ % In case the input stream has not yet been tokenized (converted % from characters to tokens), characters are tokenized one by one as % needed by \cs{peek_analysis_map_inline:n} using the current -% category code regime. +% category code régime. % \end{texnote} % \end{function} % @@ -1828,12 +1827,12 @@ % \end{macrocode} % \end{macro} % -% \begin{variable}{\c_catcode_active_tl} +% \begin{variable}{\c_@@_active_tl} % Not an implicit token! % \begin{macrocode} \group_begin: \char_set_catcode_active:N \* - \tl_const:Nn \c_catcode_active_tl { \exp_not:N * } + \tl_const:Nn \c_@@_active_tl { \exp_not:N * } \group_end: % \end{macrocode} % \end{variable} @@ -1970,13 +1969,13 @@ % % \begin{macro}[pTF]{\token_if_active:N} % Check if token is an active char token. We use the constant -% \cs{c_catcode_active_tl} for this. A technical point is that -% \cs{c_catcode_active_tl} is in fact a macro expanding to +% \cs{c_@@_active_tl} for this. A technical point is that +% \cs{c_@@_active_tl} is in fact a macro expanding to % |\exp_not:N *|, where |*| is active. % \begin{macrocode} \prg_new_conditional:Npnn \token_if_active:N #1 { p , T , F , TF } { - \if_catcode:w \exp_not:N #1 \c_catcode_active_tl + \if_catcode:w \exp_not:N #1 \c_@@_active_tl \prg_return_true: \else: \prg_return_false: \fi: } % \end{macrocode} @@ -2828,7 +2827,7 @@ end % \peek_meaning_remove:N, % } % The public functions themselves cannot be defined using -% \cs{prg_new_conditional:Npnn}. Instead, the |TF|, |T|, |F| variants +% \cs{prg_new_protected_conditional:Npnn}. Instead, the |TF|, |T|, |F| variants % are defined in terms of corresponding variants of % \cs{@@_token_generic:NNTF} or \cs{@@_token_remove_generic:NNTF}, % with first argument one of \cs{@@_execute_branches_catcode:}, diff --git a/macros/latex/required/l3kernel/l3unicode.dtx b/macros/latex/required/l3kernel/l3unicode.dtx index 179817d490..535816e979 100644 --- a/macros/latex/required/l3kernel/l3unicode.dtx +++ b/macros/latex/required/l3kernel/l3unicode.dtx @@ -2,7 +2,7 @@ % %% File: l3unicode.dtx % -% Copyright (C) 2018-2024 The LaTeX Project +% Copyright (C) 2018-2025 The LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2025-01-18} % % \maketitle % @@ -162,9 +162,7 @@ % can generate character tokens for document use: those are defined below, % in the data recovery setup. % \begin{macrocode} -\bool_lazy_or:nnTF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } +\sys_if_engine_opentype:TF { \cs_new:Npn \codepoint_str_generate:n #1 { @@ -390,9 +388,7 @@ { \exp_args:Ne \@@_to_nfd:n { \int_eval:n {#1} } } \cs_new:Npn \@@_to_nfd:n #1 { \@@_to_nfd:nn {#1} { \char_value_catcode:n {#1} } } -\bool_lazy_or:nnF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } +\sys_if_engine_opentype:F { \cs_gset:Npn \@@_to_nfd:n #1 { @@ -719,15 +715,22 @@ \tl_set:ce { l_@@_ #1 _block_tl } { \int_eval:n { \tl_use:c { l_@@_ #1 _block_tl } + 1 } } } - \prg_replicate:nn {#2} +% \end{macrocode} +% Here, we avoid \cs{prg_replicate:nn} as the number of tokens generated would be +% high: that shows in the format dump (although \TeX{} recovers memory during +% the subsequent runs). +% \begin{macrocode} + \int_step_inline:nnn + { \tl_use:c { l_@@_ #1 _pos_tl } + 1 } + { \tl_use:c { l_@@_ #1 _pos_tl } + #2 } { - \tl_set:ce { l_@@_ #1 _pos_tl } - { \int_eval:n { \tl_use:c { l_@@_ #1 _pos_tl } + 1 } } \exp_args:Nc \__kernel_intarray_gset:Nnn { g_@@_ #1 _index_intarray } - { \tl_use:c { l_@@_ #1 _pos_tl } } + {##1} \l_@@_matched_block_tl } + \tl_set:ce { l_@@_ #1 _pos_tl } + { \int_eval:n { \tl_use:c { l_@@_ #1 _pos_tl } + #2 } } \clist_clear:c { l_@@_ #1 _block_clist } } % \end{macrocode} diff --git a/macros/latex/required/l3kernel/source3.pdf b/macros/latex/required/l3kernel/source3.pdf Binary files differindex 34279f9e00..74ac2af747 100644 --- a/macros/latex/required/l3kernel/source3.pdf +++ b/macros/latex/required/l3kernel/source3.pdf diff --git a/macros/latex/required/l3kernel/source3.tex b/macros/latex/required/l3kernel/source3.tex index 00095ad319..9f664d1b77 100644 --- a/macros/latex/required/l3kernel/source3.tex +++ b/macros/latex/required/l3kernel/source3.tex @@ -2,7 +2,7 @@ File: source3.tex -Copyright (C) 1990-2012,2017-2024 The LaTeX Project +Copyright (C) 1990-2012,2017-2025 The LaTeX Project It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -57,7 +57,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2024-05-27} +\date{Released 2025-01-18} \pagenumbering{roman} \maketitle diff --git a/macros/latex/required/l3kernel/source3body.tex b/macros/latex/required/l3kernel/source3body.tex index 8471296227..4b97218447 100644 --- a/macros/latex/required/l3kernel/source3body.tex +++ b/macros/latex/required/l3kernel/source3body.tex @@ -285,7 +285,7 @@ pass it to |\foo:N|. Variables are named in a similar manner to functions, but begin with a single letter to define the type of variable: -\begin{description} +\begin{description}[leftmargin=2\parindent, labelindent*=-\parindent] \item[\texttt{c}] Constant: global parameters whose value should not be changed. \item[\texttt{g}] Parameters whose value should only be set globally. @@ -302,7 +302,7 @@ function, typically starting with the module\footnote{The module names are \texttt{\string\l_int_tmpa_int} would be very unreadable.} name and then a descriptive part. Variables end with a short identifier to show the variable type: -\begin{description}% +\begin{description}[leftmargin=2\parindent, labelindent*=-\parindent] \item[\texttt{bitset}] a set of bits (a string made up of a series of \texttt{0} and \texttt{1} tokens that are accessed by position). \item[\texttt{clist}] Comma separated list. @@ -318,7 +318,7 @@ Variables end with a short identifier to show the variable type: Applying \texttt{V}-type or \texttt{v}-type expansion to variables of one of the above types is supported, while it is not supported for the following variable types: -\begin{description} +\begin{description}[leftmargin=2\parindent, labelindent*=-\parindent] \item[\texttt{bool}] Either true or false. \item[\texttt{box}] Box register. \item[\texttt{coffin}] A \enquote{box with handles} --- a higher-level @@ -335,6 +335,21 @@ following variable types: lists (with access at both ends) and stacks. \end{description} +\subsection{Behavior of \texttt{c}-type arguments when the \texttt{N}-type token + resulting from expansion is undefined} + +When \texttt{c}-type expansion is applied, it will produce an \texttt{N}-type +token to be consumed by the underlying function. If the result of this process +is a token which is undefined, \TeX{}'s behavior is to make it equal to +|\scan_stop:| (|\relax|). + +This will likely lead to low-level errors if it occurs in contexts where +\pkg{expl3} expects a \enquote{variable}, e.g.~a \texttt{prop}, \texttt{seq}, +etc. Therefore, the programmer should ensure that \texttt{c}-type expansion is +only applied when the resulting \texttt{N}-type token will definitely exist, +i.e.~when it is either defined prior to the application of the \texttt{c}-type +expansion or will be by the underlying \texttt{N}-type function. + \subsection{Scratch variables} Modules focussed on variable usage typically provide four scratch variables, @@ -344,6 +359,19 @@ are never used by the core code. The nature of \TeX{} grouping means that as with any other scratch variable, these should only be set and used with no intervening third-party code. +There are two more special types of constants: +\begin{description}[leftmargin=2\parindent, labelindent*=-\parindent] + \item[\texttt{q}] Quark constants. + \item[\texttt{s}] Scan mark constants. +\end{description} +Similarly, each quark or scan mark name starts with the module name, +but doesn't end with a variable type, because the type is already +marked by the prefix \texttt{q} or \texttt{s}. +Some general quarks and scan marks provided by \LaTeX3 don't start +with a module name, for example \cs{s_stop}. +See documentation of quarks and scan marks in Chapter~\ref{sec:l3quarks} +for more info. + \subsection{Terminological inexactitude} A word of warning. In this document, and others referring to the \pkg{expl3} @@ -402,12 +430,12 @@ show this more clearly. They will carry out the same function but will take different types of argument: \begin{function}[label = ]{\seq_new:N, \seq_new:c} \begin{syntax} - |\seq_new:N| \meta{sequence} + |\seq_new:N| \meta{seq var} \end{syntax} When a number of variants are described, the arguments are usually - illustrated only for the base function. Here, \meta{sequence} indicates - that |\seq_new:N| expects the name of a sequence. From the argument - specifier, |\seq_new:c| also expects a sequence name, but as a + illustrated only for the base function. Here, \meta{seq var} indicates + that |\seq_new:N| expects a sequence variable. From the argument + specifier, |\seq_new:c| also expects a sequence variable, but as a name rather than as a control sequence. Each argument given in the illustration should be described in the following text. \end{function} @@ -435,7 +463,7 @@ an \texttt{f}-type argument. In this case a hollow star is used to indicate this: \begin{function}[rEXP, label = ]{\seq_map_function:NN} \begin{syntax} - |\seq_map_function:NN| \meta{seq} \meta{function} + |\seq_map_function:NN| \meta{seq var} \meta{function} \end{syntax} \end{function} diff --git a/macros/latex/required/latex-lab/README.md b/macros/latex/required/latex-lab/README.md index d87f6fedf9..89d8d9f659 100644 --- a/macros/latex/required/latex-lab/README.md +++ b/macros/latex/required/latex-lab/README.md @@ -1,6 +1,6 @@ # LaTeX laboratory -Release 2024-06-01 patch level 0 +Release 2024-11-01 ## Overview diff --git a/macros/latex/required/latex-lab/blocks-code.pdf b/macros/latex/required/latex-lab/blocks-code.pdf Binary files differindex f4898a522c..e40b24e3cb 100644 --- a/macros/latex/required/latex-lab/blocks-code.pdf +++ b/macros/latex/required/latex-lab/blocks-code.pdf diff --git a/macros/latex/required/latex-lab/blocks-doc.pdf b/macros/latex/required/latex-lab/blocks-doc.pdf Binary files differindex 90b0bd984c..ac36ba8bd6 100644 --- a/macros/latex/required/latex-lab/blocks-doc.pdf +++ b/macros/latex/required/latex-lab/blocks-doc.pdf diff --git a/macros/latex/required/latex-lab/changes.txt b/macros/latex/required/latex-lab/changes.txt index cd53086b2b..b7a1c64cf1 100644 --- a/macros/latex/required/latex-lab/changes.txt +++ b/macros/latex/required/latex-lab/changes.txt @@ -1,12 +1,159 @@ +2025-01-27 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * latex-lab-firstaid.dtx (subsection{ams classes and amsthm}): + Add missing \par to abstract env (gh/1641) + +2024-10-25 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-math.dtx: reorganized luamml and mathml options + to support also structure elements and extended the documentation. Corrected + handling of alt-texts. Added examples for the various options. + +2024-10-16 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-firstaid.dtx: correct amsthm firstaid (tagging/733), + remove now unneeded code for cleveref. + +2024-10-12 Joseph Wright <Joseph.Wright@latex-project.org> + * latex-lab-math.dtx: Sync with protected-begin status + +2024-10-11 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-toc.dtx, latex-lab-sec.dtx, latex-lab-toc-kernel-changes: move target + handling (\MakeLinkTarget patches) into the kernel. + +2024-10-11 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * latex-lab-block.dtx (subsubsection{verse environment}): + Update \@itemlabel in \l_@@_legacy_env_params_tl and not at the start of + the environment (tagging/730) + + Set the defaults for \@itemlabel, \@listctr and @nmbrlist early in the + block code before the setup code gets executed (tagging/730) + + (subsubsection{Implementation of list templates ...): + Correct logic for setting up the list counter (tagging/730) + +2024-10-04 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-firstaid.dtx: add first support for fancyvrb environments. + +2024-10-04 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-sec.dtx (subsection{Sockets}): + add missing braces around optional arg (tagging/725) + +2024-10-03 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + * latex-lab-block.dtx (subsubsection{Implementation of list templates ...}): + Pass user keys on list to \item for evaluation + +2024-10-02 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-math.dtx (subsection{Sockets}): + disable paratagging in inline math (tagging/711) + +2024-09-30 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-footnotes.dtx: remove unneeded NonStruct structure. + +2024-09-30 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + * latex-lab-math.dtx (subsection{Content grabbing}): + Correct logic for inserting below skips after displays (tagging/721) + +2024-09-26 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-firstaid.dtx: add support for theorems declared with + amsthm, amsart, amsbook, amsproc. + +2024-09-24 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-sec.dtx,latex-lab-footnotes.dtx: + correct and improve footnotes in longtable + +2024-09-24 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-toc.dtx,latex-lab-footnotes.dtx: adapt Ref handling to tagpdf 0.99f + +2024-09-18 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-amsmath.dtx,latex-lab-graphic.dtc, + latex-lab-marginpar.dtx,latex-lab-math.dtx,latex-lab-mathtools.dtx, + latex-lab-minipage.dtx,latex-lab-sec.dtx,latex-lab-table.dtx,latex-lab-text.dtx: + switch to \tag_suspend:n and \tag_resume:n + +2024-09-17 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-float.dtx: switch to tagging sockets + +2024-09-13 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * documentmetadata-support.dtx: change warning to error if pdfstandard is unknown, + see https://github.com/latex3/pdfresources/issues/77#issuecomment-2329522654. + +2024-09-03 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * documentmetadata-support.dtx: switch to T1 encoding by default for non-Unicode + engines. + +2024-09-02 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + * latex-lab-block.dtx (subsubsection{List tags}): + Do not close LI and LBody if they were never opened because of a + missing \item (issue tagging/641) + + (subsubsection{Implementation of \cs{item} template(s)}): + Set @newlist to false after the first \item (issue tagging/36) + + Call \@noitemerr in para/begin hook if hmode is started before + the first item + + (subsubsection{Implementation of block templates \ldots}): + Drop \@noitemerr from \addvspace and \addpenalty + +2024-08-29 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-math.dtx: avoid loosing math if tagging is suspended, + tagging-project issue #661 + +2024-08-22 Joseph Wright <Joseph.Wright@latex-project.org> + * latex-lab-math.dtx: correct handling of empty math processing + +2024-08-21 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-math.dtx: correct luamml patches for array, + allow to use luamml without unicode-math + +2024-08-14 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-math.dtx: add luamml support for automatic mathml generation + +2024-08-12 Joseph Wright <Joseph.Wright@latex-project.org> + * latex-lab-math.dtx: add support for math in tabulars + +2024-08-11 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-firstaid.dtx: amsproc support, discussion in PR #517 + +2024-08-11 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-block.dtx: preset verbatim para-instance, issue #119 + +2024-08-10 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-block.dtx, latex-lab-table.dtx: reset flattened level in para/restore, issue #544 + +2024-08-08 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-minipage.dtx, latex-lab-table.dtx: improve support for minipage in tables. + handle issue #37 + +2024-08-06 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-table.dtx: add support for header-columns + * latex-lab-table.dtx: add support for multirows + * latex-lab-table.dtx: handle issue #432 + * latex-lab-marginpar.dtx: handle issue #444 + +2024-07-11 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-footnote.dtx: restore paragraph defaults at the begin of the footnote + tagging-project#262 + +2024-07-13 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * latex-lab-table.dtx (subsection{Tagging support sockets}): + add plugs for tbl/leaders/begin and /end + (subsection{Misc stuff}): drop unused socket + +2024-07-11 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * latex-lab-toc.dtx, latex-lab-toc-kernel-changes: switch from configuration points + to sockets. + 2024-05-25 Ulrike Fischer <Ulrike.Fischer@latex-project.org> * latex-lab-table.dtx: disable table headers in presentation tables. 2024-05-25 Ulrike Fischer <Ulrike.Fischer@latex-project.org> - * latex-lab-firstaid.dtx: add firstaid for booktabs cmidrules, + * latex-lab-firstaid.dtx: add firstaid for booktabs cmidrules, see tagging-issue 69. 2024-04-18 Ulrike Fischer <Ulrike.Fischer@latex-project.org> - * documentmetadata-support.dtx: change handling of default language. + * documentmetadata-support.dtx: change handling of default language. The code now tries to detect languages set by babel/polyglossia. 2024-04-16 Ulrike Fischer <Ulrike.Fischer@latex-project.org> diff --git a/macros/latex/required/latex-lab/documentmetadata-support-code.pdf b/macros/latex/required/latex-lab/documentmetadata-support-code.pdf Binary files differindex 9720f83a60..c3d7a14be9 100644 --- a/macros/latex/required/latex-lab/documentmetadata-support-code.pdf +++ b/macros/latex/required/latex-lab/documentmetadata-support-code.pdf diff --git a/macros/latex/required/latex-lab/documentmetadata-support-doc.pdf b/macros/latex/required/latex-lab/documentmetadata-support-doc.pdf Binary files differindex e45892165c..9db383a0c4 100644 --- a/macros/latex/required/latex-lab/documentmetadata-support-doc.pdf +++ b/macros/latex/required/latex-lab/documentmetadata-support-doc.pdf diff --git a/macros/latex/required/latex-lab/documentmetadata-support.dtx b/macros/latex/required/latex-lab/documentmetadata-support.dtx index a629d9c551..6752e8098a 100644 --- a/macros/latex/required/latex-lab/documentmetadata-support.dtx +++ b/macros/latex/required/latex-lab/documentmetadata-support.dtx @@ -18,8 +18,8 @@ % for those people who are interested or want to report an issue. % % \begin{macrocode} -\def\documentmetadatasupportversion{1.0h} -\def\documentmetadatasupportdate{2024-03-26} +\def\documentmetadatasupportversion{1.0j} +\def\documentmetadatasupportdate{2024-09-13} % \end{macrocode} % % @@ -314,6 +314,19 @@ { \tl_new:N \g_@@_testphase_tl } % \end{macrocode} % \end{variable} +% +% \subsection{Kernel changes with \cs{DocumentMetadata}} +% \begin{macro}{\@kernel@before@DocumentMetadata} +% \begin{macrocode} +\cs_new_protected:Npn \@kernel@before@DocumentMetadata + { + \ifx\Umathcode\@undefined + \fontencoding{T1} + \renewcommand\encodingdefault{T1} + \fi + } +% \end{macrocode} +% \end{macro} % \subsection{\cs{DocumentMetadata}} % @@ -330,6 +343,10 @@ { \msg_error:nn { meta } { after-class } } { % \end{macrocode} +% Load general format changes +% \begin{macrocode} + \@kernel@before@DocumentMetadata +% \end{macrocode} % % The wanted backend must be detected first, we read the init % key and then force the loading of the backend. @@ -481,7 +498,7 @@ } ,_pdfstandard / unknown .code:n = { - \msg_warning:nnn{pdf}{unknown-standard}{#1} + \msg_error:nnn{pdf}{unknown-standard}{#1} } ,testphase .multichoice: ,testphase / tagpdf .code:n = diff --git a/macros/latex/required/latex-lab/latex-lab-amsmath.dtx b/macros/latex/required/latex-lab/latex-lab-amsmath.dtx index 57e27067cb..8591b39b39 100644 --- a/macros/latex/required/latex-lab/latex-lab-amsmath.dtx +++ b/macros/latex/required/latex-lab/latex-lab-amsmath.dtx @@ -66,7 +66,7 @@ % \subsection{File declaration} % \begin{macrocode} \ProvidesFile{latex-lab-amsmath.ltx} - [2024-02-12 v0.1b amsmath adaptions] + [2024-09-18 v0.1c amsmath adaptions] % \end{macrocode} % \subsection{Tagpdf support} % To make the code independent from tagging being loaded and active @@ -99,7 +99,7 @@ % \end{macrocode} % Stop tagging when measuring: % \begin{macrocode} - \ifmeasuring@\tag_stop:\fi + \ifmeasuring@\tag_suspend:n{\measuring}\fi \normalbaselines \ifdim\linewidth=\columnwidth \else \parshape\@ne \@totalleftmargin \linewidth @@ -174,7 +174,7 @@ \def\text@#1 {{ \int_gincr:N\g__math_mathchoice_int - \tag_stop: + \tag_suspend:n{\text@} \mathchoice { \@@_tag_if_mathstyle:en{mathchoice-\int_use:N\g__math_mathchoice_int}{0} @@ -200,8 +200,8 @@ % \end{macrocode} % % \subsection{\cs{pmb}} -% \cs{pmb} prints is argument three times. For tagging we must mark -% two of occurences as artifact. +% \cs{pmb} prints its argument three times. For tagging we must mark +% two of occurrences as artifact. % For luatex the attributes in the box must be reset, for this % we switch to expl3-boxes. % \begin{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-amsmath.pdf b/macros/latex/required/latex-lab/latex-lab-amsmath.pdf Binary files differindex bb5a689c31..4241c654b1 100644 --- a/macros/latex/required/latex-lab/latex-lab-amsmath.pdf +++ b/macros/latex/required/latex-lab/latex-lab-amsmath.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-bib.dtx b/macros/latex/required/latex-lab/latex-lab-bib.dtx index e8ee192a7b..9d336aba20 100644 --- a/macros/latex/required/latex-lab/latex-lab-bib.dtx +++ b/macros/latex/required/latex-lab/latex-lab-bib.dtx @@ -16,7 +16,7 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabbibdate{2024-02-12} +\def\ltlabbibdate{2024-07-05} \def\ltlabbibversion{0.81b} %<*driver> \documentclass{l3doc} @@ -128,7 +128,7 @@ % % \begin{function}{\@extra@binfo,\@extra@b@citeb} % -% These are taken from hyperref, they are for chapterbib compability (and also +% These are taken from hyperref, they are for chapterbib compatibility (and also % signal to chapterbib not to change the citation commands) % \end{function} % @@ -157,7 +157,7 @@ % \end{macrocode} % \begin{macro}{\@extra@binfo,\@extra@b@citeb} -% These are taken from hyperref, they are for chapterbib compability (and also +% These are taken from hyperref, they are for chapterbib compatibility (and also % signal to chapterbib not to change the citation commands) % \begin{macrocode} \providecommand*\@extra@binfo{}% @@ -270,7 +270,7 @@ % \end{macrocode} % Now we add the tagging structure. % TODO: with the next tagpdf version it should no longer be -% needed to exand the ref key. +% needed to expand the ref key. % \begin{macrocode} \AddToHookWithArguments{bibcite/before} { @@ -305,7 +305,7 @@ % We need in part different code for both systems: % with biblatex we have to take care that only the first % structure sets a label, and if -% hyperref is not loaded (or deactived) we will need additional code +% hyperref is not loaded (or deactivated) we will need additional code % but this currently doesn't exist. % We assume that no document loads both package -- that will probably break. % \begin{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-bib.pdf b/macros/latex/required/latex-lab/latex-lab-bib.pdf Binary files differindex 7befa83ed9..3518f98044 100644 --- a/macros/latex/required/latex-lab/latex-lab-bib.pdf +++ b/macros/latex/required/latex-lab/latex-lab-bib.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-block.dtx b/macros/latex/required/latex-lab/latex-lab-block.dtx index 7d08b270d2..74d68c495a 100644 --- a/macros/latex/required/latex-lab/latex-lab-block.dtx +++ b/macros/latex/required/latex-lab/latex-lab-block.dtx @@ -9,8 +9,8 @@ % % https://www.latex-project.org/lppl.txt % -\def\ltlabblockdate{2024-03-23} -\def\ltlabblockversion{0.8n} +\def\ltlabblockdate{2024-10-11} +\def\ltlabblockversion{0.8v} %<*driver> \documentclass[kernel]{l3doc} \usepackage{amstext} @@ -331,6 +331,8 @@ % \TemplateKey{par-skip}{skip}{}{\cs{parsep}} % \TemplateKey{end-skip}{skip}{}{\valuefrom{beginsep}} % \TemplateKey{end-par-skip}{skip}{}{\valuefrom{begin-par-skip}} +% \TemplateKey{item-skip}{skip}{The space in front of an item if the +% block is a list; if not the setting has no effect}{\cs{itemsep}} % \TemplateKey{beginpenalty}{integer}{}{\cs{@beginparpenalty}} % \TemplateKey{endpenalty}{integer}{}{\cs{@endparpenalty}} % \TemplateKey{leftmargin}{length}{}{\cs{leftmargin}} @@ -341,7 +343,7 @@ % % The idea of a \key{heading} key needs some further % thoughts. Maybe instead the object type should accept a second -% argument and receive input for such a headding from the document +% argument and receive input for such a heading from the document % level instead. % % The names of the keys need further thoughts and some @@ -390,7 +392,7 @@ % {Instance of type \texttt{item} to be used to format % the label string}{basic} % \TemplateKey{item-skip}{skip}{The space in front of an item in the -% list.\fmi{May need to be on a different template level}}{\cs{itemsep}} +% list. If not specified the value specified in the block template instance is used}{} % \TemplateKey{item-indent}{length}{Horizontal displacement of the item.}{0pt} % \TemplateKey{item-penalty}{integer} % {Penalty for breaking before an @@ -474,7 +476,7 @@ % \>\>\> The paragraph text before the display element \ldots\\ % \>\> \struct{/text}\\ % \>\> \struct{display element structure}\\ -% \>\>\> Content of the display structure possiblly involving inner \struct{text-unit} tags\\ +% \>\>\> Content of the display structure possibly involving inner \struct{text-unit} tags\\ % \>\> \struct{/display element structure}\\ % \>\> \struct{text}\\ % \>\>\> \ldots{} continuing the outer paragraph text\\ @@ -722,7 +724,7 @@ blockenv implementation] % \end{macrocode} % -% Generell kernel changes, also loaded by the sec and toc code. +% General kernel changes, also loaded by the sec and toc code. % \begin{macrocode} \RequirePackage{latex-lab-kernel-changes} % \end{macrocode} @@ -756,8 +758,9 @@ % % % -% \begin{macro}{\@doendpe} +% \begin{macro}{\@doendpe,\__kernel_displayblock_doendpe:} % The original \LaTeXe{} command is augmented to allow for tagging. +% TODO: use sockets for this and move to the kernel eventually. % \begin{macrocode} \def\@doendpe{\@endpetrue \def\par @@ -792,15 +795,10 @@ % \begin{macrocode} \cs_new_eq:NN \__kernel_displayblock_doendpe: \prg_do_nothing: % \end{macrocode} -% The flag itself should be set globally not locally.\fmi{verify -% that this claim is actually correct!} -% \begin{macrocode} -\def\@endpetrue {\global\let\if@endpe\iftrue} -\def\@endpefalse{\global\let\if@endpe\iffalse} -% \end{macrocode} -% \end{macro} % % +% \end{macro} +% % % \subsection{Object and template interfaces} % @@ -847,6 +845,7 @@ % % \begin{template}{block display} % +% \changes{v0.8s}{2024/10/03}{Offer item-skip key also on block templates} % \begin{macrocode} \DeclareTemplateInterface{block}{display}{1} { @@ -856,6 +855,7 @@ par-skip : skip = \parsep , end-skip : skip = \KeyValue{beginsep} , % conflict with name below end-par-skip : skip = \KeyValue{begin-par-skip} , + item-skip : skip = \itemsep , beginpenalty : integer = \UseName{@beginparpenalty} , endpenalty : integer = \UseName{@endparpenalty} , leftmargin : length = \leftmargin , @@ -1269,9 +1269,15 @@ % We do this by storing them away and then call the list % instance. Inside this instance the \texttt{setup-code} key % contains \cs{legacylistsetupcode}, which makes use of the stored values. +% \changes{v0.8v}{2024/10/11}{Update \cs{@itemlabel} in +% \cs{l_@@_legacy_env_params_tl} and not at the start of the +% environment (tagging/730)} % \begin{macrocode} - \tl_set:Nn \@itemlabel {#2} - \tl_set:Nn \l_@@_legacy_env_params_tl {#3} + \tl_set:Nn \l_@@_legacy_env_params_tl + { + \tl_set:Nn \@itemlabel {#2} + #3 + } % \end{macrocode} % % \begin{macrocode} @@ -1285,14 +1291,6 @@ % % % -% \begin{variable}{\l_@@_env_params_tl} -% Declare the variable for the parameter argument; \cs{@itemlabel} -% is already declared in \LaTeXe{}. -% \begin{macrocode} -\tl_new:N \l_@@_env_params_tl -% \end{macrocode} -% \end{variable} -% % % \begin{macro}{\legacylistsetupcode} % @@ -1308,10 +1306,14 @@ \dim_zero:N \itemindent % \end{macrocode} % -% By default a \env{list} environment is not numbered: +% By default a \env{list} environment is not numbered, but this +% happens already in the block template. +% \changes{v0.8v}{2024/10/11}{Set the defaults for \cs{@itemlabel}, +% \cs{@listctr} and \texttt{@nmbrlist} early in the block code +% before the setup code gets executed (tagging/730)} % \begin{macrocode} - \tl_set:Nn \@listctr {} - \legacy_if_set_false:n { @nmbrlist } % needed if lists are nested +% \tl_set:Nn \@listctr {} +% \legacy_if_set_false:n { @nmbrlist } % needed if lists are nested % \end{macrocode} % By default there is a simple definition for \cs{makelabel}. It can be % overwritten in the second mandatory argument to the list @@ -1569,7 +1571,7 @@ % \end{macrocode} % We need to know later if we have nested blockenvs inside % a flattened environment. Whenever we start a new blockenv we -% increment \cs{\l_@@_flattened_level_int} if it is already +% increment \cs{l__tag_block_flattened_level_int} if it is already % different from zero. If it is zero we increment it if flattening % is requested. % Thus a value of \texttt{0} means no flattening requested so far @@ -1578,14 +1580,14 @@ % is surrounded by a \texttt{text-unit} tag, while for any value above % \texttt{1} we have to omit the \texttt{text-unit}. % \begin{macrocode} - \int_compare:nNnTF \l_@@_flattened_level_int > 0 + \int_compare:nNnTF \l__tag_block_flattened_level_int > 0 { - \int_incr:N \l_@@_flattened_level_int + \int_incr:N \l__tag_block_flattened_level_int } { \bool_if:NT \l__tag_para_flattened_bool { - \int_incr:N \l_@@_flattened_level_int + \int_incr:N \l__tag_block_flattened_level_int } } % @@ -1623,6 +1625,23 @@ % \begin{macrocode} \tag_if_active:T { \use:c { @@_recipe_ \l_@@_tagging_recipe_tl : } } % \end{macrocode} +% The default for \env{list} environments is that they have an +% empty label and are not numbered (something that is then +% overwritting by the setup of a specific list). We ensure +% this here even for non-lists, because we need a defined state +% that then can be overwritting by the legacy setup code for +% the \env{list} environment in \cs{l_@@_setup_code_tl}. +% This is needed in case lists are nested as they otherwise would +% inherit outer values (and suddenly an \env{itemize} would start +% incrementing an outer \env{enumerate} counter, etc. +% \changes{v0.8v}{2024/10/11}{Set the defaults for \cs{@itemlabel}, +% \cs{@listctr} and \texttt{@nmbrlist} early in the block code +% before the setup code gets executed (tagging/730)} +% \begin{macrocode} + \tl_clear:N \@itemlabel + \tl_clear:N \@listctr + \legacy_if_set_false:n { @nmbrlist } +% \end{macrocode} % Then run the setup code if any is given in the instance. % \begin{macrocode} \l_@@_setup_code_tl @@ -1681,11 +1700,15 @@ % \end{template} % % -% \begin{macro}{\l_@@_flattened_level_int} +% \begin{macro}{\l__tag_block_flattened_level_int} % Count the levels of nested blockenvs starting with the first that -% is \enquote{flattened}. +% is \enquote{flattened}. The counter is defined in lttagging.dtx, +% but until the next release 11/24 we set it up here too % \begin{macrocode} -\int_new:N \l_@@_flattened_level_int +\int_if_exist:NF \l__tag_block_flattened_level_int + { + \int_new:N \l__tag_block_flattened_level_int + } % \end{macrocode} % \end{macro} % @@ -1725,15 +1748,19 @@ \legacy_if_gset_false:n { @inlabel } } % \end{macrocode} -% In a pure ``displayblock'' scenario \texttt{@newlist} will be -% always false and the code bypassed, but we may have an outer list -% followed immediately by a displayblock (with the \cs{item} missing) +% If we are ending a list environment and we have not seen any +% \cs{item}, i.e., \texttt{@newlist} is still true, we raise an +% error. In basic a ``displayblock'' scenario \texttt{@newlist} will +% always be false, but if such an environment appears inside an outer +% list then \cs{noitemerr} could still be triggered and that is undesirable +% (as the missing item will be detected at the wrong point and again later, +% during the outer list processing). We +% therefore run it only if the current environment is a list. +% \changes{v0.8q}{2024/09/03}{Raise a \cs{@noitemerr} if appropriate} +% \begin{macrocode} + \@@_if_list:T { \legacy_if:nT { @newlist } { \@noitemerr } } +% \end{macrocode} % \begin{macrocode} - \legacy_if:nT { @newlist } - { - \@noitemerr - \legacy_if_gset_false:n { @newlist } - } \mode_if_horizontal:TF { \@@_skip_remove_last: \@@_skip_remove_last: \par } { \@inmatherr{\end{\@currenvir}} } @@ -1743,6 +1770,13 @@ % \begin{macrocode} \__kernel_displayblock_end: % \end{macrocode} +% Resetting the \texttt{@newlist} switch is also only done if the +% current enviornment is a list and not unconditionally. +% \changes{v0.8q}{2024/09/03}{Setting \texttt{@newlist} to false +% moved after tagging code if in a list} +% \begin{macrocode} + \@@_if_list:T { \legacy_if_gset_false:n { @newlist } } +% \end{macrocode} % What to do in terms of vertical spacing in different situations % is still somewhat open to debate, right now this is more or less % implementing what \LaTeXe{} list environment have been @@ -1789,6 +1823,19 @@ % \end{macro} % % +% \begin{macro}{\@@_if_list:T} +% The following code may need some redesigning, as there is no good test for \enquote{is +% this environment a \enquote{list} that has \cs{item}s}. For now +% this here does the trick well enough.\fmi{revisit} +% \changes{v0.8q}{2024/09/03}{Provide a test for: Am I in a list?} +% \begin{macrocode} +\cs_new:Npn \@@_if_list:T + { \tl_if_eq:NnT \l_@@_block_instance_tl {list} } +% \end{macrocode} +% \end{macro} +% +% +% % \begin{macro}{\__kernel_displayblock_end:} % The kernel hook for tagging at the end of the block. % \begin{macrocode} @@ -1814,9 +1861,13 @@ % and should not inherit the setting from the outer environment. % \begin{macrocode} \socket_new_plug:nnn{tagsupport/block-endpe}{on} - { \legacy_if_gset_true:n { @endpe } } +% \end{macrocode} +% We can't use \cs{legacy_if_gset_true:n} because this is now doing +% more than setting the legacy switch +% \begin{macrocode} + { \@endpetrue } \socket_new_plug:nnn{tagsupport/block-endpe}{off} - { \legacy_if_gset_false:n { @endpe } } + { \@endpefalse } % \end{macrocode} % % \begin{macrocode} @@ -1864,6 +1915,7 @@ % % \begin{template}{block display} % +% \changes{v0.8s}{2024/10/03}{Offer item-skip key also on block templates} % \begin{macrocode} \DeclareTemplateCode{block}{display}{1} { @@ -1873,6 +1925,7 @@ par-skip = \parsep , end-skip = \l_@@_botsep_skip , end-par-skip = \l_@@_parbotsep_skip , + item-skip = \itemsep , beginpenalty = \@beginparpenalty , endpenalty = \@endparpenalty , rightmargin = \rightmargin , @@ -1981,7 +2034,7 @@ % \cs{parskip} and some other housekeeping, unless this block is inside a list and the list % \cs{item} has not yet placed. In that case the vertical % space and penalty us suppressed. This -% is controled through the legacy switches \texttt{@noparitem}, +% is controlled through the legacy switches \texttt{@noparitem}, % \texttt{minipage}, and \texttt{@nobreak}. % \begin{macrocode} \legacy_if:nTF { @noparitem } @@ -2028,7 +2081,6 @@ % \end{template} % % -% % \begin{macro}{\__kernel_displayblock_begin:, % \__kernel_displayblock_beginpar_hmode:w, % \__kernel_displayblock_beginpar_vmode:} @@ -2073,6 +2125,40 @@ % % % +% \begin{macro}{\@@_evaluate_saved_user_keys:nn} +% Keys set on individual list environments may be intended to alter +% the behavior of the template instance that defines the \cs{item} +% command. If meant to alter only a single \cs{item} command one +% would specify them in the optional argument of the \cs{item}, but +% if they should alter all items the right place would be the list +% environment. For this reason we need to store the values and then +% set them inside the \cs{item} template code using +% \cs{SetTemplateKeys} in the appropriate context (template type +% and template name). This is done in +% \cs{@@_evaluate_saved_user_keys:nn}. The context is provided in +% the two arguments (because different list environments may use +% different \cs{item} instances based on different templates. By +% default the command does +% nothing because most environments do not have user key settings. +% \changes{v0.8s}{2024/10/03}{Pass user keys on list to \cs{item} for +% evaluation} +% \begin{macrocode} +\cs_new_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn +% \end{macrocode} +% Maybe something like this should become a public function, but +% for now this is a one-off for the \cs{item} command and therefore +% coded inline and internal to the block code. +% \begin{macrocode} +%\cs_new:Npn \@@_save_user_keys:n #1 { +% \tl_if_empty:nTF {#1} +% { \cs_set_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn } +% { +% \cs_set:Npe \@@_evaluate_saved_user_keys:nn ##1##2 +% { \SetTemplateKeys{##1}{##2}{ \exp_not:n{#1} } } +% } +%} +% \end{macrocode} +% \end{macro} % % % \begin{template}{list std} @@ -2098,36 +2184,48 @@ { \@@_debug_typeout:n{template:list:std} % - \tl_if_empty:nF {#1} { \SetTemplateKeys{list}{std}{#1} } +% \end{macrocode} +% We start by looking at the user supplied keys in \texttt{\#1}. If +% there aren't any we reset \cs{@@_evaluate_saved_user_keys:nn} to +% do nothing. Otherwise we evaluate and set the keys in the contect +% of the current list template. In addition we prepare +% \cs{@@_evaluate_saved_user_keys:nn} for execution in the +% template for \cs{item}. +% \changes{v0.8s}{2024/10/03}{Prepare \cs{@@_evaluate_saved_user_keys:nn} +% for use in \cs{item}} +% \begin{macrocode} + \tl_if_empty:nTF {#1} + { \cs_set_eq:NN \@@_evaluate_saved_user_keys:nn \use_none:nn } + { + \SetTemplateKeys{list}{std}{#1} + \cs_set:Npe \@@_evaluate_saved_user_keys:nn ##1##2 + { \SetTemplateKeys{##1}{##2}{ \exp_not:n{#1} } } + } % \end{macrocode} % Has this list a counter name defined in the instance? % \begin{macrocode} \tl_if_empty:NTF \l_@@_counter_tl { % \end{macrocode} -% If not we check if \cs{@listctr} has a non-empty value to be used -% for the list counter. -% -% We better test for blank not empty in case somebody had defined -% \cs{@listctr} using \cs{renewcommand} or \cs{cs_set:Npn}. +% If not we check if \cs{@nmbrlist} is true which may be the case +% in legacy environments that used \cs{usecounter} in the argument +% to the \env{list} environment. +% \changes{v0.8v}{2024/10/11}{Correct logic for setting up the list +% counter (tagging/730)} % \begin{macrocode} - \tl_if_blank:oF \@listctr - { + \legacy_if:nT { @nmbrlist } + { % \end{macrocode} -% In that case \texttt{@nmbrlist} should have been set too, for -% example, through \cs{usecounter}, so we do not set it -% explicitly. However, we check if we should resume a previous list. +% In that case we only check if we should resume a previous list +% (\cs{@listctr} should be set in that case through the legacy +% method as well so we should be able to use it). % \begin{macrocode} \bool_if:NF \l_@@_resume_bool { \int_gset:cn{ c@ \@listctr } { \l_@@_counter_start_int - 1 } } - } -% \end{macrocode} -% If \cs{@listctr} is not set then we have definitely an unnumbered list. -% \begin{macrocode} - { \@nmbrlistfalse } + } } % \end{macrocode} % If a counter is set in the list instance we use that @@ -2157,12 +2255,28 @@ \tl_set_eq:NN \@itemlabel \l_@@_item_label_tl } % \end{macrocode} -% finally, we signal that we are at the start of a new list (which -% effects how the first \cs{item} is handled and how \cs{par} +% Finally, we signal that we are at the start of a new list (which +% affects how the first \cs{item} is handled and how \cs{par} % commands are interpreted. % \begin{macrocode} \legacy_if_gset_true:n { @newlist } % \end{macrocode} +% If we encounter horizontal material before the first \cs{item} we +% do want a \cs{@noitemerr} straight away, because afterwards we +% end up with tagging structure faults whose cause is the +% missing \cs{item}. So we setup up \cs{@@_item_everypar:} to test +% for this; when the first \cs{item} is encountered this will get +% reset. This is only relevant for vertical lists, when dealing with +% inline lists one would need to test for something else to +% identify that there is horizontal material between the start of the list and +% the first \cs{item} (maybe some \cs{spacefactor} trick could be +% used then, or the material is boxed first and the width is +% inspected as suggested by Joseph).\fmi{Think about a better +% implementation at some point.} +% \changes{v0.8q}{2024/09/02}{} +% \begin{macrocode} + \cs_set_eq:NN \@@_item_everypar: \@@_item_everypar_first: +% \end{macrocode} % % \begin{macrocode} \@@_debug_typeout:n{template:list:std~end} @@ -2251,8 +2365,19 @@ % was given. % \begin{macrocode} \tl_set_eq:NN \l_@@_label_given_tl \c_novalue_tl +% \end{macrocode} +% First we evaluate and set any keys specified on the list +% environment by calling +% \cs{@@_evaluate_saved_user_keys:nn}. Then we do the same +% with all keys specified on this \cs{item} command (which may +% overwrite one or the other setting just made). +% \changes{v0.8s}{2024/10/03}{Use \cs{@@_evaluate_saved_user_keys:nn} +% to make use of user keys on the list level} +% \begin{macrocode} + \@@_evaluate_saved_user_keys:nn {item}{std} \tl_if_empty:nF{#1}{ \SetTemplateKeys{item}{std}{#1} } % \end{macrocode} +% % If no optional argument was given then \cs{l_@@_label_given_tl} % is still equal to \cs{c_novalue_tl} and so we can distinuish % that from \verb=\item[]=. @@ -2404,16 +2529,16 @@ % % % -% \begin{macro}{\@@_item_everypar:, \@@_item_everypar_std:} +% \begin{macro}{\@@_item_everypar:, \@@_item_everypar_std:, \@@_item_everypar_first:} % The \cs{@@_item_everypar:} command is executed as part of \hook{para/begin} % but most of the time does nothing, i.e., it has the following -% default definition. +% default definition outside of lists (and most of the time within lists). % \begin{macrocode} \cs_new_eq:NN \@@_item_everypar: \prg_do_nothing: % \end{macrocode} -% +% % \begin{macrocode} -\AddToHook{para/begin}[lists]{\@@_item_everypar:} +\AddToHook{para/begin}[items]{\@@_item_everypar:} % \end{macrocode} % % Note that we have to make sure that the above code is executed @@ -2421,9 +2546,9 @@ % \texttt{@inlabel} to make a decision. % % By the end of the day both should probably move into the kernel -% hook instead! +% hook instead or, better, into sockets. % \begin{macrocode} -\DeclareHookRule{para/begin}{lists}{after}{tagpdf} +\DeclareHookRule{para/begin}{items}{after}{tagpdf} % \end{macrocode} % % @@ -2475,6 +2600,16 @@ } % \end{macrocode} % +% This is the definition of \cs{@@_item_everypar:} before the first +% \cs{item} is encountered. +% \changes{v0.8q}{2024/09/02}{Call \cs{@noitemerr} if hmode is +% started before the first item} +% \begin{macrocode} +\cs_new:Npn \@@_item_everypar_first: { + \legacy_if:nT { @newlist } { \@noitemerr } +} +% \end{macrocode} +% % \end{macro} % % @@ -2520,7 +2655,7 @@ % % \begin{macro}{\item} % Here we already have all the building blocks. Complain in math -% mode. Distingusih between first item (do necessary tagging) and +% mode. Distinguish between first item (do necessary tagging) and % later items \cs{@@_inter_item:} to % cleanly close what's before, then call \cs{@@_item_instance:n} (which % calls \cs{UseInstance}\{item\}\marg{instance}) to prepare the @@ -2541,8 +2676,16 @@ } { \legacy_if:nTF { @newlist } - { \__kernel_list_item_begin: } - { \@@_inter_item: } + { + \__kernel_list_item_begin: +% \end{macrocode} +% The first item of a list also has to change the \texttt{@newlist} switch. +% \changes{v0.8q}{2024/09/02}{Set \texttt{@newlist} to false after +% the first \cs{item}} +% \begin{macrocode} + \legacy_if_gset_false:n { @newlist } + } + { \@@_inter_item: } % \end{macrocode} % To avoid unnecessary key/val processing we make a quick check if % there was an optional argument. @@ -2751,7 +2894,7 @@ \socket_assign_plug:nn{tagsupport/block-endpe}{on} % \end{macrocode} % -% Handle the tag name and attribute classess using the key values +% Handle the tag name and attribute classes using the key values % from the current list instance. % \begin{macrocode} \tl_if_empty:NTF \l_@@_tag_name_tl @@ -2994,6 +3137,7 @@ block-instance = verbatimblock , inner-instance = , final-code = \legacyverbatimsetup , + para-instance = justify } % \end{macrocode} % \end{instance} @@ -3173,7 +3317,7 @@ % block quoteblock-4, % block quoteblock-5, % block quoteblock-6 } -% Default layout is to indent equaly from both side. +% Default layout is to indent equally from both sides. % \begin{macrocode} \DeclareInstance{block}{quoteblock-1}{display} { rightmargin = \KeyValue{leftmargin} } @@ -3468,7 +3612,7 @@ % then have to avoid adding another \texttt{text-unit}. % \begin{macrocode} { - \int_compare:nNnT \l_@@_flattened_level_int < 2 + \int_compare:nNnT \l__tag_block_flattened_level_int < 2 { \__tag_gincr_para_main_begin_int: \tag_struct_begin:n @@ -3917,15 +4061,37 @@ % Finally, at the list end we have to close the open % \texttt{LBody}, \texttt{LI}, \texttt{L}, and possibly a % \struct{text} if the last item ends with a list. +% However, if the user forgot to add an \cs{item} then there will be no +% \texttt{LI} and \texttt{LBody} open, so we check for the status +% of \texttt{@newlist}. The corresponding no-item error was +% generated earlier outside the tagging code. +% +% One could argue that it doesn't matter if the tagging is wrong +% after a \cs{@noitemerr} was issued. However, there is one case +% where it isn't an error: In the \texttt{thebibliography} +% environment (which is internally a list) it is often the case +% that documents start out with an empty environment, not +% containing any \cs{bibitem}s. For that reason \cs{@noitemerr} is +% redefined inside that environment to only produce a warning; +% hence we have to produce correct tag structures in that case. +% \changes{v0.8q}{2024/09/02}{Do not close LI and LBody if they +% never were opened.} % \begin{macrocode} \cs_set:Npn \@@_list_end: { - \legacy_if:nT { @endpe } +% \end{macrocode} +% If \texttt{@newlist} is true (i.e., when we have an error or warning +% situation) there is not much to close. +% \begin{macrocode} + \legacy_if:nF { @newlist } { - \__tag_gincr_para_main_end_int: - \tagstructend % text-unit - \@@_debug_typeout:n{Structure-end~ P~ at~ list-end \on@line } + \legacy_if:nT { @endpe } + { + \__tag_gincr_para_main_end_int: + \tagstructend % text-unit + \@@_debug_typeout:n{Structure-end~ P~ at~ list-end \on@line } + } + \tagstructend\tagstructend % end LBody, LI } - \tagstructend\tagstructend % end LBody, LI \tagstructend % end L } % \end{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-block.pdf b/macros/latex/required/latex-lab/latex-lab-block.pdf Binary files differindex 34e2a248fa..a72830d4c0 100644 --- a/macros/latex/required/latex-lab/latex-lab-block.pdf +++ b/macros/latex/required/latex-lab/latex-lab-block.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-firstaid.dtx b/macros/latex/required/latex-lab/latex-lab-firstaid.dtx index ce0d46f815..e724f37794 100644 --- a/macros/latex/required/latex-lab/latex-lab-firstaid.dtx +++ b/macros/latex/required/latex-lab/latex-lab-firstaid.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: latex-lab-firstaid.dtx (C) Copyright 2023-2024 LaTeX Project +%% File: latex-lab-firstaid.dtx (C) Copyright 2023-2025 LaTeX Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -16,8 +16,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabfirstaiddate{2024-05-25} -\def\ltlabfirstaidversion{0.85d} +\def\ltlabfirstaiddate{2025-01-27} +\def\ltlabfirstaidversion{0.85i} %<*driver> \documentclass{l3doc} \EnableCrossrefs @@ -53,7 +53,9 @@ % % Similar to the main firstaid package the goal is to remove the % patches once the packages have been updated. - +% +% \changes{v0.85g}{2024/10/04}{Removed firstaid for blindtext. No longer needed with new doenpe-code.} +% \changes{v0.85g}{2024/10/04}{Added firstaid for fancyvrb.} % \section{Implementation} % % \begin{macrocode} @@ -87,12 +89,11 @@ } } \exp_args:Ncx\str_if_eq:onT{ver@#1.#2}{#3} } -\ExplSyntaxOff % \end{macrocode} % \end{macro} % \subsection{ams classes} -% The amsart and amsbook classes do not use \cs{@author} to store the author list +% The amsart, amsbook and amsproc classes do not use \cs{@author} to store the author list % but a command \cs{authors}. To be able to nevertheless use the authors in the % xmp-metadata we map \cs{@author} to this new command. % @@ -101,9 +102,206 @@ {\def\@author{\authors}} \AddToHook{class/amsbook/after} {\def\@author{\authors}} +\AddToHook{class/amsproc/after} + {\def\@author{\authors}} % \end{macrocode} % +% \subsection{ams classes and amsthm} +% The amsart, amsbook and amsproc classes redefine the theorem code +% and this breaks the tagging added by the block code. The following +% reenables tagging. It does \emph{not} give a completly identical output +% (similar to the new theorem code, +% see \url{https://github.com/latex3/tagging-project/issues/715}). +% The code also does not try to use sockets yet, as the theorem definitions +% in the block code don't do that yet either. % +% \begin{macrocode} +\AddToHook{class/amsart/after}[latex-lab-testphase-firstaid/amsthm] + {\tag_if_active:T{\@@_firstaid_amsthm:}\@@_firstaid_ams_abstract:} +\AddToHook{class/amsbook/after}[latex-lab-testphase-firstaid/amsthm] + {\tag_if_active:T{\@@_firstaid_amsthm:}\@@_firstaid_ams_abstract:} +\AddToHook{class/amsproc/after}[latex-lab-testphase-firstaid/amsthm] + {\tag_if_active:T{\@@_firstaid_amsthm:}} +\AddToHook{package/amsthm/after}[latex-lab-testphase-firstaid/amsthm] + {\tag_if_active:T{\@@_firstaid_amsthm:}} +% \end{macrocode} +% +% \changes{v0.85i}{2025/01/26}{Add missing \cs{par} to abstract env (gh/1641)} +% \begin{macrocode} +\cs_new_protected:Npn \@@_firstaid_ams_abstract: + { +\renewenvironment{abstract}{% + \ifx\maketitle\relax + \ClassWarning{\@classname}{Abstract~ should~ precede~ + \protect\maketitle\space in~ AMS~ document~ classes;~ reported}% + \fi + \global\setbox\abstractbox=\vtop \bgroup + \normalfont\Small + \list{}{\labelwidth\z@ + \leftmargin3pc \rightmargin\leftmargin + \listparindent\normalparindent \itemindent\z@ + \parsep\z@ \@plus\p@ + \let\fullwidthdisplay\relax + }% + \item[\hskip\labelsep\scshape\abstractname.]% +}{% + \endlist + \par % <--- added + \egroup + \ifx\@setabstract\relax \@setabstracta \fi +} + } +% \end{macrocode} +% \changes{v0.85h}{2024/10/16}{moved Caption tag into \@begintheorem, tagging issue\#733} +% \begin{macrocode} +\cs_new_protected:Npn \@@_firstaid_amsthm: + { +% \end{macrocode} +% \cs{@endtheorem} must use the endblock code +% \begin{macrocode} + \def\@endtheorem{\endblockenv} +% \end{macrocode} +% In \cs{@thm} we have to remove the \cs{trivlist} +% \begin{macrocode} + \RenewDocumentCommand\@thm{mmmO{}}{% + \ifhmode\unskip\unskip\par\fi + \normalfont + \let\thmheadnl\relax + \let\thm@swap\@gobble + \thm@notefont{\fontseries\mddefault\upshape}% + \thm@headpunct{.}% add period after heading + \thm@headsep 5\p@ plus\p@ minus\p@\relax + \thm@space@setup + ##1% style overrides + \@topsep \thm@preskip % used by thm head + \@topsepadd \thm@postskip % used by \@endparenv +% \end{macrocode} +% We store the counter name so that the anchor can make use of it. +% \begin{macrocode} + \tl_set:Nn \l__block_thm_current_counter_tl{##2} + \tl_if_empty:nTF{##2} + { + \@begintheorem{##3}{}[##4] + } + { + \@kernel@refstepcounter{##2} + \@begintheorem{##3}{\csname the##2\endcsname}[##4] + } + } +% \end{macrocode} +% \cs{@begintheorem} has a larger number of changes +% \begin{macrocode} + \def\@begintheorem##1##2[##3]{% +% \end{macrocode} +% We use the theorem instance. +% \changes{v0.85h}{2024/10/16}{Added pre and post skips tagging/733} +% \begin{macrocode} + \UseInstance{blockenv}{theorem}{beginsep=\thm@preskip} +% \end{macrocode} +% There is no working key to set the endskip, so we set the skip directly +% similar to what amsthm is doing after the \cs{trivlist}. +% \begin{macrocode} + \skip_set:Nn\l__block_topsepadd_skip { \thm@postskip } +% \end{macrocode} +% While create the caption/label we disable para-tagging. +% \begin{macrocode} + \tagpdfparaOff + \mode_leave_vertical: +% \end{macrocode} +% The anchor for links. amsthm allows for unnumbered theorems so we have to test +% for an empty counter. +% \changes{v0.85h}{2024/10/16}{add test if counter is empty tagging/736} +% \begin{macrocode} + \tl_if_empty:NTF \l__block_thm_current_counter_tl + {\MakeLinkTarget[theorem]{}} + {\MakeLinkTarget{\l__block_thm_current_counter_tl}} + \group_begin: + \normalfont + \the\thm@headfont \thm@indent + \@ifempty{##1} + {\let\thmname\@gobble} +% \end{macrocode} +% we insert the MC and the Lbl structure into \cs{thmname}, +% \cs{thmnumber} and \cs{thmnote}. This will also work +% with new theorem style as long as they use these command. +% \begin{macrocode} + {\def\thmname####1{\tag_mc_begin:n {}####1\tag_mc_end:}}% + \@ifempty{##2} + {\let\thmnumber\@gobble} + {\def\thmnumber####1 + {\tag_struct_begin:n{tag=Lbl}\tag_mc_begin:n {} + ####1 + \tag_mc_end:\tag_struct_end:}}% + \@ifempty{##3} + {\let\thmnote\@gobble} + {\def\thmnote####1{\tag_mc_begin:n{}####1\tag_mc_end:}}% + \tag_struct_begin:n{tag=Caption} + \thm@swap\swappedhead\thmhead{##1}{##2}{##3}% + \tag_mc_begin:n{}\the\thm@headpunct\tag_mc_end: + \tag_struct_end: + \thmheadnl % possibly a newline. + \hskip\thm@headsep + \group_end: +% \end{macrocode} +% Now we restart para tagging and start a paragraph. The socket +% is currently defined in tagpdf, so the code should only +% be used if tagging is active! +% \begin{macrocode} + \tagpdfparaOn + \UseTaggingSocket{para/begin} % + \ignorespaces} +% \end{macrocode} +% This redefines the standard styles for the theorem heads. +% \cs{thm@headpunct} has been moved into the head code +% to make tagging more easier. +% \begin{macrocode} + \def\thmhead@plain##1##2##3{% + \thmname{##1} + \thmnumber{ + \@ifnotempty{##1}{~}\@upn{##2} + }% + \thmnote{\pdffakespace\space{\the\thm@notefont(##3)}} + } + \let\thmhead\thmhead@plain + \def\swappedhead##1##2##3{% + \thmnumber{##2} + \thmname{\@ifnotempty{##2}{\nobreakspace}##1} + \thmnote{\pdffakespace\space{\the\thm@notefont(##3)}} + } + \let\swappedhead@plain=\swappedhead +% \end{macrocode} +% At last some adjustments for the proof environment. +% The qed symbols use a drawn box by default. We add an actualtext. +% \begin{macrocode} + \renewcommand{\openbox}{\leavevmode + \hbox to.77778em{\pdf_bdc:nn{Span}{/ActualText<FEFF220E>}% + \pdffakespace\hfil\vrule + \vbox to.675em{\hrule width.6em\vfil\hrule}% + \vrule\hfil\pdf_emc:}} +% \end{macrocode} +% And redefine proof to no longer use a trivlist. +% \begin{macrocode} + \renewenvironment{proof}[1][\proofname]{\par + \pushQED{\qed}% + \UseInstance{blockenv}{theorem}{beginsep=6\p@\@plus6\p@} + \normalfont + \tagpdfparaOff + \AddToHookNext{para/begin} + {\tag_struct_begin:n{tag=Caption} + \tag_mc_begin:n{}% + \textit{##1\@addpunct{.}}% + \tag_mc_end: + \tag_struct_end: + \tagpdfparaOn + \UseTaggingSocket{para/begin} + \pdffakespace\hspace{\labelsep}} + \ignorespaces + }{% + \popQED\endblockenv\par + } + } +\ExplSyntaxOff +% \end{macrocode} % % \subsection{verse} % @@ -210,54 +408,12 @@ %\end{verbatim} % % -% \subsection{blindtext} -% -% The blindtext package generates lists with nested \cs{loop} command. -% The inner loop introduces a group around the list which error when lists are tagged -% as \cs{@doendpe} is lost. -% \begin{macrocode} -\AddToHook{file/blindtext.sty/after}[latex-lab-firstaid]{% - \FirstAidNeededT{blindtext}{sty}{\blindfiledate\space\blindfileversion\space% - blindtext-Package}% - {% - \renewcommand{\blind@items}{% - \setcounter{blind@listcount}{1}% - \loop - \ifblind@optional - \ifblind@long - \item[\blindtext@countitem] \blindtext@text - \else - \item[\blindtext@count] \blindtext@item - \fi - \else % \blind@optionalfalse - \ifblind@long - \item \blindtext@text - \else - \item \blindtext@countitem - \fi - \fi % \ifblind@optional - {% - \loop - \ifnum\value{blindlistlevel}>\value{blindlist@level}% - \stepcounter{blind@levelcount}% - \blind@list[\value{blindlist}]\relax - \addtocounter{blind@levelcount}{-1}% - \setcounter{blind@listcount}{1}% - \repeat - \expandafter}\if@endpe\@doendpe\fi % <----------changed - \ifnum\value{blind@listcount}<\value{blindlist}% - \stepcounter{blind@listcount}% - \repeat - } - }% - } -% \end{macrocode} -% -% % \subsection{cleveref} % % The cleveref package redefines \cs{@makefntext} and this means that the patches in -% the new footnote code fails. We use a hook instead +% the new footnote code fails. We use a hook instead. +% \changes{v0.85h}{2024/10/16}{Remove redefinition of refstepcounter. It no longer uses +% the hook.} % \begin{macrocode} \AddToHook{package/cleveref/after} { @@ -267,16 +423,6 @@ \protected@edef\cref@currentlabel{% [footnote][\arabic{footnote}][\cref@result]% \p@footnote\@thefnmark}} -% \end{macrocode} -% The second problem is that it redefines \cs{refstepcounter} to use an argument. -% In itself this isn't a problem but as the new definition doesn't grab the arguments -% directly it fails over the generic hook inserted at the end of the definition -% \begin{macrocode} - \RenewDocumentCommand\refstepcounter{om}{% - \IfNoValueTF{#1}% - {\refstepcounter@noarg{#2}}% - {\refstepcounter@optarg[#1]{#2}}% - }% } % \end{macrocode} % @@ -290,6 +436,7 @@ % See also issue \url{https://github.com/latex3/tagging-project/issues/69} % % +% \begin{macrocode} \ExplSyntaxOn \AddToHook{package/booktabs/after} { @@ -314,8 +461,145 @@ \tag_mc_end: \int_gdecr:N \g__tbl_row_int \cr} } -\ExplSyntaxOff +\ExplSyntaxOff +% \end{macrocode} + % +% \subsection{fancyvrb} +% The firstaid adds first partial tagging support to the environments +% of fancyvrb (inline verbatim is untested). +% This supports then also packages like minted which internally uses fancyvrb +% and classes like l3doc (where currently the verbatim environment based on fancyvrb +% is overwritten by the block code). +% The environments are surrounded by a \texttt{verbatim} structure, +% every line by a \texttt{codeline} +% structure (this requires the block code, but firstaid should be used only with +% phase-III anyway). Line numbers are tagged as Lbl, currently outside of the +% \texttt{codeline} structure. The frame lines are marked as artifact. +% +% \begin{macro}{\FV@LeaveVMode} +% If we are in vmode we have to open a text-unit structure, if we are +% in hmode we have to set para mode to flattened before the fancyhdr code +% issues the\cs{par}. The closing of the text-unit structure is handled by the +% doendpe code in the block code. +% \begin{macrocode} +\ExplSyntaxOn +\AddToHook{package/fancyvrb/after} +{ + \def\FV@LeaveVMode{% + \if@noskipsec + \leavevmode + \else + \if@FV@ResetMargins\if@inlabel\leavevmode\fi\fi + \fi + \ifvmode + \@noparlisttrue + \__tag_gincr_para_main_begin_int: + \tag_struct_begin:n{tag=\l__tag_para_main_tag_tl} + \else + \bool_set_true:N\l__tag_para_flattened_bool + \@noparlistfalse + \unskip\par + \fi + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\FV@List} +% At the begin of the list code we have to tag the frame as artifact +% and start the \texttt{verbatim} structure +% \begin{macrocode} + \def\FV@List#1{% + \begingroup + \FV@UseKeyValues + \FV@LeaveVMode + \if@inlabel\else\setbox\@labels=\box\voidb@x\fi + \FV@ListNesting{#1}% + \FV@ListParameterHook + \FV@ListVSpace + \FV@SetLineWidth + \FV@InterLinePenalty + \let\FV@ProcessLine\FV@ListProcessLine@i + \FV@CatCodes + \FV@FormattingPrep + \FV@ObeyTabsInit + \cs_if_exist:NT \FV@BeginListFrame + { + \tag_mc_begin:n{artifact} + \FV@BeginListFrame + \tag_mc_end: + } + \tag_struct_begin:n{tag=verbatim} + } +% \end{macrocode} +% \end{macro} +% \begin{macro}{\FV@EndList} +% At the end of the list code we close the \texttt{verbatim} structure and +% tag the frame as artifact. +% \begin{macrocode} + \def\FV@EndList{% + \FV@ListProcessLastLine + \tag_struct_end: + \cs_if_exist:NT \FV@EndListFrame + { + \tag_mc_begin:n{artifact} + \FV@EndListFrame + \tag_mc_end: + } + \@endparenv + \endgroup + \@endpetrue + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\FV@ListProcessLine} +% At last the tagging of the code lines. Here we have to tag also +% numbers and frame parts if they exist. +% \begin{macrocode} + \def\FV@ListProcessLine#1{% + \hbox to \hsize{% + \kern\leftmargin + \hbox to \linewidth{% + \cs_if_exist:NT \FV@LeftListNumber + { + \tag_struct_begin:n{tag=Lbl} + \tag_mc_begin:n{} + \FV@LeftListNumber + \tag_mc_end: + \tag_struct_end: + } + \cs_if_exist:NT \FV@LeftListFrame + { + \tag_mc_begin:n{artifact} + \FV@LeftListFrame + \tag_mc_end: + } + \tag_struct_begin:n{tag=codeline} + \tag_mc_begin:n{}% + \FancyVerbFormatLine{#1}% + \tag_mc_end: + \tag_struct_end:\hss + \cs_if_exist:NT \FV@RightListFrame + { + \tag_mc_begin:n{artifact} + \FV@RightListFrame + \tag_mc_end: + } + \cs_if_exist:NT \FV@RightListNumber + { + \tag_struct_begin:n{tag=Lbl} + \tag_mc_begin:n{} + \FV@RightListNumber + \tag_mc_begin:n{} + \tag_struct_end: + } + } + \hss}} + } +\ExplSyntaxOff +% \end{macrocode} +% \end{macro} % \begin{macrocode} %</package> % \end{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-firstaid.pdf b/macros/latex/required/latex-lab/latex-lab-firstaid.pdf Binary files differindex 5df8b1cf4e..b1c1cd3b65 100644 --- a/macros/latex/required/latex-lab/latex-lab-firstaid.pdf +++ b/macros/latex/required/latex-lab/latex-lab-firstaid.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-float.dtx b/macros/latex/required/latex-lab/latex-lab-float.dtx index a817133713..536aa09cfa 100644 --- a/macros/latex/required/latex-lab/latex-lab-float.dtx +++ b/macros/latex/required/latex-lab/latex-lab-float.dtx @@ -16,8 +16,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabfloatdate{2024-03-23} -\def\ltlabfloatversion{0.81e} +\def\ltlabfloatdate{2024-09-20} +\def\ltlabfloatversion{0.81f} %<*driver> \documentclass{l3doc} \EnableCrossrefs @@ -43,6 +43,9 @@ % customizations}} % % \providecommand\hook[1]{\texttt{#1}} +% \ProvideDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} +% \ProvideDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} +% % \begin{documentation} % \begin{abstract} % The following code implements a first draft for the tagging of float @@ -64,7 +67,7 @@ % % A special type, called a H-float, (provided by the float package) % is always placed in the main text stream and does not -% necessarly preserve the order with normal floats of the same type: It is basically +% necessarily preserve the order with normal floats of the same type: It is basically % a minipage with a caption. % % Floats typically contain a figure (or a table, etc.) and a caption, @@ -125,7 +128,10 @@ % % \section{Kernel commands} % \begin{function}{\@current@float@struct} -% This variable holds the structure number of current float structure. +% This variable holds the number of the current float structure. With tagging +% this is the structure number, without tagging a unique counter. A float +% can contain more than one float structure (e.g. if there is more than one +% caption). % \end{function} % % \begin{function}{\@makecaption} @@ -146,22 +152,28 @@ {Code related to the tagging of floats} % \end{macrocode} % \subsection{Variables} -% We rolemap to float to Aside, and float sections to Sect. +% We rolemap floats to Aside, and float sections to Sect. % % \begin{variable}{ % \g_@@_float_sect_prop, % \g_@@_float_types_seq, -% \@current@float@struct +% \@current@float@struct, +% \g_@@_float_int % } % These variables will hold the structure number for the float container % and the list of float types. Currently only figure and table are supported % TODO: interface to declare new float types. +% To set the target for links we need also a unique counter. +% With tagging we could use the structure number, but +% the structure commands now are hidden inside tagging sockets +% so we use a dedicated counter. % \begin{macrocode} \prop_new:N \g_@@_float_sect_prop \seq_new:N \g_@@_float_types_seq \seq_gput_right:Nn \g_@@_float_types_seq {figure} \seq_gput_right:Nn \g_@@_float_types_seq {table} \tl_new:N\@current@float@struct +\int_new:N\g_@@_float_int % \end{macrocode} % \end{variable} % @@ -176,6 +188,19 @@ % \end{macrocode} % \end{variable} % +% \begin{macro}{\@@_float_init:} +% To be able to set unique targets for links, we +% need a counter outside the tagging sockets. +% TODO: check if this command should be public or +% a socket or a hook. +% \begin{macrocode} +\cs_new_protected:Npn \@@_float_init: + { + \int_gincr:N \g_@@_float_int + \tl_set:Ne \@current@float@struct { \int_use:N \g_@@_float_int} + } +% \end{macrocode} +% \end{macro} % %\subsection{Moving float structures} % @@ -260,15 +285,71 @@ { split-float .code:n = { - \@@_float_end: - \@@_float_begin: - \MakeLinkTarget*{floatstructure.\int_use:N\c@g__tag_struct_abs_int} + \UseTaggingSocket{float/end} + \@@_float_init: + \UseTaggingSocket{float/begin} + \MakeLinkTarget*{floatstructure.\@current@float@struct} } } % \end{macrocode} % \end{macro} - -% \subsection{Patching} +% +% \subsection{Tagging sockets} +% For now we test if the sockets are already defined +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/float/begin_plug_str } + { + \NewSocket{tagsupport/float/hmode/begin}{0} + \NewSocket{tagsupport/float/hmode/end}{0} + \NewSocket{tagsupport/float/begin}{0} + \NewSocket{tagsupport/float/end}{0} + } +% \end{macrocode} +% +% \begin{plugdecl}{default (tagsupport/float/hmode/begin)} +% This plug should be used if a float is called in hmode. +% In then closes the MC-chunks and starts the structure. +% \begin{macrocode} +\NewSocketPlug {tagsupport/float/hmode/begin}{default} + { + \@@_float_stop_par: + } +\AssignSocketPlug{tagsupport/float/hmode/begin}{default} +% \end{macrocode} +% \end{plugdecl} +% +% \begin{plugdecl}{default (tagsupport/float/hmode/end)} +% This plug should be used if a float is called in hmode +% and the end of the float it then restarts the MC. +% \begin{macrocode} +\NewSocketPlug{tagsupport/float/hmode/end}{default} + { + \@@_float_start_par: + } +\AssignSocketPlug{tagsupport/float/hmode/end}{default} +% \end{macrocode} +% \end{plugdecl} +% +% \begin{plugdecl}{default (tagsupport/float/begin)} +% \begin{macrocode} +\NewSocketPlug{tagsupport/float/begin}{default} + { + \@@_float_begin: + } +\AssignSocketPlug{tagsupport/float/begin}{default} +% \end{macrocode} +% \end{plugdecl} +% +% \begin{plugdecl}{default (tagsupport/float/end)} +% \begin{macrocode} +\NewSocketPlug{tagsupport/float/end}{default} + { + \@@_float_end: + } +\AssignSocketPlug{tagsupport/float/end}{default} +% \end{macrocode} +% \end{plugdecl} +% % \begin{macro}{\@@_float_stop_par:,\@@_float_start_par:} % if a float is in a par, we need commands to stop and restart the P-mc % \begin{macrocode} @@ -287,8 +368,7 @@ \tag_struct_begin:n{tag=text}% } \tag_mc_begin:n{tag=P} - } - + } % \end{macrocode} % \end{macro} % These commands are the main commands to start and end the float tagging. @@ -315,6 +395,7 @@ \cs_new_protected:Npn\@@_float_end:{\tag_struct_end:} %end Aside % \end{macrocode} +% \subsection{Patching} % This patches the main command \cs{@xfloat}. % There is a : in the code, so we disable expl3 syntax % \begin{macrocode} @@ -337,7 +418,7 @@ % \end{macrocode} % If the float is in hmode we have to interrupt the P % \begin{macrocode} - \@nameuse{@@_float_stop_par:}% <---end P + \UseTaggingSocket{float/hmode/begin}% \@floatpenalty -\@Mii \else \@floatpenalty-\@Miii @@ -383,7 +464,8 @@ % \end{macrocode} % This starts the structure for the float. % \begin{macrocode} - \@nameuse{@@_float_begin:}% + \csname @@_float_init:\endcsname + \UseTaggingSocket{float/begin}% \global \setbox\@currbox \color@vbox \normalcolor @@ -394,14 +476,14 @@ % \end{macrocode} % We add a target for links. TODO: check that it doesn't affect spacing!! % \begin{macrocode} - \MakeLinkTarget*{floatstructure.\number\value{g__tag_struct_abs_int}}% + \MakeLinkTarget*{\@captype.struct.\@current@float@struct}% }% % \end{macrocode} % The end code of the float ... % \begin{macrocode} \def\end@float{% \@endfloatbox - \@nameuse{@@_float_end:}% + \UseTaggingSocket{float/end}% \ifnum\@floatpenalty <\z@ \@largefloatcheck \@cons\@currlist\@currbox @@ -413,7 +495,7 @@ \penalty\@floatpenalty \else \vadjust{\penalty -\@Miv \vbox{}\penalty\@floatpenalty}\@Esphack - \@nameuse{@@_float_start_par:}% restart P safe here?? + \UseTaggingSocket{float/hmode/end}% \fi \fi } @@ -423,7 +505,7 @@ \def\end@dblfloat{% \if@twocolumn \@endfloatbox - \@nameuse{@@_float_end:}% + \UseTaggingSocket{float/end}% \ifnum\@floatpenalty <\z@ \@largefloatcheck \global\dp\@currbox1sp % @@ -436,7 +518,7 @@ \penalty\@floatpenalty \else \vadjust{\penalty -\@Miv \vbox{}\penalty\@floatpenalty}\@Esphack - \@nameuse{@@_float_start_par:}% restart P safe here?? + \UseTaggingSocket{float/hmode/end}% \fi \fi \else @@ -453,10 +535,113 @@ \def\hyper@nopatch@caption{} % \end{macrocode} % +% \subsubsection{(Tagging) sockets} +% +% First some temporary sockets. +% These sockets are in lttagging. +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/caption/begin_plug_str } + { + \NewSocket{tagsupport/caption/begin}{1} + \NewSocket{tagsupport/caption/end}{0} + \NewSocket{tagsupport/caption/label/begin}{0} + \NewSocket{tagsupport/caption/label/end}{0} + } +% \end{macrocode} +% These socket are currently defined in tagpdf. +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/para/begin_plug_str } + { + \NewSocket{tagsupport/para/begin} + \NewSocket{tagsupport/para/end} + } +% \end{macrocode} +% +% \begin{socketdecl}{caption/label} +% This socket is a lightweight start for +% some interface to format the label or add a font command. +% The argument is the label text. +% The default plug \texttt{kernel} adds a colon +% and a space. +% TODO: revisit after checking float and caption packages +% to identify which sockets and hooks are needed. +% \begin{macrocode} +\NewSocket{caption/label}{1} +% \end{macrocode} +% \end{socketdecl} +% +% \begin{plugdecl}{kernel (caption/label)} +% The standard label formatting from the kernel. +% \begin{macrocode} +\NewSocketPlug{caption/label}{kernel} + { + #1:~ + } +\AssignSocketPlug{caption/label}{kernel} +% \end{macrocode} +% \end{plugdecl} +% \begin{plugdecl}{default} +% The caption begin socket takes an argument: the structure number of +% the parent float. If the argument is empty, the current structure is used. +% TODO: a tagpdf key that moves a structure to the begin of the parent. +% The caption is moved to the first position with the firstkid option. +% \begin{macrocode} +\NewSocketPlug {tagsupport/caption/begin}{default} + { + \tl_if_empty:eTF {#1} + { + \tag_struct_begin:n{tag=Caption,firstkid} + } + { + \tag_struct_begin:n{tag=Caption,parent=#1,firstkid} + } + \bool_set_true:N \l__tag_para_flattened_bool + } +\AssignSocketPlug{tagsupport/caption/begin}{default} +% \end{macrocode} +% \end{plugdecl} +% \begin{plugdecl}{default} +% \begin{macrocode} +\NewSocketPlug {tagsupport/caption/end}{default} + { + \tag_struct_end: + } +\AssignSocketPlug{tagsupport/caption/end}{default} +% \end{macrocode} +% \end{plugdecl} +% +% \begin{plugdecl}{default (tagsupport/caption/label/begin)} +% \begin{macrocode} +\NewSocketPlug {tagsupport/caption/label/begin}{default} + { +% \end{macrocode} +% suppress para tagging at the begin. +% \begin{macrocode} + \tagpdfparaOff + \tag_struct_begin:n{tag=Lbl} + \tag_mc_begin:n{} + } +\AssignSocketPlug{tagsupport/caption/label/begin}{default} +% \end{macrocode} +% \end{plugdecl} +% +% \begin{plugdecl}{default (tagsupport/caption/label/end)} +% \begin{macrocode} +\NewSocketPlug {tagsupport/caption/label/end}{default} + { + \tag_mc_end: + \tag_struct_end: + \tagpdfparaOn + } +\AssignSocketPlug{tagsupport/caption/label/end}{default} +% \end{macrocode} +% \end{plugdecl} +% +% \subsubsection{Redefinitions} +% % With hyperref that means that the \cs{refstepcounter} now can affect spacing so we % change that to the kernel refstepcounter: % \begin{macrocode} -\let\@kernel@refstepcounter\refstepcounter %as long it is not in the kernel \def\caption{% \ifx\@captype\@undefined \@latex@error{\noexpand\caption\c_space_tl outside~float}\@ehd @@ -474,22 +659,16 @@ \@kernel@refstepcounter\@captype % \end{macrocode} % we need to reset the target for \cs{addcontentsline}. +% We use \cs{@captype} to support autoref. % \begin{macrocode} - \xdef\@currentHref{floatstructure.\@current@float@struct}% + \xdef\@currentHref{\@captype.struct.\@current@float@struct}% } \expandafter\@firstofone \fi {\@dblarg{\@caption\@captype}}% } % \end{macrocode} -% As we will use the structure number in the target, we need to provide a -% theH-representation. (Once the kernel will create -% theH-representation generally this will be provided automatically, as tagpdf uses -% \cs{newcounter}) -% \begin{macrocode} -\providecommand\theHg__tag_struct_abs_int{\int_use:N\c@g__tag_struct_abs_int} -% \end{macrocode} - +% % \begin{macro}{\@makecaption} % \cs{@makecaption} is defined by the classes so we overwrite it for now % at begin document. @@ -501,53 +680,36 @@ % \end{macrocode} % we don't want tagging when storing the caption for the singleline check % \begin{macrocode} - \tag_stop:n{caption} + \SuspendTagging{\@makecaption} \sbox\@tempboxa{#1:~#2}% - \tag_start:n{caption} + \ResumeTagging{\@makecaption} % \end{macrocode} -% we stop paratagging. TODO: check +% We pass \cs{@current@float@struct} as parent structure +% number. If that is empty the socket will use the parent structure and hope ... % \begin{macrocode} - \tagtool{para=false} -% \end{macrocode} -% if caption is used outside a float there is perhaps no number, then we use -% the parent structure and hope ... -% \begin{macrocode} - \tl_if_empty:NT \@current@float@struct - { \tl_set:Ne \@current@float@struct {\tag_get:n{struct_num}} } - \tag_struct_begin:n{tag=Caption,parent=\@current@float@struct} -% \end{macrocode} -% move the caption to the begin of the float structure: -% \begin{macrocode} - \tag_if_active:T - { - \seq_gpop_right:cN {g__tag_struct_kids_\@current@float@struct _seq}\l_@@_tmpa_tl - \seq_gput_left:cV {g__tag_struct_kids_\@current@float@struct _seq}\l_@@_tmpa_tl - } + \UseTaggingSocket{caption/begin}{\@current@float@struct} \ifdim \wd\@tempboxa >\hsize - \tag_struct_begin:n{tag=Lbl} - \tag_mc_begin:n{} - #1:~ - \tag_mc_end: - \tag_struct_end: - \tag_mc_begin:n{} - #2\par - \tag_mc_end: + \UseTaggingSocket{caption/label/begin} + \UseSocket{caption/label}{#1} + \UseTaggingSocket{caption/label/end} + \UseTaggingSocket{para/begin} + #2 + \par \else % \end{macrocode} % we don't reuse the box as it doesn't contain tagging, but set the text explicitly. % \begin{macrocode} \global \@minipagefalse \hb@xt@\hsize{\hfil - \tag_struct_begin:n{tag=Lbl} - \tag_mc_begin:n{} - #1:~ - \tag_mc_end: - \tag_struct_end: - \tag_mc_begin:n{} + \UseTaggingSocket{caption/label/begin} + \UseSocket{caption/label}{#1} + \UseTaggingSocket{caption/label/end} + \UseTaggingSocket{para/begin} #2 - \tag_mc_end:\hfil}% + \UseTaggingSocket{para/end} + \hfil}% \fi - \tag_struct_end: %caption + \UseTaggingSocket{caption/end} \vskip\belowcaptionskip} } % \end{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-float.pdf b/macros/latex/required/latex-lab/latex-lab-float.pdf Binary files differindex ecba3f3d17..81f06aeceb 100644 --- a/macros/latex/required/latex-lab/latex-lab-float.pdf +++ b/macros/latex/required/latex-lab/latex-lab-float.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-footnotes.dtx b/macros/latex/required/latex-lab/latex-lab-footnotes.dtx index a3d044ab87..f4ad7edd9d 100644 --- a/macros/latex/required/latex-lab/latex-lab-footnotes.dtx +++ b/macros/latex/required/latex-lab/latex-lab-footnotes.dtx @@ -17,8 +17,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabfootnotedate{2024-03-12} -\def\ltlabfootnoteversion{0.8d} +\def\ltlabfootnotedate{2024-09-30} +\def\ltlabfootnoteversion{0.8g} %<*driver> \documentclass{l3doc} @@ -228,7 +228,8 @@ % % To cater for different layout configurations there are four % sockets that can be set by a package or -% class but there should be only one per document setting them, i.e., if two packages/classes set them they are mutually +% class but there should be only one per document setting them, +% i.e., if two packages/classes set them they are mutually % incompatible (or rather the last one wins most likely). % These are: % \begin{description} @@ -491,11 +492,21 @@ % \subsection{Technical details for the tagging} % % The following sockets are set up for kernel use, when doing tagging: +% There name and/or function will probably change as they currently +% mix tagging with the link support. +% +% TODO: review this sockets % \begin{description} % \item[\socket{tagsupport/fnmark} (1 argument)] % % \DescribeSocket[noprint]{tagsupport/fnmark} -% +% +% The socket is used in \cs{@footnotemark}/\cs{fnote_footnotemark:} +% and takes \cs{@makefnmark} as argument. It prints the mark in the text +% and surrounds it with a tagging structure and a link. As such it is +% not solely for tagging and so should not be used with \cs{UseTaggingSocket} +% as this would swallow the argument and loose the link support. +% % \fmi{describe and decide on names} % % @@ -503,31 +514,45 @@ % % \DescribeSocket[noprint]{tagsupport/fntext/begin} % +% This socket is used before the main processing socket +% (so before the \cs{insert} command). It opens the FEnote structure. +% As it sets also the tl-var for the current structure and this is used +% in destinations it should not use as tagging socket. +% % % \item[\socket{tagsupport/fntext/end} (no argument)] % % \DescribeSocket[noprint]{tagsupport/fntext/end} % +% This socket is used after the main processing socket +% (so after the \cs{insert} command). It closes the FEnote structure. % % \item[\socket{tagsupport/fntext/mark} (1 argument)] % % \DescribeSocket[noprint]{tagsupport/fntext/mark} -% +% +% This socket is used around the mark in the footnote text. +% It adds tagging support but also link support, so like the other +% tagsupport sockets it should be always active. % % \item[\socket{tagsupport/fntext/text} (1 argument)] % % \DescribeSocket[noprint]{tagsupport/fntext/text} % +% This socket handles mc-chunks around the text of the footnote. As it +% takes an argument (the text) is should not be use as tagging socket either. % % \end{description} % % % The \emph{footnotemark} should create a \texttt{/Lbl} structure\footnote{to make it easier -% to identify the role we use \texttt{/footnotemark} which we rolemap to \texttt{/Lbl}} that should contain a \texttt{/Ref} entry pointing +% to identify the role we use \texttt{/footnotemark} which we rolemap to \texttt{/Lbl}} +% that should contain a \texttt{/Ref} entry pointing % to the structure of the \emph{footnotetext}. % -% The \emph{footnotetext} should create a \texttt{/FENote}\footnote{We tag it as \texttt{/footnote} and role map it.} -% structure with a \texttt{/Ref} +% The \emph{footnotetext} should create a \texttt{/FENote}% +% \footnote{We tag it as \texttt{/footnote} and role map it.} +% structure with a \texttt{/Ref} % entry pointing to the structures of \emph{all} marks related to the note. % The mark at the begin of the % note is in a \texttt{/Lbl}\footnote{We tag it as \texttt{/footnotelabel}.} @@ -582,8 +607,8 @@ % with their own structure number as a key in a property. % % A following \cs{footnotetext} compares its own \cs{@thefnmark} with the values in -% the prop. If there is a match it stores the structure numbers and removes the entries -% from the properties (so in a normal document the property will never contain more than +% the prop. If there is one or more match it stores the structure numbers and removes the entries +% from the property (so in a normal document the property will never contain more than % a few entries). % % This works well as long as the \cs{footnotemark} commands are issued before the \cs{footnotetext} and @@ -626,9 +651,9 @@ % % \subsubsection{\cs{footref}} % -% \cs{footref} use internally the same command to set the mark as \cs{footnotemark}, it only +% \cs{footref} uses internally the same command to set the mark as \cs{footnotemark}, it only % defines \cs{@thefnmark} differently. This \cs{@thefnmark} is not suitable for the method described -% above, as it contains a reference command it can't be used to match a note, also \cs{footref} can +% above: as it contains a reference command it can't be used to match a note, also \cs{footref} can % be used after the note has already been set. \cs{footref} disables therefore the automatic detection. % % Instead the \cs{label} command is @@ -636,7 +661,7 @@ % number to setup the reference and the link. % % The structure related to the \cs{footref} is added to the end of the \texttt{/Ref} array of the note and so the -% \texttt{/Ref} array doesn't necessarly reflect the order of the marks in the document. It would probably +% \texttt{/Ref} array doesn't necessarily reflect the order of the marks in the document. It would probably % be possible to change this, but it is not clear if it actually matters and so it worth the additional coding % and processing. % @@ -672,7 +697,7 @@ % % A \cs{footnotetext} creates a bunch of destinations (in most cases this sums up to % two destinations): one for every structure number in the \texttt{/Ref} (used as target -% by the mark commands) and one for the structure number of the footnotetest itself +% by the mark commands) and one for the structure number of the footnotetext itself % (used as target by \cs{footref}s commands). % % \subsection{Implementation details regarding tagging} @@ -899,8 +924,8 @@ % This is used to pass the structure number of the note around, e.g. % to a label inside the note. % \begin{macrocode} -\tl_new:N \l_@@_currentstruct_tl -\tl_set:Nn \l_@@_currentstruct_tl {1} +\tl_new:N \l_@@_currentstruct_tl +\tl_set:Nn \l_@@_currentstruct_tl {2} % \end{macrocode} % % @@ -1150,6 +1175,21 @@ % % % \begin{macro}{\fnote_footnotetext:n} +% We temporarily test for the tagging socket until it is in the next release: +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/para/restore_plug_str } + { + \NewSocket{tagsupport/para/restore}{0} + \NewSocketPlug{tagsupport/para/restore}{default} + { + \tl_set:Nn \l__tag_para_main_tag_tl {text-unit} + \tl_set_eq:NN \l__tag_para_tag_tl\l__tag_para_tag_default_tl + \bool_set_false:N\l__tag_para_flattened_bool + } + \AssignSocketPlug{tagsupport/para/restore}{default} + } +% \end{macrocode} +% % \begin{macrocode} \cs_new_protected:Npn \fnote_footnotetext:n #1 { \@@_debug_footnotetext: @@ -1191,6 +1231,7 @@ \floatingpenalty \@MM \hsize\columnwidth \@parboxrestore + \UseTaggingSocket{para/restore} \parindent 1em % typical default used in \@makefntext moved up here \def\@currentcounter{footnote} \protected@edef \@currentlabel { \p@footnote \@thefnmark } @@ -1673,7 +1714,7 @@ % % \subsubsection{\pkg{memoir}} % The \pkg{memoir} class redefines various internal commands to inject its -% hooks and addtional code. The following reinstates the kernel command and +% hooks and additional code. The following reinstates the kernel command and % so probably breaks various options of \pkg{memoir}, but without the % changes it errors anyway. The \pkg{footmisc} package should be used to change % for example to para footnotes. @@ -1937,10 +1978,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_gput_ref:nn #1 #2 %#1 the structure number receiving the ref #2 { - \tag_if_active:T - { - \tag_struct_gput:nne {#1}{ref}{\tag_struct_object_ref:e { #2 }} - } + \tag_struct_gput:nnn {#1}{ref_num}{#2} } \cs_new_protected:Npn \fnote_gput_refs:nn #1 #2 % pair of numbers { @@ -1951,11 +1989,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macrocode} -\tl_new:N \l_@@_dflt_struct_tl -\tl_set:Nn \l_@@_dflt_struct_tl {1} -% \end{macrocode} -% kernel hooks for taggin +% kernel hooks for tagging % this sets the structure around the whole text % % @@ -1965,25 +1999,30 @@ { \tag_mc_end_push: % \end{macrocode} -% test if a footnote is allowed, if not move up to the document structure. +% test if a footnote is allowed, if not move up to the next sect or +% the document structure. % \begin{macrocode} \tag_check_child:nnTF {FENote}{pdf2} { \tag_struct_begin:n { tag=footnote } } { - \tag_struct_begin:n { tag=footnote,parent=\l_@@_dflt_struct_tl } + \tag_struct_begin:n + { + tag=footnote, +% \end{macrocode} +% We add 0 for now to ensure to get a number even if the sec code is not loaded +% or if the seq is empty (which it shouldn't unless there is an coding error) +% \begin{macrocode} + parent=\int_max:nn{2}{\tag_get:n{current_Sect}+0} + } } % \end{macrocode} % Store the current structure number for labels. % \begin{macrocode} \tl_set:Ne \l_@@_currentstruct_tl { \tag_get:n{struct_num} } % \end{macrocode} -% We want to move the label structure here. So we provide a container -% It number is |\l__fnote_currentstruct_tl| plus 1. -% \begin{macrocode} - \tag_struct_begin:n { tag=footnotelabel }\tag_struct_end: -% \end{macrocode} +% % after we have opened the structure we can use the structure number to % try to detect the connected marks. As with the marks we assume that sometimes % no auto detection is done. @@ -2066,12 +2105,9 @@ \MakeLinkTarget*{footnote*.\l_@@_currentstruct_tl} % \end{macrocode} % Now we add the tagging commands. We move the structure of the label to -% to the container at the begin of the note. -% \begin{NOTE}{UF} -% Check if the NonStruct is really needed. Perhaps we can simply move the mc. -% \end{NOTE} +% the begin of the footnote structure. % \begin{macrocode} - \tag_struct_begin:n { tag=NonStruct,parent=\l_@@_currentstruct_tl +1 } + \tag_struct_begin:n { tag=footnotelabel,parent=\l_@@_currentstruct_tl,firstkid } \tag_mc_begin:n { tag=Lbl } #1 \tag_mc_end: @@ -2446,7 +2482,7 @@ % This can use the default interface, except that a negative value for % \footnotemargin makes little sense, so we test for this and warn if -% necessary. But -\maxdimen is ok again, so would need to be a litte bit more elaborate. +% necessary. But -\maxdimen is ok again, so would need to be a little bit more elaborate. % %\AddToHook{fntext/para}{ @@ -2483,7 +2519,7 @@ \leavevmode % \end{macrocode} % Typesetting the mark twice means that one can't have any material -% inside that gets unhappy in that case. Tha shouldn't be a +% inside that gets unhappy in that case. That shouldn't be a % problem, but perhaps we have to come up with a more elaborate % solution in the end. % \begin{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-footnotes.pdf b/macros/latex/required/latex-lab/latex-lab-footnotes.pdf Binary files differindex b949e4680c..b36d34ff70 100644 --- a/macros/latex/required/latex-lab/latex-lab-footnotes.pdf +++ b/macros/latex/required/latex-lab/latex-lab-footnotes.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-graphic.dtx b/macros/latex/required/latex-lab/latex-lab-graphic.dtx index 5ea4a2db9c..b3ee3eb6c6 100644 --- a/macros/latex/required/latex-lab/latex-lab-graphic.dtx +++ b/macros/latex/required/latex-lab/latex-lab-graphic.dtx @@ -15,8 +15,8 @@ % https://github.com/latex3/latex2e/required/latex-lab % % for those people who are interested or want to report an issue. -\def\ltlabgraphicdate{2024-03-13} -\def\ltlabgraphicversion{0.80d} +\def\ltlabgraphicdate{2024-09-18} +\def\ltlabgraphicversion{0.80e} % %<*driver> \documentclass{l3doc} @@ -78,7 +78,7 @@ % The value of a \texttt{BBox} is an array of four numbers that gives the % coordinates of the left, bottom, right, and top edges % of the structure element’s bounding box. That is the rectangle that completely encloses -% its \emph{visible} content so not necessarly the TeX bounding box: +% its \emph{visible} content so not necessarily the TeX bounding box: % if \texttt{viewport} or \texttt{trim} is used and the % graphic is not clipped, the visible content can be larger. % @@ -146,8 +146,8 @@ % \item[\texttt{artifact}] When used the graphic will be tagged as artifact. This doesn't % require a \texttt{BBox} and so works also in some of the not yet supported cases described % above. -% \item[\texttt{false}] When used tagging will be stopped completly. It is then the -% responsability of the surrounding code to add appropriate tagging commands. +% \item[\texttt{false}] When used tagging will be stopped completely. It is then the +% responsibility of the surrounding code to add appropriate tagging commands. % \item[\meta{name}] Other values will be used as tag names in the structure. If the tag is not % known as a structure tag you will get an warning from tagpdf. The default name is currently % \texttt{Figure} @@ -291,7 +291,7 @@ % ,\l_@@_graphic_trim_uy_fp % } % A bunch of fp-variables (we don't use tl-vars, -% to avoid to have to take care about minus signs everwhere) +% to avoid to have to take care about minus signs everywhere) % \begin{macrocode} \fp_new:N\l_@@_graphic_sin_fp \fp_new:N\l_@@_graphic_cos_fp @@ -489,7 +489,7 @@ \bool_set_true:N \l_@@_graphic_artifact_bool \bool_set_false:N \l_@@_graphic_BBox_bool } - {false}{\tag_stop:} + {false}{\tag_suspend:n{Gin}} } {\tl_set:Nn\l_@@_graphic_struct_tl{#1}} } @@ -528,7 +528,7 @@ \bool_set_true:N \l_@@_graphic_artifact_bool \bool_set_false:N \l_@@_graphic_BBox_bool } - {false}{\tag_stop:} + {false}{\tag_suspend:n{picture}} } {\tl_set:Nn\l_@@_graphic_struct_tl{#1}} } @@ -1012,7 +1012,7 @@ \@defaultunitsset\@tempdimc{#1}\unitlength \Gin@tag@struct@begin \setbox\@picbox\hb@xt@\@tempdimc\bgroup - \tag_stop: %do not tag inside the picture box + \tag_suspend:n{\@picture} %do not tag inside the picture box \@defaultunitsset\@tempdimc{#3}\unitlength \hskip -\@tempdimc \@defaultunitsset\@tempdimc{#4}\unitlength diff --git a/macros/latex/required/latex-lab/latex-lab-graphic.pdf b/macros/latex/required/latex-lab/latex-lab-graphic.pdf Binary files differindex 18ae18a5a1..59cfbf7278 100644 --- a/macros/latex/required/latex-lab/latex-lab-graphic.pdf +++ b/macros/latex/required/latex-lab/latex-lab-graphic.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-marginpar.dtx b/macros/latex/required/latex-lab/latex-lab-marginpar.dtx index ca79d8a67f..2f293ee492 100644 --- a/macros/latex/required/latex-lab/latex-lab-marginpar.dtx +++ b/macros/latex/required/latex-lab/latex-lab-marginpar.dtx @@ -18,8 +18,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabmarginpardate{2024-02-12} -\def\ltlabmarginparversion{0.85b} +\def\ltlabmarginpardate{2024-09-18} +\def\ltlabmarginparversion{0.85d} %<*driver> \documentclass[kernel]{l3doc} @@ -72,7 +72,7 @@ % They can be tagged either as artifacts (if they are merely distracting decoration), % as small headings before the paragraph, or as |Aside|. Unlike the PDF 1.7 fallback |Note| % the structure |Aside| is not allowed inside |P|, -% so if |Aside| is used, it must be placed before or after the current |P| in the surounding |text-unit|, +% so if |Aside| is used, it must be placed before or after the current |P| in the surrounding |text-unit|, % or it must split the |P|. Splitting is probably not so good as % |\marginpar| is often used somewhere in the middle of sentence. % The best default is probably to use |Aside|, find the parent |text-unit| and add it there. @@ -153,13 +153,38 @@ \socket_new:nn {tagsupport/marginpar/end}{0} % \end{macrocode} % \end{socketdecl} +% +% \begin{macro}{\@@_get_marginpar_parent:N,\@@_get_marginpar_parent_aux:nn} +% In a paragraph we must retrieve +% the structure number of the surrounding Part structure +% TODO: if this is needed in more places this should +% go into tagpdf. +% \begin{macrocode} +\cs_new_protected:Npn\@@_get_marginpar_parent_aux:nn #1 #2 + { + \str_if_eq:eeT{\use_ii:nn #1}{Part}{\seq_put_right:Nn\l_@@_tmpa_seq {#2}} + } +\cs_new_protected:Npn \@@_get_marginpar_parent:N #1 + { + \seq_clear:N\l_@@_tmpa_seq + \seq_map_pairwise_function:NNN + \g_@@_struct_tag_stack_seq + \g_@@_struct_stack_seq + \@@_get_marginpar_parent_aux:nn + \seq_put_right:Nn\l_@@_tmpa_seq {2} + \seq_get_left:NN \l_@@_tmpa_seq #1 + } +\cs_generate_variant:Nn \tag_struct_begin:n {e} +% \end{macrocode} +% \end{macro} % \begin{plugdecl}{tagsupport/marginpar/begin,tagsupport/marginpar/end} % \begin{macrocode} \socket_new_plug:nnn {tagsupport/marginpar/begin}{default} { \if_mode_horizontal: - \tag_mc_end: - \tag_struct_begin:n{tag=Aside,parent=\g__tag_para_main_struct_tl}% + \tag_mc_end: + \@@_get_marginpar_parent:N \l_@@_tmpa_tl + \tag_struct_begin:e{tag=Aside,parent=\l_@@_tmpa_tl}% \else: \tag_struct_begin:n{tag=Aside}% \fi: @@ -202,9 +227,9 @@ \long\def\@ympar#1{% \@savemarbox\@marbox{#1}% \global\setbox\@currbox\copy\@marbox - \tag_stop: + \tag_suspend:n{\@ympar} \@xympar - \tag_start:} + \tag_resume:n{\@ympar}} % \end{macrocode} % \end{macro} % @@ -223,9 +248,9 @@ \property_record:ee { tag_marginpar-opt-\int_use:N\g__kernel_marginpar_int }{page} }% - \tag_stop: + \tag_suspend:n{\@xmpar} \@savemarbox\@currbox{#2}% - \tag_start: + \tag_resume:n{\@xmpar} } % \end{macrocode} % order matters! the tagged box should be first so that it can pick up @@ -233,15 +258,15 @@ % \begin{macrocode} { \@savemarbox\@currbox{#2}% - \tag_stop: + \tag_suspend:n{\@xmpar} \@savemarbox\@marbox{#1 \property_record:ee { tag_marginpar-opt-\int_use:N\g__kernel_marginpar_int }{page}} - \tag_start: + \tag_resume:n{\@xmpar} } - \tag_stop: + \tag_suspend:n{\@xmpar} \@xympar - \tag_start: + \tag_resume:n{\@xmpar} } %</package> % \end{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-marginpar.pdf b/macros/latex/required/latex-lab/latex-lab-marginpar.pdf Binary files differindex 5379c2d640..081ffda756 100644 --- a/macros/latex/required/latex-lab/latex-lab-marginpar.pdf +++ b/macros/latex/required/latex-lab/latex-lab-marginpar.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-math.dtx b/macros/latex/required/latex-lab/latex-lab-math.dtx index 0dbc591185..94d31c817b 100644 --- a/macros/latex/required/latex-lab/latex-lab-math.dtx +++ b/macros/latex/required/latex-lab/latex-lab-math.dtx @@ -19,13 +19,13 @@ % for those people who are interested or want to report an issue. % % -\def\ltlabmathdate{2024-04-16} -\def\ltlabmathversion{0.5j} +\def\ltlabmathdate{2024-10-25} +\def\ltlabmathversion{0.6i} % %<*driver> \documentclass{l3doc} \EnableCrossrefs -\CodelineIndex +\CodelineIndex \usepackage{todonotes} @@ -40,7 +40,7 @@ % \title{The \texttt{latex-lab-math} code\thanks{}} % \author{Frank Mittelbach, Joseph Wright, \LaTeX{} Project} % \date{v\ltlabmathversion\ \ltlabmathdate} -% +% % \maketitle % % \newcommand\NEW[1]{\marginpar{\mbox{}\hfill\fbox{New: #1}}} @@ -77,21 +77,21 @@ % \tableofcontents % % \section{Introduction} -% \car*{Todo: update all the documentation! Both here and +% \car*{Todo: update all the documentation! Both here and % (what little there is!) in the implementation section.} % % Tagging math involves a variety of tasks that require that math is captured before the % typesetting -% \begin{itemize} -% \item When typesetting the math MC-tags and structure commands must -% be inserted at the begin and the end, and perhaps also around lines -% or other subparts of the equation. +% \begin{itemize} +% \item When typesetting the math MC-tags and structure commands must +% be inserted at the begin and the end, and perhaps also around lines +% or other subparts of the equation. % \item The source and/or a mathml-representation of the source must be available % so that it can be (perhaps after some preprocessing) be used in an associated file % or in an alternate text -% \item It must be possible to measure the math for e.g. a bbox setting. +% \item It must be possible to measure the math for, e.g., a bbox setting. % \end{itemize} -% +% % This file implements capture of all math mode material at the outer % level, i.e., a formula is captured in its entirety with inner text % blocks (possibly containing further math) absorbed as part of the @@ -101,24 +101,24 @@ %\end{verbatim} % would only result in a single capture of the tokens % ``\verb*/a \in A \text{ for all $a<5$}/''. -% +% % % \section{Math capture} \label{sec:mathcapture} -% In the current setup +% In the current setup % \begin{itemize} % \item |$|, |\(...\)| and |$$| grab (through a command in \cs{everymath}/cs{everydisplay}) % if the boolean \cs{l_@@_collected_bool} is false. % If the boolean is true they behave normally and can for example contain verbatim. -% -% \item All (registered) environments grab their body +% +% \item All (registered) environments grab their body % regardless of the state of the boolean. For -% |equation|, |equation*| and |math| this is a change as they no longer can +% |equation|, |equation*| and |math| this is a change as they no longer can % contain verbatim. -% +% % \item BUG: |\[...\]| grabs if \cs{l_@@_collected_bool} is false. If it is -% true it falls back to |equation*| and then errors because this can't find the end. -% \end{itemize} -% +% true it falls back to |equation*| and then errors because this can't find the end. +% \end{itemize} +% % \subsection{Code level interfaces} % % \begin{function}{\math_register_env:n, \math_register_env:nn} @@ -163,49 +163,52 @@ % material. % \end{itemize} % \end{function} -% +% % \section{Math tagging} -% -% The tagging code has to handle +% +% \subsection{Code requirements} +% The tagging code has to handle % \begin{itemize} -% \item the embedding into the surrounding. This means -% \begin{itemize} -% \item closing and reopening MC-chunks +% \item the embedding into the surrounding. This means +% \begin{itemize} +% \item closing and reopening MC-chunks % \item closing and reopening text/P-structures % \item handling interferences of the tagging code with penalties and spacing. % \end{itemize} % \item the actual tagging which means to do some or all of the following tasks: % \begin{itemize} % \item setup content for an associated source file -% \item setup content for an associated mathml file +% \item setup content for an associated mathml file % \item setup content for the /Alt key % \item setup content for the /ActualText key % \item setup attributes -% \item add associated files +% \item add associated files % \item add a Formula structure -% \item surround subparts (e.g. lines) with Formula sub structures +% \item surround subparts (e.g., lines) with Formula sub structures % (perhaps with their own set of additional content) -% \item surround elements of the equation with mathml structure elements +% \item surround elements of the equation with mathml structure elements % (currently only luatex with luamml) % \end{itemize} % \end{itemize} -% +% % \subsection{Inline math} -% +% % The embedding code is added through -% the sockets +% the sockets % \begin{itemize} -% \item |tagsupport/math/inline/begin| +% \item |tagsupport/math/inline/begin| % \item |tagsupport/math/inline/end| -% \end{itemize} +% \end{itemize} % The sockets simply push and pop the MC currently. Without -% tagging they use the noop-plug. -% +% tagging they use the noop-plug. +% % The actual tagging is in done through the sockets % \begin{itemize} % \item |tagsupport/math/inline/formula/begin| % This socket takes the math as argument and its code -% should output it for typesetting. Without tagging the +% should output it for typesetting. +% It is not \emph{used} as a tagging socket as the math argument should +% not be lost without tagging, so without tagging the % socket uses the identity plug. % The |default| plug of the socket calls these three internal sockets % for the tagging support: @@ -216,55 +219,62 @@ % \item |tagsupport/math/struct/begin| This calls \cs{tag_struct_begin:n}. % It should also write the associated files if needed. % \item |tagsupport/math/substruct/begin| this handles subparts. -% TODO: does it really make sense in inline math to have that?? +% TODO: does it really make sense in inline math to have that?? % \end{itemize} % \item |tagsupport/math/inline/formula/end| % This socket ends the formula structure(s). The |default| % plug calls these internal sockets: % \begin{itemize} % \item |tagsupport/math/substruct/end| -% \item |tagsupport/math/struct/end| +% \item |tagsupport/math/struct/end| % \end{itemize} -% \end{itemize} -% +% \end{itemize} +% % \subsection{Display math} -% +% % \textit{to be written} -% +% % \subsection{Associated Files} -% +% % The current code allows the attachment of two types of associated file to the % Formula structure: -% the \LaTeX\ source and a MathML representation. +% the \LaTeX\ source and a MathML representation. % Technically both can be attached---AF is an array -% of file references---practically there can be problems with PDF consumers: -% e.g. ngpdf used both and so showed the equation twice -% (this has been corrected in the newest version) and +% of file references-----in practice there can be problems with PDF consumers: +% e.g., ngpdf used both and so showed the equation twice +% (this has been corrected in the newest version) and % Foxit seems to see only the first AF in the array (so we attach the % mathml as first file). -% -% The \LaTeX\ source can be (and is) attached automatically. +% +% The \LaTeX\ source can be (and is) attached automatically. % It can be suppressed by an option with -% \texttt{math/tex/AF=false}, see below. -% -% The MathML is attached if a file |\jobname-mathml.html| is found and -% if it contains a suitable MathML snippet for the current formula. +% \texttt{math/tex/AF=false}, see below. +% +% The MathML is attached if the files |\jobname-mathml.html| and/or +% |\jobname-luamml-mathml.html| are found +% and if they contains a suitable MathML snippet for the current formula. +% If the files contain more than one suitable snippet (as identified by the hash) +% the first one is used. +% |\jobname-luamml-mathml.html| is automatically generated (see below section~\ref{sec:luamml}) +% and read after |\jobname-mathml.html|. This means that |\jobname-mathml.html| can contain +% improved versions of a formula. +% % The MathML processing can be suppressed globally by emptying the list of % mathml files with |math/mathml/sources=|. Locally for a formula |math/mathml/AF=false| -% can be used. -% -% For a MathML representation a file with such representations must be provided. -% If the equation is numbered the numbering should be part of the MathML as +% can be used. +% +% For a MathML representation a file with such representations must be provided. +% If the equation is numbered the numbering should be part of the MathML as % the |Lbl| substructure is ignored if an MathML is used (see https://github.com/foxitsoftware/PDF_UA-2). -% -% The MathML representation is given in a special format. +% +% The MathML representation is given in a special format. % It is meant to be a valid html file % that can be viewed in a browser. % For this it can start with |<!DOCTYPE html><html>| and end with |</html>| -% It should have the extension \texttt{.html}. The \meta{mathml} content +% It should have the extension \texttt{.html}. The \meta{mathml} content % is read with special catcodes, so can contain ambersands, hashes, comment chars % and unmatched braces such as |<mo>{</mo>| -% +% % The file should contain a number of representations in this format: % \begin{quote} % |<div>| \\ @@ -278,176 +288,338 @@ % \end{quote} % The keywords |<div>|, |<h2>\mml|, |<p>|, |<math|, |</math>| |</div>| are required as % they are used to delimit the arguments by the \LaTeX{} code. -% +% % \meta{key} and \meta{source} are only used for debugging, they help to identify % the equation referred by this representation. The source should be used correctly escaped % |&| and |<| so that if gives valid html! -% -% \meta{attributes} is not required either, but can e.g. contain attributes +% +% \meta{attributes} is not required either, but can, e.g., contain attributes % to improve the display in a browser: % \begin{verbatim} % <math alttext="\mathbf{G}" class="ltx_Math" display="inline"> % \end{verbatim} % It can also contain the name space declaration: |xmlns="http://www.w3.org/1998/Math/MathML"|% % \footnote{But it is probably not needed and only blows up the PDF.} -% -% -% By default the code tries at the begin of the document -% to read a file |\jobname-mathml.html| in the |html|-format. -% The file name can be changed with |mathml/setfiles={filename1,filename2}| -% (without extension, |html| is added automatically). -% If there is a list, all files are loaded. +% +% +% By default the code tries at the begin of the document +% to read a file |\jobname-mathml.html| in the |html|-format. +% The file name can be changed with |mathml/setfiles={filename1,filename2}| +% (without extension, |html| is added automatically). +% If there is a list, all files are loaded. % If a file doesn't exist it is ignored, only an info is written to the log. -% -% Currently every MathML-snippet from a file is embedded into the PDF, -% it is not checked first if it is actually used (simply writing everything to the PDF -% is a bit easier than keeping everything in memory and also means that -% the snippets are one after the other in the PDF). -% -% As mentioned above the MathML-AF can be suppressed for the equations in a group with +% +% Currently every MathML-snippet from a file is embedded into the PDF, +% it is not checked first if it is actually used (simply writing everything to the PDF +% is a bit easier than keeping everything in memory and also means that +% the snippets are one after the other in the PDF). +% +% As mentioned above the MathML-AF can be suppressed for the equations in a group with % |math/mathml/AF=false|, or -% completly by setting |math/mathml/sources=| in the preamble. -% +% completely by setting |math/mathml/sources=| in the preamble. +% % Files embedded in a PDF can be listed in the attachments panel of a PDF viewer. % This is probably not so useful for lots of small files (but one could create -% collections), but as long as PDF editors or viewers don't offer +% collections), but as long as PDF editors or viewers don't offer % proper support to access the AF it can help so have them there. The MathML are % added by default, but the \LaTeX{} source not. This can be changed with % |viewer/pane/mathsource=true| (anywhere in the document) and |viewer/pane/mathml=false| (in the -% preamble, before the external file is read). +% preamble, before the external file is read). +% +% +% \subsection{Automatic mathml creation with luamml}\label{sec:luamml} +% +% If lualatex and the package \pkg{unicode-math} is used +% the package \texttt{luamml} is loaded and +% will automatically generate the file |\jobname-luamml-mathml.html| +% with mathml representations of all math formulas. +% This file is then used in subsequent compilations and works also with +% pdflatex. +% +% The generation of the file can be suppressed (in the preamble) +% with |math/mathml/luamml/write=false|. % -% \subsection{Options} -% -% +% If the package \pkg{unicode-math} is not used, +% the loading of \pkg{luamml} and with it the generation of the file can be forced +% with |math/mathml/luamml/load=true| or |math/mathml/luamml/write=true| +% but be aware that it is then possible that various symbols +% are mapped to the wrong Unicode code points. +% +% The package \pkg{luamml} is still quite experimental and the output should be checked. +% The |\jobname-luamml-mathml.html| file may be previewed in a browser although +% you may need to add additional css or javascript declarations +% to enable browser support for all mathml constructs. +% +% +% \subsection{Summary of math options} +% The following options exist to make math more accessible: +% \begin{description} +% \item[ActualText] An \texttt{ActualText} can be placed on structure elements, +% but can also be added in the stream on a \texttt{BDC} marker with a \texttt{Span} +% tag (normally an independant marker without an MCID number, it is not clear yet +% if it can be used on a MC-chunk). +% The content is a text string, typically one or a few Unicode characters. +% \texttt{ActualText} is meant to replaces the content +% and should only be used on small entities, +% e.g., to define the semantic or the Unicode code point of a symbol. +% \texttt{ActualText} is not supported by all PDF reader. +% It is also unknown where it should be used at best (in a structure element, +% or on an independent Span-BDC) and what happens if it is used in more than +% one place. +% \begin{description} +% \item[enabled by default?] False +% \item[how to enable/disable] No interface yet. +% \texttt{ActualText} can only be added on the Formula structure element by +% changing the \texttt{tagsupport/math/content} or some other socket. +% For a BDC marker one can, e.g., use +% \begin{verbatim} +% \pdf_string_from_unicode:nnN{utf16/hex}{€}\l_tmpa_tl +% \pdf_bdc:ee{Span}{/ActualText\l_tmpa_tl}content\pdf_emc: +% \end{verbatim} +% There should be no pagebreak in the \meta{content} and the BDC should be correctly +% nested into tagging, so, e.g., a \cs{leavevmode} should be issued before the bdc command. +% \item[Consumer support] in part and in part buggy, needs tests \ldots +% \end{description} +% +% \item[Alt] Like \texttt{ActualText} the \texttt{Alt} key can be used on +% structure elements and on \texttt{Span} in the stream. It should contain a description +% of the content and is mainly meant for images. PDF/UA-1, +% which views math formulas as illustrations, mandates the key +% also for \texttt{Formula} structure elements. +% \begin{description} +% \item[enabled by default?] false unless PDF/UA-1 is detected, +% then it is enabled in the begindocument/end hook +% (this will reconsidered when it is clear, that +% the use of \texttt{Alt} does not shadow mathml). It can be enabled for +% all engines and PDF versions. +% \item[enable/disable] \verb+\tagpdfsetup{math/alt/use}+ (local boolean, +% so can be used on individual equations) +% \item[default value] A template text (stored in \cs{l_@@_content_template_tl}) +% starting with \texttt{LaTeX formula starts}. +% \item[user value] No interface currently provided. This needs optional arguments +% or an external setup command. +% See \url{https://github.com/latex3/tagging-project/discussions/717}. +% +% \end{description} +% +% \item[source-AF] The \LaTeX{}-source of the equation can +% be attached as an associated file with mime-type +% application/Fx-tex. The \texttt{AFRelationship} is \texttt{Source}. +% The source is embedded without expansion. This means that targets of +% references and macros are not resolved. +% The files are by default not shown in the EmbeddedFiles pane, +% this can be enabled with |viewer/pane/mathsource=true|. +% If an A-standard is used, it must be one that allows embedded files, e.g., A-4f. +% +% \begin{description} +% \item[enabled by default?] true for all engines and PDF versions +% \item[enable/disable] \verb+\tagpdfsetup{math/tex/AF}+ (local boolean, so can +% be used on individual equations) +% \item[default value] source code including dollars or environment name. +% \item[consumer support] Currently only ngpdf makes +% use of it: if there is no mathml it passes the source to mathjax. +% \end{description} +% +% \item[luamml] The following options make (with lualatex) use +% of the \pkg{luamml} package. \pkg{luamml} is currently automatically +% loaded (at the end of the preamble) if \pkg{unicode-math} has been detected. +% The loading can be forced or suppressed +% with \verb+\tagpdfsetup{math/mathml/luamml/load=true/false}+. +% +% \pkg{luamml} affects all math, locally it can be stopped with |math/mathml/ignore|, +% or by using the commands described in the package. +% +% \item[mathml-AF] A mathml representation of the equation can be attached +% to the structure. The configuration possibilities are rather complex as the +% keys have to control three different tasks: +% The \emph{generation} of the file with the mathml fragments, +% the \emph{reading} and \emph{embedding} of the mathml fragments, +% and the \emph{association} of a mathml fragment to a specific equation. +% +% \begin{description} +% \item[generation] +% With pdf\LaTeX{} mathml fragments can not be generated automatically, +% but a file with dummy fragments for every equation will be written if +% \verb+\tagpdfsetup{math/mathml/write-dummy}+ is issued in the preamble. +% +% With lua\LaTeX{} a file with mathml fragments will be created automatically +% if the package \pkg{luamml} has been loaded (see above). +% +% \item[reading and embedding] +% By default the code will read and embed +% mathml from |\jobname-mathml.html| and |\jobname-luamml-mathml.html| in this order and +% the first fragment with a new hash value will be inserted.% +% The list of sources and their order can be changed with the key +% |math/mathml/sources|, setting that to an empty value suppresses +% the loading mathml associated files completely. For efficiency reasons +% it embeds math fragments directly, there is no check yet if the fragment is +% actually used. +% +% The files are by default shown in the EmbeddedFiles pane, +% this can be disabled with |viewer/pane/mathml=false|. +% +% \item[attaching] A mathml fragment is currently +% attached as an associated file to an Formula if the hash of +% the source matches the hash of the fragment. This is not a perfect test: +% equations with the same source and so the same hash +% can have different mathml representation, e.g., +% if there are references or commands or counters in the equation. This +% will change in a feature version. +% The attachment can be suppressed locally with |math/mathml/AF=false|. +% The mathml fragment will still be embedded in the PDF! +% +% % TODO: adapt test +% \end{description} +% +% \item[mathml structure elements] +% Mathml structure elements can be used in PDF~2.0 directly. +% In PDF~1.7. one could theoretically +% use them if one declares a role mapping first, +% (this can be done with \verb+\tagpdfsetup{role/mathml-tags}+) +% which maps all to \texttt{Span}. But such a role mapping currently breaks reading, +% e.g. in Adobe, and so it is not recommended. +% +% Automatic generation of structure elements is only possible with +% lualatex. It requires that the packages \pkg{luamml} and \pkg{tagpdf} +% have been loaded. +% \begin{description} +% \item[enabled by default?] false +% \item[enable/disable] \verb+\tagpdfsetup{math/mathml/structelem}+ +% (local setting, so can be used with grouping on individual equations). +% \item[consumer support] Needs more tests. +% \end{description} +% +% \end{description} +% +% +% % \section{Known current bugs, etc.} -% \car*{New Section, now with subsections.\\ -% As indicated, these lists are probably incomplete.\\ -% Some of these have been addressed in a more recent branch.} % % \subsection{Capture/grabbing problems} -% +% % \begin{enumerate} -% \item Incorrect grabbing of |$|-math when there is also -% explicit |$|-math within a \textit{text environment} +% \item Incorrect grabbing of |$|-math when there is also +% explicit |$|-math within a \textit{text environment} % that is itself within the math that should all be grabbed. % For example, % \begin{verbatim} % $a\begin{minipage}{1cm}$b$\end{minipage}$ % \end{verbatim} % would only result in the capture of the tokens -% ``\verb*/a\begin {minipage}{1cm}/''. +% ``\verb*/a\begin {minipage}{1cm}/''. % This can be avoided by an additional brace group: % \begin{verbatim} % $a{\begin{minipage}{1cm}$b$\end{minipage}}$ -% \end{verbatim} -% +% \end{verbatim} +% % \item Similar incorrect grabbing with |$$| also. -% +% % \item The grabbing, for all the display environments (and |\) \]|), needs -% to deal with nesting: \pkg{amsmath} contains code for this. -% -% \item The math can't contain verbatim and verbatim-like commands. This is +% to deal with nesting: \pkg{amsmath} contains code for this. +% +% \item The math can't contain verbatim and verbatim-like commands. This is % nothing new for the \pkg{amsmath} environments but changes |$| and |\[\]| -% and |equation*| (see e.g. tagging-project issue \#30). -% +% and |equation*| (see, e.g., tagging-project issue \#30). +% % \item Begin and end of the math or math environment can not be hidden in commands. -% For example \verb+>{$}l<{$}+ in a tabular would lead to errors. -% Defining |\[| to fall back to |equation*| doesn't work if |equation*| is +% For example \verb+>{$}l<{$}+ in a tabular would lead to errors. +% Defining |\[| to fall back to |equation*| doesn't work if |equation*| is % a grabbing environment. -% +% % \item The behaviour of |\[...\]| is faulty. See above. -% \end{enumerate} +% \end{enumerate} % % \subsection{Fake math} -% In a number of places in \LaTeX{} math commands (mainly |$|) is used -% only for technical reason, e.g. to access a math font, to setup a symbol -% or to use \cs{vcenter}. -% +% In a number of places in \LaTeX{} math commands (mainly |$|) is used +% only for technical reason, e.g., to access a math font, to setup a symbol +% or to use \cs{vcenter}. +% % The code identifies such fake math mostly by making use of the \cs{m@th} command % where two methods are used for the automatic detection: -% +% % \begin{itemize} -% \item After grabbing math content the code checks if the content contains the token +% \item After grabbing math content the code checks if the content contains the token % \cs{m@th} and if yes it doesn't call the processor before reinserting % the content and perhaps adding tagging code. % This method requires that the math can be grabbed (e.g. that the end dollar is visible) % and that the \cs{m@th} is visible. It applies for example in \cs{@iiiparbox} where the % code from |$\vcenter| to |\m@th$| is grabbed an put back. It does not work for % example for |tabular| where the dollars and the \cs{m@th} token are spread around -% over three commands. |tabular| needs therefore manual intervention. -% +% over three commands. |tabular| needs therefore manual intervention. +% % A look in the list of usages (in \texttt{usage-of-m@th.md}) justifies this approach. % All usages are either not math at all, or related to small elements that probably -% shouldn't be grabbed and processed on their own. +% shouldn't be grabbed and processed on their own. % % \item \cs{m@th} is redefined so that it sets the boolean \cs{l_@@_collected_bool} % to true. If \cs{m@th} is used inside math that has been grabbed % this doesn't change much as the boolean is set by the grabbing anyway. For usages % outside math the benefit is not so clear: The setting avoids that in \cs{LaTeXe} % the epsilon is processed as math, but it also prevents that the content of the amsmath -% command \cs{boxed} is processed as math. +% command \cs{boxed} is processed as math. % It means that if one wants to reenable math processing inside some (fake) math % one has to do it after \cs{m@th} calls. % \end{itemize} -% -% Open problems +% +% \subsubsection{Open problems} +% % \begin{enumerate} % \item The grabbing code doesn't pass the info that it detected a \cs{m@th} token. % This means that the tagging code has to do the same check (and doesn't do this % in all cases yet). -% -% \item Commands are missing to locally disable the grabbing and processing, e.g. +% +% \item Commands are missing to locally disable the grabbing and processing, e.g., % to handle |tabular|. -% +% % \item It must be checked if setting the boolean in \cs{m@th} really makes sense -% or if commands like \cs{LaTeXe} should be handled manually. -% +% or if commands like \cs{LaTeXe} should be handled manually. +% % \end{enumerate} -% +% % \subsection{Processor} -% +% % The grabbed math is at first passed to the processor. The processor is not called -% in a measuring phase (from the amsmath \cs{ifmeasuring@}) and if the \cs{m@th} -% token is detected. +% in a measuring phase (from the amsmath \cs{ifmeasuring@}) and if the \cs{m@th} +% token is detected. % It is not quite clear what purpose the processor has. As it is a public interface % it can't be used for internal code. And typesetting happens later and the processor % can't really change this. Currently it is mostly used for debugging and messages. % If the \cs{m@th} is found the \cs{l_@@_fakemath_bool} is set, so if the code % is changed this must be preserved. -% +% % \subsection{Other problems} -% -% \begin{enumerate} -% \item +% +% \begin{enumerate} +% \item % The presence of \cs{m@th} in association with \cs{ensuremath} -% does not necessarily indicate fakemath. This is because -% wanting mathsurround to be zero is very reasonable and common, +% does not necessarily indicate fakemath. This is because +% wanting mathsurround to be zero is very reasonable and common, % \emph{even when the math is genuine} (and hence needs to be collected). -% -% TODO: this claim needs some examples. -% -% \item User-defined environments can create problems; but this area, of -% new, copied and changed environments, has not yet been developed. -% +% +% TODO: this claim needs some examples. +% +% \item User-defined environments can create problems; but this area, of +% new, copied and changed environments, has not yet been developed. +% % \car*{Joseph wrote, inter alia:\\ % My thinking [regarding] \cs{RegisterMathEnvironment}\\ % - (New) Math environments should not be created-then-patched, but only -% generated by a [(future)] dedicated command (\cs{DeclareMathEnvironment}, +% generated by a [(future)] dedicated command (\cs{DeclareMathEnvironment}, % presumably)\\ % - Math environments created with \pkg{ltcmd} [commands] should not be copied, . . .\\ % - Package authors should be able to manually set up math environments with a public boolean.} -% \end{enumerate} +% \end{enumerate} % % % \subsection{Other ToDos} % % \begin{enumerate} -% \item Add (some of) the math display commands that were \enquote{lifted from +% \item Add (some of) the math display commands that were \enquote{lifted from % plain}, e.g., \cs{displaylines} \cs{eqalign}(??). % \item The breqn packages changes catcodes and that isn't yet covered % by our mechanism. % \item \cs{intertext} is not correctly taken into account by the -% code splitting multiline math into subformulas. +% code splitting multiline math into subformulas. % \end{enumerate} % % @@ -494,7 +666,7 @@ % neatly. % \begin{macrocode} \AddToHook{begindocument/before}{ \RequirePackage { amsmath } } -% \end{macrocode} +% \end{macrocode} % % % \subsection{Data structures} @@ -502,7 +674,7 @@ % \begin{variable}{\l_@@_collected_bool} % Tracks whether math mode material has been collected, which happens inside % \pkg{amsmath} environments as well as those handled directly here. -% If true following math will not grab and/or process. +% If true following math will not grab and/or process. % See \ref{sec:mathcapture} for details. % \begin{macrocode} \bool_new:N \l_@@_collected_bool @@ -511,7 +683,7 @@ % % \begin{variable}{\l_@@_fakemath_bool} % Tracks whether math mode material has been identified as fake math during -% the grabbing phase, which happens currently if the +% the grabbing phase, which happens currently if the % grabbed contents contains the \cs{m@th} token. % % \begin{macrocode} @@ -532,20 +704,21 @@ \tl_new:N \g_@@_grabbed_math_tl % \end{macrocode} % \end{variable} -% +% % \begin{variable}{\l_@@_tmpa_tl,\l_@@_tmpa_skip,\l_@@_tmpa_str} % Temporary variables % \begin{macrocode} \tl_new:N \l_@@_tmpa_tl \skip_new:N \l_@@_tmpa_skip +\str_new:N \l_@@_tmpa_str % \end{macrocode} % \end{variable} % % \begin{variable}{\l_@@_content_alt_tl, % \l_@@_content_actual_tl, % \l_@@_content_AF_tl} -% Temporary variables to hold math content that should -% be used in actual or alt text and stored as AF. +% Temporary variables to hold math content that should +% be used in actual or alt text and stored as AF. % \begin{macrocode} \tl_new:N \l_@@_content_alt_tl \tl_new:N \l_@@_content_actual_tl @@ -554,15 +727,15 @@ \tl_new:N \l_@@_content_AF_mathml_tl % \end{macrocode} % \end{variable} -% +% % \subsection{Tagging tools} -% The following commands implement small tagging code chunks. +% The following commands implement small tagging code chunks. % This should probably be collected and moved into tagpdf later. % \begin{macro}{\__tag_tool_close_P:} % This closes a P/text-chunk, both the MC and the structure and % increases the counter manually. % \begin{macrocode} -\cs_new_protected:Npn \__tag_tool_close_P: +\cs_new_protected:Npn \__tag_tool_close_P: { \tag_if_active:T { @@ -574,14 +747,14 @@ } % \end{macrocode} % \end{macro} -% -% We add also an attribute. -% \begin{macrocode} +% +% We add also an attribute. +% \begin{macrocode} \tl_new:N\l_@@_attribute_class_tl \tagpdfsetup {role/new-attribute = {inline} {/O /Layout /Placement/Inline}, role/new-attribute = {display} {/O /Layout /Placement/Block}, - } + } % \end{macrocode} % % \subsection{Code related to AF} @@ -592,8 +765,12 @@ % \l__tag_math_mathml_AF_bool, % \g__tag_math_mathml_AF_bool, % \l__tag_math_mathml_pane_bool, -% \l__tag_math_alt_bool +% \l__tag_math_alt_bool, +% \g__tag_math_luamml_tl, % } +% The variable \cs{g__tag_math_luamml_tl} is initially 0 and +% the user key can set it to -1 or 1. This allows to distinguish +% the unset case from a value set by the user. % \begin{macrocode} \bool_new:N\l__tag_math_texsource_AF_bool \bool_new:N\l__tag_math_texsource_pane_bool @@ -601,9 +778,11 @@ \bool_new:N\g__tag_math_mathml_AF_bool \bool_new:N\l__tag_math_mathml_pane_bool \bool_new:N\l__tag_math_alt_bool +\tl_new:N\g__tag_math_luamml_tl +\tl_gset:Nn\g__tag_math_luamml_tl {0} % \end{macrocode} % \end{variable} -% +% % \begin{variable}{ % \g_@@_mathml_total_int, % \g_@@_mathml_int, @@ -613,13 +792,13 @@ % } % \cs{g_@@_mml_total_int} records the mathml fragments read in. % \cs{g_@@_mml_int} records the mathml fragments read in with a different hash. -% \cs{g_@@_AF_total_int} records the number of math structures that try to -% attach a mathml AF. +% \cs{g_@@_AF_total_int} records the number of math structures that try to +% attach a mathml AF. % \cs{g_@@_AF_found_int} records the number of math structures for which a fitting -% mathml is found. +% mathml is found. % \cs{g_@@_AF_attached_int} records the number of math structures which got a mathml fragment % (if mathml-AF are not disabled locally this should be the equal to the previous number. -% +% % \begin{macrocode} \int_new:N\g_@@_mathml_total_int \int_new:N\g_@@_mathml_int @@ -631,13 +810,15 @@ % % \begin{variable}{\l__tag_math_mathml_files_clist} % A sequence to store the file list for the mathml. +% We also check the luamml file. % \begin{macrocode} \clist_new:N\l__tag_math_mathml_files_clist -\clist_put_right:Ne\l__tag_math_mathml_files_clist {\c_sys_jobname_str-mathml} +\clist_put_right:Ne\l__tag_math_mathml_files_clist + {\c_sys_jobname_str-mathml,\c_sys_jobname_str-luamml-mathml} % \end{macrocode} % \end{variable} - -% This is the internal variant of the \cs{mml} command. +% +% This is the internal variant of the \cs{mml} command. % \begin{macro}{\@@_AF_mml:nnnn} % \begin{macrocode} \cs_new_protected:Npn \@@_AF_mml:nnnn #1 #2 #3 #4 @@ -653,22 +834,22 @@ % \end{macrocode} % a simple Desc key, take care that it is a valid string! % \begin{macrocode} - \pdfdict_put:nne {l_pdffile/Filespec} {Desc}{(mathml-#1)} + \pdfdict_put:nne {l_pdffile/Filespec} {Desc}{(mathml-#1)} \pdffile_embed_stream:nnN {#4}{mathml-#1.xml}\l_@@_tmpa_tl % \end{macrocode} -% not strictly necessary but makes the files visible in the file attachment -% page +% not strictly necessary but makes the files visible in the file attachment +% page % \begin{macrocode} \bool_if:NT \l__tag_math_mathml_pane_bool {\pdfmanagement_add:nne {Catalog/Names}{EmbeddedFiles}{\l_@@_tmpa_tl}} \tl_new:c{g_@@_mathml_#3_tl} - \tl_gset_eq:cN{g_@@_mathml_#3_tl}\l_@@_tmpa_tl + \tl_gset_eq:cN{g_@@_mathml_#3_tl}\l_@@_tmpa_tl } - } + } % \end{macrocode} % \end{macro} % -% The html reader. +% The html reader. % \begin{macrocode} \cs_new_protected:Npn \@@_AF_html_reader:w#1</h2>#2<p>#3</p>#4<p>#5</p>#6<math{ \begingroup @@ -685,39 +866,382 @@ \@@_AF_mml:nnnn{#1}{#2}{#3}{#4} } % \end{macrocode} +% +% As with luatex we write two files we define a few constants for +% the shared texts. +% +% \begin{macro} +% {\c_@@_mathml_write_init_tl,\l_@@_mathml_write_before_tl, +% \c_@@_mathml_write_after_tl,\c_@@_mathml_write_final_tl} +% \begin{macrocode} +\tl_const:Nn \c_@@_mathml_write_init_tl + { + <!DOCTYPE~html> + \iow_newline: + <html> + \iow_newline: + } +\tl_new:N \l_@@_mathml_write_before_tl +\tl_const:Nn \c_@@_mathml_write_after_tl + { + \iow_newline: + </div> + \iow_newline: + } +\tl_const:Nn \c_@@_mathml_write_final_tl + { + </html> + } +% \end{macrocode} +% \end{macro} +% \begin{socketdecl}{tagsupport/math/mathml/write/prepare} +% To prepare the hash and the starting command we use a socket, so +% that both the dummy and luamml can make use of it. +% \begin{macrocode} +\socket_new:nn {tagsupport/math/mathml/write/prepare}{0} +% \end{macrocode} +% \end{socketdecl} +% +% \begin{plugdecl}{On} +% \begin{macrocode} +\socket_new_plug:nnn{tagsupport/math/mathml/write/prepare}{On} + { + \str_set:NV\l_@@_tmpa_str\l_@@_content_AF_source_tl + \str_replace_all:Nnn\l_@@_tmpa_str{&}{&} + \str_replace_all:Nnn\l_@@_tmpa_str{<}{<} + \tl_set:Nn \l_@@_mathml_write_before_tl + { + <div> + \iow_newline: + <h2>\c_backslash_str mml\c_space_tl \int_use:N \g_@@_math_total_int </h2> + \iow_newline: + <p>\l_@@_tmpa_str</p> + \iow_newline: + <p>\l_@@_content_hash_tl </p> + \iow_newline: + } + } +% \end{macrocode} +% \end{plugdecl} +% +% With luatex we automatically generate mathml with \pkg{luamml} if the package +% can be loaded and \pkg{unicode-math} is detected. +% We start the process in the begindocument/end hook +% so that the reading from a previous compilation can happen before! % +% For other engines, for future name changes +% and in case luamml is not loaded we provide +% some commands +% \begin{macrocode} +\cs_new_protected:Npn\@@_provide_luamml_commands: + { + \providecommand\luamml_flag_structelem:{} + \cs_if_free:NT \luamml_structelem: + { + \cs_set_eq:NN\luamml_structelem:\luamml_flag_structelem: + } + \providecommand\luamml_flag_process:{} + \cs_if_free:NT \luamml_process: + { + \cs_set_eq:NN\luamml_process:\luamml_flag_process: + } + \providecommand\luamml_flag_ignore:{} + \cs_if_free:NT \luamml_ignore: + { + \cs_set_eq:NN\luamml_ignore:\luamml_flag_ignore: + } + } +% \end{macrocode} +% \begin{macrocode} +\sys_if_engine_luatex:TF + { +% \end{macrocode} +% Temporary (!) fixes for endarray +% \begin{macrocode} + \cs_new_protected:Npn \@@_correct_luamml_array_patches: + { + \AddToHook{package/array/after} + { + \cs_set:Npn \endarray + { + \tbl_crcr:n{endarray} + \__luamml_array_save_array: + \egroup + \UseTaggingSocket{tbl/finalize} + \tbl_restore_outer_cell_data: + \egroup + \mode_if_math:T { \__luamml_array_finalize_array: } + \@arrayright + \gdef \@preamble {} + } + \cs_set:Npn \@classz + { + \@classx + \@tempcnta \count@ + \prepnext@tok + \@addtopreamble { + \ifcase \@chnum + \hfil + \hskip 1sp + \d@llarbegin + \cs_if_eq:NNTF \d@llarbegin \begingroup { + \insert@column + \d@llarend + } { + \__luamml_array_init_col: + \insert@column + \luamml_flag_save:nn {} {mtd} + \d@llarend + \__luamml_array_finalize_col:w 0~ + } + \do@row@strut + \hfil + \or + \hskip 1sp + \d@llarbegin + \cs_if_eq:NNTF \d@llarbegin \begingroup { + \insert@column + \d@llarend + } { + \__luamml_array_init_col: + \insert@column + \luamml_flag_save:nn {} {mtd} + \d@llarend + \__luamml_array_finalize_col:w 1~ + } + \do@row@strut + \hfil + \or + \hfil + \hskip 1sp + \d@llarbegin + \cs_if_eq:NNTF \d@llarbegin \begingroup { + \insert@column + \d@llarend + } { + \__luamml_array_init_col: + \insert@column + \luamml_flag_save:nn {} {mtd} + \d@llarend + \__luamml_array_finalize_col:w 2~ + } + \do@row@strut + \or + \setbox \ar@mcellbox \vbox \@startpbox { \@nextchar } + \insert@pcolumn + \@endpbox + \ar@align@mcell + \do@row@strut + \or + \vtop \@startpbox { \@nextchar } + \insert@pcolumn + \@endpbox + \do@row@strut + \or + \vbox \@startpbox { \@nextchar } + \insert@pcolumn + \@endpbox + \do@row@strut + \fi + } + \prepnext@tok + } + } + } +% \end{macrocode} +% +% \begin{macrocode} + \AddToHook{begindocument/before} + { + \str_case:on \g_@@_luamml_load_tl + { + { 1 } { + \RequirePackage { luamml } + \@@_correct_luamml_array_patches: + \AddToHook{begindocument/end} + { + \@@_luamml_activate_write: + } + } + {-1 } { + \AddToHook{begindocument/end} + { + \msg_note:nnnn { tag } + { luamml-status }{ disabled }{ not~create } + } + } + { 0 } + { + \@ifpackageloaded { unicode-math } + { + \RequirePackage { luamml } + \@@_correct_luamml_array_patches: + \AddToHook{begindocument/end} + { + \@@_luamml_activate_write: + } + } + { \msg_warning:nn { tag }{ unicode-math-missing } } + } + } + \@@_provide_luamml_commands: + } + } + { + \@@_provide_luamml_commands: + } +\msg_new:nnn { tag }{ luamml-status } + { + luamml~has~been~#1~and~will~#2~an~MathML~file. + } + +\msg_new:nnn { tag }{ unicode-math-missing } + { + The~package~unicode-math~is~missing\\ + luamml~will~not~create~an~MathML~file.\\ + To~avoid~this~warning~load~unicode-math~\\ + or~disable~luamml~with~\\ + \tl_to_str:n{\tagpdfsetup{math/mathml/luamml/load=false}}\\ + or~force~luamml~with~\\ + \tl_to_str:n{\tagpdfsetup{math/mathml/luamml/load=true}} + } +\cs_new_protected:Npn \@@_luamml_activate_write: + { + \bool_if:NT \g_@@_luamml_write_bool + { +% \end{macrocode} +% to avoid that nothing is written in the first run, we must activate the sockets: +% \begin{macrocode} + \bool_gset_true:N\g__tag_math_mathml_AF_bool + \AssignSocketPlug{tagsupport/math/struct/begin}{mathml-AF} + \AssignSocketPlug{tagsupport/math/struct/end}{mathml-AF} + \AssignSocketPlug{tagsupport/math/substruct/begin}{single} + \AssignSocketPlug{tagsupport/math/substruct/end}{single} + \int_set:Nn \l__luamml_pretty_int { 7 } + \RegisterFamilyMapping\symsymbols{oms} + \RegisterFamilyMapping\symletters{oml} + \AssignSocketPlug{tagsupport/math/mathml/write/prepare}{On} + \iow_new:N \g_@@_luamml_iow + \iow_open:Nn \g_@@_luamml_iow {\c_sys_jobname_str-luamml-mathml.html} + \iow_now:Ne \g_@@_luamml_iow { \c_@@_mathml_write_init_tl } + \cs_new:Npn \@@_luamml_output_hook:n ##1 + { + \tl_if_empty:NF \l_@@_mathml_write_before_tl + { + \iow_now:Ne \g_@@_luamml_iow + { + \l_@@_mathml_write_before_tl + ##1 + \c_@@_mathml_write_after_tl + } + } + } + \__luamml_register_output_hook:N \@@_luamml_output_hook:n +% \end{macrocode} +% At the end of the document we must finish and close the file: +% \begin{macrocode} + \AddToHook{enddocument/afterlastpage} + { + \iow_now:Ne \g_@@_luamml_iow + { \c_@@_mathml_write_final_tl } + \iow_close:N \g_@@_luamml_iow + } + \msg_note:nnnn { tag } + { luamml-status }{ enabled }{ create } + } + } +% \end{macrocode} +% And now keys to activate/deactivate luamml feature +% \begin{variable}{\g_@@_luamml_load_tl} +% This variable will be used to suppress the loading of luamml +% altogether. +% \begin{macrocode} +\tl_new:N \g_@@_luamml_load_tl +\tl_gset:Nn \g_@@_luamml_load_tl {0} +% \end{macrocode} +% \end{variable} +% \begin{variable}{\g_@@_luamml_write_bool} +% This variable decides if luamml writes a mathml +% altogether. +% \begin{macrocode} +\bool_new:N \g_@@_luamml_write_bool +\bool_gset_true:N \g_@@_luamml_write_bool +% \end{macrocode} +% \end{variable} +% +% \begin{macrocode} +\msg_new:nnn { tag }{ PDF-2.0-recommended } + { + The~key~#1~will~not~work~properly~with~PDF~#2.\\ + Switching~to~PDF~2.0~is~recommended. + } +\keys_define:nn { __tag / setup } + { +% \end{macrocode} +% At first a key to suppress the loading altogether +% \begin{macrocode} + math/mathml/luamml/load .choice: , + math/mathml/luamml/load/true .code:n = {\tl_gset:Nn \g_@@_luamml_load_tl{1}}, + math/mathml/luamml/load/false .code:n = {\tl_gset:Nn \g_@@_luamml_load_tl{-1}}, + math/mathml/luamml/load .default:n = true, + math/mathml/luamml/load .usage:n=preamble, +% \end{macrocode} +% A key to activate math structure elements. It shouldn't +% be issued in the preamble as luamml is not yet loaded. +% \begin{macrocode} + math/mathml/structelem .code:n = + { + \pdf_version_compare:NnT < {2.0} + { + \msg_warning:nnne { tag }{ PDF-2.0-recommended } + { math/mathml/structelem }{ \pdf_version: } + } + \AddToHook{begindocument/end}{\luamml_structelem:} + }, +% \end{macrocode} +% and a key to call the ignore flag. This should only be used locally. +% \begin{macrocode} + math/mathml/ignore .code:n = {\luamml_ignore:}, +% \end{macrocode} +% \begin{macrocode} + math/mathml/luamml/write .choice:, + math/mathml/luamml/write/true .code:n = + { + \tl_gset:Nn \g_@@_luamml_load_tl{1} + \bool_gset_true:N \g_@@_luamml_write_bool + }, + math/mathml/luamml/write/false .code:n = + { + \bool_gset_false:N \g_@@_luamml_write_bool + }, + math/mathml/luamml/write .default:n = true, + math/mathml/luamml/write .usage:n=preamble, +% \end{macrocode} +% alias keys for compatibility +% \begin{macrocode} + math/mathml/luamml .bool_gset:N = \g_@@_luamml_write_bool, + math/mathml/luamml .usage:n=preamble + } +% \end{macrocode} % \begin{socketdecl}{tagsupport/math/mathml/write} % This writes a html-dummy with the hash and the math content. % This should be optional, so it uses a socket that can be disabled -% +% % \begin{macrocode} \socket_new:nn {tagsupport/math/mathml/write}{0} % \end{macrocode} % \end{socketdecl} -% +% % \begin{plugdecl}{On} % \begin{macrocode} \socket_new_plug:nnn{tagsupport/math/mathml/write}{On} { - \str_set:NV\l_@@_tmpa_str\l_@@_content_AF_source_tl - \str_replace_all:Nnn\l_@@_tmpa_str{&}{&} - \str_replace_all:Nnn\l_@@_tmpa_str{<}{<} - \iow_now:Ne \g_@@_writedummy_iow + \iow_now:Ne \g_@@_writedummy_iow { - \iow_newline: - <div> - \iow_newline: - <h2>\c_backslash_str mml\c_space_tl \int_use:N \g_@@_math_total_int </h2> - \iow_newline: - <p>\l_@@_tmpa_str</p> - \iow_newline: - <p>\l_@@_content_hash_tl </p> - \iow_newline: + \l_@@_mathml_write_before_tl <math></math> - \iow_newline: - </div> - \iow_newline: + \c_@@_mathml_write_after_tl } } % \end{macrocode} @@ -727,32 +1251,32 @@ \keys_define:nn { __tag / setup } { - math/mathml/write-dummy .code:n = + math/mathml/write-dummy .code:n = { \bool_gset_true:N \g__tag_math_mathml_AF_bool - \tl_if_exist:NF\g_@@_writedummy_iow + \tl_if_exist:NF\g_@@_writedummy_iow { \iow_new:N \g_@@_writedummy_iow - \iow_open:Nn \g_@@_writedummy_iow - { + \iow_open:Nn \g_@@_writedummy_iow + { \c_sys_jobname_str-mathml-dummy.html } \iow_now:Ne \g_@@_writedummy_iow { - <!DOCTYPE~html> - \iow_newline: - <html> + \c_@@_mathml_write_init_tl } + \AssignSocketPlug {tagsupport/math/mathml/write/prepare}{On} \AssignSocketPlug {tagsupport/math/mathml/write}{On} \AddToHook{enddocument/afterlastpage} { - \iow_now:Nn \g_@@_writedummy_iow {</html>} + \iow_now:Ne \g_@@_writedummy_iow + { \c_@@_mathml_write_final_tl } \iow_close:N \g_@@_writedummy_iow } - } + } }, - math/mathml/write-dummy .usage:n=preamble - } + math/mathml/write-dummy .usage:n=preamble + } % \end{macrocode} % % \begin{macro}{\@@_AF_process_mathml_files:} @@ -763,9 +1287,9 @@ \hbox_set:Nn \l_@@_tmpa_box { \pdfdict_put:nnn { l_pdffile/Filespec }{AFRelationship} { /Supplement } - \pdfdict_put:nne - { l_pdffile }{Subtype} - { \pdf_name_from_unicode_e:n{application/mathml+xml} } + \pdfdict_put:nne + { l_pdffile }{Subtype} + { \pdf_name_from_unicode_e:n{application/mathml+xml} } \char_set_catcode_other:N \# \cs_set_eq:NN\mml \@@_AF_html_reader:w \clist_map_inline:Nn \l__tag_math_mathml_files_clist @@ -779,13 +1303,13 @@ { \typeout{Info:~mathml~file~##1~does~not~exist}%info message } - } + } } \bool_if:NT\g__tag_math_mathml_AF_bool { \typeout{Info:~Activating~mathml~support} - \AssignSocketPlug{tagsupport/math/struct/begin}{test-mathml} - \AssignSocketPlug{tagsupport/math/struct/end}{test-mathml} + \AssignSocketPlug{tagsupport/math/struct/begin}{mathml-AF} + \AssignSocketPlug{tagsupport/math/struct/end}{mathml-AF} % \end{macrocode} % mathml handling doesn't like subparts, so we disable them for now: % \begin{macrocode} @@ -795,29 +1319,29 @@ { \iow_term:n{MathML~statistic} \iow_term:n{================} - \iow_term:e{==>~\int_use:N\g_@@_mathml_total_int\c_space_tl + \iow_term:e{==>~\int_use:N\g_@@_mathml_total_int\c_space_tl MathML~fragments~read} - \iow_term:e{==>~\int_use:N\g_@@_mathml_int\c_space_tl + \iow_term:e{==>~\int_use:N\g_@@_mathml_int\c_space_tl different~MathML~fragments} - \iow_term:e{==>~\int_use:N\g_@@_math_total_int\c_space_tl + \iow_term:e{==>~\int_use:N\g_@@_math_total_int\c_space_tl math~fragments~found} - \iow_term:e{==>~\int_use:N\g_@@_mathml_AF_found_int\c_space_tl + \iow_term:e{==>~\int_use:N\g_@@_mathml_AF_found_int\c_space_tl fitting~MathML~AF~found} - \iow_term:e{==>~\int_use:N\g_@@_mathml_AF_attached_int\c_space_tl + \iow_term:e{==>~\int_use:N\g_@@_mathml_AF_attached_int\c_space_tl MathML~AF~attached} } - } + } } -\AddToHook{begindocument}{\@@_AF_process_mathml_files:} +\AddToHook{begindocument}{\@@_AF_process_mathml_files:} % \end{macrocode} % \end{macro} -% +% % \subsection{Mathstyle detection} % In some cases we need to detect the mathstyle used in a \cs{mathchoice} -% command and to disable/enable tagging in the unused branches. +% command and to disable/enable tagging in the unused branches. % This is currently only used in the amstext command \cs{text} % but is perhaps also needed in other cases, so we create a general command. -% +% %\begin{macro}{\l_@@_mathstyle_int,\g_@@_mathchoice_int,mathstyle} % \begin{macrocode} \int_new:N \l_@@_mathstyle_int @@ -828,43 +1352,64 @@ % For now internal, but perhaps will need a public version. % The command should be used in every branch of a \cs{mathchoice} % (with the correct mathstyle number) and with an unique label (which should -% be the same in every branch). -% \cs{g_@@_mathchoice_int} can be e.g. increased before the mathchoice and +% be the same in every branch). +% \cs{g_@@_mathchoice_int} can be, e.g., increased before the mathchoice and % then used. % \begin{macro}{\@@_tag_if_mathstyle:nn} % \begin{macrocode} -\cs_new_protected:Npn \@@_tag_if_mathstyle:nn #1 #2 +\cs_new_protected:Npn \@@_tag_if_mathstyle:nn #1 #2 %#1 refers to label %#2 is a number for the mathstyle (typically 0,2,4,6) { \int_set:Nn \l_@@_mathstyle_int {#2} \property_record:nn {#1} { mathstyle } \int_compare:nNnTF { \property_ref:nn {#1}{ mathstyle} } = { #2 } - { \tag_start: }{ \tag_stop: } + { \tag_resume:n{\mathchoice} }{ \tag_suspend:n{\mathchoice} } } -\cs_generate_variant:Nn \@@_tag_if_mathstyle:nn {en} +\cs_generate_variant:Nn \@@_tag_if_mathstyle:nn {en} % \end{macrocode} % \end{macro} -% +% % \subsection{Tagging options} % \begin{macrocode} \keys_define:nn { __tag / setup } { math/mathml/sources .clist_set:N = \l__tag_math_mathml_files_clist, - math/alt/use .bool_set:N = \l__tag_math_alt_bool, + math/alt/use .bool_set:N = \l__tag_math_alt_bool, viewer/pane/mathml .bool_set:N = \l__tag_math_mathml_pane_bool, viewer/pane/mathml .initial:n = true, - viewer/pane/mathsource .bool_set:N = \l__tag_math_texsource_pane_bool, + viewer/pane/mathsource .bool_set:N = \l__tag_math_texsource_pane_bool, math/mathml/AF .bool_set:N = \l__tag_math_mathml_AF_bool, math/mathml/AF .initial:n = true, math/tex/AF .bool_set:N = \l__tag_math_texsource_AF_bool, math/tex/AF .initial:n = true - } + } +% \end{macrocode} +% alt is required for pdf/UA-1. +% TODO: l3pdfmeta should support this test. +% \begin{macrocode} +\AddToHook{begindocument/end} + { + \str_if_eq:eeT + {1} + { + \exp_last_unbraced:Ne\use_i:nn + {\GetDocumentProperties{document/pdfstandard-UA}} + \c_empty_tl\c_empty_tl + } + { + \bool_if:NF \l__tag_math_alt_bool + { + \typeout{PDF/UA-1~detected.~Enabling~alt~text~on~Formula} + } + \bool_set_true:N\l__tag_math_alt_bool + } + } % \end{macrocode} % % \subsection{Sockets} % \subsubsection{Main inline math sockets} -% +% % \begin{socketdecl} % { % tagsupport/math/inline/begin, @@ -873,11 +1418,11 @@ % tagsupport/math/inline/formula/end, % } % The first two sockets are meant to embed inline -% math into the surrounding (so to close/reopen e.g. MC-chunks). -% The other two implement the actual formula structure. +% math into the surrounding (so to close/reopen, e.g., MC-chunks). +% The other two implement the actual formula structure. % The formula sockets are despite their naming not symmetric: -% the begin socket is issued after the math has started, while -% the end socket is after the math! +% the begin socket is issued after the math has started, while +% the end socket is after the math! % \begin{macrocode} \socket_new:nn {tagsupport/math/inline/begin}{0} \socket_new:nn {tagsupport/math/inline/end}{0} @@ -885,8 +1430,8 @@ \socket_new:nn {tagsupport/math/inline/formula/end}{0} % \end{macrocode} %\end{socketdecl} -% -% +% +% % \begin{plugdecl}{MC} % \begin{macrocode} \socket_new_plug:nnn @@ -896,39 +1441,42 @@ \socket_new_plug:nnn {tagsupport/math/inline/end} {MC} - {\tag_mc_begin_pop:n{}} + {\tag_mc_begin_pop:n{}} % \end{macrocode} % \end{plugdecl} -% -% We probably will want to test different tagging receipes. +% +% We probably will want to test different tagging recipes. % \begin{plugdecl}{default} % \begin{macrocode} \socket_new_plug:nnn {tagsupport/math/inline/formula/begin} {default} - { - \socket_use:n{tagsupport/math/content} - \socket_use:n{tagsupport/math/struct/begin} +% \end{macrocode} +% \changes{v0.6g}{2024-10-02}{disable paratagging, issue \#711} +% \begin{macrocode} + { \tagpdfparaOff + \tag_socket_use:n{math/content} + \tag_socket_use:n{math/struct/begin} % \end{macrocode} % TODO: does inline math need subformula handling? % \begin{macrocode} % inner formula if multiple parts (not really implemented yet) - \socket_use:n{tagsupport/math/substruct/begin} + \tag_socket_use:n{math/substruct/begin} #1 - \socket_use:n{tagsupport/math/end} + \tag_socket_use:n{math/end} } \socket_new_plug:nnn {tagsupport/math/inline/formula/end} {default} - { + { \socket_use:n{tagsupport/math/substruct/end} \socket_use:n{tagsupport/math/struct/end} - } + } % \end{macrocode} % \end{plugdecl} -% +% % \subsubsection{Main display math sockets} -% +% % \begin{socketdecl} % { % tagsupport/math/display/begin, @@ -937,12 +1485,15 @@ % tagsupport/math/display/formula/end, % } % The first two sockets are meant to embed display -% math into the surrounding (so to close/reopen e.g. MC-chunks and +% math into the surrounding (so to close/reopen, e.g., MC-chunks and % P-structure). -% The other two implement the actual formula structure. +% The other two implement the actual formula structure. % The formula sockets are despite their naming not symmetric: -% the begin socket is issued after the math has started, while -% the end socket is after the math! +% the begin socket is issued after the math has started, while +% the end socket is after the math! +% The socket |tagsupport/math/display/formula/begin| should similar to +% the inline version not be used as tagging socket so that the argument, the math, +% is not lost. % \begin{macrocode} \socket_new:nn {tagsupport/math/display/begin}{0} \socket_new:nn {tagsupport/math/display/end}{0} @@ -961,7 +1512,7 @@ {tagsupport/math/display/end} {default} { - } + } % \end{macrocode} % \end{plugdecl} @@ -971,25 +1522,25 @@ \socket_new_plug:nnn {tagsupport/math/display/formula/begin} {default} - { - \socket_use:n{tagsupport/math/content} - \socket_use:n{tagsupport/math/struct/begin} - \socket_use:n{tagsupport/math/substruct/begin} - #1 - \socket_use:n{tagsupport/math/end} + { + \tag_socket_use:n{math/content} + \tag_socket_use:n{math/struct/begin} + \tag_socket_use:n{math/substruct/begin} + #1 + \tag_socket_use:n{math/end} } \socket_new_plug:nnn {tagsupport/math/display/formula/end} {default} - { + { \socket_use:n{tagsupport/math/substruct/end} \socket_use:n{tagsupport/math/struct/end} - } + } % \end{macrocode} % \end{plugdecl} % % \subsubsection{Internal sockets} -% +% % \begin{variable}{\l_@@_content_template_tl} % The default text used as alt or actual text. % \begin{macrocode} @@ -1003,7 +1554,7 @@ \c_space_tl \exp_not:N\end{\g_@@_grabbed_env_tl} \c_space_tl LaTeX~ formula~ ends~ - } + } % \end{macrocode} % \end{variable} @@ -1013,7 +1564,7 @@ \tl_new:N\l_@@_texsource_template_tl \tl_const:Nn\c_@@_inline_env_tl {math} \tl_set:Nn \l_@@_texsource_template_tl - { + { \tl_if_eq:NNTF\g_@@_grabbed_env_tl\c_@@_inline_env_tl { $ @@ -1024,29 +1575,29 @@ \exp_not:N\begin{\g_@@_grabbed_env_tl} \exp_not:V\g_@@_grabbed_math_tl \exp_not:N\end{\g_@@_grabbed_env_tl} - } - } + } + } % \end{macrocode} % \end{variable} -% +% % \begin{socketdecl}{tagsupport/math/content} -% The math content is stored in associated files and used for +% The math content is stored in associated files and used for % actual and alternative text. As the exact text is still % unclear we use a socket to be able to test variants. % The socket should set all four tl vars above, if needed -% to identical values. It can use the two variables +% to identical values. It can use the two variables % \cs{g_@@_grabbed_env_tl} and \cs{g_@@_grabbed_math_tl} % \begin{macrocode} \socket_new:nn {tagsupport/math/content}{0} % \end{macrocode} % \end{socketdecl} -% +% % Some default sockets to set the contents. -% TODO: think about naming convention. +% TODO: think about naming convention. % TODO: think how this should organized so that one % has options to change from the outside and so that -% there are less repetitions. +% there are less repetitions. % \begin{plugdecl}{actual+source} % \begin{macrocode} \socket_new_plug:nnn @@ -1056,17 +1607,17 @@ \tl_set:Ne\l_@@_content_actual_tl { \l_@@_content_template_tl - } - \tl_set:Ne \l_@@_content_AF_source_tl + } + \tl_set:Ne \l_@@_content_AF_source_tl { \l_@@_texsource_template_tl - } + } \tl_set:Nn \l_@@_content_AF_mathml_tl {} \tl_set:Nn \l_@@_content_alt_tl {} } % \end{macrocode} -% \end{plugdecl} -% +% \end{plugdecl} +% % \begin{plugdecl}{alt+source} % \begin{macrocode} \socket_new_plug:nnn @@ -1076,26 +1627,26 @@ \tl_set:Ne\l_@@_content_alt_tl { \l_@@_content_template_tl - } - \tl_set:Ne \l_@@_content_AF_source_tl + } + \tl_set:Ne \l_@@_content_AF_source_tl { \l_@@_texsource_template_tl - } + } \tl_set:Nn \l_@@_content_AF_mathml_tl {} \tl_set:Nn \l_@@_content_actual_tl {} } % \end{macrocode} % \end{plugdecl} % \begin{macrocode} -\socket_assign_plug:nn {tagsupport/math/content}{alt+source} +\socket_assign_plug:nn {tagsupport/math/content}{alt+source} % \end{macrocode} % % \begin{socketdecl}{tagsupport/math/struct/begin, % tagsupport/math/struct/end} -% For the main structure we use a socket too. -% This allow e.g. to create a special one for luamml -% which setups additional objects. -% The begin socket can use the two variables +% For the main structure we use a socket too. +% This allows, e.g., to create a special one for luamml +% which setups additional objects. +% The begin socket can use the two variables % \cs{g_@@_grabbed_env_tl} and \cs{g_@@_grabbed_math_tl} % \begin{macrocode} \socket_new:nn {tagsupport/math/struct/begin}{0} @@ -1110,12 +1661,22 @@ {tagsupport/math/struct/begin} {default} { - \bool_if:NTF\l__tag_math_texsource_AF_bool + \bool_if:NTF\l__tag_math_texsource_AF_bool { \tl_set_eq:NN \l_@@_content_AF_source_tmpa_tl \l_@@_content_AF_source_tl } { \tl_clear:N \l_@@_content_AF_source_tmpa_tl } + \tl_if_eq:NnTF\g_@@_grabbed_env_tl {math} + { + \tl_set:Nn\l_@@_attribute_class_tl{inline} + } + { + \tl_set:Nn\l_@@_attribute_class_tl{display} + } + \bool_if:NF\l__tag_math_alt_bool + { \tl_set:Nn \l_@@_content_alt_tl{} } \tag_struct_begin:n { tag=Formula, + attribute-class=\l_@@_attribute_class_tl, texsource = \l_@@_content_AF_source_tmpa_tl, title-o = \g_@@_grabbed_env_tl, actualtext = \l_@@_content_actual_tl, @@ -1126,19 +1687,18 @@ {tagsupport/math/struct/end} {default} { \tag_struct_end: } - -\socket_assign_plug:nn {tagsupport/math/struct/begin}{default} -\socket_assign_plug:nn {tagsupport/math/struct/end}{default} -% \end{macrocode} -% \end{plugdecl} -% -% \begin{plugdecl}{test-mathml} -% This (test-)socket tries to add a mathml-AF to formula. -% It is activated if a mathml.html has been found and loaded. -% Additionally it also sets an attribute -% (this can perhaps be done by default anyway.) -% As it disturbs the reading of the AF it currently deactivates the /Alt key, -% unless it has been reenabled with |math/alt/use=true| + +\socket_assign_plug:nn {tagsupport/math/struct/begin}{default} +\socket_assign_plug:nn {tagsupport/math/struct/end}{default} +% \end{macrocode} +% \end{plugdecl} +% +% \begin{plugdecl}{mathml-AF} +% This socket tries to add a mathml-AF to formula. +% It is activated if a mathml.html has been found and loaded. +% As it disturbs the reading of the AF +% it currently deactivates the /Alt key, +% unless it has been reenabled with |math/alt/use=true| % \begin{macrocode} \cs_generate_variant:Nn \str_mdfive_hash:n {o} \tl_new:N\l_@@_content_hash_tl @@ -1151,48 +1711,52 @@ % \begin{macrocode} \socket_new_plug:nnn {tagsupport/math/struct/begin} - {test-mathml} - { - \int_gincr:N\g_@@_math_total_int - \tl_set:Ne\l_@@_content_hash_tl - {\str_mdfive_hash:o { \l_@@_content_AF_source_tl }} - \tl_set_eq:NN\l_@@_grabbed_math_tl\g_@@_grabbed_math_tl + {mathml-AF} + { + \int_gincr:N\g_@@_math_total_int + \tl_set:Ne\l_@@_content_hash_tl + {\str_mdfive_hash:o { \l_@@_content_AF_source_tl }} + \tl_set_eq:NN\l_@@_grabbed_math_tl\g_@@_grabbed_math_tl \tl_if_eq:NnTF\g_@@_grabbed_env_tl {math} { - \tl_set:Nn\l_@@_attribute_class_tl{inline} + \tl_set:Nn\l_@@_attribute_class_tl{inline} } { \tl_set:Nn\l_@@_attribute_class_tl{display} } \bool_if:NF\l__tag_math_alt_bool - { \tl_set:Nn \l_@@_content_alt_tl{} } + { \tl_set:Nn \l_@@_content_alt_tl{} } % \end{macrocode} % debugging option. TODO: hide in debug key. % \begin{macrocode} \tl_if_exist:cTF { g_@@_mathml_ \l_@@_content_hash_tl _tl } - { - \int_gincr:N\g_@@_mathml_AF_found_int - \bool_if:NTF \l__tag_math_mathml_AF_bool - { - \int_gincr:N\g_@@_mathml_AF_attached_int - \typeout {Inserting~mathml~with~Hash~\l_@@_content_hash_tl} - } - { - \typeout {Ignoring~mathml~with~Hash~\l_@@_content_hash_tl} - } - } - { - \typeout{WARNING:~mathml~missing~for~hash~\l_@@_content_hash_tl} - } - \socket_use:n {tagsupport/math/mathml/write} % write hash if request - \bool_if:NTF\l__tag_math_texsource_AF_bool + { + \int_gincr:N\g_@@_mathml_AF_found_int + \bool_if:NTF \l__tag_math_mathml_AF_bool + { + \int_gincr:N\g_@@_mathml_AF_attached_int + \typeout {Inserting~mathml~with~Hash~\l_@@_content_hash_tl} + } + { + \typeout {Ignoring~mathml~with~Hash~\l_@@_content_hash_tl} + } + } + { + \bool_if:NT \l__tag_math_mathml_AF_bool + { + \typeout {WARNING:~mathml~missing~for~hash~\l_@@_content_hash_tl} + } + } + \socket_use:n {tagsupport/math/mathml/write/prepare} + \socket_use:n {tagsupport/math/mathml/write} % write hash if request + \bool_if:NTF\l__tag_math_texsource_AF_bool { \tl_set_eq:NN \l_@@_content_AF_source_tmpa_tl \l_@@_content_AF_source_tl } - { \tl_clear:N \l_@@_content_AF_source_tmpa_tl } + { \tl_clear:N \l_@@_content_AF_source_tmpa_tl } \tag_struct_begin:n { tag=Formula, attribute-class=\l_@@_attribute_class_tl, % - AFref = + AFref = \bool_if:NT\l__tag_math_mathml_AF_bool { \cs_if_exist_use:c {g_@@_mathml_ \l_@@_content_hash_tl _tl} @@ -1207,13 +1771,13 @@ % \begin{macrocode} \socket_new_plug:nnn {tagsupport/math/struct/end} - {test-mathml} + {mathml-AF} { \tag_struct_end: - } + } % \end{macrocode} % \end{plugdecl} -% +% % \begin{socketdecl}{tagsupport/math/substruct/begin, % tagsupport/math/substruct/end} % This holds the code to handle subparts of the formula. @@ -1222,7 +1786,7 @@ \socket_new:nn {tagsupport/math/substruct/end}{0} % \end{macrocode} % \end{socketdecl} -% +% % \begin{plugdecl}{default} % \begin{macrocode} \socket_new_plug:nnn @@ -1232,16 +1796,16 @@ \socket_new_plug:nnn {tagsupport/math/substruct/end} {default} - { + { \tagmcend \if@subformulas \tagstructend \fi - } -\socket_assign_plug:nn {tagsupport/math/substruct/begin}{default} -\socket_assign_plug:nn {tagsupport/math/substruct/end}{default} -% \end{macrocode} -% \end{plugdecl} + } +\socket_assign_plug:nn {tagsupport/math/substruct/begin}{default} +\socket_assign_plug:nn {tagsupport/math/substruct/end}{default} +% \end{macrocode} +% \end{plugdecl} % \begin{plugdecl}{single} % We need an option to disable subparts as it is unclear @@ -1253,7 +1817,7 @@ { \typeout{====>subpart~splitting~deactivated} \typeout{====>grabbed~math=\meaning\g_@@_grabbed_math_tl} - \tag_mc_begin:n{} + \tag_mc_begin:n{} } \socket_new_plug:nnn {tagsupport/math/substruct/end} @@ -1261,21 +1825,21 @@ { \tag_mc_end:} % \end{macrocode} % \end{plugdecl} -% +% % \begin{socketdecl}{tagsupport/math/end} % A socket used at the end of the math (before the closing dollar(s)) -% which can e.g. set a flag for luamml. +% which can, e.g., set a flag for luamml. % \begin{macrocode} \socket_new:nn {tagsupport/math/end}{0} % \end{macrocode} % \end{socketdecl} - -% + +% % \begin{macro}{\__tag_math_disable:} % Similar to the table code we collect the plugs that should be % assigned to do nothing if we don't want tagging % \begin{macrocode} -\cs_new_protected:Npn \__tag_math_disable: +\cs_new_protected:Npn \__tag_math_disable: { \socket_assign_plug:nn {tagsupport/math/inline/begin}{noop} \socket_assign_plug:nn {tagsupport/math/inline/end}{noop} @@ -1284,16 +1848,16 @@ \socket_assign_plug:nn {tagsupport/math/display/begin}{noop} \socket_assign_plug:nn {tagsupport/math/display/end}{noop} \socket_assign_plug:nn {tagsupport/math/display/formula/begin}{identity} - \socket_assign_plug:nn {tagsupport/math/display/formula/end}{noop} - } + \socket_assign_plug:nn {tagsupport/math/display/formula/end}{noop} + } % \end{macrocode} % \end{macro} -% +% % \begin{macro}{\__tag_math_enable:} % Similar to the table code we collect the default plugs that should be % assigned if we want tagging % \begin{macrocode} -\cs_new_protected:Npn \__tag_math_enable: +\cs_new_protected:Npn \__tag_math_enable: { \socket_assign_plug:nn {tagsupport/math/inline/begin}{MC} \socket_assign_plug:nn {tagsupport/math/inline/end}{MC} @@ -1303,7 +1867,7 @@ \socket_assign_plug:nn {tagsupport/math/display/end}{default} \socket_assign_plug:nn {tagsupport/math/display/formula/begin}{default} \socket_assign_plug:nn {tagsupport/math/display/formula/end}{default} - } + } % \end{macrocode} % \end{macro} % At begin document we can activate: @@ -1349,49 +1913,65 @@ % \subsection{Content grabbing} % % \begin{macro}{\@@_grab_dollar:w} -% Grab up to a single |$|, for inline math mode, suppressing -% any processing if the token is \tn{m@th} found in the content. -% -% \fmi{what's that test doing?} -% -% \car{It is some kind of fix, to avoid the remote -% possibility that the math is empty, making the code -% produce an unwanted \texttt{\$\$}.} -% -%\car{cf.~the code for this in \cs{@ensuredmath}} -% -%\car{It is harmless but unnecessary in the dollardollar grabbing below.} -% +% \begin{macro}{\@@_grab_dollar:n} +% \changes{v0.6c}{2024-08-22}{Correct handling of empty math segments} +% Top-level function to handle grabbing of inline math mode delimited by +% |$| tokens. We provide two different ways to do that: a token-by-token +% one that can be used everywhere, and a fast delimited one that does not +% work anywhere that the end |$| token may be hidden, most obviously in +% tabulars. The function here is therefore set up as a variable starting +% point. % \begin{macrocode} -\cs_new_protected:Npn \@@_grab_dollar:w % $ - #1 $ +\cs_new_protected:Npn \@@_grab_dollar:w { \@@_grab_dollar_delim:w } +% \end{macrocode} +% After grabbing inline math material, there is again common processing +% independent of mechanism of collection. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_dollar:n #1 { % \end{macrocode} -% \fmi{what's that test doing?} +% We need to do processing first as this picks up \enquote{fake} math mode: +% that information is needed below. % \begin{macrocode} - \tl_if_blank:nF {#1} - { - \@@_process:nn { math } {#1} % $ + \@@_process:nn { math } {#1} % \end{macrocode} % We do not want math tagging in fakemath or when measuring, % We also do not want math tagging if tagging has been suspended. % \begin{macrocode} - \bool_lazy_or:nnTF - {\legacy_if_p:n { measuring@ }} - { \l_@@_fakemath_bool } - { #1 $ } + \bool_lazy_any:nTF + { + {\legacy_if_p:n { measuring@ }} + { \l_@@_fakemath_bool } + { \tl_if_blank_p:n {#1} } + } + { + #1 $ % $ + } { - \tag_socket_use:n {math/inline/begin} %end P-MC - \tag_socket_use:nn {math/inline/formula/begin}{#1} - $ + \tag_socket_use:n {math/inline/begin} %end P-MC +% \end{macrocode} +% We do no use a tagging socket here, so that the argument (the +% math) is not lost, tagging-project issue 661. +% \begin{macrocode} + \socket_use:nn {tagsupport/math/inline/formula/begin}{#1} + $ % $ \tag_socket_use:n {math/inline/formula/end} \tag_socket_use:n {math/inline/end} % restart P-MC - } - } + } } % \end{macrocode} % \end{macro} -% +% \end{macro} +% +% \begin{macro}{\@@_grab_dollar_delim:w} +% Grab up to a single |$|, for inline math mode, suppressing +% any processing if the token is \tn{m@th} found in the content. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_dollar_delim:w #1 $ % $ + { \@@_grab_dollar:n {#1} } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@@_grab_dollardollar:w} % And for the classical \TeX{} display structure. % \begin{macrocode} @@ -1401,17 +1981,17 @@ \tl_if_blank:nF {#1} { \@@_process:nn { equation* } {#1} - \socket_use:n {tagsupport/math/display/begin} + \tag_socket_use:n {math/display/begin} \socket_use:nn{tagsupport/math/display/formula/begin}{#1} - $$ } + $$ } % \end{macrocode} -% +% % The end code is added through a \cs{aftergroup} so we % store it inside a command. % \begin{macrocode} -\cs_new_protected:Npn \@@_tag_dollardollar_display_end: +\cs_new_protected:Npn \@@_tag_dollardollar_display_end: { % \typeout{== tag dollarldollar display end} % \ShowTagging{struct-stack} @@ -1420,15 +2000,30 @@ % TODO why is that needed? where is para-tagging disabled? % \begin{macrocode} \tagpdfparaOn +% \end{macrocode} +% The \cs{postdisplaypenalty} was temporarily set to 10000 inside +% the display and the \cs{belowdisplayskip} and the +% \cs{belowdisplayshortskip} was negated, so whatever was inserted +% it should have been a negative skip. Whatever skip was added we +% pick it ups value up here, so that we can correct the spacing +% after the tagging code was inserted. +% \begin{macrocode} \l_@@_tmpa_skip \lastskip - \socket_use:n{tagsupport/math/display/formula/end} - \penalty \postdisplaypenalty + \tag_socket_use:n{math/display/formula/end} % \end{macrocode} -% This reinserts the below display skips. It must be doubled to -% get the right amount: +% Now we add a skip without indroducing a page break possibility, +% that should bring the current vertical position back to the point +% where \TeX{} would add the penalty and the \enquote{below skip}. +% \changes{v0.6f}{2024-09-30}{Correct logic for inserting below skips +% after displays (tagging/721)} % \begin{macrocode} - \skip_vertical:n { -\l_@@_tmpa_skip * 2 } -% + \nobreak + \skip_vertical:n { -\l__math_tmpa_skip } % remove the negative belowdisplayskip +% \end{macrocode} +% Then we finally add the real stuff: +% \begin{macrocode} + \penalty \postdisplaypenalty + \skip_vertical:n { -\l__math_tmpa_skip } % insert the correct skip \@doendpe % this has no \end{...} to take care of it } @@ -1463,6 +2058,164 @@ % \end{macrocode} % \end{macro} % +% \subsection{Token-by-token inline grabbing} +% +% Grabbing inline math token-by-token is more involved. The mechanism here +% is essentially a simplified version of that originally seen in +% \pkg{collcell} and refined in \pkg{siunitx}. We make use of the fact that +% in math mode spaces are ignored, so we have to deal with only \texttt{N}-type +% tokens and groups. Furthermore, there is no need to look inside groups, so +% the only special cases are a small selection of \texttt{N}-type tokens. +% +% \begin{variable}{\l_@@_grabbed_tl} +% For collection of the material piecewise. +% \begin{macrocode} +\tl_new:N \l_@@_grabbed_tl +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_@@_grab_env_int} +% Needed to count up the number of nested environments encountered. +% \begin{macrocode} +\int_new:N \l_@@_grab_env_int +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\@@_grab_dollar_loop:} +% \begin{macro}{\@@_grab_loop:} +% The lead-off here establishes a group: we need that as we will have to +% be careful in the way \tn{cr} is handled and ensure this is only +% manipulated whilst grabbing. The main loop is then started. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_dollar_loop: + { + \group_begin: + \tl_clear:N \l_@@_grabbed_tl + \@@_grab_loop: + } +\cs_new_protected:Npn \@@_grab_loop: + { + \peek_remove_spaces:n + { + \peek_meaning:NTF \c_group_begin_token + { \@@_grab_loop_group:n } + { \@@_grab_loop_token:N } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_grab_loop_group:n} +% \begin{macro}{\@@_grab_loop_store:n} +% Handling of grabbed groups is pretty easy. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_loop_group:n #1 + { \@@_grab_loop_store:n { {#1} } } +\cs_new_protected:Npn \@@_grab_loop_store:n #1 + { + \tl_put_right:Nn \l_@@_grabbed_tl {#1} + \@@_grab_loop: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_grab_loop_token:N} +% \begin{macro} +% { +% \@@_grab_loop_$: , +% \@@_grab_loop_\\: , +% \@@_grab_loop_\begin: , +% \@@_grab_loop_\end: , +% \@@_grab_loop_\ignorespaces: , +% \@@_grab_loop_\unskip: , +% \@@_grab_loop_\textonly@unskip: +% } +% Filter out the special cases: for performance reasons, use a hash table +% approach rather than a loop (\emph{cf.}~\pkg{collcell}). +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_loop_token:N #1 + { + \cs_if_exist_use:cF + { @@_grab_loop_ \token_to_str:N #1 : } + { \@@_grab_loop_store:n {#1} } + } +\cs_new_protected:cpn { @@_grab_loop_ \token_to_str:N $ : } + { \@@_grab_loop_end: } +\cs_new_protected:cpn { @@_grab_loop_ \token_to_str:N \\ : } + { + \int_compare:nNnTF \l_@@_grab_env_int = 0 + { \@@_grab_loop_newline: } + { \@@_grab_loop_store:n { \\ } } + } +% \end{macrocode} +% In contrast to \pkg{collcell}, nesting is tracked by counting +% \cs{begin}/\cs{end} pairs: this is needed in case there is a tabular-like +% construct containing |\\| inside a cell. As a result, the end-of-tabular +% can be detected without checking the name argument: if \cs{end} is +% encountered at nesting level~0, we've hit the end of a cell. In that case, +% end the row and leave the environment to clean up. +% \begin{macrocode} +\cs_new_protected:cpn { @@_grab_loop_ \token_to_str:N \begin : } + { + \int_incr:N \l_@@_grab_env_int + \@@_grab_loop_store:n { \begin } + } +\cs_new_protected:cpn { @@_grab_loop_ \token_to_str:N \end : } + { + \int_compare:nNnTF \l_@@_grab_env_int = 0 + { + \@@_grab_loop_newline: + \end + } + { + \int_decr:N \l_@@_grab_env_int + \@@_grab_loop_store:n { \end } + } + } +\tl_map_inline:nn { \ignorespaces \unskip \textonly@unskip } + { + \cs_new_protected:cpn { @@_grab_loop_ \token_to_str:N #1 : } + { \@@_grab_loop: } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_grab_loop_newline:} +% To allow collection of tokens in the part of the \tn{halign} template after +% |#|, we need \TeX{} to see the primitive with the loop token in the right +% place. That is done by re-defining \tn{cr} at present. Ideally there would +% be a socket in the definition of \texttt{tabular}, etc., to handle this: +% there is also the need to examine in interaction with \pkg{longtable}, which +% also redefines \tn{cr}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_loop_newline: + { + \if_false: { \fi: + \cs_set_protected:Npn \cr + { + \@@_grab_loop: + \tex_cr:D + } + \if_false: } \fi: + \\ + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_grab_loop_end:} +% Clean up and pass on. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_loop_end: + { + \exp_args:NNV \group_end: + \@@_grab_dollar:n \l_@@_grabbed_tl + } +% \end{macrocode} +% \end{macro} +% % \subsection{Marking math environments} % % A general mechanism for math mode environments that do not grab their @@ -1644,7 +2397,7 @@ } { % \typeout{==>A3} - \__tag_tool_close_P: + \__tag_tool_close_P: } \socket_use:nn{tagsupport/math/display/formula/begin}{} \tagpdfparaOff @@ -1662,7 +2415,7 @@ \cs_new_protected:Npn \math_register_env:n #1 { \math_register_env:nn {#1} { } } - + \NewDocumentCommand \RegisterMathEnvironment { O{} m } { \math_register_env:nn {#2} {#1} } % \end{macrocode} @@ -1749,7 +2502,7 @@ { \cs_gset_protected:Npn \[ % \] { - \@@_grab_eqn:w + \@@_grab_eqn:w % \bool_if:NTF \l_@@_collected_bool % { \begin { equation* } } % { \@@_grab_eqn:w } @@ -1847,7 +2600,7 @@ % \end{macrocode} % % Tabulars currently contain a \$ that shouldn't trigger math -% tagging. +% tagging. % \begin{macrocode} \RequirePackage{array} \tl_if_in:NnT\@tabular{$} @@ -1856,11 +2609,15 @@ \leavevmode \UseTaggingSocket{tbl/hmode/begin}% \hbox \bgroup - \bool_set_true:N \l_@@_collected_bool + \bool_set_true:N \l_@@_collected_bool $ \bool_set_false:N \l_@@_collected_bool \col@sep\tabcolsep \let\d@llarbegin\begingroup \let\d@llarend\endgroup +% \end{macrocode} +% A proper switching mechanism is needed: for the present, do directly. +% \begin{macrocode} + \cs_set_protected:Npn \@@_grab_dollar:w { \@@_grab_dollar_loop: } \@tabarray} } % \end{macrocode} @@ -1877,10 +2634,10 @@ } % \end{macrocode} % \end{macro} -% +% % \subsection{Disable math grabbing in the begindocument hook} % For example amsart uses math to measure text there. -% +% % \begin{macrocode} \tl_gput_right:Nn\@kernel@before@begindocument { @@ -1996,7 +2753,7 @@ % \end{macrocode} % Also for "false?" % \begin{macrocode} -\def\measuring@true{\let\ifmeasuring@\iftrue\tag_stop:} +\def\measuring@true{\let\ifmeasuring@\iftrue\tag_suspend:n{\measuring}} % \end{macrocode} % % \begin{macrocode} @@ -2004,7 +2761,7 @@ \math_register_halign_env:nn {align}{} \math_register_halign_env:nn {align*}{} \math_register_halign_env:nn {alignat}{} - \math_register_halign_env:nn {alignat*}{} + \math_register_halign_env:nn {alignat*}{} \math_register_halign_env:nn {flalign}{} \math_register_halign_env:nn {flalign*}{} \math_register_halign_env:nn {gather}{} @@ -2085,8 +2842,8 @@ % % \begin{macro}{\@@_split_at_nl:NN} -% This splits grabbed math at newlines. -% +% This splits grabbed math at newlines. +% % \begin{macrocode} \cs_new:Npn \@@_split_at_nl:NN #1#2 { \tl_set:Nf \l_@@_tmpa_tl { @@ -2105,14 +2862,14 @@ #2 \\ #3 \s_stop } } - + \cs_new_protected:Npn \@@_split_at_nl_aux:nnNN #1 #2 #3 #4 { \tl_gset:Nn #4 {#1} \tl_gset:Nn #3 {#2} } -\cs_new:Npn \@@_split_chk_if_begin:ww +\cs_new:Npn \@@_split_chk_if_begin:ww #1 \begin #2 #3 \s_mark #4 \\ \q_nil \\ \s_stop { \quark_if_nil:nTF {#2} @@ -2163,11 +2920,11 @@ { \exp_end: { #4 #1 } } { \@@_split_final_cleanup:w #3 \s_mark { #4 #1 #2 } } } - + \cs_new:Npn \@@_split:n #1 { \@@_split_at_nl_first:w #1 \\ \q_nil \\ \s_stop } - -% this looks unused. + +% this looks unused. %\NewDocumentCommand \splitnl { mm +m } % { % \tl_set:Nf \l_@@_tmpa_tl { \split:n {#3} } @@ -2179,12 +2936,12 @@ % % % \begin{macro}{\maybestartnewformulatag} -% +% % \begin{macrocode} \newif\if@subformulas -\tl_new:N \result - +\tl_new:N \result + \cs_new_protected:Npn\grabaformulapartandstart { \@@_split_at_nl:NN \g_@@_grabbed_math_tl \result \typeout{====>first-result=\meaning\result} @@ -2204,7 +2961,7 @@ % but we add a short text to satisfy the pdf/ua-2 validator % \begin{macrocode} % alt=\result, - alt = subformula, + alt = subformula, title-o=\resulttitle } } @@ -2242,7 +2999,7 @@ % \tl_if_empty:NF \g_@@_grabbed_math_tl { - \tagmcend + \tagmcend \tagstructend \grabaformulapartandmayberestart } @@ -2258,21 +3015,21 @@ % \typeout{===>~ in~ hook} % \math_register_halign_env:nn {dmath}{} % \math_register_halign_env:nn {dgroup*}{} -%} +%} % \end{macrocode} -% +% % \begin{macrocode} \ExplSyntaxOff % \end{macrocode} -% +% % \begin{macrocode} %<@@=> % \end{macrocode} -% +% % \begin{macrocode} %</kernel> % \end{macrocode} % % \Finale % -% +% diff --git a/macros/latex/required/latex-lab/latex-lab-math.pdf b/macros/latex/required/latex-lab/latex-lab-math.pdf Binary files differindex 728777fa58..b6cd2eb02d 100644 --- a/macros/latex/required/latex-lab/latex-lab-math.pdf +++ b/macros/latex/required/latex-lab/latex-lab-math.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-mathpkg.pdf b/macros/latex/required/latex-lab/latex-lab-mathpkg.pdf Binary files differindex 19f9fbbb03..3de59344dd 100644 --- a/macros/latex/required/latex-lab/latex-lab-mathpkg.pdf +++ b/macros/latex/required/latex-lab/latex-lab-mathpkg.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-mathtools.dtx b/macros/latex/required/latex-lab/latex-lab-mathtools.dtx index aa27cbf01d..ed8b6e467e 100644 --- a/macros/latex/required/latex-lab/latex-lab-mathtools.dtx +++ b/macros/latex/required/latex-lab/latex-lab-mathtools.dtx @@ -18,12 +18,14 @@ % % for those people who are interested or want to report an issue. % +\def\ltlabmathtoolsdate{2024-09-18} +\def\ltlabmathtoolsversion{0.80a} %<*driver> \documentclass{l3doc} \EnableCrossrefs \CodelineIndex \begin{document} - \DocInput{latex-lab-amsmath.dtx} + \DocInput{latex-lab-mathtools.dtx} \end{document} %</driver> % @@ -32,7 +34,7 @@ % % \title{The \texttt{latex-lab-mathtools} code\thanks{}} % \author{\LaTeX{} Project} -% +% \date{v\ltlabmathtoolsversion\ \ltlabmathtoolsdate} % \maketitle % % \newcommand\fmi[1]{\begin{quote} TODO: \itshape #1\end{quote}} @@ -66,7 +68,7 @@ % \subsection{File declaration} % \begin{macrocode} \ProvidesFile{latex-lab-mathtools.ltx} - [2023-01-05 v0.1a mathtools adaptions] + [2024-07-13 v0.1a mathtools adaptions] % \end{macrocode} % \subsection{Tagpdf support} % To make the code independent from tagging being loaded and active @@ -117,7 +119,7 @@ % \end{macrocode} % Stop tagging when measuring: % \begin{macrocode} - \ifmeasuring@\tag_stop:\fi + \ifmeasuring@\tag_suspend:n{\measuring}\fi \normalbaselines \ifdim \ifdim\@totalleftmargin=\z@ @@ -156,7 +158,7 @@ \noalign{% \penalty\postdisplaypenalty\vskip\abovedisplayshortskip \vbox{% - \ifmeasuring@\tag_stop:\fi + \ifmeasuring@\tag_suspend:n{\measuring}\fi \normalbaselines \MH_if_dim:w \MH_if_dim:w \@totalleftmargin=\z@ @@ -185,7 +187,7 @@ \vskip\normallineskiplimit \vskip\l_MT_above_shortintertext_sep \vbox{% - \ifmeasuring@\tag_stop:\fi + \ifmeasuring@\tag_suspend:n{\measuring}\fi \normalbaselines \MH_if_dim:w \MH_if_dim:w \@totalleftmargin=\z@ diff --git a/macros/latex/required/latex-lab/latex-lab-mathtools.pdf b/macros/latex/required/latex-lab/latex-lab-mathtools.pdf Binary files differindex d89429b3d2..55d8283b59 100644 --- a/macros/latex/required/latex-lab/latex-lab-mathtools.pdf +++ b/macros/latex/required/latex-lab/latex-lab-mathtools.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-minipage.dtx b/macros/latex/required/latex-lab/latex-lab-minipage.dtx index ffbe5357e7..eed595a531 100644 --- a/macros/latex/required/latex-lab/latex-lab-minipage.dtx +++ b/macros/latex/required/latex-lab/latex-lab-minipage.dtx @@ -18,8 +18,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabminipagedate{2023-10-30} -\def\ltlabminipageversion{0.81c} +\def\ltlabminipagedate{2024-09-18} +\def\ltlabminipageversion{0.81e} %<*driver> \documentclass{l3doc} \EnableCrossrefs @@ -120,12 +120,18 @@ % \end{macrocode} % insert the socket % \begin{macrocode} - \socket_use:n{tagsupport/minipage/before}% new + \UseTaggingSocket{minipage/before}% new \setbox\@tempboxa\vbox\bgroup \color@begingroup \hsize\@tempdima \textwidth\hsize \columnwidth\hsize \@parboxrestore +% \end{macrocode} +% minipages are perhaps used in environments where the tagging of paragraphs +% has been altered. So we try to restore this. TODO: this should +% perhaps be done in \cs{@parboxrestore} directly. +% \begin{macrocode} + \UseTaggingSocket{para/restore} \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@ \socket_assign_plug:nn{fntext/process}{mp}% \let\@listdepth\@mplistdepth \@mplistdepth\z@ @@ -150,10 +156,10 @@ % As the parbox command is called, we must prevent that it adds its % additional tagging commands: % \begin{macrocode} - \tag_stop:n{minipage} + \tag_suspend:n{minipage} \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}% - \tag_start:n{minipage} - \socket_use:n{tagsupport/minipage/after} %new end ... + \tag_resume:n{minipage} + \UseTaggingSocket{minipage/after} %new end ... } % \end{macrocode} % @@ -164,8 +170,15 @@ \leavevmode \@pboxswfalse \setlength\@tempdima{#4}% - \socket_use:n{tagsupport/parbox/before} - \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}% + \UseTaggingSocket{parbox/before} + \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore +% \end{macrocode} +% parbox are perhaps used in environments where the tagging of paragraphs +% has been altered. So we try to restore this. TODO: this should +% perhaps be done in \cs{@parboxrestore} directly. +% \begin{macrocode} + \UseTaggingSocket{para/restore} + #5\@@par}% \ifx\relax#2\else \setlength\@tempdimb{#2}% \edef\@parboxto{to\the\@tempdimb}% @@ -179,7 +192,7 @@ \csname bm@#3\endcsname}% \if@pboxsw \m@th$\fi \@end@tempboxa% - \socket_use:n{tagsupport/parbox/after} + \UseTaggingSocket{parbox/after} } % \end{macrocode} % @@ -191,9 +204,11 @@ \socket_new_plug:nnn{tagsupport/minipage/before}{tag/dflt} { % \end{macrocode} -% As there was a \cs{leavevmode} before that is a P/text open that we have to close. +% As there was a \cs{leavevmode} before that is a P/text open that we have to close +% if para tagging is active: % \begin{macrocode} - \tag_mc_end_push:\tag_struct_end: + \tag_mc_end_push: + \bool_if:NT \l__tag_para_bool {\tag_struct_end:} % \end{macrocode} % TODO: the P can be further up, we need a proper method to test and handle this. % \begin{macrocode} @@ -203,13 +218,25 @@ % similar for the other sockets: % \begin{macrocode} \socket_new_plug:nnn{tagsupport/minipage/after}{tag/dflt} - {\tag_struct_end:\tag_struct_begin:n{tag=\l__tag_para_tag_tl}\tag_mc_begin_pop:n{}} + { + \tag_struct_end: + \bool_if:NT \l__tag_para_bool {\tag_struct_begin:n{tag=\l__tag_para_tag_tl}} + \tag_mc_begin_pop:n{} + } \socket_new_plug:nnn{tagsupport/parbox/before}{tag/dflt} - {\tag_mc_end_push:\tag_struct_end:\tag_struct_begin:n{tag=\l__ltboxes_tag_tl}} + { + \tag_mc_end_push: + \bool_if:NT \l__tag_para_bool {\tag_struct_end:} + \tag_struct_begin:n{tag=\l__ltboxes_tag_tl} + } \socket_new_plug:nnn{tagsupport/parbox/after}{tag/dflt} - {\tag_struct_end:\tag_struct_begin:n{tag=\l__tag_para_tag_tl}\tag_mc_begin_pop:n{}} + { + \tag_struct_end: + \bool_if:NT \l__tag_para_bool {\tag_struct_begin:n{tag=\l__tag_para_tag_tl}} + \tag_mc_begin_pop:n{} + } % \end{macrocode} % Activate the default tagging plug % \begin{macrocode} diff --git a/macros/latex/required/latex-lab/latex-lab-minipage.pdf b/macros/latex/required/latex-lab/latex-lab-minipage.pdf Binary files differindex 9eaffaeb9b..c9b2491f83 100644 --- a/macros/latex/required/latex-lab/latex-lab-minipage.pdf +++ b/macros/latex/required/latex-lab/latex-lab-minipage.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-namespace.dtx b/macros/latex/required/latex-lab/latex-lab-namespace.dtx index cfc06c7b09..d76dd8d489 100644 --- a/macros/latex/required/latex-lab/latex-lab-namespace.dtx +++ b/macros/latex/required/latex-lab/latex-lab-namespace.dtx @@ -26,7 +26,7 @@ % \fi % \title{Prototype reimplementation of \LaTeXe{}'s role mapping} % \author{\LaTeX{} Project, initial implementation Ulrike Fischer} -% \date{v0.8b 2024-03-24} +% \date{v0.8b 2024-07-05} % % \maketitle % @@ -37,7 +37,7 @@ % \section{Introduction} % % This short file collects tag names from the \LaTeX{} namespace and their role mapping used -% in the latex-lab files. The names and the roles are not necessarly the final ones! +% in the latex-lab files. The names and the roles are not necessarily the final ones! % % Later settings of the same tag overwrite previous settings. % The syntax of a line is a list of three strings ending with commas: diff --git a/macros/latex/required/latex-lab/latex-lab-namespace.pdf b/macros/latex/required/latex-lab/latex-lab-namespace.pdf Binary files differindex 2dfea04dee..131f3cbb97 100644 --- a/macros/latex/required/latex-lab/latex-lab-namespace.pdf +++ b/macros/latex/required/latex-lab/latex-lab-namespace.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-new-or-1.pdf b/macros/latex/required/latex-lab/latex-lab-new-or-1.pdf Binary files differindex dbfef1a84c..6bd4065f37 100644 --- a/macros/latex/required/latex-lab/latex-lab-new-or-1.pdf +++ b/macros/latex/required/latex-lab/latex-lab-new-or-1.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-new-or-2.pdf b/macros/latex/required/latex-lab/latex-lab-new-or-2.pdf Binary files differindex 6a354382ac..10e0f07095 100644 --- a/macros/latex/required/latex-lab/latex-lab-new-or-2.pdf +++ b/macros/latex/required/latex-lab/latex-lab-new-or-2.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-sec.dtx b/macros/latex/required/latex-lab/latex-lab-sec.dtx index f3786c2ddb..936eee9ed2 100644 --- a/macros/latex/required/latex-lab/latex-lab-sec.dtx +++ b/macros/latex/required/latex-lab/latex-lab-sec.dtx @@ -16,8 +16,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabsecdate{2024-02-12} -\def\ltlabsecversion{0.84c} +\def\ltlabsecdate{2024-10-04} +\def\ltlabsecversion{0.84f} %<*driver> \documentclass[kernel]{l3doc} \EnableCrossrefs @@ -121,7 +121,7 @@ % commands must be at the right grouping level. % \end{itemize} % -% \subsection{Funktions and keys} +% \subsection{Functions and keys} % % \begin{function}{\tag_tool:n,\tagtool} % @@ -138,7 +138,7 @@ % to allow e.g. to put an epigraph or similar in front. % % \item The number in \cs{part} and \cs{chapter} is currently not correctly -% tagged as a \texttt{Lbl} as this requires to redefine the internal (class dependant) +% tagged as a \texttt{Lbl} as this requires to redefine the internal (class dependent) % commands too. % % \end{itemize} @@ -198,28 +198,31 @@ % We must ensure that manual targets (e.g. in unnumbered sections) % correctly update \cs{@currentHref}. For this we extend the kernel definition of % \cs{MakeLinkTarget} -% +% TODO: remove after release 2024/11 % \begin{macrocode} %<*kernelchange> \ExplSyntaxOn -\int_new:N\g__kernel_target_int -\RenewDocumentCommand\MakeLinkTarget{sO{}m} - {% - \ifvmode - \special{}% - \else - \@savsf\spacefactor - \smash{}% - \spacefactor\@savsf - \fi - \IfBooleanTF {#1} - { - \tl_gset:Ne \@currentHref {#3} +\str_if_exist:cF { l__socket_tagsupport/recordtarget_plug_str } + { + \int_new:N\g__kernel_target_int + \RenewDocumentCommand\MakeLinkTarget{sO{}m} + {% + \ifvmode + \special{}% + \else + \@savsf\spacefactor + \smash{}% + \spacefactor\@savsf + \fi + \IfBooleanTF {#1} + { + \tl_gset:Ne \@currentHref {#3} + } + { + \int_gincr:N\g__kernel_target_int + \tl_gset:Ne \@currentHref {target*.\int_use:N\g__kernel_target_int} + } } - { - \int_gincr:N\g__kernel_target_int - \tl_gset:Ne \@currentHref {target*.\int_use:N\g__kernel_target_int} - } } \ExplSyntaxOff %</kernelchange> @@ -227,45 +230,56 @@ % % \begin{macrocode} %<*package> +%<@@=tag> % \end{macrocode} % \subsubsection{Tagging commands} % % -% \begin{variable}{\g__tag_sec_stack_seq} -% The stack holds the tag and the level. +% \begin{variable}{\g_@@_sec_stack_seq} +% The stack holds the tag, the level and the structure number. % \begin{macrocode} -\seq_new:N \g__tag_sec_stack_seq -\seq_gpush:Nn\g__tag_sec_stack_seq {{Document}{-100}} +\seq_new:N \g_@@_sec_stack_seq +\seq_gpush:Nn\g_@@_sec_stack_seq {{Document}{-100}{2}} % \end{macrocode} % \end{variable} % -% \begin{variable}{\l__tag_sec_Sect_bool} +% \begin{macro}{\@@_get_data_current_Sect:} +% This allows to retrieve the number of the current Sect structure (or +% Document if we are outside any Sect) with |\tag_get:n{current_Sect}| +% \begin{macrocode} +\cs_new:Npn \@@_get_data_current_Sect: + { + \exp_last_unbraced:Ne\use_iii:nnn{\seq_item:Nn\g_@@_sec_stack_seq{1}} + } +% \end{macrocode} +% \end{macro} +% \begin{variable}{\l_@@_sec_Sect_bool} % This boolean controls if a Sect structure is opened. % \begin{macrocode} -\bool_new:N \l__tag_sec_Sect_bool -\bool_set_true:N\l__tag_sec_Sect_bool +\bool_new:N \l_@@_sec_Sect_bool +\bool_set_true:N\l_@@_sec_Sect_bool % \end{macrocode} % \end{variable} - -% -% \begin{macro}{\__tag_sec_begin:nn} +% +% \begin{macro}{\@@_sec_begin:nn} % This starts a sectioning structure. % Currently the tag is fix, either Sect or Part, depending on the level, % but this will perhaps change. The second argument is currently unused. % \begin{macrocode} -\cs_new_protected:Npn\__tag_sec_begin:nn #1 #2 %#1 level #2 keyval +\cs_new_protected:Npn\@@_sec_begin:nn #1 #2 %#1 level #2 keyval { \tag_struct_begin:n { tag= {\int_compare:nNnTF {#1}={-1}{Part}{Sect}} ,#2 } - \seq_gpush:Ne \g__tag_sec_stack_seq {{\g__tag_struct_tag_tl}{\int_eval:n{#1}}} + \seq_gpush:Ne \g_@@_sec_stack_seq + {{\g_@@_struct_tag_tl}{\int_eval:n{#1}}{\g_@@_struct_stack_current_tl}} } % \end{macrocode} % \end{macro} % -% \begin{macro}{\__tag_sec_end:n} +% \begin{macro}{\@@_sec_end:n} % \begin{macrocode} \msg_new:nnn { tag } {wrong-sect-nesting} { @@ -273,65 +287,65 @@ It~is~not~equal~to~the~current~structure~#2~on~the~main~stack } -\cs_new_protected:Npn\__tag_sec_end:n #1 % #1 level +\cs_new_protected:Npn\@@_sec_end:n #1 % #1 level { - \seq_get:NN \g__tag_sec_stack_seq \l__tag_tmpa_tl - \int_compare:nNnT {#1}<{\exp_last_unbraced:NV\use_ii:nn\l__tag_tmpa_tl+1} + \seq_get:NN \g_@@_sec_stack_seq \l_@@_tmpa_tl + \int_compare:nNnT {#1}<{\exp_last_unbraced:NV\use_ii:nnn\l_@@_tmpa_tl+1} { - \seq_get:NN\g__tag_struct_tag_stack_seq \l__tag_tmpb_tl + \seq_get:NN\g_@@_struct_tag_stack_seq \l_@@_tmpb_tl \exp_args:Nee \tl_if_eq:nnTF - {\exp_last_unbraced:NV\use_i:nn\l__tag_tmpa_tl} - {\exp_last_unbraced:NV\use_i:nn\l__tag_tmpb_tl} + {\exp_last_unbraced:NV\use_i:nnn\l_@@_tmpa_tl} + {\exp_last_unbraced:NV\use_i:nn\l_@@_tmpb_tl} { - \seq_gpop:NN \g__tag_sec_stack_seq \l__tag_tmpa_tl + \seq_gpop:NN \g_@@_sec_stack_seq \l_@@_tmpa_tl \tag_struct_end: - \__tag_sec_end:n {#1} + \@@_sec_end:n {#1} } { \msg_warning:nnee {tag}{wrong-sect-nesting} - { \exp_last_unbraced:NV\use_i:nn \l__tag_tmpa_tl } - { \exp_last_unbraced:NV\use_i:nn \l__tag_tmpb_tl } + { \exp_last_unbraced:NV\use_i:nnn \l_@@_tmpa_tl } + { \exp_last_unbraced:NV\use_i:nn \l_@@_tmpb_tl } } } } % \end{macrocode} % \end{macro} -% \begin{macro}{\__tag_tool_para_split:} +% \begin{macro}{\@@_tool_para_split:} % Runin-sectioning command must separate the heading from the following text. % % \begin{macrocode} -\cs_new_protected:Npn \__tag_tool_para_split: +\cs_new_protected:Npn \@@_tool_para_split: { \tag_mc_end: \tag_struct_end: - \tag_struct_begin:n{tag=\l__tag_para_tag_default_tl} + \tag_struct_begin:n{tag=\l_@@_para_tag_default_tl} \tag_mc_begin:n{} - \__tag_setup_restore_para_default: + \@@_setup_restore_para_default: } % \end{macrocode} % \end{macro} -% \begin{macro}{\__tag_setup_restore_para_default:} +% \begin{macro}{\@@_setup_restore_para_default:} % We change the para tagging in the sectioning code. % This here restores the default. Currently it only resets the % the tag, but perhaps more will be needed later. % \begin{macrocode} -\cs_new_protected:Npn \__tag_setup_restore_para_default: +\cs_new_protected:Npn \@@_setup_restore_para_default: { - \tl_set:Nn \l__tag_para_main_tag_tl {text-unit} - \tl_set_eq:NN\l__tag_para_tag_tl\l__tag_para_tag_default_tl + \tl_set:Nn \l_@@_para_main_tag_tl {text-unit} + \tl_set_eq:NN\l_@@_para_tag_tl\l_@@_para_tag_default_tl } % \end{macrocode} % \end{macro} % -% \begin{macro}{\__tag_sec_end_display:} +% \begin{macro}{\@@_sec_end_display:} % \begin{macrocode} -\cs_new_protected:Npn \__tag_sec_end_display: +\cs_new_protected:Npn \@@_sec_end_display: { \tag_struct_end: %P = Hn - \__tag_setup_restore_para_default: + \@@_setup_restore_para_default: } % \end{macrocode} % \end{macro} @@ -339,17 +353,17 @@ % Open sec structures should be closed at the end of the document. This should % be done before tagpdf closes the Document structure. % \begin{macrocode} -\hook_gput_code:nnn{tagpdf/finish/before}{tagpdf/sec}{\__tag_sec_end:n{-10}} +\hook_gput_code:nnn{tagpdf/finish/before}{tagpdf/sec}{\@@_sec_end:n{-10}} \hook_gset_rule:nnnn {tagpdf/finish/before}{tagpdf/sec}{before}{tagpdf} % \end{macrocode} % % The commands \cs{mainmatter}, \cs{backmatter}, \cs{frontmatter} and % \cs{appendix} close all \texttt{Sect} and \texttt{Part} structures. % \begin{macrocode} -\AddToHook{cmd/frontmatter/before}{\__tag_sec_end:n{-10}} -\AddToHook{cmd/mainmatter/before} {\__tag_sec_end:n{-10}} -\AddToHook{cmd/backmatter/before} {\__tag_sec_end:n{-10}} -\AddToHook{cmd/appendix/before} {\__tag_sec_end:n{-10}} +\AddToHook{cmd/frontmatter/before}{\@@_sec_end:n{-10}} +\AddToHook{cmd/mainmatter/before} {\@@_sec_end:n{-10}} +\AddToHook{cmd/backmatter/before} {\@@_sec_end:n{-10}} +\AddToHook{cmd/appendix/before} {\@@_sec_end:n{-10}} % \end{macrocode} % % \subsection{Tagging tools} @@ -368,57 +382,57 @@ { ,sec-start-part .code:n = { - \bool_if:NT\l__tag_sec_Sect_bool + \bool_if:NT\l_@@_sec_Sect_bool { - \__tag_sec_end:n {-1} - \__tag_sec_begin:nn{-1}{tag=Part} + \@@_sec_end:n {-1} + \@@_sec_begin:nn{-1}{tag=Part} } \tag_struct_begin:n{tag=part,title=#1} % \end{macrocode} % We remap here the text-unit from the paragraph to NonStruct. -% It would be better to suppress it completly as with the other +% It would be better to suppress it completely as with the other % sectioning commands, but this would require to redefine \cs{@spart} % and \cs{@part}, as there is the grouping, and these commands are % all slightly different in the standard classes. So this is delayed % to the time when sectioning commands are redefined with templates. % \begin{macrocode} - \tl_set:Nn\l__tag_para_main_tag_tl {NonStruct} - \tl_set:Nn\l__tag_para_tag_tl {Span} + \tl_set:Nn\l_@@_para_main_tag_tl {NonStruct} + \tl_set:Nn\l_@@_para_tag_tl {Span} } - ,sec-stop-part .code:n = {\__tag_sec_end_display:} + ,sec-stop-part .code:n = {\@@_sec_end_display:} ,sec-start-chapter .code:n = { - \bool_if:NT\l__tag_sec_Sect_bool + \bool_if:NT\l_@@_sec_Sect_bool { - \__tag_sec_end:n {0} - \__tag_sec_begin:nn{0}{tag=Sect} + \@@_sec_end:n {0} + \@@_sec_begin:nn{0}{tag=Sect} } \tag_struct_begin:n{tag=chapter,title=#1} % \end{macrocode} % similar to part we remap to NonStruct for now ... % \begin{macrocode} - \tl_set:Nn\l__tag_para_main_tag_tl {NonStruct} - \tl_set:Nn\l__tag_para_tag_tl {Span} + \tl_set:Nn\l_@@_para_main_tag_tl {NonStruct} + \tl_set:Nn\l_@@_para_tag_tl {Span} } ,sec-stop-chapter .meta:n = { sec-stop-part} ,sec-start .code:n = % #1 is a name like "section" { - \bool_if:NT\l__tag_sec_Sect_bool + \bool_if:NT\l_@@_sec_Sect_bool { - \__tag_sec_end:n {\cs_if_exist_use:c{toclevel@#1}+0} - \__tag_sec_begin:nn {\cs_if_exist_use:c{toclevel@#1}+0}{tag=Sect} + \@@_sec_end:n {\cs_if_exist_use:c{toclevel@#1}+0} + \@@_sec_begin:nn {\cs_if_exist_use:c{toclevel@#1}+0}{tag=Sect} } - \tl_set:Nn\l__tag_para_tag_tl{#1} + \tl_set:Nn\l_@@_para_tag_tl{#1} } ,sec-start .value_required:n = true - ,sec-split-para .code:n = {\__tag_tool_para_split:} - ,restore-para .code:n = {\__tag_setup_restore_para_default:} + ,sec-split-para .code:n = {\@@_tool_para_split:} + ,restore-para .code:n = {\@@_setup_restore_para_default:} ,sec-stop .code:n = { - \par\__tag_sec_end:n {\cs_if_exist_use:c{toclevel@#1}+0} + \par\@@_sec_end:n {\cs_if_exist_use:c{toclevel@#1}+0} } ,sec-stop .value_required:n = true - ,sec-add-grouping .bool_set:N = \l__tag_sec_Sect_bool + ,sec-add-grouping .bool_set:N = \l_@@_sec_Sect_bool } % \end{macrocode} % @@ -433,6 +447,7 @@ % The tagging inside relies on the para tagging. % We do not yet use keyval in the optional argument, as this requires latex-dev % and the naming of the keys and their key family is unclear. +% \changes{v0.84f}{2024/10/04}{Added braces around optional arg (tagging/725)} % \begin{macrocode} \AddToHook{class/after} { @@ -476,7 +491,7 @@ \IfBooleanTF {#1} { \@spart {#3} } - { \@part [#2]{#3} } + { \@part [{#2}]{#3} } % \end{macrocode} % and now the closing command for the tagging of the title. % \begin{macrocode} @@ -528,7 +543,7 @@ \IfBooleanTF {#1} { \@schapter {#3} } - { \@chapter [#2]{#3} } + { \@chapter [{#2}]{#3} } % \end{macrocode} % and now the closing command for the tagging of the title. % \begin{macrocode} @@ -583,7 +598,7 @@ \IfBooleanTF {#1} { \@spart {#3} } - { \@part [#2]{#3} } + { \@part [{#2}]{#3} } % \end{macrocode} % and now the closing command for the tagging of the title. % \begin{macrocode} @@ -669,8 +684,8 @@ % \begin{macrocode} \cs_new_protected:Npn \@kernel@tag@hangfrom #1 { - \tagstructbegin{tag=\l__tag_para_tag_tl} - \cs_if_exist_use:N \__tag_gincr_para_begin_int: + \tagstructbegin{tag=\l_@@_para_tag_tl} + \cs_if_exist_use:N \@@_gincr_para_begin_int: \tagstructbegin{tag=Lbl} \setbox\@tempboxa \hbox @@ -680,7 +695,7 @@ % \begin{macrocode} \bool_lazy_and:nnT {\tag_if_active_p:} - {\g__tag_mode_lua_bool} + {\g_@@_mode_lua_bool} {\tagmcbegin{tag=Lbl}} {#1} } @@ -689,12 +704,12 @@ % the paratagging. We do not disable paratagging completely, to % avoid that the numbering goes wrong. % \begin{macrocode} - \tag_stop:n{hangfrom} + \tag_suspend:n{hangfrom} \hangindent \wd\@tempboxa\noindent % \end{macrocode} % Restart tagging and insert the box. % \begin{macrocode} - \tag_start:n{hangfrom} + \tag_resume:n{hangfrom} \tagmcbegin{}\box\@tempboxa\tagmcend\tagstructend\tagmcbegin{}} % \end{macrocode} % This command is used to tag the numbers of runin. We do not try @@ -715,6 +730,7 @@ % \cs{@sect} is only changed to replace the hyperref patches % and to use the new \cs{@kernel@tag@hangfrom} and \cs{@kernel@tag@svsec} % \begin{macrocode} +%<@@=> \def\@sect#1#2#3#4#5#6[#7]#8{% \ifnum #2>\c@secnumdepth \def\@svsec{\@hyp@section@target@nnn{[section]}{}{#3}} @@ -727,7 +743,7 @@ \@tempskipa #5\relax \ifdim \@tempskipa>\z@ \begingroup - \tagtool{para-flattened=true} % or \bool_set_true\l__tag_para_flattened_bool + \tagtool{para-flattened=true} % or \bool_set_true\l_@@_para_flattened_bool #6{% \ifnum #2>\c@secnumdepth \@hangfrom {\hskip #3\relax\@svsec}% diff --git a/macros/latex/required/latex-lab/latex-lab-sec.pdf b/macros/latex/required/latex-lab/latex-lab-sec.pdf Binary files differindex 6471291a8a..45f0af6742 100644 --- a/macros/latex/required/latex-lab/latex-lab-sec.pdf +++ b/macros/latex/required/latex-lab/latex-lab-sec.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-table.dtx b/macros/latex/required/latex-lab/latex-lab-table.dtx index 38596478ae..c65667e8ed 100644 --- a/macros/latex/required/latex-lab/latex-lab-table.dtx +++ b/macros/latex/required/latex-lab/latex-lab-table.dtx @@ -16,8 +16,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabtbldate{2024-05-25} -\def\ltlabtblversion{0.85i} +\def\ltlabtbldate{2024-09-18} +\def\ltlabtblversion{0.85n} %<*driver> \documentclass{l3doc} \EnableCrossrefs @@ -100,6 +100,7 @@ % support for the tagging of tables. A list of the known limitations % is shown below. % +% \subsection{Loading} % The module is not loaded automatically (i.e., not yet integrated % into any \texttt{phase-XX}) and by itself it doesn't activate % tagging. For experimenting with table tagging it is therefore best @@ -113,7 +114,26 @@ % It will then automatically tag all table environments it already supports with % the exception of tables in the header and footer of the page (where tagging is disabled). % Such tables can be nested. +% +% Inside cells the automatic tagging of paragraphs is disabled with the exception of +% p/m/b-type cells. % +% Rows do not need to contain a full number of \&, missing cells are automatically +% added with an empty TD-structure. +% +% You should not insert meaningful text with \verb+!{...}+ or \verb+@{...}+ or \cs{noalign} +% between the rows or columns of the table. +% With pdflatex such text will be unmarked, with lualatex it will be marked as artifact. +% Either case means that it will be currently ignored in the +% structure.\footnote{While it is theoretically possible +% to collect such text and move it into a structure it would require manual markup +% from the author to clarify where this text belongs too.} +% +% As mentioned below the \pkg{colortbl} doesn't work fully with the tagging, +% but when it does, colors inside the table are currently ignored. If such a color +% has a semantic meaning (like \enquote{important value}) this meaning will be lost. +% +% \subsection{Untagged and presentation tables} % If a table should not be tagged as table, for example because it is merely used % as a layout to ensure that the content is properly aligned % or because it is a not yet (fully) supported table structure, @@ -130,41 +150,43 @@ % The key should currently only be used in a group as there is no key (yet) to reset to the default % tag names. % -% Inside cells the automatic tagging of paragraphs is disabled with the exception of -% p/m/b-type cells. -% -% Rows do not need to contain a full number of \&, missing cells are automatically -% added with an empty TD-structure. -% +% \subsection{Header rows and columns} % There is some basic support\footnote{This is not meant to be the % final interface, though.} for headers. With\footnote{The old key name \texttt{table-header-rows} still % works but is deprecated.} % \begin{quote} % \verb|\tagpdfsetup{table/header-rows={|\meta{list of row numbers}\verb|}| +% \verb|\tagpdfsetup{table/header-columns={|\meta{list of column numbers}\verb|}| % \end{quote} % you can -% declare which (absolute) row numbers should be tagged as header rows. -% It applies to all tables until it is changed to a different list of row numbers or undone by setting -% the key to \meta{empty}. -% A row number can be -% negative, then the counting starts from the end of the table. There is no support -% for header columns yet. In a \env{longtable} the code will currently use the \cs{endhead} or +% declare which (absolute) row and column numbers should be tagged as header rows and header columns. +% It applies to all tables until it is changed to a different list of row or +% columns numbers or undone by setting +% the keys to \meta{empty}. +% A row or column number can be +% negative, then the counting starts from the end of the table. +% In a \env{longtable} the code will currently use the \cs{endhead} or % \cs{endfirsthead} rows as header if one of these commands has been % used and in that case the code % ignores a \texttt{table/header-rows} setting. % -% You should not insert meaningful text with \verb+!{...}+ or \verb+@{...}+ or \cs{noalign} -% between the rows or columns of the table. -% With pdflatex such text will be unmarked, with lualatex it will be marked as artifact. -% Either case means that it will be currently ignored in the -% structure.\footnote{While it is theoretically possible -% to collect such text and move it into a structure it would require manual markup -% from the author to clarify where this text belongs too.} +% \subsection{Spanning of cells} % -% As mentioned below the \pkg{colortbl} doesn't yet work properly with the tagging, -% but once it does, then colors inside the table will probably be -% simply ignored (at least initially). If such a color -% has a semantic meaning (like \enquote{important value}) this meaning will be lost. +% \cs{multicolumn} is supported out of the box and will create a structure with a +% suitable \texttt{ColSpan} attribute\footnote{The code uses actually an attribute \emph{class}. +% The validator PAC doesn't handle this correctly currently and complains about a missing attribute.} +% +% For cells spanning rows some preliminary support exists\footnote{The interface is bound to change!}: +% If you add +% \begin{quote} +% \verb|\tagpdfsetup{table/multirow={|\meta{number of rows}\verb|}| +% \end{quote} +% to a cell the code will add the suitable \texttt{RowSpan} attribute and suppress the tagging of affected +% cells in the following rows. This will also work if the current cell is a \cs{multicolumn}, then +% the cell will span both rows and columns. It is the duty of the author to +% ensure that all cells below and covered by a \texttt{RowSpan} are empty! +% The code neither checks that nor does +% it tries to suppress content. % % Feedback and problems with the code can be reported at % \url{https://github.com/latex3/tagging-project} either in form of @@ -183,19 +205,19 @@ % \item the \env{array} environment is assumed to be part of math and tagging as a table is disabled for % it. % -% \item Row spans are not yet supported (and the \pkg{multirow} package is untested). +% \item Row spans can only be added manually (the \pkg{multirow} package is untested). % -% \item The \pkg{colortbl} package breaks tagging if there are nested tables. It also breaks -% the filling up of incomplete rows. +% \item The \pkg{colortbl} package breaks tagging if there are nested tables. % % \item The \pkg{tabularray} package use a completed different % method to create tables and will not be supported by this code. % % \item The \pkg{nicematrix} package is currently incompatible. % -% \item Most other packages related to tables in \LaTeX{} are not yet tested, +% \item Most other packages related to tables in \LaTeX{} are not fully tested, % that includes packages that change rules like \pkg{booktabs}, \pkg{hhline}, -% \pkg{arydshln}, \pkg{hvdashln}. +% \pkg{arydshln}, \pkg{hvdashln}. Some problems have been resolved, either +% in the packages or through a firstaid which can be loaded the \verb+testphase=firstaid+. % % \item \env{longtable} currently only works with lualatex. % With other engines it breaks as its output @@ -208,9 +230,9 @@ % the tagging of the table must be deactivated with \verb|\tagpdfsetup{table/tagging=false}| % or \verb|\tagpdfsetup{table/tagging=presentation}|. % -% \item Only simple header rows are currently supported. Columns and complex headers with +% \item Only simple header rows and columns are currently supported. Complex headers with % subheaders will be handled later as that needs some syntax changes. Tables -% with more than one header row are probably not pdf/UA as the headers array in +% with more than one header row or column are probably not pdf/UA as the headers array in % the cells is missing. % % \item A \pkg{longtable} \cs{caption} is currently simply formatted as a multicolumn and @@ -259,9 +281,6 @@ % % \item Longtable captions should be properly supported. % -% \item Handle p-cells better. para-tagging should probably be enabled, -% but Part can't be a child of TD, so this should probably be changed to Div here. -% Also there is a stray MC somewhere. % % \item More packages must be tested. % \end{itemize} @@ -292,8 +311,8 @@ % ,\l_@@_cellattribute_tl % ,\l_@@_rowattribute_tl % ,\l_@@_tmpa_clist -% ,\l_@@_tmpa_seq % ,\l_@@_tmpa_tl +% ,\l_@@_tmpa_str % } % This is for the celltag, e.g. TD or TH: % \begin{macrocode} @@ -319,10 +338,16 @@ \tl_new:N \l_@@_rowattribute_tl \tl_set:Nn \l_@@_rowattribute_tl {} % \end{macrocode} +% Variable to store cell info like which cell must be skipped when tagging multirows. +% \begin{macrocode} +\prop_new:N\g_@@_untagged_cells_prop +\prop_new:N\l_@@_saved_untagged_cells_prop +% \end{macrocode} % Temp variables % \begin{macrocode} \clist_new:N \l_@@_tmpa_clist \tl_new:N \l_@@_tmpa_tl +\str_new:N \l_@@_tmpa_str % \end{macrocode} % \end{macro} % @@ -330,7 +355,41 @@ % % % This are the standard plugs for tagging of cells and rows. -% +% +% The following two sockets are defined in lttagging, but we check +% for their existence until the release 11/2024. +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/tbl/init/celldata_plug_str } + { + \NewSocket{tagsupport/tbl/init/celldata}{0} + \NewSocket{tagsupport/tbl/restore/celldata}{0} + } +% \end{macrocode} +% \begin{plugdecl}{default} +% This socket is used inside \cs{tbl_init_cell_data_for_table} for the +% case that this a nested table in a cell. +% \begin{macrocode} +\NewSocketPlug{tagsupport/tbl/init/celldata}{default} + { + \prop_set_eq:NN\l_@@_saved_untagged_cells_prop \g_@@_untagged_cells_prop + \prop_gclear:N \g_@@_untagged_cells_prop + } +\AssignSocketPlug{tagsupport/tbl/init/celldata}{default} +% \end{macrocode} +% \end{plugdecl} + +% \begin{plugdecl}{default} +% This socket is used inside \cs{tbl_restore_outer_cell_data:} and restores +% values when a nested table is ended. +% \begin{macrocode} +\NewSocketPlug{tagsupport/tbl/restore/celldata}{default} + { + \prop_gset_eq:NN\g_@@_untagged_cells_prop \l_@@_saved_untagged_cells_prop + } +\AssignSocketPlug{tagsupport/tbl/restore/celldata}{default} +% \end{macrocode} +% \end{plugdecl} +% % \begin{plugdecl}{TD} % \begin{macrocode} \NewSocketPlug{tagsupport/tbl/cell/begin}{TD} @@ -340,21 +399,44 @@ % always even if the noop plug is in force this needs a different solution. % \begin{macrocode} \@@_show_curr_cell_data: - \tag_struct_begin:n +% \end{macrocode} +% We test if the cell should be tagged at all. +% \begin{macrocode} + \@@_if_tag_cell:nnT {\g_@@_row_int } { \g_@@_col_int } { - tag =\l_@@_celltag_tl, - attribute-class =\l_@@_cellattribute_tl - } - \seq_gput_right:Ne \g_@@_struct_cur_seq { \tag_get:n {struct_num} } +% \end{macrocode} +% this sets row headers +% \begin{macrocode} + \clist_if_in:NVT \l_@@_header_columns_clist\g_@@_col_int + { + \tl_set:Nn \l_@@_celltag_tl {TH} + \tl_set:Ne \l_@@_cellattribute_tl {\l_@@_cellattribute_tl,TH-row} + } +% \end{macrocode} +% Here we handle negative value for row headers: +% \begin{macrocode} + \tl_set:Ne \l_@@_tmpa_tl {\int_eval:n { \g_@@_col_int - 1 - \g_@@_table_cols_tl }} + \clist_if_in:NoT \l_@@_header_columns_clist { \l_@@_tmpa_tl } + { + \tl_set:Nn \l_@@_celltag_tl {TH} + \tl_set:Ne \l_@@_cellattribute_tl {\l_@@_cellattribute_tl,TH-row} + } + \tag_struct_begin:n + { + tag =\l_@@_celltag_tl, + attribute-class ={\l_@@_cellattribute_tl} + } + \seq_gput_right:Ne \g_@@_struct_cur_seq { \tag_get:n {struct_num} } % \end{macrocode} % we store the cells of multicolumns as negative number. This allow to skip them % or to use them as needed. % \begin{macrocode} - \int_step_inline:nn { \g_@@_span_tl - 1 } - { - \seq_gput_right:Ne \g_@@_struct_cur_seq { -\tag_get:n {struct_num} } - } - \tag_mc_begin:n{} + \int_step_inline:nn { \g_@@_span_tl - 1 } + { + \seq_gput_right:Ne \g_@@_struct_cur_seq { -\tag_get:n {struct_num} } + } + \tag_mc_begin:n{} + } } % \end{macrocode} % \end{plugdecl} @@ -363,8 +445,11 @@ % \begin{macrocode} \NewSocketPlug{tagsupport/tbl/cell/end}{TD} { - \tag_mc_end: - \tag_struct_end: + \@@_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int } + { + \tag_mc_end: + \tag_struct_end: + } } % \end{macrocode} % \end{plugdecl} @@ -376,18 +461,26 @@ \NewSocketPlug{tagsupport/tbl/pcell/begin}{TDpbox} { \@@_show_curr_cell_data: - \tag_struct_begin:n + \@@_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int } { - tag =\l__tbl_pcelltag_tl, - attribute-class =\l__tbl_cellattribute_tl - } - \seq_gput_right:Ne \g__tbl_struct_cur_seq { \tag_get:n {struct_num} } - \int_step_inline:nn { \g__tbl_span_tl - 1 } - { - \seq_gput_right:Ne \g__tbl_struct_cur_seq { -\tag_get:n {struct_num} } - } - \tagpdfparaOn - \tl_set:Nn \l__tag_para_main_tag_tl {Div} + \clist_if_in:NVT \l_@@_header_columns_clist\g_@@_col_int + { + \tl_set:Nn \l_@@_celltag_tl {TH} + \tl_set:Ne \l_@@_cellattribute_tl {\l_@@_cellattribute_tl,TH-row} + } + \tag_struct_begin:n + { + tag =\l_@@_pcelltag_tl, + attribute-class ={\l_@@_cellattribute_tl} + } + \seq_gput_right:Ne \g_@@_struct_cur_seq { \tag_get:n {struct_num} } + \int_step_inline:nn { \g_@@_span_tl - 1 } + { + \seq_gput_right:Ne \g_@@_struct_cur_seq { -\tag_get:n {struct_num} } + } + \tagpdfparaOn + \tl_set:Nn \l__tag_para_main_tag_tl {Div} + } } % \end{macrocode} % \end{plugdecl} @@ -396,7 +489,12 @@ % \begin{macrocode} \NewSocketPlug{tagsupport/tbl/pcell/end}{TDpbox} { - \tag_struct_end: + \@@_if_tag_cell:nnT {\g_@@_row_int } { \g_@@_col_int } + { + \tag_struct_end: + \legacy_if:nT {@endpe}{\par} + \mode_if_vertical:T{ \tagpdfparaOff } + } } % \end{macrocode} % \end{plugdecl} @@ -432,7 +530,7 @@ { \@@_trace:n {==>~ - stucture~stored~for~row~\int_use:N\g_@@_row_int :~ + structure~stored~for~row~\int_use:N\g_@@_row_int :~ \seq_use:Nn \g_@@_struct_cur_seq {,} } } @@ -447,21 +545,49 @@ % normal tables which can also be used inline and nested and % \enquote{vmode} tables like longtable. % +% \begin{macro}{\l__tag_block_flattened_level_int} +% Count the levels of nested blockenvs starting with the first that +% is \enquote{flattened}. The counter is defined in lttagging.dtx, +% but until the next release 11/24 we set it up here too so that we can +% use it in the following socket +% \begin{macrocode} +\int_if_exist:NF \l__tag_block_flattened_level_int + { + \int_new:N \l__tag_block_flattened_level_int + } +% \end{macrocode} +% \end{macro} +% +% \begin{plugdecl}{Table} +% Inside a TD or TR Part is not allowed as child. For structures that restore +% paragraph settings we therefore need a special plug that adjust the settings. +% Currently we set the para main tag to Div. This leads to double Div-structures +% but flattening the paragraph doesn't work, it errors if there is a list inside. +% \begin{macrocode} +\NewSocketPlug{tagsupport/para/restore}{Table} + { + \tl_set:Nn \l__tag_para_main_tag_tl {Div} + \tl_set_eq:NN \l__tag_para_tag_tl\l__tag_para_tag_default_tl + \bool_set_true:N \l__tag_para_bool + \bool_set_false:N \l__tag_para_flattened_bool + \int_zero:N \l__tag_block_flattened_level_int + } +% \end{macrocode} +% \end{plugdecl} +% % \begin{plugdecl}{Table} % Inside a table we currently only disable paratagging. We assume -% that these sockets are in an environment group, so there is no +% that these sockets are called in a group, so there is no % need to reenable paratagging. % \begin{macrocode} \NewSocketPlug{tagsupport/tbl/init}{Table} { - \tag_if_active:T - { - \bool_set_false:N \l__tag_para_bool + \bool_set_false:N \l__tag_para_bool + \AssignSocketPlug{tagsupport/para/restore}{Table} % \end{macrocode} % We also initialize the structure data variables a this point. % \begin{macrocode} - \@@_init_struct_data: - } + \@@_init_struct_data: } % \end{macrocode} % \end{plugdecl} @@ -573,7 +699,7 @@ \prop_if_exist:cT { g__tag_struct_ \l_@@_tmpa_tl _prop } { - \exp_args:No \__tag_struct_prop_gput:nnn {\l_@@_tmpa_tl} {S}{/Artifact} + \__tag_struct_prop_gput:onn { \l_@@_tmpa_tl } {S}{/Artifact} } } } @@ -664,7 +790,7 @@ \prop_if_exist:cT { g__tag_struct_ \l_@@_tmpa_tl _prop } { - \exp_args:No\__tag_struct_prop_gput:nnn {\l_@@_tmpa_tl} {S}{/Artifact} + \__tag_struct_prop_gput:onn {\l_@@_tmpa_tl} {S}{/Artifact} } } } @@ -711,7 +837,7 @@ \tag_mc_end_push: % \end{macrocode} % Close the P-chunk. This assumes that para-tagging is active. -% For nested tables that is not necessarly true, so we test for it. +% For nested tables that is not necessarily true, so we test for it. % \begin{macrocode} \bool_lazy_and:nnT { \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool } @@ -729,7 +855,7 @@ \tag_struct_end: % \end{macrocode} % reopen the P-chunk. This assumes that para-tagging is active. -% For nested tables that is not necessarly true, so we test for it. +% For nested tables that is not necessarily true, so we test for it. % \begin{macrocode} \bool_lazy_and:nnT { \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool } @@ -778,15 +904,32 @@ {/O /Table /ColSpan~\int_eval:n{#1}} } \tl_set:Ne \l_@@_cellattribute_tl - {colspan-\int_eval:n{#1}} + {\l_@@_cellattribute_tl,colspan-\int_eval:n{#1}} } } % \end{macrocode} -% TODO: move to tagpdf +% \end{plugdecl} +% +% +% +% +% \begin{plugdecl}{code} +% The sockets will be in lttagging.dtx, but that may only happen in +% the next main release, so for now we test if they are in the +% format and if not define them now. +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/tbl/leaders/end_plug_str } + { + \NewSocket{tagsupport/tbl/leaders/begin}{0} + \NewSocket{tagsupport/tbl/leaders/end}{0} + } +% \end{macrocode} +% % \begin{macrocode} -\tag_if_active:T - { \cs_generate_variant:Nn \__tag_attr_new_entry:nn {ee} } - +\NewSocketPlug{tagsupport/tbl/leaders/begin}{code} + { \tag_mc_begin:n{artifact} } +\NewSocketPlug{tagsupport/tbl/leaders/end}{code} + { \tag_mc_end: } % \end{macrocode} % \end{plugdecl} % @@ -810,8 +953,7 @@ % \subsection{Interfaces to tagging} % % \subsubsection{Tagging helper commands} -% -% + % \subsubsection{Disabling/enabling} % % For now we have only the option true/false but this will probably be extended @@ -839,6 +981,8 @@ \AssignSocketPlug{tagsupport/tbl/vmode/begin}{noop} \AssignSocketPlug{tagsupport/tbl/vmode/end}{noop} \AssignSocketPlug{tagsupport/tbl/colspan}{noop} + \AssignSocketPlug{tagsupport/tbl/leaders/begin}{noop} + \AssignSocketPlug{tagsupport/tbl/leaders/end}{noop} } % \end{macrocode} % \end{macro} @@ -866,6 +1010,8 @@ \AssignSocketPlug{tagsupport/tbl/vmode/begin}{Table} \AssignSocketPlug{tagsupport/tbl/vmode/end}{Table} \AssignSocketPlug{tagsupport/tbl/colspan}{code} + \AssignSocketPlug{tagsupport/tbl/leaders/begin}{code} + \AssignSocketPlug{tagsupport/tbl/leaders/end}{code} } % \end{macrocode} % \end{macro} @@ -886,14 +1032,15 @@ \tl_set:Nn\l_@@_pcelltag_tl {NonStruct} \tl_set:Nn\l_@@_celltag_tl {text} \tl_set:Nn\l_@@_tabletag_tl {Div} - \clist_clear:N \l_@@_header_rows_clist + \clist_clear:N \l_@@_header_rows_clist + \clist_clear:N \l_@@_header_columns_clist }, table/tagging .default:n = true, table/tagging .initial:n = true } % \end{macrocode} % This are the old key names kept for now for -% compability. They will got at some time. +% compatibility. They will got at some time. % \begin{macrocode} \keys_define:nn { __tag / setup } { @@ -955,11 +1102,12 @@ % \end{macrocode} % -% \begin{variable}{\l_@@_header_rows_clist} -% This holds the numbers of the header rows. Negative numbers are +% \begin{variable}{\l_@@_header_rows_clist,\l_@@_header_columns_clist} +% This holds the numbers of the header rows and columns. Negative numbers are % possible and count from the last column backwards. % \begin{macrocode} \clist_new:N \l_@@_header_rows_clist +\clist_new:N \l_@@_header_columns_clist % \end{macrocode} % \end{variable} % @@ -982,14 +1130,26 @@ { \__tag_struct_prop_gput:nnn{ ####1 }{S}{/TH} % \end{macrocode} -% This need refinement once row headers (and perhaps other attributes) -% are used too, but for now it should be ok. +% This sets the scope class. If the header has already a row attribute +% we replace by TH-both. % \begin{macrocode} \prop_get:cnNTF { g__tag_struct_####1_prop } { C } \l_@@_tmpa_tl - {\__tag_struct_prop_gput:nne{ ####1 }{C}{[/TH-col~\l_@@_tmpa_tl]} } + { + \str_set:Ne \l_@@_tmpa_str {\l_@@_tmpa_tl} + \str_remove_once:Nn \l_@@_tmpa_str {[} + \str_remove_once:Nn \l_@@_tmpa_str {]} + \str_if_in:NnTF\l_@@_tmpa_str{/TH-row} + { + \str_replace_once:Nnn \l_@@_tmpa_str {/TH-row}{/TH-both} + \__tag_struct_prop_gput:nne{ ####1 }{C}{[\l_@@_tmpa_str]} + } + { + \__tag_struct_prop_gput:nne{ ####1 }{C}{[/TH-col~\l_@@_tmpa_str]} + } + } {\__tag_struct_prop_gput:nnn{ ####1 }{C}{/TH-col}} } } @@ -1004,6 +1164,7 @@ \keys_define:nn { __tag / setup } { table/header-rows .clist_set:N = \l_@@_header_rows_clist, + table/header-columns .clist_set:N = \l_@@_header_columns_clist, % \end{macrocode} % obsolete older name: % \begin{macrocode} @@ -1011,8 +1172,114 @@ } % \end{macrocode} % +% \subsection{Multirow support} +% +% \begin{macro}{\@@_multirow:n} +% This command makes the current cell into a multirow cell: +% it creates, if needed, an RowSpan-attribute, adds it to the attributes +% of the cell structure, and marks all following cells spanned by the multirow +% as cells that should not be tagged. The argument is the number of spanned row +% (including the current row). +% \begin{macrocode} +\cs_if_exist:NT \__tag_struct_prop_gput:nnn + { + \cs_generate_variant:Nn \__tag_struct_prop_gput:nnn {one} + } +\cs_new_protected:Npn \@@_multirow:n #1 + { +% \end{macrocode} +% Create an attribute if needed: +% \begin{macrocode} + \prop_get:NeNF \g__tag_attr_entries_prop + {rowspan-\int_eval:n{#1}} + \l_@@_tmpa_tl + { + \__tag_attr_new_entry:ee + {rowspan-\int_eval:n{#1}} + {/O /Table /RowSpan~\int_eval:n{#1}} + } +% \end{macrocode} +% ensure that the attribute is marked as used: +% \begin{macrocode} + \seq_gput_left:Ne\g__tag_attr_class_used_seq + {\pdf_name_from_unicode_e:n{rowspan-\int_eval:n{#1}}} +% \end{macrocode} +% Get the structure number of the current cell +% \begin{macrocode} + \seq_get_right:NN\g_@@_struct_cur_seq \l_@@_tmpb_tl +% \end{macrocode} +% If we are in a multicolumn the number can be negative and +% this must be changed +% \begin{macrocode} + \tl_set:Ne \l_@@_tmpb_tl { \int_abs:n{\l_@@_tmpb_tl} } +% \end{macrocode} +% no we must update an existing attribute. +% TODO: simplify this ... (see also colspan handling). +% \begin{macrocode} + \prop_get:cnNTF + { g__tag_struct_\l_@@_tmpb_tl _prop } + { C } + \l_@@_tmpa_tl + { + \tl_remove_once:Nn \l_@@_tmpa_tl {[} + \tl_remove_once:Nn \l_@@_tmpa_tl {]} + \__tag_struct_prop_gput:one{ \l_@@_tmpb_tl } + {C} + {[/rowspan-\int_eval:n{#1}~\l_@@_tmpa_tl]} + } + { + \__tag_struct_prop_gput:one{ \l_@@_tmpb_tl } + {C} + {[/rowspan-\int_eval:n{#1}]} + } +% \end{macrocode} +% Now mark the spanned cells that should be ignored. +% \begin{macrocode} + \@@_gset_untagged_row_cells:nn {#1-1}{\g_@@_span_tl} + } +% \end{macrocode} +% \end{macro} % +% \begin{macrocode} +\keys_define:nn{ __tag / setup } + { table/multirow .code:n = {\@@_multirow:n {#1} } + ,table/multirow .default:n = 1 + } +% \end{macrocode} % +% \begin{macro}{\@@_gset_untagged_row_cells:nn} +% This command stores the row and column numbers of the cells in the following row(s) +% that should not be tagged as they are a part of a rowspan. +% \begin{macrocode} +\cs_new_protected:Npn \@@_gset_untagged_row_cells:nn #1 #2 % #1 number of rows, #2 number of columns + { + \int_step_inline:nn {#1} + { + \int_step_inline:nn {#2} + { + \prop_gput:Nee \g_@@_untagged_cells_prop + { \int_eval:n {\g_@@_row_int + ##1},\int_eval:n{\g_@@_col_int + ####1 -1 } }{} + } + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_if_tag_cell:nn} +% We must be able to detect if a cell should be tagged. For this +% we define a conditional --- if more options are needed it can be extended. +% \begin{macrocode} +\prg_new_protected_conditional:Npnn\@@_if_tag_cell:nn #1 #2 %#1 row, #2 col + { T,TF } + { + \prop_get:NeNTF \g_@@_untagged_cells_prop + {\int_eval:n{#1},\int_eval:n{#2}}\l__tbl_tmpa_tl + { \prg_return_false:} + { \prg_return_true: } + } +% \end{macrocode} +% \end{macro} +% % \subsection{Misc stuff} % % \begin{macro}{\@@_show_curr_cell_data:} @@ -1037,13 +1304,6 @@ % cell of a row, but still inside that cell, so we use two % commands. The one adding is used in the row/end socket. % \begin{macrocode} -\NewSocket{tbl/celldata/missingcount}{1} -\NewSocketPlug{tbl/celldata/missingcount}{code}{\tbl_count_missing_cells:n{#1}} -\AssignSocketPlug{tbl/celldata/missingcount}{code} - -% \end{macrocode} -% -% \begin{macrocode} \cs_new:Npn \@@_add_missing_cells: { % \end{macrocode} @@ -1058,6 +1318,7 @@ additional~cell(s)~into~previous~row:} \int_step_inline:nn { \g_@@_missing_cells_int } { + \int_gincr:N\g_@@_col_int \UseTaggingSocket{tbl/cell/begin} \UseTaggingSocket{tbl/cell/end} } @@ -1164,9 +1425,9 @@ } \hbox to\z@{\hss\parbox[t]\LTcapwidth{% \reset@font - \tag_stop:n{caption} + \tag_suspend:n{caption} \sbox\@tempboxa{#1{#2:~}#3}% - \tag_start:n{caption} + \tag_resume:n{caption} \ifdim\wd\@tempboxa>\hsize #1{#2:~}#3% \else diff --git a/macros/latex/required/latex-lab/latex-lab-table.pdf b/macros/latex/required/latex-lab/latex-lab-table.pdf Binary files differindex 11416f56ac..0340fe0ce7 100644 --- a/macros/latex/required/latex-lab/latex-lab-table.pdf +++ b/macros/latex/required/latex-lab/latex-lab-table.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-testphase.dtx b/macros/latex/required/latex-lab/latex-lab-testphase.dtx index f0a6fe65d0..1134654cd6 100644 --- a/macros/latex/required/latex-lab/latex-lab-testphase.dtx +++ b/macros/latex/required/latex-lab/latex-lab-testphase.dtx @@ -47,7 +47,7 @@ % % Currently the values |phase-I|, |phase-II|, |phase-III| and |new-or| (bundles |new-or-1| % and |new-or-2|) are provided. -% |tagpdf| is an undocumented alias for |phase-II| which is kept for compability. +% |tagpdf| is an undocumented alias for |phase-II| which is kept for compatibility. % The value |math| combines various math related files. % % \StopEventually{\setlength\IndexMin{200pt} \PrintIndex } diff --git a/macros/latex/required/latex-lab/latex-lab-testphase.pdf b/macros/latex/required/latex-lab/latex-lab-testphase.pdf Binary files differindex be1f2e220f..20de31d599 100644 --- a/macros/latex/required/latex-lab/latex-lab-testphase.pdf +++ b/macros/latex/required/latex-lab/latex-lab-testphase.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-text.dtx b/macros/latex/required/latex-lab/latex-lab-text.dtx index fe9b6ababc..7ca99191dc 100644 --- a/macros/latex/required/latex-lab/latex-lab-text.dtx +++ b/macros/latex/required/latex-lab/latex-lab-text.dtx @@ -16,8 +16,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabtextdate{2023-07-20} -\def\ltlabtextversion{0.85a} +\def\ltlabtextdate{2024-09-18} +\def\ltlabtextversion{0.85b} %<*driver> \documentclass{l3doc} @@ -78,11 +78,11 @@ \tag_mc_end_push: \tag_struct_begin:n{tag=Span,actualtext=LaTeX} \tag_mc_begin:n{} - \tag_stop:n{LaTeX} + \tag_suspend:n{LaTeX} } \AddToHook{cmd/LaTeX/after} { - \tag_start:n{LaTeX} + \tag_resume:n{LaTeX} \tag_mc_end: \tag_struct_end: \tag_mc_begin_pop:n{} diff --git a/macros/latex/required/latex-lab/latex-lab-text.pdf b/macros/latex/required/latex-lab/latex-lab-text.pdf Binary files differindex 7a3ae27c86..54d4f02c79 100644 --- a/macros/latex/required/latex-lab/latex-lab-text.pdf +++ b/macros/latex/required/latex-lab/latex-lab-text.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-title.pdf b/macros/latex/required/latex-lab/latex-lab-title.pdf Binary files differindex 957ba9f7a3..471267e34a 100644 --- a/macros/latex/required/latex-lab/latex-lab-title.pdf +++ b/macros/latex/required/latex-lab/latex-lab-title.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-toc-hyperref-changes.pdf b/macros/latex/required/latex-lab/latex-lab-toc-hyperref-changes.pdf Binary files differindex ab8469f7f6..8f6be2f8d9 100644 --- a/macros/latex/required/latex-lab/latex-lab-toc-hyperref-changes.pdf +++ b/macros/latex/required/latex-lab/latex-lab-toc-hyperref-changes.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.dtx b/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.dtx index bb88ffdcb0..2934a26168 100644 --- a/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.dtx +++ b/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.dtx @@ -17,8 +17,8 @@ % for those people who are interested or want to report an issue. % % dates for latex-lab-kernel-changes.sty (pulled from various sources, see ins) -\def\ltlabkerneldate{2024-02-12} -\def\ltlabkernelversion{0.85c} +\def\ltlabkerneldate{2024-07-11} +\def\ltlabkernelversion{0.85d} %<*driver> \documentclass{l3doc} \EnableCrossrefs @@ -44,6 +44,11 @@ % % \providecommand\hook[1]{\texttt{#1}} % +% +% \ProvideDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} +% \ProvideDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl} +% \ProvideDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} +% % \begin{abstract} % \end{abstract} % @@ -68,67 +73,14 @@ % \end{macrocode} % % \subsection{Providing the counter representation \cs{theHxx} generally} -% [kernel?] -% -% The \cs{theHxx} representation allows to create a unique representation of a counter -% that is for example used to create destination names. It will also be needed -% to add |/Ref| keys to various tagging structures. It makes therefore sense -% to provide it by default as soon as a counter is created. The |\@addtoreset| change -% (taken also from hyperref) tries to ensure the counter stays unique if it is reset. -% -% At first we suppress the patches from hyperref: +% +% This has been moved to base. +% +% We still suppress the patches from hyperref: % \begin{macrocode} \def\hyper@nopatch@counter{} % \end{macrocode} -% -% \begin{macrocode} -\def\@definecounter#1{\expandafter\newcount\csname c@#1\endcsname - \setcounter{#1}\z@ - \global\expandafter\let\csname cl@#1\endcsname\@empty - \@addtoreset{#1}{@ckpt}% - \global\expandafter\let\csname p@#1\endcsname\@empty - \expandafter\gdef\csname theH#1\endcsname{\the\value{#1}}%new - \expandafter - \gdef\csname the#1\expandafter\endcsname\expandafter - {\expandafter\@arabic\csname c@#1\endcsname}} -\def\@addtoreset#1#2{\expandafter\@cons\csname cl@#2\endcsname {{#1}}% - \expandafter\gdef\csname theH#1\endcsname{\csname theH#2\endcsname.\the\value{#1}}% -} -% \end{macrocode} -% The following counters are defined in the kernel -% \begin{macrocode} -\gdef\theHenumi{\the\value{enumi}} -\gdef\theHenumii{\the\value{enumii}} -\gdef\theHenumiii{\the\value{enumiii}} -\gdef\theHenumiv{\the\value{enumiv}} -\gdef\theHequation{\the\value{equation}} -\gdef\theHfootnote{\the\value{footnote}} -\gdef\theHmpfootnote{\the\value{mpfootnote}} -% \end{macrocode} -% -% \subsection{Providing and updating \cs{@currentHref}} -% [kernel?] -% -% \cs{@currentHref} contains the current unique representation of a counter. -% It is useful also without hyperref as it allows to connect with a |/Ref| -% key a toc entry with the heading it refers too. So \cs{refstepcounter} -% is extended to update the command. This is done at the begin so that the -% hyperref code can still adapt it later (using the cmd/refstepcounter/after hook -% would be too late, and could also break with cleverref.) -% -% We also provide a kernel version that hyperref doesn't touch and so will never -% set a target. -% \begin{macrocode} -\def\@currentHref{} -\def\refstepcounter#1{\stepcounter{#1}% - \edef\@currentcounter{#1}% - \xdef\@currentHref {#1.\csname theH#1\endcsname}% - \protected@edef\@currentlabel - {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}% -} -\let\@kernel@refstepcounter\refstepcounter -% \end{macrocode} -% + % \subsection{Assigning the headings level numbers} % [kernel?] % @@ -160,17 +112,21 @@ % catch as much as possible, see also tagging issue \#20. This should work also % without hyperref. The property is defined in tagpdf-base, so the code would % work also without tagging but we add a test anyway, this is probably faster. +% TODO: remove % \begin{macrocode} \ExplSyntaxOn -\AddToHookWithArguments{cmd/MakeLinkTarget/after} - { - \tag_if_active:T - { - \tl_if_blank:VF \@currentHref - { - \prop_gput:Nee \g__tag_struct_dest_num_prop {\@currentHref}{\tag_get:n{struct_num}} - } - } +\str_if_exist:cF { l__socket_tagsupport/recordtarget_str } + { + \AddToHookWithArguments{cmd/MakeLinkTarget/after} + { + \tag_if_active:T + { + \tl_if_blank:VF \@currentHref + { + \prop_gput:Nee \g__tag_struct_dest_num_prop {\@currentHref}{\tag_get:n{struct_num}} + } + } + } } \ExplSyntaxOff % \end{macrocode} @@ -187,12 +143,24 @@ % \subsection{\cs{contentsline} extension} % [latex-lab] % The tagging code must add code at the begin and end of \cs{contentsline}. -% This code must have access to the arguments. We set it up as config point -% for now. +% This code must have access to the arguments. They are passed +% together in tagging socket. +% \begin{socketdecl}{tagsupport/toc/contentsline/before, +% tagsupport/toc/contentsline/after} +% Tagging sockets at the begin and end of contentsline. +% They receive \emph{all} contentsline arguments as one argument +% in four brace groups. The socket code should then use the parts it needs. +% The sockets will be in lttagging.dtx, but that may only happen in +% the next main release, so for now we test if they are in the +% format and if not define them now. % \begin{macrocode} -\def\@contentsline@cfgpoint@before#1#2#3#4{} -\def\@contentsline@cfgpoint@after#1#2#3#4{} +\str_if_exist:cF { l__socket_tagsupport/toc/contentsline/before_plug_str } + { + \NewSocket{tagsupport/toc/contentsline/before}{1} + \NewSocket{tagsupport/toc/contentsline/after}{1} + } % \end{macrocode} +% \end{socketdecl} % for the hooks we need that the \cs{l@XX} pass also the destination and % that \cs{l@XX} takes three arguments. % TODO: test that, if there are two many problems we should pass the @@ -200,10 +168,10 @@ % \begin{macrocode} \def\contentsline#1#2#3#4% {% - \@contentsline@cfgpoint@before{#1}{#2}{#3}{#4}% + \UseTaggingSocket{toc/contentsline/before}{{#1}{#2}{#3}{#4}}% \gdef\@contentsline@destination{#4}% \csname l@#1\endcsname{#2}{#3}% - \@contentsline@cfgpoint@after{#1}{#2}{#3}{#4}% + \UseTaggingSocket{toc/contentsline/after}{{#1}{#2}{#3}{#4}}% } % \end{macrocode} % @@ -225,17 +193,33 @@ % \subsection{\cs{@starttoc}} % [kernel?] % -% We add a configuration point before and after reading the file +% We add a tagging socket before and after reading the file % for the tagging. +% \begin{socketdecl}{tagsupport/toc/starttoc/before, +% tagsupport/toc/starttoc/after} +% Tagging sockets for the begin and end of start of \cs{@starttoc}. +% They take one argument, the extension. +% The sockets will be in lttagging.dtx, but that may only happen in +% the next main release, so for now we test if they are in the +% format and if not define them now. +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/toc/starttoc/before_plug_str } + { + \NewSocket{tagsupport/toc/starttoc/before}{1} + \NewSocket{tagsupport/toc/starttoc/after}{1} + } +% \end{macrocode} +% \begin{macrocode} +% \end{macrocode} +% \end{socketdecl} +% % \begin{macrocode} -\def\@starttoc@cfgpoint@before#1{} -\def\@starttoc@cfgpoint@after#1{} \def\@starttoc#1{% \begingroup \makeatletter - \@starttoc@cfgpoint@before{#1}% + \UseTaggingSocket{toc/starttoc/before}{#1}% \@input{\jobname.#1}% - \@starttoc@cfgpoint@after{#1}% + \UseTaggingSocket{toc/starttoc/after}{#1}% \if@filesw \expandafter\newwrite\csname tf@#1\endcsname \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax @@ -269,15 +253,32 @@ \NewMirroredHookPairWithArguments{contentsline/page/before}{contentsline/page/after}{4}% % \end{macrocode} % -% The dot in the leader must be set as artifact. +% The dots in the leader must be set as artifact. % But luatex requires that the mc are set outside the leaders. -% So we need a config point. +% So we need sockets. % % \cs{@dottedtocline} needs hooks and formatting commands. -% We add a sixth argument so that it can grab the destination too. +% To make the leaders into artifact we use tagging sockets. +% The declaration should perhaps be moved into lttagging so that +% it can be used also by external packages even if the tagging code is not +% loaded? +% \begin{socketdecl}{tagsupport/toc/leaders/before, +% tagsupport/toc/leaders/after} +% Tagging sockets to make the dot leaders an artifact. +% They do not take an argument. +% The sockets will be in lttagging.dtx, but that may only happen in +% the next main release, so for now we test if they are in the +% format and if not define them now. +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/toc/leaders/before_plug_str } + { + \NewSocket{tagsupport/toc/leaders/before}{0} + \NewSocket{tagsupport/toc/leaders/after}{0} + } +% \end{macrocode} +% \end{socketdecl} +% The destination is accessed through \cs{@contentsline@destination}. % \begin{macrocode} -\def\@dottedtocline@cfgpoint@leaders#1{#1} - \def\@dottedtocline#1#2#3#4#5{% \ifnum #1>\c@tocdepth \else \vskip \z@ \@plus.2\p@ @@ -291,10 +292,11 @@ \csname contentsline@text@#1@format\endcsname{#4}% \UseHookWithArguments{contentsline/text/after}{4}{#1}{#4}{#5}{\@contentsline@destination}% \nobreak - \@dottedtocline@cfgpoint@leaders{% + \UseTaggingSocket{toc/leaders/before}\SuspendTagging{toc/leaders}% \leaders\hbox{$\m@th \mkern \@dotsep mu\hbox{.}\mkern \@dotsep - mu$}\hfill}% + mu$}\hfill + \ResumeTagging{toc/leaders}\UseTaggingSocket{toc/leaders/after}% \nobreak \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor \UseHookWithArguments{contentsline/page/before}{4}{#1}{#4}{#5}{\@contentsline@destination}% diff --git a/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.pdf b/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.pdf Binary files differindex 386a193381..2e3cbedb31 100644 --- a/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.pdf +++ b/macros/latex/required/latex-lab/latex-lab-toc-kernel-changes.pdf diff --git a/macros/latex/required/latex-lab/latex-lab-toc.dtx b/macros/latex/required/latex-lab/latex-lab-toc.dtx index 7235eb9ed9..15dd403bdf 100644 --- a/macros/latex/required/latex-lab/latex-lab-toc.dtx +++ b/macros/latex/required/latex-lab/latex-lab-toc.dtx @@ -16,8 +16,8 @@ % % for those people who are interested or want to report an issue. % -\def\ltlabtocdate{2023-10-16} -\def\ltlabtocversion{0.85b} +\def\ltlabtocdate{2024-09-26} +\def\ltlabtocversion{0.85e} %<*driver> \documentclass{l3doc} \EnableCrossrefs @@ -42,7 +42,10 @@ % \newcommand{\docclass}{document class \marginpar{\raggedright document class % customizations}} % -% \providecommand\hook[1]{\texttt{#1}} +% +% \ProvideDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl} +% \ProvideDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl} +% \ProvideDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl} % % \begin{abstract} % \end{abstract} @@ -111,66 +114,32 @@ % Defined by tagpdf. % \end{variable} % -% \cs{refstepcounter} doesn't use \cs{MakeLinkTarget} (yet) so -% we have to patch it too to store the relation between -% destination names/\cs{@currentHref} and structure numbers +% We have to to store the relation between +% destination names/\cs{@currentHref} and structure numbers. +% With a current kernel this is done in \cs{refstepcounter} +% through the |recordtarget| socket. If that doesn't exist yet +% we patch: % -% The property is set up in tagpdf-test so that one -% doesn't has to check if the prop exists or not. +% TODO remove after release 2024/11 % \begin{macrocode} -\AddToHook{cmd/refstepcounter/after} - { - \tl_if_blank:VF \@currentHref - { - \prop_gput:Nee \g_@@_struct_dest_num_prop {\@currentHref}{\tag_get:n{struct_num}} - } - } -\AddToHook{cmd/H@refstepcounter/after} - { - \tl_if_blank:VF \@currentHref - { - \prop_gput:Nee \g_@@_struct_dest_num_prop {\@currentHref}{\tag_get:n{struct_num}} - } - } -% \end{macrocode} -% \begin{variable}{\g_@@_struct_ref_by_dest_prop} -% This variable contains structures whose Ref key should be updated -% at the end to point to structured related with this destination. -% As this is probably need in other places too, it is not only a toc-variable. -% Moved into tagpdf! -% \end{variable} -% -% \begin{macro}{\g_@@_struct_ref_by_dest:} -% This command is executed and update the Ref keys -% of the structures listed in |\g_@@_struct_ref_by_dest_prop|. -% It is currently only relevant for the |TOCI|. But other structures -% could need that later too. -% The command is executed in the |tagpdf/finish/before| hook. -% \begin{macrocode} -\msg_new:nnn { tag } {struct-dest-unknown} - { - Destination~#1~has~no~related~structure.\\ - /Ref~for~structure~#2~not~updated - } - -\cs_new_protected:Npn \g_@@_struct_ref_by_dest: +\str_if_exist:cF { l__socket_tagsupport/recordtarget_plug_str } { - \prop_map_inline:Nn\g_@@_struct_ref_by_dest_prop - { - \prop_get:NnNTF \g_@@_struct_dest_num_prop {##2} \l_@@_tmpa_tl - { - \@@_struct_gput_data_ref:ee - { ##1 } - { \tag_struct_object_ref:e{ \l_@@_tmpa_tl }} - } - { - \msg_warning:nnnn {tag}{struct-dest-unknown}{##2}{ ##1} - } - } - } -\hook_gput_code:nnn {tagpdf/finish/before}{tagpdf/struct/Ref}{\g_@@_struct_ref_by_dest:} + \AddToHook{cmd/refstepcounter/after} + { + \tl_if_blank:VF \@currentHref + { + \prop_gput:Nee \g_@@_struct_dest_num_prop {\@currentHref}{\tag_get:n{struct_num}} + } + } + \AddToHook{cmd/H@refstepcounter/after} + { + \tl_if_blank:VF \@currentHref + { + \prop_gput:Nee \g_@@_struct_dest_num_prop {\@currentHref}{\tag_get:n{struct_num}} + } + } + } % \end{macrocode} -% \end{macro} % % \section{Toc code} % \begin{variable}{\g_@@_toc_level_int,\g_@@_toc_stack_seq} @@ -196,14 +165,17 @@ \tag_struct_begin:n{tag=TOC,title=#1} } % \end{macrocode} -% Now map it into the config point: +% \end{macro} +% Now define the tagging plug and assign it to the socket. +% \begin{plugdecl}{default} % \begin{macrocode} -\cs_set_protected:Npn\@starttoc@cfgpoint@before#1 - { - \@@_toc_starttoc_init:n{#1} - } +\NewSocketPlug{tagsupport/toc/starttoc/before}{default} + { + \@@_toc_starttoc_init:n{#1} + } +\AssignSocketPlug{tagsupport/toc/starttoc/before}{default} % \end{macrocode} -% \end{macro} +% \end{plugdecl} % \begin{macro}{\@@_toc_starttoc_finalize:} % \begin{macrocode} \cs_new_protected:Npn \@@_toc_starttoc_finalize: @@ -215,15 +187,18 @@ \seq_gclear:N \g_@@_toc_stack_seq } % \end{macrocode} -% Now map it into the config point: +% \end{macro} +% Now define the tagging plug and assign it to the socket. +% \begin{plugdecl}{default} % \begin{macrocode} -\cs_set_protected:Npn\@starttoc@cfgpoint@after#1 - { - \@@_toc_starttoc_finalize: - } +\NewSocketPlug{tagsupport/toc/starttoc/after}{default} + { + \@@_toc_starttoc_finalize: + } +\AssignSocketPlug{tagsupport/toc/starttoc/after}{default} % \end{macrocode} -% \end{macro} - +% \end{plugdecl} +% % \begin{macro}{\@@_toc_end:n} % This commands ends all TOC on the stack with a level higher than the argument % \begin{macrocode} @@ -249,10 +224,11 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_toc_contentsline_begin:nnn} +% \begin{macro}{\@@_toc_contentsline_begin:nnnn} % This is main command executed at the begin of a |\contentsline|. % \begin{macrocode} -\cs_new_protected:Npn \@@_toc_contentsline_begin:nnn #1 #2 #3 %#1 level, #2 content, #3 destination +\cs_new_protected:Npn \@@_toc_contentsline_begin:nnnn #1 #2 #3 #4 + %#1 level, #2 content, #3 page number (unused) #4 destination { \tag_if_active:T { @@ -298,40 +274,44 @@ % \begin{macrocode} \group_begin: \text_declare_expand_equivalent:Nn \numberline \use_none:n - \exp_args:Ne \tag_struct_begin:n{tag=TOCI,title={\text_purify:n {#2}}} + \exp_args:Ne + \tag_struct_begin:n{tag=TOCI,title={\text_purify:n {#2}}} % \end{macrocode} -% The TOCI structure should get a /Ref, so we put a request with its destination -% name into the prop. +% The TOCI structure should get a /Ref, we use a destination +% to retrieve it. % \begin{NOTE}{UF} % This only works with hyperref currently. Without hyperref we % need to store fake names. % \end{NOTE} % \begin{macrocode} - \prop_gput:Nee \g_@@_struct_ref_by_dest_prop - { \tag_get:n {struct_num} }{#3} + \tag_struct_gput:nnn { \tag_get:n {struct_num} }{ref_dest}{#4} \seq_gpush:Ne \g_@@_toc_stack_seq {{TOCI}\use:c{toclevel@#1}} \group_end: } } } % \end{macrocode} -% Now map it into the config point: +% \end{macro} +% Now define the tagging plug and assign it to the socket. +% \begin{plugdecl}{default} % \begin{macrocode} -\cs_set_protected:Npn\@contentsline@cfgpoint@before#1#2#3#4 +\NewSocketPlug{tagsupport/toc/contentsline/before}{default} { - \@@_toc_contentsline_begin:nnn {#1}{#2}{#4} - } + \@@_toc_contentsline_begin:nnnn #1 + } +\AssignSocketPlug{tagsupport/toc/contentsline/before}{default} % \end{macrocode} -% \end{macro} +% \end{plugdecl} % -% \begin{macro}{\@@_toc_contentsline_end:n} +% \begin{macro}{\@@_toc_contentsline_end:nnnn} % This is the closing code of a |\contentsline|. % If the contentsline was actually printed, the code has to % close the TOCI structure and to update the stack. % \begin{macrocode} \msg_new:nnn {tag}{toc-no-TOCI}{Missing~TOCI~structure~on~toc~stack} -\cs_new_protected:Npn \@@_toc_contentsline_end:n #1 %#1 level name +\cs_new_protected:Npn \@@_toc_contentsline_end:nnnn #1 #2 #3 #4 +% #1 level, #2 content (unused), #3 page number (unused) #4 destination (unused) { \int_compare:nNnF { \use:c{toclevel@#1} } > {\use:c{c@tocdepth}} { @@ -348,14 +328,17 @@ } } % \end{macrocode} -% Now we map it to the config point +% \end{macro} +% Now define the tagging plug and assign it to the socket. +% \begin{plugdecl}{default} % \begin{macrocode} -\cs_set_protected:Npn \@contentsline@cfgpoint@after #1#2#3#4 - { - \@@_toc_contentsline_end:n {#1} - } +\NewSocketPlug{tagsupport/toc/contentsline/after}{default} + { + \@@_toc_contentsline_end:nnnn #1 + } +\AssignSocketPlug{tagsupport/toc/contentsline/after}{default} % \end{macrocode} -% \end{macro} +% \end{plugdecl} % % \subsection{Tagging of the content} % This need discussion. @@ -380,12 +363,16 @@ \tag_struct_end: \tag_mc_begin:n{tag=Reference}} % \end{macrocode} -% +% \begin{plugdecl}{artifact} % \begin{macrocode} -\def\@dottedtocline@cfgpoint@leaders#1{% - \tag_mc_begin:n{artifact}\tag_stop:n{leaders}\nobreak#1\nobreak\tag_start:n{leaders}\tag_mc_end:} +\NewSocketPlug{tagsupport/toc/leaders/before}{artifact} + {\tag_mc_begin:n{artifact}\nobreak} +\NewSocketPlug{tagsupport/toc/leaders/after}{artifact} + {\nobreak\tag_mc_end:} +\AssignSocketPlug{tagsupport/toc/leaders/before}{artifact} +\AssignSocketPlug{tagsupport/toc/leaders/after}{artifact} % \end{macrocode} - +% \end{plugdecl} % % \begin{macrocode} %</package> diff --git a/macros/latex/required/latex-lab/latex-lab-toc.pdf b/macros/latex/required/latex-lab/latex-lab-toc.pdf Binary files differindex fe8b2a89ac..023c05e58e 100644 --- a/macros/latex/required/latex-lab/latex-lab-toc.pdf +++ b/macros/latex/required/latex-lab/latex-lab-toc.pdf diff --git a/macros/latex/required/latexbug/changes.txt b/macros/latex/required/latexbug/changes.txt index 034f3d7fe5..990fc8a92a 100644 --- a/macros/latex/required/latexbug/changes.txt +++ b/macros/latex/required/latexbug/changes.txt @@ -1,3 +1,8 @@ +2024-07-16 Yukai Chou <muzimuzhi@gmail.com> + + * latexbug.dtx: + Add historic package versions owned by "us(*)" + 2024-06-17 Frank Mittelbach <Frank.Mittelbach@latex-project.org> * latexbug.dtx: diff --git a/macros/latex/required/latexbug/latexbug.dtx b/macros/latex/required/latexbug/latexbug.dtx index da0a7c995c..64a6ffbc0c 100644 --- a/macros/latex/required/latexbug/latexbug.dtx +++ b/macros/latex/required/latexbug/latexbug.dtx @@ -267,7 +267,7 @@ % \begin{macrocode} %<*package> \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{latexbug}[2024/06/17 v1.0o Bug-classification] +\ProvidesPackage{latexbug}[2024/07/16 v1.0p Bug-classification] % \end{macrocode} % % \begin{macro}{\latexbug@empty} @@ -372,6 +372,8 @@ cp858.def = us , cp865.def = us , decmulti.def = us , doc-v3beta.sty = us , +doc-2016-02-15.sty = us, +doc-2021-06-01.sty = us, doc.sty = us , docstrip.tex = us , exscale.sty = us , @@ -518,6 +520,7 @@ x2enc.dfu = us , afterpage.sty = us , array-2016-10-06.sty = us , array-2020-02-10.sty = us , +array-2023-11-01.sty = us , array.sty = us , bm.sty = us , calc.sty = us , @@ -535,12 +538,14 @@ layout.sty = us , longtable-2020-01-07.sty = us , longtable.sty = us , multicol-2017-04-11.sty = us , +multicol-2019-10-01.sty = us , multicol.sty = us , q.tex = us , r.tex = us , rawfonts.sty = us , s.tex = us , shellesc.sty = us , +showkeys-2014-10-28.sty = us , showkeys.sty = us , somedefs.sty = us , tabularx.sty = us , @@ -557,6 +562,7 @@ varioref.sty = us , verbatim.sty = us , verbtest.tex = us , x.tex = us , +xr-2023-07-04.sty = us , xr.sty = us , xspace.sty = us , %--------------------------------- babel (locale files) @@ -1601,6 +1607,7 @@ l3str-enc-iso88599.def = us* , xcoffins.sty = us* , xgalley.sty = us* , xparse.sty = us* , +xtemplate-2023-10-10.sty = us* , xtemplate.sty = us* , %--------------------------------- TAGGING PROJECT pdfmanagement-testphase.sty = us* diff --git a/macros/latex/required/latexbug/latexbug.pdf b/macros/latex/required/latexbug/latexbug.pdf Binary files differindex 7d71a756db..b6ee633e01 100644 --- a/macros/latex/required/latexbug/latexbug.pdf +++ b/macros/latex/required/latexbug/latexbug.pdf diff --git a/macros/latex/required/tools/README.md b/macros/latex/required/tools/README.md index ca735824e0..21a3594585 100644 --- a/macros/latex/required/tools/README.md +++ b/macros/latex/required/tools/README.md @@ -1,7 +1,7 @@ The LaTeX `tools` bundle ======================== -Release 2024-06-01a +Release 2024-11-01 Overview -------- diff --git a/macros/latex/required/tools/afterpage.pdf b/macros/latex/required/tools/afterpage.pdf Binary files differindex 6f5022e586..25768e1c76 100644 --- a/macros/latex/required/tools/afterpage.pdf +++ b/macros/latex/required/tools/afterpage.pdf diff --git a/macros/latex/required/tools/array.dtx b/macros/latex/required/tools/array.dtx index b1dd336225..f4c8ab28d8 100644 --- a/macros/latex/required/tools/array.dtx +++ b/macros/latex/required/tools/array.dtx @@ -39,7 +39,7 @@ % \begin{macrocode} %<+package>\NeedsTeXFormat{LaTeX2e}[2024/06/01] %<+package>\ProvidesPackage{array} -%<+package> [2024/06/14 v2.6d Tabular extension package (FMi)] +%<+package> [2024/10/17 v2.6g Tabular extension package (FMi)] % % \fi % @@ -259,7 +259,7 @@ % \begin{table}[!t] % \begin{center} % \setlength{\extrarowheight}{1pt} -% \begin{tabular}{|>{\tt}c|m{9cm}|} +% \begin{tabular}{|>{\ttfamily}c|m{9cm}|} % \hline % \multicolumn{2}{|c|}{Unchanged options}\\ % \hline @@ -382,6 +382,20 @@ % \end{itemize} % % +% +% \subsection{A note on the allowed content of \texttt{>\{...\}} and +% \texttt{<\{...\}}} +% +% These specifiers are meant to hold declarations, such as +% \verb=>{\itshape}=. They cannot end in commands that take arguments +% without providing these arguments as part of the \verb={...}=. It +% would be a mistaken assumption that they pick up all or parts of the +% alignment entry data if their argument is not provided. E.g., +% \verb=>{\textbf}= would not make the whole column bold nor would it +% make the first character bold (technically it would try to +% bolden \cs{ignorespaces}). Thus, it would not fail with an error, +% but effectively the output would be wrong and not as expected. +% % \subsection{The behavior of the \texttt{\string\\} command} % % In the basic \texttt{tabular} implementation of \LaTeX{} the \cs{\bslash} @@ -464,16 +478,16 @@ % "\newcolumntype{L}{>{$}l<{$}}" \\ % "\newcolumntype{R}{>{$}r<{$}}" % \end{quote} -% Then we can use \texttt{C} to get centred LR-mode in an -% \texttt{array}, or centred math-mode in a \texttt{tabular}. +% Then we can use \texttt{C} to get centered LR-mode in an +% \texttt{array}, or centered math-mode in a \texttt{tabular}. % -% The example given above for `centred decimal points' could be +% The example given above for `center decimal points' could be % assigned to a \texttt{d} specifier with the following command. % \begin{quote} % "\newcolumntype{d}{>{\centerdots}c<{\endcenterdots}}" % \end{quote} % -% The above solution always centres the dot in the +% The above solution always centers the dot in the % column. This does not look too good if the column consists of large % numbers, but to only a few decimal places. An alternative definition % of a \texttt{d} column is @@ -715,7 +729,7 @@ % % A similar problem happened when "\extrarowheight" was used. For that % reason m-cells now manually position the cell content which -% allows to ignore this extra space request during the vertical aligment. +% allows to ignore this extra space request during the vertical alignment. % % % \subsection{Bugs and Features} @@ -734,7 +748,7 @@ % user the opportunity of overriding the settings of a % "\newcolumntype" defined using these declarations. For example, % suppose in an \texttt{array} environment we use a \texttt{C} -% column defined as above. The \texttt{C} specifies a centred text +% column defined as above. The \texttt{C} specifies a centered text % column, however ">{\bfseries}C", which re-writes to % ">{\bfseries}>{$}c<{$}" would not specify a bold column as might % be expected, as the preamble would essentially expand to @@ -896,14 +910,14 @@ Bug reports can be opened (category \texttt{#1}) at\\% % % \section{A note on the updates done December 2023} % -% We introduced support for tagged PDf and at the same time we added +% We introduced support for tagged PDF and at the same time we added % code to determine row and column numbers for each cell in % preparation for supporting formatting or type specifications for individual % cells (or group of cells) from the outside, e.g., \enquote{rows 1, % 2, and 10 are header rows} (syntax to be decided). % % This new code is already written with L3 programming layer conventions -% while most of the legay code is still as it was before. This make the code +% while most of the legacy code is still as it was before. This make the code % currently somewhat clattered, unfortunately. Eventually this will all move to L3 % programming layer but this will take time. % @@ -1345,7 +1359,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % of \textsf{token} register $15$ instead of $1$ later on. % % The example above referred to an older version of =\save@decl= which -% inserted a =\relex= inside the token register. This is now moved to +% inserted a =\relax= inside the token register. This is now moved to % the places where the actual token registers are inserted (look for % =\the@toks=) because the old version would still make =@= % expressions to moving arguments since after expanding the second @@ -1373,6 +1387,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \begin{macro}{\insert@column} % \begin{macro}{\@sharp} % \begin{macro}{\textonly@unskip} +% \begin{macro}{\@protected@firstofone} % We now define the macro =\insert@column= which will do % this work for us. % \begin{macrocode} @@ -1385,10 +1400,116 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \begin{macrocode} \UseTaggingSocket{tbl/cell/begin}% % \end{macrocode} -% Here, we assume that the \textsf{count} register +% Next we have to insert the toks register holding the content of +% \verb=>{...}=. Here, we assume that the \textsf{count} register % =\@tempcnta= has saved the value $=\count@= - 1$. +% +% To keep \TeX{} happy if there is a look ahead in the tabular +% preamble, i.e., starting in \verb=>{...}=, which uses the +% Appendix~D trick (for example, anything with a trailing optional +% argument defined by \pkg{ltcmd}), we wrap everything here in a +% protected version of \cs{@firstofone}. \TeX{} otherwise can get +% confused about the value of the master counter, and we get some +% strange errors. We suspected that there was an underlying issue +% is the \TeX{} engine, but it turned out to be rather hard to get +% to the bottom of it, because the master counter is not accessible +% through \TeX{}'s tracing tools. Thus, all we could do was +% producing various example documents, observing results, as well +% as staring at a printout of the \TeX{} program. As an example, +% without this approach, something like +% \begin{verbatim} +% \NewDocumentCommand\foo{o}{x} +% \begin{tabular}{>{\foo}l} +% Foo +% \end{tabular} +% \end{verbatim} +% failed. That can be fixed by adding a \cs{relax} after the +% \cs{@tempcnta}, but that then leads to issues if you are +% collecting whole cells (tagging code or \pkg{collcell}), where +% you can no longer alter the meaning of \cs{cr} as the master +% counter goes wrong due to an obscure bug (or perhaps, say, an +% undocumented feature of \TeX{}). Eventually, we were able to pin +% down the root cause and really understand why +% \cs{@protected@firstofone} solves the problem, even though it +% looks like a nonsense addition to the code that does nothing +% useful.\footnote{So it is a \TeX{} engine bug that was in there +% from day one, or if you like, it is a hidden feature that is not +% explained; neither in the \TeX{}book nor in the program code. We +% don't really expect this to change in \TeX{} after such a long +% time, other than perhaps documenting it as a feature, so this is +% a proper solution to the problem and not just a workaround.} +% +% The problem is that \TeX{} tries to conserve stack space, and +% when the last token of an existing token list is a macro, then +% this token list is \emph{first} removed from memory (reducing the +% stack) \emph{before} the macro replacement text (as a new +% token list) is given to the parser adding a new stack level. This +% is done using the routine \texttt{end\_token\_list} in the \TeX{} +% program and ending the u-part of an \cs{halign} column with this +% routine immediately sets the \emph{master counter} used by alignments to +% zero (see chapter~22 and Appendix~D of the \TeX{}book). This +% means that technically the expansion of the last token in the u-part (if it +% is a macro) is not executed in the context of the u-part, but in +% the context of the alignment entry in the document. That normally +% doesn't make any difference whatsoever --- unless you play +% around (as we sometimes have to) with tricks like those from +% Appendix~D. +% +% To illustrate the issue we show a bit of strange low-level plain +% \TeX{} code.\footnote{If all of this looks mighty strange to you, +% don't worry. You will be unlikely to need to know about it. It is +% just there so that programmers at some point in the future do not +% have to wonder too much why there is this odd +% \cs{@protected@firstofone} that apparently does nothing +% useful. It took us several nights of head scratching to come up +% with these minimal examples and then some more time to understand +% what the heck is going on inside \TeX{}---thanks to Bruno for the +% right ideas on the latter.} Below are two very special grouping +% commands that are like \cs{bgroup} and \cs{egroup} but also +% affect the alignment master counter when expanded (see +% \TeX{}book p.385). If one of them is used as the +% last macro in the u-part of a column, then you get strange errors +% that you shouldn't get. +% \begin{verbatim} +% \def\bbgroup{{\ifnum0=`}\fi} +% \def\eegroup{\ifnum0=`{\fi}} +% +% % Fails with an error message, but there should be none: +% \halign{% +% \message{u-part^^J}% +% \bbgroup % <-- in the u-part +% \eegroup % <-- in the u-part +% #% +% \message{v-part^^J}% +% \hfill\cr +% \message{body^^J}x +% \cr +% } +% +% % Fails but should work, the v-part is never reached: +% \halign{% +% \message{u-part^^J}% +% \bbgroup % <-- in the u-part +% #% +% \message{v-part^^JJ}% +% \eegroup % <-- in the v-part +% \hfill\cr +% \message{body^^J}x +% \cr +% } +% \end{verbatim} +% +% So the trick we use now is making \cs{@protected@firstofone} the +% last macro in the u-part, i.e., before the \cs{@sharp}. That way +% its argument is always fully expanded as part of the alignment +% entry and not as part of the u-part and this way we know exactly +% what the master counter value is at this point, regardless of the content of +% \verb=>{...}=. +% +% \changes{v2.6f}{2024/09/13}{Stop parsing for optional argument (gh/1468)} +% \changes{v2.6g}{2024/10/12}{Further work to support optional args in preamble (gh/1468)} % \begin{macrocode} - \the@toks \the \@tempcnta + \@protected@firstofone { \the@toks \the \@tempcnta \ignorespaces } % \end{macrocode} % Next follows the =#= sign which specifies the place % where the text of the column shall be inserted. To avoid @@ -1396,14 +1517,16 @@ Bug reports can be opened (category \texttt{#1}) at\\% % =\@addtopreamble= we hide this sign in the command % =\@sharp= which is temporarily occupied with % =\relax= during the build-up of the preamble. -% To remove unwanted spaces before and after the column text, we set -% an =\ignorespaces= in front and a =\unskip= afterwards. +% To remove unwanted spaces before and after the column in text mode, +% we set an =\ignorespaces= in front (see above) and a =\unskip= +% afterwards; in math mode, the latter is suppressed while the +% \cs{ignorespaces} makes no difference. % \changes{v2.0e}{1991/02/07}{Added \{\} around \cs{@sharp} for new ftsel} -% \changes{v2.0h}{1992/06/22}{Removed \{\} again in favour of +% \changes{v2.0h}{1992/06/22}{Removed \{\} again in favor of % \cs{d@llarbegin}} % \changes{v2.6b}{2024/04/08}{Do not \cs{unskip} if in math mode (gh/1323)} % \begin{macrocode} - \ignorespaces \@sharp \textonly@unskip + \@sharp \textonly@unskip % \end{macrocode} % Then the second \textsf{token} register follows whose number should % be saved in =\count@=. @@ -1428,10 +1551,15 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \begin{macrocode} \protected\def\textonly@unskip{\ifhmode\unskip\fi} % \end{macrocode} +% \changes{v2.6g}{2024/10/12}{Further work to support optional args in preamble (gh/1468)} +% We need an engine-protected function that is just \cs{@firstofone}: +% \begin{macrocode} +\protected\long\def\@protected@firstofone#1{#1} +% \end{macrocode} +% \end{macro} % \end{macro} % \end{macro} % \end{macro} -% % % \begin{macro}{\insert@pcolumn} % Handling pcolumn-cells needs slightly different handling when @@ -1442,7 +1570,10 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \begin{macrocode} \def\insert@pcolumn{% \UseTaggingSocket{tbl/pcell/begin}% - \the@toks \the \@tempcnta +% \end{macrocode} +% \changes{v2.6f}{2024/09/13}{Stop parsing for optional argument (gh/1468)} +% \begin{macrocode} + \the@toks \the \@tempcnta \relax \ignorespaces \@sharp \unskip \the@toks \the \count@ \relax \UseTaggingSocket{tbl/pcell/end}% @@ -1882,7 +2013,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % For that reason the new implementation does the centering % manually: First we check the height of the cell and if that is % less or equal to =\ht\strutbox= we assume that this is a -% single line cell. In that case we don't do any vertical maneuvre +% single line cell. In that case we don't do any vertical maneuver % and simply output the box, i.e., make it behave like a single % line p-cell. % @@ -1900,7 +2031,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % is how much do we need to move down? If there is any % =\arraystretch= in place then the first line will have some % unusual height and we don't want to consider that when finding -% the middle point. So we substract from the cell height the height +% the middle point. So we subtract from the cell height the height % of that strut. But of course we want to include the normal height % of the first line (which would be something like =\ht\strutbox=) % so we need to add that. On the other hand, when centering around @@ -2325,7 +2456,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% \lineskip \z@ \baselineskip \z@ % \end{macrocode} -% Don't use \cs{m@th} here as that signals to the math taggingg +% Don't use \cs{m@th} here as that signals to the math tagging % code that this is fake math that should not be tagged. % \changes{v2.6a}{2023/12/11}{Support for tagged PDF} % \begin{macrocode} @@ -2451,7 +2582,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % % We then start a special brace which I have directly % copied from the original definition. It is -% necessary, because the =\futurlet= in =\@ifnextchar= +% necessary, because the =\futurelet= in =\@ifnextchar= % might % expand a following =&= \textsf{token} in a construction like % =\\ &=. This would otherwise end the alignment template at a @@ -2464,7 +2595,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % that a =&= will not be considered belonging to the current % =\halign= while we are looking for a =*= or =[=. % For further information see -% \cite[Appendix D]{bk:knuth}. +% \cite[Appendix~D]{bk:knuth}. % \begin{macrocode} \iffalse{\fi\ifnum 0=`}\fi % \end{macrocode} @@ -2649,14 +2780,14 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \section{The Environment Definitions} % % After these preparations we are able to define the environments. They -% only differ in the initialisations of =\d@llar...=, =\col@sep= +% only differ in the initializations of =\d@llar...=, =\col@sep= % and =\@halignto=. % % \begin{macro}{\@halignto} % \begin{macro}{\d@llarbegin} % \begin{macro}{\d@llarend} % =\d@llar= has to be -% locally asigned since otherwise nested \textsf{tabular} and \textsf{array} +% locally assigned since otherwise nested \textsf{tabular} and \textsf{array} % environments (via =\multicolumn=) are impossible. % For 25 years or so =\@halignto= was set globally (to save space on the % save stack, but that was a mistake: if there is a tabular in the @@ -2664,7 +2795,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % able overwrite the =\@halignto= % setting of a tabular in the main text resulting in a very weird error. % \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} -% \changes{v2.0g}{1992/06/18}{`d@llarbegin defined on toplevel.} +% \changes{v2.0g}{1992/06/18}{`d@llarbegin defined on top-level.} % When the new font selection scheme is in force we have to % we surround all =\halign= entries % with braces. See remarks in TUGboat 10\#2. Actually we are going @@ -2714,7 +2845,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \begin{macro}{\tabular} % \begin{macro}{\tabular*} % The environments \textsf{tabular} and \textsf{tabular$*$} differ -% only in the initialisation of the command =\@halignto=. Therefore +% only in the initialization of the command =\@halignto=. Therefore % we define % \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)} % \begin{macrocode} @@ -2996,7 +3127,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % rewrites (in the token register "\NC@list") will look like % "\NC@do *" "\NC@do C" "\NC@do L". % So we need to define "\NC@do" as a one argument macro which -% initialises the rewriting of the specified column. Let us assume that +% initializes the rewriting of the specified column. Let us assume that % `C' is the argument. % \begin{macrocode} \def\NC@do#1{% @@ -3064,7 +3195,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \end{macro} % % \subsection{The $*$--form} -% We view the $*$-form as a slight generalisation of the system +% We view the $*$-form as a slight generalization of the system % described in the previous subsection. The idea is to define a $*$ % column by a command of the form: % \begin{verbatim} @@ -3440,7 +3571,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \subsection{Implementing column types \texttt{w} and \texttt{W}} % % In TugBoat 38/2 an extension was presented that implemented two -% aditional column types \texttt{w} and \texttt{W}. These have now +% additional column types \texttt{w} and \texttt{W}. These have now % been added to the package itself. % % @@ -3502,7 +3633,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % the cell content is too wide. % \changes{v2.4f}{2017/11/07}{Column type added} % \changes{v2.5a}{2020/04/06}{Use \cs{d@llarbegin} and \cs{d@llarend} so -% that cell is typeset in mathmode inside \texttt{array} (gh/297)} +% that cell is typeset in math mode inside \texttt{array} (gh/297)} % \begin{macrocode} \newcolumntype{W}[2] {>{\begin{lrbox}\ar@cellbox\d@llarbegin}% @@ -3517,7 +3648,46 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \end{macro} % % +% \subsection{Handling \cs{cline}} % +% In the past \pkg{array} did not have to concern itself with +% \cs{cline} but simply used the definition already provided in the +% kernel. However, for tagged PDF output this definition is +% insufficient, because it causes incorrect row counting and the rules +% it generates would need to be marked as artifacts. +% We therefore update it here. +% +% +% \begin{macro}{\@cline} +% Tagging support for \cs{cline} +% \changes{v2.6e}{2024/07/13}{Support for tagging \cs{cline} (tagging/134)} +% \begin{macrocode} +\ExplSyntaxOn +\def\@cline#1-#2\@nil{ + \omit + \@multicnt#1 + \advance\@multispan\m@ne + \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi + \@multicnt#2 + \advance\@multicnt-#1 + \advance\@multispan\@ne +% \end{macrocode} +% The rule needs artifact tagging in tagged PDF. +% \begin{macrocode} + \UseTaggingSocket{tbl/leaders/begin} + \leaders\hrule\@height\arrayrulewidth\hfill + \UseTaggingSocket{tbl/leaders/end} +% \end{macrocode} +% To the row counting the above appears like an extra row, so we +% have to correct the count. +% \begin{macrocode} + \tbl_gdecr_row_count: + \cr + \noalign{\vskip-\arrayrulewidth} +} +\ExplSyntaxOff +% \end{macrocode} +% \end{macro} % % % \begin{macrocode} diff --git a/macros/latex/required/tools/array.pdf b/macros/latex/required/tools/array.pdf Binary files differindex 1dbefd1b52..9085b9a982 100644 --- a/macros/latex/required/tools/array.pdf +++ b/macros/latex/required/tools/array.pdf diff --git a/macros/latex/required/tools/bm.pdf b/macros/latex/required/tools/bm.pdf Binary files differindex 901cc7b7ab..dab3f41a33 100644 --- a/macros/latex/required/tools/bm.pdf +++ b/macros/latex/required/tools/bm.pdf diff --git a/macros/latex/required/tools/calc.pdf b/macros/latex/required/tools/calc.pdf Binary files differindex 31a94ddcf7..b27aed4f0e 100644 --- a/macros/latex/required/tools/calc.pdf +++ b/macros/latex/required/tools/calc.pdf diff --git a/macros/latex/required/tools/changes.txt b/macros/latex/required/tools/changes.txt index b61f939445..9a3c944b20 100644 --- a/macros/latex/required/tools/changes.txt +++ b/macros/latex/required/tools/changes.txt @@ -9,6 +9,67 @@ are not part of the distribution. All changes above are only part of the development branch for the next release. ================================================================================ +######################### +# 2024-11-01 Release +######################### + +2024-10-30 David Carlisle <David.Carlisle@latex-project.org> + + * amsmath.dtx: Guard the \protect tests from primitive if tokens + in the definition (gh/1448) + +2024-10-27 David Carlisle <David.Carlisle@latex-project.org> + + * longtable.dtx Guard against increasing \pagegoal past \maxdimen (gh/1495) + + +2024-10-12 Joseph Wright <Joseph.Wright@latex-project.org> + + * array.dtx (section{The insertion of declarations ...}): + Further work on handling optional arguments in the argument + of >{...} to work around a master counter oddity (gh/1468) + +2024-09-18 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx (section{The insertion of declarations ...}): + Stop parsing too far for an optional argument if >{...} ends in a command + with a trailing optional arg (gh/1468) + +2024-09-17 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + * multicol.dtx: add tagging support (tagging/705) + +2024-09-12 David Carlisle <David.Carlisle@latex-project.org> + + * build.lua, tools.ins: + Modify fileerr extraction to write rename-to-empty-base.tex rather than .tex + to comply with expected security change in texlive 2025 + build.lua modified to rename rename-to-empty-base.tex to .tex after unpacking. + +2024-08-13 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + + * longtable.dtx: + store row number of head also if it ends with a \cr + (tagging-project-gh/554). + +2024-07-13 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * array.dtx (subsection{Handling \cs{cline}}): + Support for tagging \cline (tagging/134) + +2024-07-04 Ulrike Fischer <Ulrike.Fischer@latex-project.org> + + * longtable.dtx: + Added \LTcaptype (from package ltcaption) to support other types + beside table and to support unnumbered longtables (gh/1377). + + +2024-06-28 Frank Mittelbach <Frank.Mittelbach@latex-project.org> + + * multicol.dtx: + Update documentation to reflect that \sloppy isn't using + \tolerance=10000 any longer (it did in the early days of LaTeX) + (gh/1385) + 2024-06-14 David Carlisle <David.Carlisle@latex-project.org> * array.dtx move \ExplSyntaxOff earlier so error message spaces preserved gh/1378 diff --git a/macros/latex/required/tools/dcolumn.pdf b/macros/latex/required/tools/dcolumn.pdf Binary files differindex 341d57b5af..51d55f2083 100644 --- a/macros/latex/required/tools/dcolumn.pdf +++ b/macros/latex/required/tools/dcolumn.pdf diff --git a/macros/latex/required/tools/delarray.pdf b/macros/latex/required/tools/delarray.pdf Binary files differindex 800d3289bb..0f6e6b4a62 100644 --- a/macros/latex/required/tools/delarray.pdf +++ b/macros/latex/required/tools/delarray.pdf diff --git a/macros/latex/required/tools/enumerate.pdf b/macros/latex/required/tools/enumerate.pdf Binary files differindex db34e7b7bb..4da735348b 100644 --- a/macros/latex/required/tools/enumerate.pdf +++ b/macros/latex/required/tools/enumerate.pdf diff --git a/macros/latex/required/tools/fileerr.pdf b/macros/latex/required/tools/fileerr.pdf Binary files differindex 6fc6ce3a27..8bc6d1b386 100644 --- a/macros/latex/required/tools/fileerr.pdf +++ b/macros/latex/required/tools/fileerr.pdf diff --git a/macros/latex/required/tools/fontsmpl.pdf b/macros/latex/required/tools/fontsmpl.pdf Binary files differindex 0e001b9309..fa447ded99 100644 --- a/macros/latex/required/tools/fontsmpl.pdf +++ b/macros/latex/required/tools/fontsmpl.pdf diff --git a/macros/latex/required/tools/ftnright.pdf b/macros/latex/required/tools/ftnright.pdf Binary files differindex 5b92d84459..2f20227e33 100644 --- a/macros/latex/required/tools/ftnright.pdf +++ b/macros/latex/required/tools/ftnright.pdf diff --git a/macros/latex/required/tools/hhline.pdf b/macros/latex/required/tools/hhline.pdf Binary files differindex 805d96d267..7217208cb6 100644 --- a/macros/latex/required/tools/hhline.pdf +++ b/macros/latex/required/tools/hhline.pdf diff --git a/macros/latex/required/tools/indentfirst.pdf b/macros/latex/required/tools/indentfirst.pdf Binary files differindex 7f7383c969..438e2155ba 100644 --- a/macros/latex/required/tools/indentfirst.pdf +++ b/macros/latex/required/tools/indentfirst.pdf diff --git a/macros/latex/required/tools/l3sys-query.pdf b/macros/latex/required/tools/l3sys-query.pdf Binary files differindex c07b8955aa..103a058be7 100644 --- a/macros/latex/required/tools/l3sys-query.pdf +++ b/macros/latex/required/tools/l3sys-query.pdf diff --git a/macros/latex/required/tools/layout.pdf b/macros/latex/required/tools/layout.pdf Binary files differindex e5cf32690c..e2fffa0159 100644 --- a/macros/latex/required/tools/layout.pdf +++ b/macros/latex/required/tools/layout.pdf diff --git a/macros/latex/required/tools/longtable.dtx b/macros/latex/required/tools/longtable.dtx index cc3a939e7a..061d7b5610 100644 --- a/macros/latex/required/tools/longtable.dtx +++ b/macros/latex/required/tools/longtable.dtx @@ -28,7 +28,7 @@ %</dtx> %<package>\NeedsTeXFormat{LaTeX2e}[1995/06/01] %<package> -% Try the 2020 version for any rollback before that date: +% Try the 2020 version for any rollback before that date: %<package>\DeclareRelease{}{1994-06-01}{longtable-2020-01-07.sty} %<package> %<package>\DeclareRelease{v4.13}{2020-01-02}{longtable-2020-01-07.sty} @@ -38,7 +38,7 @@ %<driver> \ProvidesFile{longtable.drv} % \fi % \ProvidesFile{longtable.dtx} - [2024-04-26 v4.20 Multi-page Table package (DPC)] + [2024-10-27 v4.22 Multi-page Table package (DPC)] % % \iffalse %<*driver> @@ -179,7 +179,7 @@ % \env{longtable}, which has most of the features of the \env{tabular} % environment, but produces tables which may be broken by \TeX's % standard page-breaking algorithm. It also shares some features with -% the \env{table} environment. In particular it uses the same counter, +% the \env{table} environment. In particular it uses by default the same counter, % \texttt{table}, and has a similar "\caption" command. Also, the % standard "\listoftables" command lists tables produced by either the % \env{table} or \env{longtable} environments. @@ -335,6 +335,29 @@ % \caption{A floating table} % \end{table} % +% \section{Counter and Caption Types} +% +% As mentioned in the introduction \env{longtable} uses and updates by default +% the \texttt{table} counter, the "\caption" command creates a table caption +% which is added to the list of tables. +% Packages like \pkg{ltcaption} added more flexibility here by adding the +% command "\LTcaptype" which allowed to change the type, e.g. to a listing. +% Starting with version 4.21 \pkg{longtable} supports this command directly. +% \DescribeMacro{\LTcaptype}% +% By redefining this command it is possible to change the counter and caption type. +% After "\renewcommand\LTcaptype{"\meta{counter}"}" \env{longtable} will update +% the counter \meta{counter}, use "\fnum@"\meta{counter} in the caption (which +% typically will make use of "\"\meta{counter}"name" and "\the"\meta{counter}), and +% write content line entries into the file with the extension stored in the +% command "\ext@"\meta{counter}. When \pkg{hyperref} is loaded the name of +% the anchor will use \meta{counter} too. Packages or documents that change +% "\LTcaptype" to some nonstandard value must ensure that the counter +% \meta{counter} and the commands "\fnum@"\meta{counter} +% and "\ext@"\meta{counter} exist and do not error. +% If "\LTcaptype" is empty no counter is advanced and "\"\meta{counter}"name" in +% the caption is suppressed. +% +% % \section{Captions and Headings} % % At the start of the table one may specify lines which are to appear at @@ -907,6 +930,15 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\LTcaptype} +% The name used as counter, in caption, "\addcontentsline" and in targets. +% "\providecommand" is used for compability with \pkg{ltcaption} +% \changes{v4.21}{2024/07/04} +% {Added \cs{LTcaptype} to support other types beside table.} +% \begin{macrocode} +\providecommand\LTcaptype{table} +% \end{macrocode} +% \end{macro} % \subsection{Internal Parameters} % % \begin{macro}{\LT@head} @@ -957,8 +989,11 @@ % are preserved correctly when "\includeonly" is used. In the rest of % the file "\LT@tables" has been replaced by "\c@LT@tables" without % further comment. +% \changes{v4.21}{2024/07/04} +% {Provide a \cs{theH}-representation for targets.} % \begin{macrocode} \newcounter{LT@tables} +\providecommand\theHLT@tables{\theLT@tables} % \end{macrocode} % \end{macro} % @@ -1050,12 +1085,12 @@ \LT@err{longtable not in 1-column mode}\@ehc \fi % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \UseTaggingSocket{tbl/vmode/begin}% % \end{macrocode} -% +% % \begin{macrocode} \begingroup % \end{macrocode} @@ -1080,6 +1115,9 @@ % Since Version 3.02, \package{longtable} has used the internal counter % "\c@LT@tables". The \LaTeX\ counter "table" is still incremented % so that "\caption" works correctly. +% \changes{v4.21}{2024/07/04} +% {Use \cs{LTcaptype} instead of \texttt{table} in various places +% to support other types beside table.} % \begin{macrocode} \def\LT@array[#1]#2{% % \end{macrocode} @@ -1097,25 +1135,31 @@ % TODO: When a line is killed the structure subtree is there already % too and must be removed. If hard to do, then maybe at first warn if the % construction is used. -% +% % \cs{LT@array} is executed in a group, so we can disable para-tagging here. % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \UseTaggingSocket{tbl/init} - \@kernel@refstepcounter{table}\stepcounter{LT@tables} + \tl_if_empty:eTF { \LTcaptype } + { + \tl_gset:Ne \@currentHref {LT@tables.\theHLT@tables} + } + { + \@kernel@refstepcounter{\LTcaptype}\stepcounter{LT@tables} % \end{macrocode} -% The target is created rather late and a \cs{label} can come earlier, +% The target is created rather late and a \cs{label} can come earlier, % so we have to define \cs{@currentHref} explicitly. We can't currently % assume that \cs{theHtable} is defined always. % \begin{macrocode} - \tl_gset:Ne \@currentHref {table.\cs_if_exist_use:N\theHtable} + \tl_gset:Ne \@currentHref {\LTcaptype.\cs_if_exist_use:c {theH\LTcaptype}} + } % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Managing cell indexes} % \begin{macrocode} \tbl_gzero_row_count: % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \UseTaggingSocket{tbl/longtable/init} @@ -1225,7 +1269,7 @@ \begingroup \@mkpream{#2}% % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Managing cell indexes} % \begin{macrocode} \tbl_count_table_cols: @@ -1271,12 +1315,12 @@ \tabskip\z@ \@arstrut % \end{macrocode} % Insert the tagging socket to start the row and initialize the cell -% data for the row. +% data for the row. % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \UseTaggingSocket{tbl/row/begin}% % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Managing cell indexes} % \begin{macrocode} \tbl_init_cell_data_for_row: @@ -1314,7 +1358,7 @@ column:~ \the\g_@@_col_int } % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \tbl_if_row_was_started:T @@ -1399,7 +1443,7 @@ % We also have to make sure that this breakpoint doesn't affect how the next % page is broken, so we make the penalty 9999 (10000 is infinite and thus not % a legal breakpoint) and cancel out the "\kern" with a new "\kern". -% +% % I don't think this is the \emph{right} solution to the problem (that would be % that the standard output routine has a feature for syncronizing with % typesetting, as part of the preparations for switching output routine), but @@ -1476,9 +1520,17 @@ \maxdepth\z@ \fi % \end{macrocode} -% +% \changes{v4.21}{2024/07/04} +% {Use \cs{LTcaptype} to support other types beside table and handle +% the case if it is empty.} % \begin{macrocode} - \MakeLinkTarget{table} + \tl_if_empty:eTF{\LTcaptype} + { + \MakeLinkTarget{LT@tables} + } + { + \MakeLinkTarget{\LTcaptype} + } % \end{macrocode} % Put the table head on the page, and then switch to the new output % routine. @@ -1487,12 +1539,12 @@ % \begin{macrocode} \ifvoid\LT@firsthead\copy\LT@head\else\box\LT@firsthead\fi\nobreak % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \UseTaggingSocket{tbl/longtable/head} % \end{macrocode} -% +% % \begin{macrocode} \output{\LT@output}} \ExplSyntaxOff @@ -1524,18 +1576,18 @@ % \begin{macrocode} \tbl_crcr:n {endlongtable} % \end{macrocode} -% +% % \changes{v4.01}{1996/04/11} % {(DPC) use \cs{noalign} to sneak in \cs{LT@entry@chop}} % \begin{macrocode} \noalign{% % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \UseTaggingSocket{tbl/longtable/finalize} % \end{macrocode} -% +% % \begin{macrocode} \let\LT@entry\LT@entry@chop \xdef\LT@save@row{\LT@save@row}}% @@ -1579,19 +1631,28 @@ \ifx\LT@save@row\LT@@@@save@row \else \LT@warn{Column~ widths~ have~ changed\MessageBreak - in~ table~ \thetable}% + in~ + \tl_if_empty:eTF{\LTcaptype} + {longtable~ \theLT@tables} + {\LTcaptype\c_space_tl\use:c{the\LTcaptype}} + } \LT@final@warn \fi % \end{macrocode} -% Force one more go with the \env{longtable} output routine. +% Force one more go with the \env{longtable} output routine. +% Guard the special start of page value of "\pagegoal". % \changes{v4.14}{2020/02/07} % {Rearrange vertical space tests for tools/3512 (floats on same page)} +% \changes{v4.22}{2024/10/27} +% {Keep \cs{pagegoal} below \cs{maxdimen} gh1495} % \begin{macrocode} \endgraf\penalty -\LT@end@pen \ifvoid\LT@foot\else \global\advance\vsize\ht\LT@foot \global\advance\@colroom\ht\LT@foot - \dimen@\pagegoal\advance\dimen@\ht\LT@foot\pagegoal\dimen@ + \ifdim\pagegoal<\maxdimen + \dimen@\pagegoal\advance\dimen@\ht\LT@foot\pagegoal\dimen@ + \fi \fi % \end{macrocode} % Now close the group to return to the standard routine. @@ -1613,7 +1674,7 @@ % \begin{macrocode} \ifvoid\footins\else\insert\footins{}\fi % \end{macrocode} -% +% % \changes{v4.19}{2023/12/16}{Support for tagged PDF} % \begin{macrocode} \UseTaggingSocket{tbl/vmode/end}% @@ -2161,7 +2222,6 @@ \tbl_gdecr_row_count: \penalty\@M} \@gtempa} -\ExplSyntaxOff %<@@=> % \end{macrocode} % \end{macro} @@ -2187,14 +2247,22 @@ % {Add new control argument} % \changes{v4.16}{2021/05/07} % {use \cs{ext@table} gh/561} -% \begin{macrocode} -\def\LT@c@ption#1[#2]#3{% - \LT@makecaption#1\fnum@table{#3}% - \def\@tempa{#2}% - \ifx\@tempa\@empty\else - {\let\\\space - \addcontentsline{\ext@table}{table}{\protect\numberline{\thetable}{#2}}}% - \fi} +% \changes{v4.21}{2024/07/04} +% {Use \cs{LTcaptype} to support other types beside table.} +% \begin{macrocode} +\def\LT@c@ption#1[#2]#3{ + \tl_if_empty:eTF{\LTcaptype} + {\LT@makecaption\@gobble{}{#3}} + {\LT@makecaption#1{\csname fnum@\LTcaptype\endcsname}{#3} + \def\@tempa{#2} + \ifx\@tempa\@empty\else + {\let\\\space + \addcontentsline + {\@nameuse{ext@\LTcaptype}} + {\LTcaptype} + {\protect\numberline{\@nameuse{the\LTcaptype}}{#2}}} + \fi}} +\ExplSyntaxOff % \end{macrocode} % \end{macro} % @@ -2375,7 +2443,7 @@ \ExplSyntaxOn \def\LT@end@hd@ft#1{% % \end{macrocode} -% +% % This command is used to store the head and foot boxes. % We need to retrieve and store the row so that we can clean % up the structure in the finalize code. @@ -2388,7 +2456,7 @@ % \end{macrocode} % TODO: This is exposing internal counters, so it should be encapsulated % in some interface command (but I'm not sure what that should be -% called, so not done yet. +% called, so not done yet. % \changes{v4.19}{2023/12/16}{Managing cell indexes} % \begin{macrocode} \tbl_count_missing_cells:n {head/foot} @@ -2413,19 +2481,28 @@ % To get out of this trap we run \cs{crcr} (which would normally % come inside \cs{LT@echunk}. That will then trigger \cs{everycr} % and update row counter unnecessarily, but now we have a defined state, so -% we can use \cs{noalign} to undo that. +% we can use \cs{noalign} to undo that. % We also change \cs{LT@rows} so that further \cs{cr}s do not do % any harm (as explained above. % % The \cs{crcr} inside \cs{LT@echunk} will be bypassed in that case % as we have just executed a \cs{crcr} and are still in scanning modus for -% \cs{omit} or \cs{noalign}. +% \cs{omit} or \cs{noalign}. % \begin{macrocode} { \crcr \noalign{ % \end{macrocode} -% +% \changes{v4.22}{2024/08/13}{Store header row numbers} +% \begin{macrocode} + \int_step_inline:nn + { \LT@rows } + { + \seq_gput_left:ce + {g_@@_\cs_to_str:N #1 _rows_seq } + { \int_eval:n {\g_@@_row_int - ##1 } } + } +% \end{macrocode} % \changes{v4.19}{2023/12/16}{Managing cell indexes} % \begin{macrocode} \tbl_gdecr_row_count: % undo the increment @@ -2442,7 +2519,7 @@ {Increase~ LTchunksize}% \fi \setbox#1\box\z@ - \@@_trace:n {-->>~ Saving~\noexpand#1} + \@@_trace:n {-->>~ Saving~\noexpand#1} \LT@get@widths \LT@bchunk} % \end{macrocode} @@ -2501,7 +2578,7 @@ \bgroup % \end{macrocode} % \changes{v4.12}{2019/02/06}{Color group to match array package} -% \changes{v4.18}{2023/08/25}{Use \cs{everypar} to match array package, github 1128}% +% \changes{v4.18}{2023/08/25}{Use \cs{everypar} to match array package, github 1128} % \begin{macrocode} \color@begingroup \let\@footnotetext\LT@p@ftntext @@ -2509,7 +2586,7 @@ \@arrayparboxrestore \everypar{% \vrule \@height \ht\@arstrutbox \@width \z@ - \everypar{}}% + \everypar{}}% } % \end{macrocode} % \end{macro} diff --git a/macros/latex/required/tools/longtable.pdf b/macros/latex/required/tools/longtable.pdf Binary files differindex 2bd06f4562..bd4cf6b680 100644 --- a/macros/latex/required/tools/longtable.pdf +++ b/macros/latex/required/tools/longtable.pdf diff --git a/macros/latex/required/tools/manifest.txt b/macros/latex/required/tools/manifest.txt index 004245d1d5..c07b6cd831 100644 --- a/macros/latex/required/tools/manifest.txt +++ b/macros/latex/required/tools/manifest.txt @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 1993-2021 +% Copyright (C) 1993-2024 % The LaTeX Project and any individual authors listed elsewhere % in this file. % @@ -49,7 +49,7 @@ bm.dtx Access bold math symbols. calc.dtx - Infix arithmetic expresions. Contributed to the distribution by + Infix arithmetic expressions. Contributed to the distribution by Kresten Krab Thorup and Frank Jensen. enumerate.dtx @@ -60,7 +60,7 @@ fileerr.dtx missing file error loop. fontsmpl.dtx - Package and test file for producing `font samples' + Package and test file for producing `font samples'. ftnright.dtx Place footnotes in the right hand column in two-column mode. @@ -77,7 +77,7 @@ multicol.dtx rawfonts.dtx Preload fonts under the old internal font names of LaTeX2.09. - Not recomended for new packages, but may help when updating old + Not recommended for new packages, but may help when updating old files. shellesc.dtx @@ -103,7 +103,7 @@ verbatim.dtx Flexible version of verbatim environment. xr.dtx - eXternall References. Extend \ref to access \label commands in + eXternal References. Extend \ref to access \label commands in other documents. xspace.dtx diff --git a/macros/latex/required/tools/multicol.dtx b/macros/latex/required/tools/multicol.dtx index 4d86448002..90decb3bb1 100644 --- a/macros/latex/required/tools/multicol.dtx +++ b/macros/latex/required/tools/multicol.dtx @@ -20,7 +20,7 @@ % \iffalse This is a METACOMMENT % %% Package `multicol' to use with LaTeX2e -%% Copyright 1989-2023 Frank Mittelbach +%% Copyright 1989-2024 Frank Mittelbach %% %% In addition to the terms of LPPL any distributed version %% (unchanged or modified) of multicol has to keep the statement @@ -77,7 +77,7 @@ %% not for the payment of a license fee per se (which might or might %% not follow from this evaluation). %% -%% The license fee, if any, can be payed either to the LaTeX fund +%% The license fee, if any, can be paid either to the LaTeX fund %% (see ltx3info.txt in the base LaTeX distribution) or to the author of %% the program who can be contacted at %% @@ -98,7 +98,7 @@ %<driver> \ProvidesFile{multicol.drv} % \fi % \ProvidesFile{multicol.dtx} - [2024/05/23 v1.9h multicolumn formatting (FMi)] + [2024/09/14 v1.9i multicolumn formatting (FMi)] % % % @@ -403,12 +403,17 @@ % the most important is called |\tolerance|: this controls the % allowed `looseness' (i.e.\ the amount of blank space between words). % Its default value is 200 (the \LaTeX{} |\fussy|) which is too -% small for narrow columns. On the other hand the |\sloppy| -% declaration (which sets |\tolerance| to $10000=\infty$) is too -% large, allowing really bad spacing.\footnote{Look at the next -% paragraph, it was set with the \cs{sloppy} declaration.} -% -% \begin{sloppypar} +% small for narrow columns. + +% Setting it to \texttt{10000} (a.k.a.\ $\infty$) means arbitrary bad +% lines are possible. With that setting \LaTeX{} will make most lines +% perfect but intermix them with really bad lines. This was the +% setting originally used by \cs{sloppy} (nowadays it is a bit more +% cautious and used \texttt{9999} which makes a huge +% difference).\footnote{Look at the next paragraph, it was set with +% the \cs{tolerance}\texttt{=10000}.} +% +% \begin{sloppypar}\tolerance=10000 % \DescribeMacro\multicoltolerance \DescribeMacro\multicolpretolerance % We therefore use a |\multicoltolerance| parameter for the % |\tolerance| value inside the \mc{} environment. Its default value @@ -417,10 +422,10 @@ % be done outside the \mc{} environment. Since |\tolerance| is set % to |\multicoltolerance| at the beginning of every \textsf{multicols} % environment one can locally overwrite this default by assigning -% \verb*+\tolerance = +\meta{desired value}. There also exists a +% \cs{tolerance}\texttt{=}\meta{desired value}. There also exists a % |\multicolpretolerance| parameter holding the value for % |\pretolerance| within a \mc{} environment. Both parameters are -% usually used only by package designers. +% usually used only by package or class designers. % \end{sloppypar} % % Generation of multicolumn output can be divided into two parts. In @@ -679,7 +684,7 @@ % this value will additionally trace the mark handling % algorithm. It will show what marks are found, what marks are % considered, etc. To fully understand this information you will -% probably have to read carefully trough the implementation. +% probably have to read carefully through the implementation. % \item[$\meta{number}\geq 4$.] Setting \meta{number}\pagebreak[2] to % such a high value will additionally place an |\hrule| into your % output, separating the part of text which had already been @@ -1945,7 +1950,7 @@ % the balancing happened in the output routine then \TeX{} reverts % to the |\prevdepth| that was current before the OR once the OR has % finished. In short |\prevdepth| is something you can't set -% globally it is alway local to the current list being built. Thus +% globally it is always local to the current list being built. Thus % we need to set it back to zero here to avoid incorrect spacing. % \changes{v1.8h}{2014/09/12}{Set \cs{prevdepdth} for current vlist % when returning from multicols environment} @@ -2216,7 +2221,7 @@ % \begin{macro}{\multicolmindepthstring} % The default minimum depth of each column corresponds to the depth % of a `p' in the current font. This makes sense for Latin-based -% languages and was hard-wired intitially, but for Asian languages +% languages and was hard-wired initially, but for Asian languages % it is better to use a zero depth (and alternatively one might % want to use the depth of a strut or a parentheses). So we now % offer a way to adjust this while maintaining backward @@ -2462,7 +2467,7 @@ % If |\kept@firstmark| is non-empty then |\kept@botmark| must be % non-empty too so we can use their values. Otherwise we use the % value of |\kept@topmark| which was first initialized when we -% gathered the |\partical@page| and later on was updated to the +% gathered the |\partial@page| and later on was updated to the % |\botmark| for the preceding page. % % \changes{v1.4a}{1992/02/14}{\cs{botmark} set to \cs{splitbotmark}} @@ -2938,7 +2943,7 @@ % marks from this box. This has to be done \emph{before} we add a % penalty of $-10000$ to the top of the box, otherwise only an % empty box will be considered. But even that is not enough: the box -% may contain \cs{columnbreak}s in which case doing some artifical +% may contain \cs{columnbreak}s in which case doing some artificial % splitting to get the marks out still fails to see all marks % unless we take some special precaution in \cs{get@keptmarks} % (which is now done). @@ -3625,12 +3630,22 @@ % \changes{v1.6g}{2006/02/23}{Added \cs{@minipagefalse}} % \changes{v1.6h}{2008/12/05}{Use \cs{@endfloatbox} to better support % the modifications done by the float package} +% \changes{v1.9i}{2024/09/14}{Added tagging support} % Even if this should be used as a hook we use a |@| in the % name since it is more for experts. -% \begin{macrocode} +% For now we test if the socket is already defined +% \begin{macrocode} +\ExplSyntaxOn +\str_if_exist:cF { l__socket_tagsupport/float/end_plug_str } + { + \NewSocket{tagsupport/float/end}{0} + \NewSocket{tagsupport/float/hmode/end}{0} + } +\ExplSyntaxOff \def\set@floatcmds{% \let\@dblfloat\@dbflt \def\end@dblfloat{\@endfloatbox + \UseTaggingSocket{float/end}% \@largefloatcheck \outer@nobreak % \end{macrocode} @@ -3652,6 +3667,7 @@ \fi \ifnum\@floatpenalty=-\@Mii \@Esphack + \UseTaggingSocket{float/hmode/end}% \fi}} % \end{macrocode} % \end{macro} diff --git a/macros/latex/required/tools/multicol.pdf b/macros/latex/required/tools/multicol.pdf Binary files differindex 28ba5b1c4d..63da9583fc 100644 --- a/macros/latex/required/tools/multicol.pdf +++ b/macros/latex/required/tools/multicol.pdf diff --git a/macros/latex/required/tools/rawfonts.pdf b/macros/latex/required/tools/rawfonts.pdf Binary files differindex 55ecb5ea8a..997c204982 100644 --- a/macros/latex/required/tools/rawfonts.pdf +++ b/macros/latex/required/tools/rawfonts.pdf diff --git a/macros/latex/required/tools/shellesc.pdf b/macros/latex/required/tools/shellesc.pdf Binary files differindex 6fd4aab93d..a47f54a229 100644 --- a/macros/latex/required/tools/shellesc.pdf +++ b/macros/latex/required/tools/shellesc.pdf diff --git a/macros/latex/required/tools/showkeys.pdf b/macros/latex/required/tools/showkeys.pdf Binary files differindex 130a561fc9..09bb262272 100644 --- a/macros/latex/required/tools/showkeys.pdf +++ b/macros/latex/required/tools/showkeys.pdf diff --git a/macros/latex/required/tools/somedefs.pdf b/macros/latex/required/tools/somedefs.pdf Binary files differindex 1326a47b6e..742cf885e0 100644 --- a/macros/latex/required/tools/somedefs.pdf +++ b/macros/latex/required/tools/somedefs.pdf diff --git a/macros/latex/required/tools/tabularx.pdf b/macros/latex/required/tools/tabularx.pdf Binary files differindex 6a8e0d0c21..02e95d8c00 100644 --- a/macros/latex/required/tools/tabularx.pdf +++ b/macros/latex/required/tools/tabularx.pdf diff --git a/macros/latex/required/tools/theorem.dtx b/macros/latex/required/tools/theorem.dtx index a9c3ccae3e..3fbba473ba 100644 --- a/macros/latex/required/tools/theorem.dtx +++ b/macros/latex/required/tools/theorem.dtx @@ -24,7 +24,7 @@ %% % % -\def\FMithmInfo{2023/07/05 v2.2c Theorem extension package (FMi)} +\def\FMithmInfo{2024/08/06 v2.2c Theorem extension package (FMi)} % % \ProvidesFile{theorem.dtx}[\FMithmInfo] %\iffalse % this is a METACOMMENT ! @@ -952,7 +952,6 @@ % % \subsubsection{The \texttt{changebreak} style} % -% \begin{macrocode} % This style option is stored in the file |thcb.sty|. % \begin{macrocode} %<*thcb> diff --git a/macros/latex/required/tools/theorem.pdf b/macros/latex/required/tools/theorem.pdf Binary files differindex ec0d2a0e69..4bf5e62691 100644 --- a/macros/latex/required/tools/theorem.pdf +++ b/macros/latex/required/tools/theorem.pdf diff --git a/macros/latex/required/tools/tools-overview.pdf b/macros/latex/required/tools/tools-overview.pdf Binary files differindex 86a57d927e..d03234e1f8 100644 --- a/macros/latex/required/tools/tools-overview.pdf +++ b/macros/latex/required/tools/tools-overview.pdf diff --git a/macros/latex/required/tools/tools-overview.tex b/macros/latex/required/tools/tools-overview.tex index 54f4b5ed63..3d45a5e2fc 100644 --- a/macros/latex/required/tools/tools-overview.tex +++ b/macros/latex/required/tools/tools-overview.tex @@ -132,7 +132,7 @@ Access bold math symbols. }% \entry{calc}{% - Infix arithmetic expresions. Contributed to the distribution by + Infix arithmetic expressions. Contributed to the distribution by Kresten Krab Thorup and Frank Jensen. }% \entry{dcolumn}{% @@ -149,7 +149,7 @@ missing file error loop. }% \entry{fontsmpl}{% - Package and test file for producing \emph{font samples} + Package and test file for producing \emph{font samples}. }% \entry{ftnright}{% Place footnotes in the right hand column in two-column mode. @@ -173,7 +173,7 @@ }% \entry{rawfonts}{% Preload fonts under the old internal font names of \LaTeX{}2.09. - Not recomended for new packages, but may help when updating old + Not recommended for new packages, but may help when updating old files. }% \entry{shellesc}{% @@ -206,7 +206,7 @@ Flexible version of verbatim environment. }% \entry{xr}{% - eXternall References. Extend \cs{ref} to access \cs{label} commands in + eXternal References. Extend \cs{ref} to access \cs{label} commands in other documents. }% \entry{xspace}{% diff --git a/macros/latex/required/tools/tools.ins b/macros/latex/required/tools/tools.ins index 8687d49d7f..776215ff2e 100644 --- a/macros/latex/required/tools/tools.ins +++ b/macros/latex/required/tools/tools.ins @@ -195,6 +195,8 @@ given in the file `manifest.txt'. \file{r.tex}{\from{fileerr.dtx}{run}} \file{x.tex}{\from{fileerr.dtx}{exit}}} +\generate{\file{rename-to-empty-base.tex}{\from{fileerr.dtx}{return}}} + \Msg{***********************************************************} \Msg{*} @@ -202,8 +204,9 @@ given in the file `manifest.txt'. \Msg{* files into a directory searched by TeX:} \Msg{*} \Msg{* All the files with extension `.sty' and `.tex'} -\Msg{* Note there also may be a file .tex which is `invisible'} -\Msg{* on some operating systems.} +\Msg{* TeX may be blocked from writing a file called `.tex',} +\Msg{* so generated a file with name `rename-to-empty-base.tex'.} +\Msg{* Rename that file to `.tex' after the docstrip generation.} \Msg{*} \Msg{* To produce the documentation run the .dtx files through LaTeX.} \Msg{*} @@ -211,14 +214,4 @@ given in the file `manifest.txt'. \Msg{***********************************************************} -\Msg{} -\Msg{* Finally trying to make a file `.tex'.} -\Msg{* (Placed at the end of this run, as this} -\Msg{* may fail on some operating systems.)} - -\let\oldopenout\openout -\def\openout{\batchmode\immediate\oldopenout} - -\generate{\file{.tex}{\from{fileerr.dtx}{return}}} - \endbatchfile diff --git a/macros/latex/required/tools/trace.pdf b/macros/latex/required/tools/trace.pdf Binary files differindex 5f047d4005..e2dd5382a7 100644 --- a/macros/latex/required/tools/trace.pdf +++ b/macros/latex/required/tools/trace.pdf diff --git a/macros/latex/required/tools/varioref.pdf b/macros/latex/required/tools/varioref.pdf Binary files differindex 41013052cf..677d2d7d41 100644 --- a/macros/latex/required/tools/varioref.pdf +++ b/macros/latex/required/tools/varioref.pdf diff --git a/macros/latex/required/tools/verbatim.pdf b/macros/latex/required/tools/verbatim.pdf Binary files differindex ad5bced403..7551cea7d2 100644 --- a/macros/latex/required/tools/verbatim.pdf +++ b/macros/latex/required/tools/verbatim.pdf diff --git a/macros/latex/required/tools/xr.pdf b/macros/latex/required/tools/xr.pdf Binary files differindex 5da2dabe0b..92e74213f5 100644 --- a/macros/latex/required/tools/xr.pdf +++ b/macros/latex/required/tools/xr.pdf diff --git a/macros/latex/required/tools/xspace.pdf b/macros/latex/required/tools/xspace.pdf Binary files differindex 02c44368bb..f6d193af07 100644 --- a/macros/latex/required/tools/xspace.pdf +++ b/macros/latex/required/tools/xspace.pdf |