diff options
Diffstat (limited to 'macros/latex/required')
219 files changed, 8442 insertions, 5692 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..afbc13b963 100644 --- a/macros/latex/required/babel/base/README.md +++ b/macros/latex/required/babel/base/README.md @@ -1,8 +1,8 @@ -## Babel 24.7 +## Babel 24.13 -2024-06-26 +2024-11-08 -`babel` is the multilingual framework for localizing documents in +`babel` is the multilingual framework to localize 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 @@ -10,9 +10,9 @@ languages even work with Plain formats. The latest stable version is available on <https://ctan.org/pkg/babel>. -Changes in version 24.7 are described in: +Changes in version 24.13 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-24.13.html Apart from the manual, you can find information on some aspects of babel at: @@ -43,15 +43,18 @@ You may also report them to the current maintainer more informally on: https://latex3.github.io/babel/contact.html -Bugs related to specific languages are best reported to their +Bugs related to specific languages are best reported to theirs 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. +24.13 2024-11-08 + * French: Added ‘transform values’ for punctuation.space. + * Pashto: Persian and Islamic calendar (which fixes an error, + too). + * Fixes: + - Uyghur hyphenation mechanism stopped working. + - The Hebrew calendar converter raised an error. ``` ### 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..d5e651bde5 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..08e61332a7 100644 --- a/macros/latex/required/babel/base/babel.dtx +++ b/macros/latex/required/babel/base/babel.dtx @@ -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}% + [2024/11/08 v24.13 + 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,7 +74,7 @@ \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`\}} @@ -75,7 +84,6 @@ \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,12 +97,17 @@ 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 @@ -106,61 +119,88 @@ \href{https://latex3.github.io/babel/news/% whats-new-in-babel-\bbltempa.\bbltempb.html}% {\raisebox{.15ex}{$\oplus$}}% - \fi}}\enspace\ignorespaces} + \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 \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 +214,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 +252,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} @@ -272,9 +323,19 @@ 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} @@ -284,14 +345,13 @@ are some notes for the latest versions in recent features can be still 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 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}It doesn't work for me!] You can ask for help in some forums like \textsf{tex.stackexchange}, but if you have @@ -306,26 +366,35 @@ 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} +\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. + +‘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} -\subsection{Monolingual documents} +\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 +404,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 +445,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} are 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 +469,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 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. \end{note} \begin{note} @@ -472,157 +494,177 @@ 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 be also 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 `#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} - 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{} (ie, |\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). +\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 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. \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,6 +683,11 @@ _\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} @@ -651,946 +698,318 @@ _\foreignlanguage{spanish}{Español}_. 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} - -\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} - -\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} - -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} - -\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{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} - -\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} - -\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} - -\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} - -\Describe{\foreignlanguage}{\oarg{option-list}\marg{language}\marg{text}} - -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. - -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. -\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. - -Actually, there might be some non-local changes, as this environment -is roughly equivalent to: -\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. - -\subsection{More on selection} - -\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. +\subsection{Multilingual documents: the ‘classical’ way} -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. +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 (eg, |spanish| and |french|). -\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} +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. \begin{example} -With -\begin{verbatim} -\babeltags{de = german} -\end{verbatim} -you can write -\begin{verbatim} -text \textde{German text} text -\end{verbatim} -and + In \LaTeX, the preamble of the document: \begin{verbatim} -text -\begin{de} - German text -\end{de} -text +\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{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: -\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} -\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). - -\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{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} -\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 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. +\documentclass{article} -\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. +\usepackage[T1]{fontenc} -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 +_\usepackage[english,french]{babel}_ -\Describe\defineshorthand{\texttt{[}\langlist\texttt{]}% - \marg{shorthand}\marg{code}} +\begin{document} -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. +Plus ça change, plus c'est la même chose! -\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. +_\selectlanguage{english}_ -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. +And an English paragraph, with a short text in +_\foreignlanguage{french}{français}_. -\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: -\begin{verbatim} -\defineshorthand[*polish,*portuguese]{"-}{\babelhyphen{repeat}} +\end{document} \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 -\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 easy typing phonetic characters with \textsf{tipa}: + 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} -\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, 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.) +\documentclass{article} -\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} +_\usepackage[vietnamese,danish]{babel}_ -\bigskip +\begin{document} -For your records, here is a list of shorthands, but you must double -check them, as they may change:\footnote{Thanks to Enrico Gregorio} +Danish: \prefacename, \alsoname, \today. -\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.} +\selectlanguage{vietnamese} -\Describe\ifbabelshorthand{\marg{character}\marg{true}\marg{false}} +Vietnamese: \prefacename, \alsoname, \today. -\New{3.23} Tests if a character has been made a shorthand. +\end{document} +\end{verbatim} +\end{example} \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 + 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} -\AtBeginDocument{\DeleteShortVerb{\|}} +\documentclass[_italian_]{book} +\usepackage[ngerman,_main=italian_]{babel} \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 |`|. +\begin{note} + Once loaded a language, you can select it with the corresponding + BCP47 tag. See section \ref{bcp47} for further details. +\end{note} -\Describe{shorthands=}{\meta{char}\meta{char}... -$\string|$ \texttt{off}} -The only language shorthands activated -are those given, like, eg: +\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} -\usepackage[esperanto,french,_shorthands=:;!?_]{babel} +\addto\extrasfrench{\inputencoding{latin1}} +\addto\extrasrussian{\inputencoding{koi8-r}} \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. +\end{note} -\Describe\AfterBabelLanguage{\marg{option-name}\marg{code}} +\subsection{Multilingual documents: the ‘modern’ way} -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|!). +If lazy loading is not enough for your purposes, you can still tell +which languages should be loaded as either class or package options. +However, there are 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, ie, main and + secondary ones are loaded in the ‘modern’ way. +\end{itemize} \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: +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} -\usepackage[base]{babel} -\AfterBabelLanguage{foo}{% - \let\macroFoo\macro - \let\macro\relax} -\usepackage[foo,bar]{babel} +\usepackage[dutch,ngerman,thai,provide=*]{babel} +\babelfont{rm}{Norasi} \end{verbatim} \end{example} -\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} - -\begin{warning} - Currently this option is not compatible with languages loaded on the - fly. -\end{warning} +More complex combinations can be handled with |\babelprovide|, +explained below. -\subsection{\texttt{ini} files} -\label{inifiles} +\subsection{Languages supported by \babel{} in the ‘classical’ mode} -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. +(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 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). -|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). +Except in a few cases (eg, |ngerman|, |serbianc|, |acadian|) names are +those of the Unicode CLDR (or based on them). -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. +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} - 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} -\begin{verbatim} -\documentclass{book} +\begingroup -\usepackage{babel} -_\babelprovide[import, main]{georgian}_ +\bigskip\hrule\nobreak -\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans} +\makeatletter +\def\tag#1#2{\par + \hspace{-2em}\textcolor{thered}{\texttt{#1}}#2\enspace} +\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 -\begin{document} +\bigskip -\tableofcontents +\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. -\chapter{სამზარეულო და სუფრის ტრადიციები} +\bigskip\hrule\nobreak -ქართული ტრადიციული სამზარეულო ერთ-ერთი უმდიდრესია მთელ მსოფლიოში. +\begin{multicols}{2} +\leftskip2em\parindent0pt +\tag{afrikaans}{} +\tag{albanian}{} +\tag{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{farsi}{} +\note{Requires \textsf{arabi}.} +\tag{finnish}{} +\tag{french}{} +\subtagalt{acadian}{} +\tag{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{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{lowersorbian}{} +\tag{macedonian}{} +\tag{malay}{} +\tag{mongolian}{} +\tag{ngerman}{} +\note{This block refers to the new ortography.} +\subtagalt{naustrian}{} +\subtagalt{nswissgerman}{} +\note{Swiss High German} +\tag{northernsami}{} +\tag{norwegian}{} +\subtag{norsk}{} +\tag{nynorsk}{} +\tag{occitan}{} +\tag{piedmontese}{} +\tagmin{pinyin}{} +\tag{polish}{} +\tag{portuguese}{} +\subtagalt{brazilian}{} +\tag{romanian}{} +\tag{romansh}{} +\tag{russian}{} +\tag{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}{} +\tag{ukrainian}{} +\tag{uppersorbian}{} +\tag{vietnamese}{} +\tag{welsh}{} +\end{multicols} +\endgroup +\hrule +\bigskip -\end{document} -\end{verbatim} -\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{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} \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: + 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[_georgian_]{book} -\usepackage[_provide=*_]{babel} -\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans} +\documentclass{article} +\usepackage[hindi]{babel} +\begin{document} +{\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{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, @@ -1607,18 +1026,10 @@ 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)}} @@ -1652,7 +1063,7 @@ There are some notes in a few locales. \bigskip\hrule\nobreak \begin{multicols}{2} -\leftskip2em +\leftskip2em\parindent0pt \tag{abkhazian}{}{ab} \tag{afar}{}{aa} \tag{afrikaans}{\hascapu\hascapl}{af} @@ -1708,6 +1119,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 +1128,6 @@ language from \texttt{greek}.} \tag{belarusian}{\hascapu\hascapl}{be} \tag{bemba}{}{bem} \tag{bena}{}{bez} -\tag{bengali}{\hascapu}{bn} \tag{bhojpuri}{}{bho} \tag{blin}{}{byn} \tag{bodo}{}{brx} @@ -1734,6 +1145,7 @@ language from \texttt{greek}.} \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} @@ -1806,7 +1218,6 @@ Egypt, with tag \texttt{ar-EG}.} \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} @@ -1891,7 +1302,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} @@ -1964,10 +1374,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} @@ -2023,7 +1435,6 @@ with tag \texttt{gsw} is a different language.} \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 +1492,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} @@ -2169,54 +1579,78 @@ in Switzerland.} \hrule \bigskip -\subsection{Selecting fonts} +\subsection{Fonts in Unicode engines} +\label{fonts} -\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.} +\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} -\Describe\babelfont{\oarg{language-list}\marg{font-family}% - \oarg{font-options}\marg{font-name}} +\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. + +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.) \begin{note} - See the note in the previous section about some issues in - specific languages. + 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 the + commands line, with \textsf{albatross} (requires Java) or with + something like \texttt{fc-list :charset=1033C family} (in this case, + a Gothic character, the script required by the |gothic| language). \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. +\Describe\babelfont{\oarg{language-list}\marg{font-family}% + \oarg{font-options}\marg{font-name}} + +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 (eg, |*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. \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 +1687,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 |fontenc|, 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} +With some scripts, the \textsf{Harfbuzz} renderer is preferred: +\begin{verbatim} + \babelfont[_*arabic, *devanagari_]{rm}[_Renderer=Harfbuzz_]{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. @@ -2277,10 +1735,6 @@ to select fonts in addition to the three basic families. \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). \end{note} \begin{note} @@ -2312,6 +1766,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 Davis 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 +1784,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 +1827,815 @@ 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{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 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}[Renderer=Harfbuzz]{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 (eg, |\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 lead 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 an 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 (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} + +% All of these keys can be preceded by |main.| (eg, |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 BCP47 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 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{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{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;\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 + \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 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} -\subsection{Modifying a language} +\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 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, 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). The Harfbuzz renderer still has some issues, so + as a rule of thumb: +\begin{itemize} +\item prefer the default renderer in alphabetic scripts (like Latin, + Greek and Cyrillic); +\item resort to Harfbuzz in complex scripts with heavy contextual + analysis (like Arabic and Devanagari). +\end{itemize} + See + \href{https://github.com/latex3/luaotfload/wiki/Comparing-the-modes}{Comparing + the modes} for further info. 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} + +% \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 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 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,_ +_ 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 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|; 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. + +\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 (eg, |\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}} @@ -2376,15 +2655,15 @@ redefined behave with the ‘new way’ described in the following 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,7 +2676,7 @@ 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} @@ -2414,15 +2693,15 @@ value restored. \end{note} Macros to be run when a language is selected can be add to - |\extras|\m{lang}: + |\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 +2711,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 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. +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 +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{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}} @@ -2470,7 +2790,269 @@ 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 and 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 date format they 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 + years. 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| (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 to +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 use always + |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 @@ -2513,7 +3095,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 +3110,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 +3132,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. +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 (ie, 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,10 +3185,9 @@ 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 + Let's assume your document (\luatex{} or \xetex{}) is mainly in Polytonic Greek with but with some sections in Italian. Then, the first attempt should be: \begin{verbatim} @@ -2655,7 +3226,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 +3237,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: @@ -2727,21 +3299,252 @@ one whose script is Latin. be still 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 (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<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 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} + +\Describe{\babelhyphenmins}{% + \optstar\texttt{[}\langlist\texttt{]}% + \marg{left}\marg{right}\oarg{hyphenationmin}} + +\New{24.10} See the news page for the rationale for this commands. 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 are 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 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{\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}). + +\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 +3552,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 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). 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 +3578,322 @@ 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 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}{\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 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). + +\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 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 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: +\begin{verbatim} +\defineshorthand[*polish,*portuguese]{"-}{\babelhyphen{repeat}} +\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}} + +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 easy 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, 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.) + +\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 (ie, 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, 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. + \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,9 +3902,9 @@ well dates do not rely on |\arabic|.) For example: \begin{verbatim} -\babelprovide[import]{telugu} - % Or also, if you want: - % \babelprovide[import, maparabic]{telugu} +\usepackage[telugu, provide=*]{babel} + % Or also, if you want, with: + % provide={ maparabic } \babelfont{rm}{Gautami} % With luatex, better with Harfbuzz \begin{document} _\telugudigits{1234}_ @@ -2808,51 +3914,52 @@ _\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 @@ -2861,7 +3968,7 @@ 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 \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 @@ -2873,7 +3980,7 @@ which is deprecated). \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 +3995,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} @@ -3040,313 +4147,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 +4191,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 @@ -3625,6 +4431,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’). @@ -3638,11 +4445,10 @@ Declares a new character class, which is assigned to the characters in hyphen (eg,~|.,;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 +4510,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,85 +4531,7 @@ 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{Selecting scripts} +\subsection{Scripts} Currently \babel{} provides no standard interface to select scripts, because they are best selected with either |\fontencoding| @@ -3821,8 +4549,62 @@ Some languages sharing the same script define macros to switch it (eg, 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.} +therefore it has been deprecated (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,7 +4631,7 @@ 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 -- @@ -3908,10 +4690,14 @@ 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 +4716,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} @@ -4015,7 +4800,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}} @@ -4105,10 +4890,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}} @@ -4165,18 +4957,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| @@ -4196,249 +4988,6 @@ command is available always in bidi documents, even without 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 @@ -4460,7 +5009,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 +5025,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}} @@ -4528,93 +5077,80 @@ 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 doesn’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\}}.} + +\trans{cleveref}{Because of a long standing bug in this package, some +languages can raise and 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 -The following packages can be useful, too (the list is still -far from complete): +\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 \textit{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} @@ -4634,12 +5170,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, 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 (eg, \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 +5183,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 @@ -4686,9 +5214,8 @@ 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: +following the language name by a colon and the encoding code. For +example: \begin{verbatim} german:T1 hyphenT1.ger german hyphen.ger @@ -4696,18 +5223,7 @@ 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} @@ -4737,7 +5253,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,11 +5262,13 @@ 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 (eg, \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: @@ -4758,41 +5276,40 @@ Some recommendations: \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 + 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 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 features requests. As to \texttt{ldf} files, now language files are “outsourced” and are @@ -4806,8 +5323,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 +5332,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 +5360,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 +5379,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 @@ -5009,38 +5529,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 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} @@ -5119,9 +5636,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 |lfd| 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} @@ -5156,7 +5680,7 @@ and clearer. A ``selector'' selects a group of definition 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, +|unicode| must be used for \luatex{} and \xetex{}. Without a selector, the LICR representation (ie, with macros like |\~{n}| instead of |ñ|) is assumed. @@ -5239,12 +5763,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, ie, if |\date<language>| exists). \begin{note} The package option |strings| introduced in version 3.9 (around 2013) @@ -5257,17 +5781,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. @@ -5323,25 +5844,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 +5856,14 @@ 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. There are also many contributors for specific languages, which are mentioned in the respective files. Without them, \babel{} just @@ -5401,24 +5908,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 +5924,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,26 +5937,26 @@ 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 +% 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 @@ -5479,15 +5971,14 @@ wouldn’t exist. % \section{Tools} % % \begin{macrocode} -%<<version=24.7>> -%<<date=2024/06/26>> +%<<version=24.13>> +%<<date=2024/11/08>> % \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 +6012,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 +6027,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} -% -% \begin{macro}{\bbl@exp} +% \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 +6064,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 +6089,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 $\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. % % \begin{macrocode} \begingroup @@ -5636,12 +6119,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, ie, not |\relax| and not empty, % % \begin{macrocode} \def\bbl@ifblank#1{% @@ -5650,7 +6132,6 @@ 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 @@ -5688,7 +6169,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. % @@ -5716,7 +6197,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 +6227,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 +6283,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 +6296,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 +6324,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 +6338,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 +6355,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 +6431,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. @@ -6007,7 +6484,7 @@ wouldn’t exist. % % 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 +6511,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 +6523,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 +6532,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,12 +6565,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 +\DeclareOption{provide+=*}{\chardef\bbl@iniflag\tw@} % second = 2 +\DeclareOption{provide*=*}{\chardef\bbl@iniflag\thr@@} % second + main % A separate option \let\bbl@autoload@options\@empty \DeclareOption{provide@=*}{\def\bbl@autoload@options{import}} @@ -6145,7 +6619,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 +6630,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 +6641,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 +6671,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{% @@ -6280,10 +6751,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 +6761,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 +6811,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{% @@ -6392,7 +6852,7 @@ wouldn’t exist. % 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 +6871,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 +6880,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 +6916,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. % @@ -6520,13 +6948,11 @@ wouldn’t exist. \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 +6963,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 +6977,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 +6992,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 +7001,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 +7012,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 +7033,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 @@ -6630,10 +7052,9 @@ wouldn’t exist. \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 +7073,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 +7100,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 +7118,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 +7140,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 +7170,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 +7201,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 @@ -6843,6 +7241,12 @@ wouldn’t exist. \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@{/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 +7258,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 +7294,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 +7318,11 @@ wouldn’t exist. \expandafter\let\csname endotherlanguage*\endcsname\relax % \end{macrocode} % -% \end{environment} +% \macro{\foreignlanguage} % -% \begin{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 +7385,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 +7406,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 +7414,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 +7427,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 +7474,10 @@ wouldn’t exist. \endgroup}} % \end{macrocode} % -% \end{macro} -% -% \begin{environment}{hyphenrules} +% \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 +7501,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 +7515,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,9 +7525,7 @@ 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 @@ -7161,27 +7554,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 +7586,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 +7597,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 +7620,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 +7640,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 +7799,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 +7823,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 +7875,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 +7950,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 +7961,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 +7984,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 +7994,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,40 +8030,22 @@ 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 % necessary. % @@ -7716,21 +8060,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 +8102,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 "| (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|). % % \begin{macrocode} \def\bbl@active@def#1#2#3#4{% @@ -7813,9 +8141,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 +8154,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 +8167,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 +8185,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 +8207,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 +8230,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 +8262,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 +8280,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 +8291,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 +8306,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 +8322,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 +8332,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 +8349,16 @@ wouldn’t exist. \AtEndOfPackage{\let\bbl@restoreactive\@gobble}} % \end{macrocode} % -% \end{macro} -% -% \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|. +% \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 +8369,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 +8409,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 +8438,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 +8458,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,11 +8468,8 @@ 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 @@ -8174,7 +8486,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 +8524,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 +8538,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} -% -% \begin{macro}{\useshorthands} +% \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 (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. % % \begin{macrocode} \def\useshorthands{% @@ -8273,12 +8576,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 +8609,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 +8644,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 +8664,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,10 +8710,6 @@ 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 % shorthands are usually deactivated. % @@ -8461,8 +8749,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,9 +8780,6 @@ 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 % expanded. To prevent that and to be able to use the character |~| @@ -8511,20 +8796,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 +8817,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 +8871,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} +% \macro{\bbl@declare@ttribute} +% This command adds the new language/attribute combination to the list +% of known attributes. % -% \begin{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 +8898,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 +8924,14 @@ wouldn’t exist. \fi} % \end{macrocode} % -% \end{macro} -% -% \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. +% \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 +8945,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 +8961,46 @@ wouldn’t exist. \AtBeginDocument{\bbl@clear@ttribs} % \end{macrocode} % -% \end{macro} -% -% \subsection{Support for saving macro definitions} +% \subsection{Support for saving and redefining macros} % -% 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 +9021,62 @@ wouldn’t exist. \bbl@exp{\def\\\originalTeX{\the\toks@\the#1\relax}}} % \end{macrocode} % -% \end{macro} -% \end{macro} +% \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} +% +% \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} % -% \begin{macro}{\bbl@frenchspacing} -% \begin{macro}{\bbl@nonfrenchspacing} +% \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 +9087,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 +9124,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 +9163,36 @@ wouldn’t exist. \fi}} % \end{macrocode} % -% \end{macro} +% \macro{\babelhyphenmins} % -% \begin{macro}{\bbl@allowhyphens} +% Only \LaTeX{} (basically because it’s defined with a \LaTeX{} tool). % -% 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.}. +% \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} +% +% \macro{\bbl@allowhyphens} +% +% 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 +9200,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 @@ -8935,7 +9240,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 +9251,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 +9272,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 @@ -9143,14 +9444,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 @@ -9211,7 +9512,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 +9586,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 +9629,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 +9640,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 +9663,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 +9688,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 +9702,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 +9722,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 +9733,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 +9756,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 +9765,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 +9824,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 +9856,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 +9873,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 +9883,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 +9915,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 +9925,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 +9968,18 @@ wouldn’t exist. \ProvideTextCommandDefault{\grq}{\UseTextSymbol{OT1}\grq} % \end{macrocode} % -% \end{macro} -% \end{macro} +% \macro{\glqq} +% \macro{\grqq} % -% \begin{macro}{\glqq} -% \begin{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 +9993,10 @@ wouldn’t exist. \ProvideTextCommandDefault{\grqq}{\UseTextSymbol{OT1}\grqq} % \end{macrocode} % -% \end{macro} -% \end{macro} -% -% \begin{macro}{\flq} -% \begin{macro}{\frq} +% \macro{\flq} +% \macro{\frq} % -% The `french' single guillemets. +% The `french' single guillemets. % % \begin{macrocode} \ProvideTextCommandDefault{\flq}{% @@ -9733,13 +10005,10 @@ wouldn’t exist. \textormath{\guilsinglright}{\mbox{\guilsinglright}}} % \end{macrocode} % -% \end{macro} -% \end{macro} +% \macro{\flqq} +% \macro{\frqq} % -% \begin{macro}{\flqq} -% \begin{macro}{\frqq} -% -% The `french' double guillemets. +% The `french' double guillemets. % % \begin{macrocode} \ProvideTextCommandDefault{\flqq}{% @@ -9748,24 +10017,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 +10046,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 +10057,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 +10084,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 +10091,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 +10133,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 +10156,7 @@ wouldn’t exist. \let\babelpatterns\babelprehyphenation \let\babelcharproperty\babelprehyphenation \fi +%</package|core> % \end{macrocode} % % \subsection{Creating and modifying languages} @@ -9945,7 +10169,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 +10182,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 +10190,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 +10211,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 +10244,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 +10312,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 +10333,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) == @@ -10416,7 +10537,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 +10546,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 +10575,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 +10611,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 +10642,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 +10659,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 +10745,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 +10788,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 +10799,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 +10835,7 @@ 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. -% +% % \begin{macrocode} \def\bbl@iniwarning#1{% \bbl@ifunset{bbl@@kv@identification.warning#1}{}% @@ -10768,7 +10890,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 +10908,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>|. % @@ -10881,9 +11005,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 +11046,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,% @@ -10971,8 +11095,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{% @@ -11088,17 +11212,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 +11309,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 +11361,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 +11407,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}} @@ -11283,6 +11432,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 @@ -11376,67 +11527,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 +11537,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}% @@ -11484,9 +11582,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 +11645,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 +11671,67 @@ wouldn’t exist. \typeout{*******}} % \end{macrocode} % +% \subsection{BCP-47 related commands} +% +% \begin{macrocode} +\newif\ifbbl@bcpallowed +\bbl@bcpallowedfalse +\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. Can be prece +% +% \begin{macrocode} +\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} +% \end{macrocode} +% % \section{Adjusting the Babel behavior} % % A generic high level interface is provided to adjust some global @@ -11545,7 +11740,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 +11750,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 +11764,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}{% @@ -11701,7 +11897,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 @@ -11721,9 +11917,7 @@ 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 @@ -11764,10 +11958,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 +11993,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 +12017,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 +12026,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 +12045,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,9 +12055,7 @@ 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 % define citation labels. When packages such as \pkg{natbib} or @@ -11894,9 +12076,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 +12086,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 @@ -11930,9 +12108,7 @@ 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. @@ -11948,11 +12124,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 +12200,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 +12234,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 +12291,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 +12332,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 +12356,12 @@ wouldn’t exist. {}}} % \end{macrocode} % -% \end{macro} +% \macro{\substitutefontfamily} % -% \begin{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 +12385,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 +12436,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 +12481,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 +12491,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 +12512,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 +12550,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 +12562,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 +12600,20 @@ 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@rscripts{% + ,Garay,Todhri,Imperial Aramaic,Avestan,Cypriot,Elymaic,Hatran,Hebrew,% + Old Hungarian,Kharoshthi,Lydian,Mandaean,Manichaean,Mende Kikakui,% + Meroitic Cursive,Meroitic,Old North Arabian,Nabataean,N'Ko,% + Old Turkic,Orkhon,Palmyrene,Inscriptional Pahlavi,Psalter Pahlavi,% + Phoenician,Inscriptional Parthian,Hanifi,Samaritan,Old Sogdian,% + Old South Arabian,Yezidi,}% \def\bbl@provide@dirs#1{% \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts\bbl@rscripts}% \ifin@ @@ -12453,9 +12644,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 +12717,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 +12747,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 +12772,6 @@ wouldn’t exist. \@empty}} \fi % \end{macrocode}% -% \end{macro} -% % \subsection{Language options} % % Languages are loaded when processing the corresponding option @@ -12629,6 +12815,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 +12824,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}{}} @@ -12676,16 +12864,26 @@ 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 @@ -12717,7 +12915,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 +12927,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 +12941,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 +12981,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 +13005,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 +13022,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 +13041,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 +13057,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 +13069,7 @@ wouldn’t exist. \input babel.def \let\bbl@onlyswitch\@undefined %</kernel> +% \end{macrocode} % % \section{Error messages} % @@ -12875,6 +13079,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 +13151,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 +13171,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 +13183,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 +13226,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 +13265,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 +13295,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 +13312,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 +13347,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 +13436,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 +13447,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 @@ -13324,15 +13520,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 +13563,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 +13594,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 +13605,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 +13624,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,33 +13645,19 @@ 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}{% @@ -13487,8 +13668,10 @@ wouldn’t exist. \fi}% \edef\bbl@tempa{#1}% \def\bbl@tempb{#2}% Used by \bbl@bblfont - \bbl@loadfontspec - \EnableBabelHook{babel-fontspec}% Just calls \bbl@switchfont + \ifx\fontspec\@undefined + \usepackage{fontspec}% + \fi + \EnableBabelHook{babel-fontspec}% \bbl@bblfont} \newcommand\bbl@bblfont[2][]{% 1=features 2=fontname, @font=rm|sf|tt \bbl@ifunset{\bbl@tempb family}% @@ -13653,17 +13836,10 @@ wouldn’t exist. {\\\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}% \begingroup #4% \xdef#1{\f@family}% eg, \bbl@rmdflt@lang{FreeSerif(0)} @@ -13700,13 +13876,9 @@ wouldn’t exist. %<</Font selection>> % \end{macrocode} % -% \section{Hooks for XeTeX and LuaTeX} +% \macro{\BabelFootnote} % -% \subsection{XeTeX} -% -% 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 +13930,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 +14003,11 @@ 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} <@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 @@ -13940,7 +14117,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 +14133,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 +14145,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 +14239,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*}% @@ -14190,9 +14367,10 @@ wouldn’t exist. % (3) in the middle of |plain.def| and |babel.sty|, by |babel.def|, % with the commands and other definitions for |luatex| (eg, % |\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 +14516,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 +14537,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 +14574,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 +14674,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 +14735,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,7 +14769,6 @@ end #2}}}% \fi}} % \end{macrocode} -% \end{macro} % % \subsection{Southeast Asian scripts} % @@ -14563,29 +14781,8 @@ end % 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 +14791,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) @@ -14638,7 +14833,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 +14846,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 +14867,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) @@ -14697,8 +14891,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 +14909,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,10 +14941,10 @@ 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) @@ -14769,7 +14965,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 +14976,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}') @@ -14829,7 +15023,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 +15044,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 +15210,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 +15228,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 @@ -15077,9 +15271,6 @@ end % \subsection{Common stuff} % % \begin{macrocode} -\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont} -\AddBabelHook{babel-fontspec}{beforestart}{\bbl@ckeckstdfonts} -\DisableBabelHook{babel-fontspec} <@Font selection@> % \end{macrocode} % @@ -15100,14 +15291,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 +15410,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 +15470,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 +15490,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 +15516,30 @@ 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%-%.]+)|([%-%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 +15549,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 +15616,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,7 +15658,7 @@ 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 @@ -15478,6 +15672,10 @@ end 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 +15702,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 +15712,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 +15739,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 +15754,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 @@ -15633,6 +15833,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} @@ -15827,6 +16033,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 +16149,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 +16185,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 +16225,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 +16252,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 +16292,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 +16398,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 @@ -16094,10 +16429,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,24 +16513,12 @@ 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 - return head +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.fetch_subtext = {} @@ -16227,7 +16550,7 @@ 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) @@ -16243,7 +16566,7 @@ Babel.fetch_subtext[0] = function(head) -- 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 @@ -16291,7 +16614,7 @@ Babel.fetch_subtext[1] = function(head) word_nodes[#word_nodes+1] = item elseif item.id == 7 and item.subtype == 3 then - word_string = word_string .. '|' + word_string = word_string .. '|' word_nodes[#word_nodes+1] = item -- (1) Go to next word if nothing was found, and (2) implicitly @@ -16304,7 +16627,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 +16651,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 +16772,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 +16783,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 +16804,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 +16855,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 +16868,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,16 +16906,16 @@ 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) @@ -16621,7 +16945,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 +17056,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 +17092,19 @@ 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 + {0x1F300, 0x1F9FF, 'on'} } Babel.characters = { @@ -22895,8 +23214,6 @@ Babel.characters = { % % \begin{macrocode} %<*basic-r> -Babel = Babel or {} - Babel.bidi_enabled = true require('babel-data-bidi.lua') @@ -22970,13 +23287,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 @@ -23085,7 +23402,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 +23411,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,8 +23478,6 @@ end % % \begin{macrocode} %<*basic> -Babel = Babel or {} - -- eg, Babel.fontmap[1][<prefontid>]=<dirfontid> Babel.fontmap = Babel.fontmap or {} @@ -23232,7 +23545,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 +23567,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 +23602,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 +23611,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 +23682,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 +23739,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 +23755,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: @@ -23600,6 +23921,15 @@ function Babel.bidi(head, ispar, hdir) return head end +-- Make sure anything is marked as 'bidi done' (including nodes inserted +-- after the babel algorithm). +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> % \end{macrocode} % @@ -23620,14 +23950,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 +23976,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 +23999,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 +24059,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 +24111,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 +24213,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 +24272,13 @@ Babel.cjk_breaks = { % % \section{The `nil' language} % -% This `language' does nothing, except setting the hyphenation patterns to -% nohyphenation. -% -% For this language currently no special definitions are needed or -% available. +% This `language' does nothing, except setting the hyphenation patterns +% to nohyphenation. 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 +24286,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 +24300,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 +24351,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 +24662,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 +24844,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 +24854,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 +25033,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 +25108,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 +25128,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 +25140,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 +25154,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 +25222,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 +25242,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 +25277,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 +25320,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 +25444,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 +25455,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 +25478,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 +25515,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..a268eb3194 100644 --- a/macros/latex/required/babel/base/babel.ins +++ b/macros/latex/required/babel/base/babel.ins @@ -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{2024/11/08} \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..3d13d2f2a2 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..3fe6559437 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}[2024/11/08 v24.] %</dtx> % %% File 'bbcompat.dtx' diff --git a/macros/latex/required/firstaid/changes.txt b/macros/latex/required/firstaid/changes.txt index cbabfcbb72..5bfe7f1a53 100644 --- a/macros/latex/required/firstaid/changes.txt +++ b/macros/latex/required/firstaid/changes.txt @@ -1,3 +1,8 @@ +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..68877bc24d 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/10/16} +\def\LaTeXFirstAidVersion{v1.1g} % \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,34 @@ {[\@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 +% \begin{macrocode} + \AddToHook{label}[firstaid/cleveref] + {\ifx + \@currentcounter\@empty + \else + \firstaid@cref@updatelabeldata{\@currentcounter} + \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..12b3d30be9 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..80629d5ef5 100644 --- a/macros/latex/required/l3kernel/CHANGELOG.md +++ b/macros/latex/required/l3kernel/CHANGELOG.md @@ -7,6 +7,57 @@ this project uses date-based 'snapshot' version identifiers. ## [Unreleased] +## [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] + +### Fixed +- `\seq_map_pairwise_function:NNN` not work with `\seq_map_break:(n)` (issue \#1587) + +### Changed +- Increase outdent of long function names in `l3doc` (issue \#1585) + +## [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 @@ -1742,7 +1793,14 @@ 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/2024-11-02...HEAD +[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..d048951c6d 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 2024-11-02 Overview -------- diff --git a/macros/latex/required/l3kernel/expl3.dtx b/macros/latex/required/l3kernel/expl3.dtx index 4b4e61d3c8..2d0a15de88 100644 --- a/macros/latex/required/l3kernel/expl3.dtx +++ b/macros/latex/required/l3kernel/expl3.dtx @@ -24,7 +24,7 @@ % %<*driver|generic|package|2ekernel> %</driver|generic|package|2ekernel> -\def\ExplFileDate{2024-05-27}% +\def\ExplFileDate{2024-11-02}% %<*driver> \documentclass[full]{l3doc} \usepackage{graphicx} @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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..611d4ad06f 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..ca71fc3daf 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..91576320b0 100644 --- a/macros/latex/required/l3kernel/interface3.tex +++ b/macros/latex/required/l3kernel/interface3.tex @@ -58,7 +58,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2024-05-27} +\date{Released 2024-11-02} \pagenumbering{roman} \maketitle diff --git a/macros/latex/required/l3kernel/l3basics.dtx b/macros/latex/required/l3kernel/l3basics.dtx index 69e4441580..934bffb39f 100644 --- a/macros/latex/required/l3kernel/l3basics.dtx +++ b/macros/latex/required/l3kernel/l3basics.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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} diff --git a/macros/latex/required/l3kernel/l3bitset.dtx b/macros/latex/required/l3kernel/l3bitset.dtx index 4559b56fd3..79a5a21b4d 100644 --- a/macros/latex/required/l3kernel/l3bitset.dtx +++ b/macros/latex/required/l3kernel/l3bitset.dtx @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3bootstrap.dtx b/macros/latex/required/l3kernel/l3bootstrap.dtx index 861f0bb5a6..105304afe4 100644 --- a/macros/latex/required/l3kernel/l3bootstrap.dtx +++ b/macros/latex/required/l3kernel/l3bootstrap.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3box.dtx b/macros/latex/required/l3kernel/l3box.dtx index 808d22da23..6499104961 100644 --- a/macros/latex/required/l3kernel/l3box.dtx +++ b/macros/latex/required/l3kernel/l3box.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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..53db15109b 100644 --- a/macros/latex/required/l3kernel/l3cctab.dtx +++ b/macros/latex/required/l3kernel/l3cctab.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3clist.dtx b/macros/latex/required/l3kernel/l3clist.dtx index 5adb01cffb..dc6caccf0d 100644 --- a/macros/latex/required/l3kernel/l3clist.dtx +++ b/macros/latex/required/l3kernel/l3clist.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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 @@ -618,8 +621,9 @@ % % \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 +652,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 +1433,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 +1515,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} diff --git a/macros/latex/required/l3kernel/l3coffins.dtx b/macros/latex/required/l3kernel/l3coffins.dtx index 62dc5f92ad..7eda18d6e7 100644 --- a/macros/latex/required/l3kernel/l3coffins.dtx +++ b/macros/latex/required/l3kernel/l3coffins.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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..99c81e4980 100644 --- a/macros/latex/required/l3kernel/l3color.dtx +++ b/macros/latex/required/l3kernel/l3color.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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 @@ -243,9 +243,9 @@ % % \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} @@ -325,7 +325,7 @@ % \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} @@ -338,7 +338,7 @@ % % \begin{function}[added = 2022-01-26]{\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 @@ -406,20 +406,20 @@ % % \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{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}. % \end{function} % % \section{Creating new color models} @@ -495,7 +495,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 +697,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} diff --git a/macros/latex/required/l3kernel/l3debug.dtx b/macros/latex/required/l3kernel/l3debug.dtx index 21e6747a84..c3554aab6d 100644 --- a/macros/latex/required/l3kernel/l3debug.dtx +++ b/macros/latex/required/l3kernel/l3debug.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -69,7 +69,7 @@ % % Standard file identification. % \begin{macrocode} -\ProvidesExplFile{l3debug.def}{2024-05-27}{}{L3 Debugging support} +\ProvidesExplFile{l3debug.def}{2024-11-02}{}{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..87c7708eb8 100644 --- a/macros/latex/required/l3kernel/l3deprecation.dtx +++ b/macros/latex/required/l3kernel/l3deprecation.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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..1f7a29efa5 100644 --- a/macros/latex/required/l3kernel/l3doc.dtx +++ b/macros/latex/required/l3kernel/l3doc.dtx @@ -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}{2024-11-02}{} {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 2024-11-02} % \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,23 @@ 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: + \bool_lazy_or:nnTF + { \sys_if_engine_luatex_p: }{ \sys_if_engine_xetex_p: } + { + \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 +1629,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 +2171,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 +2191,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 +2551,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 +2616,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 +2665,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 +2717,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 +2733,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 +2860,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 +3233,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 @@ -3714,7 +3734,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 +3859,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 +4274,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} % diff --git a/macros/latex/required/l3kernel/l3doc.pdf b/macros/latex/required/l3kernel/l3doc.pdf Binary files differindex 42960f5e6f..de0bcf60e8 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..fb69b714fb 100644 --- a/macros/latex/required/l3kernel/l3docstrip.dtx +++ b/macros/latex/required/l3kernel/l3docstrip.dtx @@ -63,7 +63,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3docstrip.pdf b/macros/latex/required/l3kernel/l3docstrip.pdf Binary files differindex efc8882c36..061cd6fc44 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..3ca2c517b1 100644 --- a/macros/latex/required/l3kernel/l3expan.dtx +++ b/macros/latex/required/l3kernel/l3expan.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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 diff --git a/macros/latex/required/l3kernel/l3file.dtx b/macros/latex/required/l3kernel/l3file.dtx index 546222711e..ceadf34dc0 100644 --- a/macros/latex/required/l3kernel/l3file.dtx +++ b/macros/latex/required/l3kernel/l3file.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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,10 @@ % \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}. % \end{function} % % \subsection{Information about files and file contents} @@ -844,11 +846,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 +867,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 +943,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} diff --git a/macros/latex/required/l3kernel/l3flag.dtx b/macros/latex/required/l3kernel/l3flag.dtx index 88e726df35..7741a9b0da 100644 --- a/macros/latex/required/l3kernel/l3flag.dtx +++ b/macros/latex/required/l3kernel/l3flag.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-assign.dtx b/macros/latex/required/l3kernel/l3fp-assign.dtx index e6fa97423e..4fcaf71864 100644 --- a/macros/latex/required/l3kernel/l3fp-assign.dtx +++ b/macros/latex/required/l3kernel/l3fp-assign.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % \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} diff --git a/macros/latex/required/l3kernel/l3fp-aux.dtx b/macros/latex/required/l3kernel/l3fp-aux.dtx index 1ad33e235e..807710de08 100644 --- a/macros/latex/required/l3kernel/l3fp-aux.dtx +++ b/macros/latex/required/l3kernel/l3fp-aux.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-basics.dtx b/macros/latex/required/l3kernel/l3fp-basics.dtx index e2d93219b0..11c244aa1f 100644 --- a/macros/latex/required/l3kernel/l3fp-basics.dtx +++ b/macros/latex/required/l3kernel/l3fp-basics.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-convert.dtx b/macros/latex/required/l3kernel/l3fp-convert.dtx index 4983a3dd1f..23f7a2213d 100644 --- a/macros/latex/required/l3kernel/l3fp-convert.dtx +++ b/macros/latex/required/l3kernel/l3fp-convert.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-expo.dtx b/macros/latex/required/l3kernel/l3fp-expo.dtx index 7577f640d4..d65a147e15 100644 --- a/macros/latex/required/l3kernel/l3fp-expo.dtx +++ b/macros/latex/required/l3kernel/l3fp-expo.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-extended.dtx b/macros/latex/required/l3kernel/l3fp-extended.dtx index 596dc86ef2..cedbc91888 100644 --- a/macros/latex/required/l3kernel/l3fp-extended.dtx +++ b/macros/latex/required/l3kernel/l3fp-extended.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-functions.dtx b/macros/latex/required/l3kernel/l3fp-functions.dtx index b9e269b988..444e8189fa 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 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-logic.dtx b/macros/latex/required/l3kernel/l3fp-logic.dtx index 486a3bc579..baa08b4216 100644 --- a/macros/latex/required/l3kernel/l3fp-logic.dtx +++ b/macros/latex/required/l3kernel/l3fp-logic.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-parse.dtx b/macros/latex/required/l3kernel/l3fp-parse.dtx index 7853c40132..d272cadf11 100644 --- a/macros/latex/required/l3kernel/l3fp-parse.dtx +++ b/macros/latex/required/l3kernel/l3fp-parse.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-random.dtx b/macros/latex/required/l3kernel/l3fp-random.dtx index ff999926ab..91c3a20477 100644 --- a/macros/latex/required/l3kernel/l3fp-random.dtx +++ b/macros/latex/required/l3kernel/l3fp-random.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-round.dtx b/macros/latex/required/l3kernel/l3fp-round.dtx index 0d39b8a26a..a4202b4fea 100644 --- a/macros/latex/required/l3kernel/l3fp-round.dtx +++ b/macros/latex/required/l3kernel/l3fp-round.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-symbolic.dtx b/macros/latex/required/l3kernel/l3fp-symbolic.dtx index 88e214f49e..0db79ef775 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 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-traps.dtx b/macros/latex/required/l3kernel/l3fp-traps.dtx index fec48bc163..b300528ec5 100644 --- a/macros/latex/required/l3kernel/l3fp-traps.dtx +++ b/macros/latex/required/l3kernel/l3fp-traps.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % \maketitle % % \begin{documentation} diff --git a/macros/latex/required/l3kernel/l3fp-trig.dtx b/macros/latex/required/l3kernel/l3fp-trig.dtx index 7c40c6198f..46cad5c8f9 100644 --- a/macros/latex/required/l3kernel/l3fp-trig.dtx +++ b/macros/latex/required/l3kernel/l3fp-trig.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp-types.dtx b/macros/latex/required/l3kernel/l3fp-types.dtx index e9269e1f03..049a6eea82 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 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3fp.dtx b/macros/latex/required/l3kernel/l3fp.dtx index d273b057ea..0cbfd20153 100644 --- a/macros/latex/required/l3kernel/l3fp.dtx +++ b/macros/latex/required/l3kernel/l3fp.dtx @@ -49,7 +49,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -108,7 +108,7 @@ % 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$. @@ -198,7 +198,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} @@ -773,9 +776,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 +907,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} diff --git a/macros/latex/required/l3kernel/l3fparray.dtx b/macros/latex/required/l3kernel/l3fparray.dtx index f48de27af3..52b91d1296 100644 --- a/macros/latex/required/l3kernel/l3fparray.dtx +++ b/macros/latex/required/l3kernel/l3fparray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3int.dtx b/macros/latex/required/l3kernel/l3int.dtx index 45050964de..9782fe452c 100644 --- a/macros/latex/required/l3kernel/l3int.dtx +++ b/macros/latex/required/l3kernel/l3int.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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:MV, \int_gset:cV +% } % \begin{syntax} % \cs{int_set:Nn} \meta{integer} \Arg{int expr} % \end{syntax} @@ -426,7 +414,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 +434,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} @@ -1483,9 +1476,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 +1489,8 @@ { #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} diff --git a/macros/latex/required/l3kernel/l3intarray.dtx b/macros/latex/required/l3kernel/l3intarray.dtx index aa49275e78..9a9a5d64e8 100644 --- a/macros/latex/required/l3kernel/l3intarray.dtx +++ b/macros/latex/required/l3kernel/l3intarray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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..2678f3f965 100644 --- a/macros/latex/required/l3kernel/l3kernel-functions.dtx +++ b/macros/latex/required/l3kernel/l3kernel-functions.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3keys.dtx b/macros/latex/required/l3kernel/l3keys.dtx index 13772d1781..c9220d7279 100644 --- a/macros/latex/required/l3kernel/l3keys.dtx +++ b/macros/latex/required/l3kernel/l3keys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -500,9 +500,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 +510,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 +649,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 } % { @@ -1926,19 +1924,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 +1947,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} % diff --git a/macros/latex/required/l3kernel/l3legacy.dtx b/macros/latex/required/l3kernel/l3legacy.dtx index 4cfce5c5f1..b76516d1b0 100644 --- a/macros/latex/required/l3kernel/l3legacy.dtx +++ b/macros/latex/required/l3kernel/l3legacy.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3luatex.dtx b/macros/latex/required/l3kernel/l3luatex.dtx index eb10d5aecc..d7a6058a15 100644 --- a/macros/latex/required/l3kernel/l3luatex.dtx +++ b/macros/latex/required/l3kernel/l3luatex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -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..68058724e8 100644 --- a/macros/latex/required/l3kernel/l3msg.dtx +++ b/macros/latex/required/l3kernel/l3msg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3names.dtx b/macros/latex/required/l3kernel/l3names.dtx index 5cdd1361e3..95aeafe4a6 100644 --- a/macros/latex/required/l3kernel/l3names.dtx +++ b/macros/latex/required/l3kernel/l3names.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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..6082a4a8f0 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..ab42ee7d9e 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..0dc154f266 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..b65c38e4da 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..72b0bd7508 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..1ee5999389 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..796821593a 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..545b732f7a 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..66d91ae341 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..1e56ef2837 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..1d50364e6e 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..c5460e4ca7 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..517857c7dd 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..624fd08326 100644 --- a/macros/latex/required/l3kernel/l3pdf.dtx +++ b/macros/latex/required/l3kernel/l3pdf.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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 @@ -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..e9835fb3f0 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, @@ -78,6 +79,7 @@ etex,l3kernel,The LaTeX Project,https://www.latex-project.org/latex3.html,https: 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 +134,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 +164,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 +206,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 +216,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, @@ -239,6 +246,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 +266,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 +297,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 +309,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..3063489a71 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..c4f2ab1fa0 100644 --- a/macros/latex/required/l3kernel/l3prg.dtx +++ b/macros/latex/required/l3kernel/l3prg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -664,7 +664,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..47cd52320c 100644 --- a/macros/latex/required/l3kernel/l3prop.dtx +++ b/macros/latex/required/l3kernel/l3prop.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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{key1} |=| \meta{value1} |,| \\ +% ~~~~\meta{key2} |=| \meta{value2} |,| \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{key1} |=| \meta{value1} |,| \\ +% ~~~~\meta{key2} |=| \meta{value2} |,| \ldots{} \\ +% ~~\} % \end{syntax} % Creates a new constant \enquote{flat} \meta{property list} or raises % an error if the @@ -224,11 +224,11 @@ % \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{prop~var} \\ +% ~~\{ \\ +% ~~~~\meta{key1} |=| \meta{value1} |,| \\ +% ~~~~\meta{key2} |=| \meta{value2} |,| \ldots{} \\ +% ~~\} % \end{syntax} % Creates a new constant \enquote{linked} \meta{prop~var} or raises an % error if the @@ -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{key1} |=| \meta{value1} |,| \\ +% ~~~~\meta{key2} |=| \meta{value2} |,| \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 @@ -386,7 +386,7 @@ % 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} then the \meta{tl~var} is set % to the special marker \cs{q_no_value}. The \meta{token list % variable} is set within the current \TeX{} group. See also % \cs{prop_get:NnNTF}. @@ -405,7 +405,7 @@ % 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} 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}. @@ -424,11 +424,11 @@ % 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} 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} diff --git a/macros/latex/required/l3kernel/l3quark.dtx b/macros/latex/required/l3kernel/l3quark.dtx index 136596a3fe..5c6b0ca2d4 100644 --- a/macros/latex/required/l3kernel/l3quark.dtx +++ b/macros/latex/required/l3kernel/l3quark.dtx @@ -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 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3regex.dtx b/macros/latex/required/l3kernel/l3regex.dtx index 6ca9c8eeed..1fa9f71f08 100644 --- a/macros/latex/required/l3kernel/l3regex.dtx +++ b/macros/latex/required/l3kernel/l3regex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -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} @@ -5970,7 +5970,7 @@ % 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 +% In case no specific catcode is requested, we take into account the % current catcode regime (at the time the replacement is performed) % as much as reasonable, with all impossible catcodes (escape, % newline, etc.) being mapped to \enquote{other}. diff --git a/macros/latex/required/l3kernel/l3seq.dtx b/macros/latex/required/l3kernel/l3seq.dtx index 38fc9471a9..120081197b 100644 --- a/macros/latex/required/l3kernel/l3seq.dtx +++ b/macros/latex/required/l3kernel/l3seq.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -249,78 +249,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 +371,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} @@ -747,7 +747,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 +852,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} @@ -2409,6 +2409,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..2e15eb2866 100644 --- a/macros/latex/required/l3kernel/l3skip.dtx +++ b/macros/latex/required/l3kernel/l3skip.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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,7 +760,10 @@ % \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} @@ -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:Nn, \muskip_set:cn, +% \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..c599739d56 100644 --- a/macros/latex/required/l3kernel/l3sort.dtx +++ b/macros/latex/required/l3kernel/l3sort.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3str-convert.dtx b/macros/latex/required/l3kernel/l3str-convert.dtx index baf705fe0c..1976b092b1 100644 --- a/macros/latex/required/l3kernel/l3str-convert.dtx +++ b/macros/latex/required/l3kernel/l3str-convert.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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. diff --git a/macros/latex/required/l3kernel/l3str.dtx b/macros/latex/required/l3kernel/l3str.dtx index f4f7b94b88..94a74b17d1 100644 --- a/macros/latex/required/l3kernel/l3str.dtx +++ b/macros/latex/required/l3kernel/l3str.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -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..3bc937254f 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..32395f1377 100644 --- a/macros/latex/required/l3kernel/l3styleguide.tex +++ b/macros/latex/required/l3kernel/l3styleguide.tex @@ -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 2024-11-02} \begin{document} diff --git a/macros/latex/required/l3kernel/l3syntax-changes.pdf b/macros/latex/required/l3kernel/l3syntax-changes.pdf Binary files differindex 99e93c2ccc..5d7b4faff4 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..d86cba73d8 100644 --- a/macros/latex/required/l3kernel/l3syntax-changes.tex +++ b/macros/latex/required/l3kernel/l3syntax-changes.tex @@ -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 2024-11-02} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/required/l3kernel/l3sys.dtx b/macros/latex/required/l3kernel/l3sys.dtx index b2228c7fd9..4a600987da 100644 --- a/macros/latex/required/l3kernel/l3sys.dtx +++ b/macros/latex/required/l3kernel/l3sys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -336,9 +336,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 +374,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. @@ -1030,7 +1030,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..921a8a0614 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..cb01e6f812 100644 --- a/macros/latex/required/l3kernel/l3term-glossary.tex +++ b/macros/latex/required/l3kernel/l3term-glossary.tex @@ -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 2024-11-02} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/required/l3kernel/l3text-case.dtx b/macros/latex/required/l3kernel/l3text-case.dtx index 89cdb9e2b1..a9847bf900 100644 --- a/macros/latex/required/l3kernel/l3text-case.dtx +++ b/macros/latex/required/l3kernel/l3text-case.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3text-map.dtx b/macros/latex/required/l3kernel/l3text-map.dtx index 3573002244..52e304ec15 100644 --- a/macros/latex/required/l3kernel/l3text-map.dtx +++ b/macros/latex/required/l3kernel/l3text-map.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3text-purify.dtx b/macros/latex/required/l3kernel/l3text-purify.dtx index 35390811aa..8163fead6a 100644 --- a/macros/latex/required/l3kernel/l3text-purify.dtx +++ b/macros/latex/required/l3kernel/l3text-purify.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3text.dtx b/macros/latex/required/l3kernel/l3text.dtx index bcfd15cb62..559bc158ae 100644 --- a/macros/latex/required/l3kernel/l3text.dtx +++ b/macros/latex/required/l3kernel/l3text.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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 diff --git a/macros/latex/required/l3kernel/l3tl-analysis.dtx b/macros/latex/required/l3kernel/l3tl-analysis.dtx index 4df9ee68a3..d3342eb876 100644 --- a/macros/latex/required/l3kernel/l3tl-analysis.dtx +++ b/macros/latex/required/l3kernel/l3tl-analysis.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3tl-build.dtx b/macros/latex/required/l3kernel/l3tl-build.dtx index 6cd9822ad2..e3c615f5b2 100644 --- a/macros/latex/required/l3kernel/l3tl-build.dtx +++ b/macros/latex/required/l3kernel/l3tl-build.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % diff --git a/macros/latex/required/l3kernel/l3tl.dtx b/macros/latex/required/l3kernel/l3tl.dtx index 71d68d532c..3d08f2354b 100644 --- a/macros/latex/required/l3kernel/l3tl.dtx +++ b/macros/latex/required/l3kernel/l3tl.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \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} @@ -1110,7 +1110,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] % { diff --git a/macros/latex/required/l3kernel/l3token.dtx b/macros/latex/required/l3kernel/l3token.dtx index 03bf46b101..8dc792cab5 100644 --- a/macros/latex/required/l3kernel/l3token.dtx +++ b/macros/latex/required/l3kernel/l3token.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -660,7 +660,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 +671,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 +781,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 diff --git a/macros/latex/required/l3kernel/l3unicode.dtx b/macros/latex/required/l3kernel/l3unicode.dtx index 179817d490..5708992806 100644 --- a/macros/latex/required/l3kernel/l3unicode.dtx +++ b/macros/latex/required/l3kernel/l3unicode.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2024-05-27} +% \date{Released 2024-11-02} % % \maketitle % @@ -719,15 +719,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..463d639fb0 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..08d3319b5e 100644 --- a/macros/latex/required/l3kernel/source3.tex +++ b/macros/latex/required/l3kernel/source3.tex @@ -57,7 +57,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2024-05-27} +\date{Released 2024-11-02} \pagenumbering{roman} \maketitle diff --git a/macros/latex/required/l3kernel/source3body.tex b/macros/latex/required/l3kernel/source3body.tex index 8471296227..44b67816d6 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 @@ -344,6 +344,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} 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..6ed0532584 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..421ff15cd0 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..35c77075d6 100644 --- a/macros/latex/required/latex-lab/changes.txt +++ b/macros/latex/required/latex-lab/changes.txt @@ -1,12 +1,154 @@ +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..5fec54a3cb 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..562f8d98bc 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..828677fe17 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..507ada06ef 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..4b0855a05d 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..118baccd79 100644 --- a/macros/latex/required/latex-lab/latex-lab-firstaid.dtx +++ b/macros/latex/required/latex-lab/latex-lab-firstaid.dtx @@ -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{2024-10-16} +\def\ltlabfirstaidversion{0.85h} %<*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,179 @@ {\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:}} +\AddToHook{class/amsbook/after}[latex-lab-testphase-firstaid/amsthm] + {\tag_if_active:T{\@@_firstaid_amsthm:}} +\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.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 +381,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 +396,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 +409,7 @@ % See also issue \url{https://github.com/latex3/tagging-project/issues/69} % % +% \begin{macrocode} \ExplSyntaxOn \AddToHook{package/booktabs/after} { @@ -314,8 +434,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..a43b493f7d 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..3915910cc0 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..c928060b5f 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..48065014f2 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..9db1bd0b70 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..fb2a43437f 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..d16a507e01 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..3eb43692cb 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..7878bcfd34 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..3792133f44 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..b80a1c4b15 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..24491f9568 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..22a509f3ec 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..8476deafbd 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..cd840f015f 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..fc808ba24f 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..c81bcd9eb8 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..329c0beb36 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..2c3d82f7fe 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..071c82c763 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 |