summaryrefslogtreecommitdiff
path: root/macros/latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-10-21 03:04:35 +0000
committerNorbert Preining <norbert@preining.info>2024-10-21 03:04:35 +0000
commit6c36a80687be9b4a10263a5f07169443f525a406 (patch)
treef60ef385a4331d607586c27348f0e3311f173a05 /macros/latex
parent75e20d10d2992ee47748cddb2d268a7fb6741e4b (diff)
CTAN sync 202410210304
Diffstat (limited to 'macros/latex')
-rw-r--r--macros/latex/contrib/sjtutex/sjtutex.dtx20
-rw-r--r--macros/latex/contrib/sjtutex/sjtutex.pdfbin724629 -> 725422 bytes
-rw-r--r--macros/latex/required/babel/base/README.md19
-rw-r--r--macros/latex/required/babel/base/babel-code.pdfbin675546 -> 676588 bytes
-rw-r--r--macros/latex/required/babel/base/babel.dtx1369
-rw-r--r--macros/latex/required/babel/base/babel.ins5
-rw-r--r--macros/latex/required/babel/base/babel.pdfbin458414 -> 468056 bytes
-rw-r--r--macros/latex/required/babel/base/bbcompat.dtx2
8 files changed, 816 insertions, 599 deletions
diff --git a/macros/latex/contrib/sjtutex/sjtutex.dtx b/macros/latex/contrib/sjtutex/sjtutex.dtx
index bcf46b7fbe..095a940c0f 100644
--- a/macros/latex/contrib/sjtutex/sjtutex.dtx
+++ b/macros/latex/contrib/sjtutex/sjtutex.dtx
@@ -216,7 +216,7 @@
Please update your TeX distribution}{}}
%</class>
%<*!(driver|install)>
-%<+!driver>\GetIdInfo$Id: sjtutex.dtx 78f11bc 2024-06-29 23:01:32 +0800 Alexara Wu <alexarawu@outlook.com> $
+%<+!driver>\GetIdInfo$Id: sjtutex.dtx ce44827 2024-10-21 00:12:31 +0800 Alexara Wu <alexarawu@outlook.com> $
%<class&thesis> {Thesis document class for Shanghai Jiao Tong University (SJTUTeX)}
%<class&thesis>\ProvidesExplClass{sjtuthesis}
%<class&report> {Report document class for Shanghai Jiao Tong University (SJTUTeX)}
@@ -335,7 +335,7 @@
%<font&cjk&founder&zh>\ProvidesExplFile{sjtu-cjk-font-founder-zh.def}
%<font&cjk&founder&ja> {Founder CJK fonts definition for Japanese (SJTUTeX)}
%<font&cjk&founder&ja>\ProvidesExplFile{sjtu-cjk-font-founder-ja.def}
-%<!driver> {\ExplFileDate}{2.1.3}{\ExplFileDescription}
+%<!driver> {\ExplFileDate}{2.1.4}{\ExplFileDescription}
%</!(driver|install)>
%
%<*driver>
@@ -343,7 +343,7 @@
\documentclass{ctxdoc}
\newcommand{\sjtutex}{SJTU\TeX}
\expandafter\def\csname ver@\jobname.dtx\endcsname
- {2024/06/29 v2.1.3 SJTUTeX}
+ {2024/10/21 v2.1.4 SJTUTeX}
\usepackage{float}
\usepackage{multirow}
\usepackage{longtable}
@@ -4869,10 +4869,11 @@
% 汉字分散对齐的表格列说明符。
% \begin{macrocode}
\newcolumntype { \SJTU@CT@D } [ 1 ]
- { >{ \begin { SJTU@CJK@FTS } {#1} } c <{ \end { SJTU@CJK@FTS } } }
+ { > { \begin { SJTU@CJK@FTS } {#1} } c < { \end { SJTU@CJK@FTS } } }
% \end{macrocode}
%
% \changes{v2.1}{2023/11/30}{标题页信息栏改用表格实现。}
+% \changes{v2.1.4}{2024/08/14}{标题页信息栏允许手动换行。}
% \begin{macro}[int]{\@@_title_page_info_i:nnn,\@@_title_page_info_i:nxx,
% \@@_title_page_info_ii:n}
% 信息输出。
@@ -4886,7 +4887,12 @@
{
\exp_not:o { \cs:w c_@@_name_ ##1 _ #1 _tl \cs_end: }
&
- \exp_not:o { \cs:w l_@@_info_ ##1 _ #1 _tl \cs_end: }
+ \exp_not:N \hbox:n
+ {
+ \exp_not:N \tabular [ t ] { @{} l @{} }
+ \exp_not:o { \cs:w l_@@_info_ ##1 _ #1 _tl \cs_end: }
+ \exp_not:N \endtabular
+ }
}
}
\group_begin:
@@ -4951,7 +4957,7 @@
{
\exp_not:N \SJTU@CT@D { 5 em }
@ { \exp_not:V \c_@@_name_info_sep_zh_tl }
- >{ \exp_not:N \normalfont } l
+ > { \exp_not:N \setbaselineskip { 22.5 bp } \exp_not:N \normalfont } l
}
{
author,
@@ -5015,7 +5021,7 @@
%<en> r @ { \exp_not:V \c_@@_name_info_sep_en_tl }
%<de> r @ { \exp_not:V \c_@@_name_info_sep_de_tl }
%<ja> r @ { \exp_not:V \c_@@_name_info_sep_ja_tl }
- >{ \exp_not:N \normalfont } l
+ > { \exp_not:N \setbaselineskip { 22.5 bp } \exp_not:N \normalfont } l
}
{ author, \l_@@_info_supervisors_clist }
} ,
diff --git a/macros/latex/contrib/sjtutex/sjtutex.pdf b/macros/latex/contrib/sjtutex/sjtutex.pdf
index a5994fd3be..44ed7415c7 100644
--- a/macros/latex/contrib/sjtutex/sjtutex.pdf
+++ b/macros/latex/contrib/sjtutex/sjtutex.pdf
Binary files differ
diff --git a/macros/latex/required/babel/base/README.md b/macros/latex/required/babel/base/README.md
index 2567f7ec34..553a7b9eca 100644
--- a/macros/latex/required/babel/base/README.md
+++ b/macros/latex/required/babel/base/README.md
@@ -1,6 +1,6 @@
-## Babel 24.11
+## Babel 24.12
-2024-10-05
+2024-10-20
`babel` is the multilingual framework to localize documents in
LaTeX, LuaLaTeX, XeLaTeX. It manages culturally-determined
@@ -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.11 are described in:
+Changes in version 24.12 are described in:
-https://latex3.github.io/babel/news/whats-new-in-babel-24.11.html
+https://latex3.github.io/babel/news/whats-new-in-babel-24.12.html
Apart from the manual, you can find information on some aspects of babel at:
@@ -48,9 +48,14 @@ respective authors.
### Summary of latest changes
```
-24.11 2024-10-05
- * Start a thorough review of the manual.
- * (lua) Transform variables.
+24.12 2024-10-20
+ * Fixes:
+ - Date sometimes missing with lazy loading.
+ - Wrong stigma in some Greek numerals.
+ - Wrong handling of ‘complex’ class options.
+ * More tools for automated document generation workflows:
+ - New LaTeX hook: presets.
+ - New command: \PassOptionsToLocale.
```
### Previous changes
diff --git a/macros/latex/required/babel/base/babel-code.pdf b/macros/latex/required/babel/base/babel-code.pdf
index b4a04b5029..19abc23a6e 100644
--- a/macros/latex/required/babel/base/babel-code.pdf
+++ b/macros/latex/required/babel/base/babel-code.pdf
Binary files differ
diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx
index d71d80d19a..012619e64b 100644
--- a/macros/latex/required/babel/base/babel.dtx
+++ b/macros/latex/required/babel/base/babel.dtx
@@ -32,7 +32,9 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2024/10/05 v24.11 The Babel package]
+\ProvidesFile{babel.dtx}%
+ [2024/10/20 v24.12
+ The multilingual framework for pdfLaTeX, LuaLaTeX and XeLaTeX]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -396,12 +398,11 @@ document encoding is UTF-8). Other scripts require loading
(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 \xetex{} and \luatex{}). 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}
@@ -506,9 +507,7 @@ even better, make sure the encoding in your editor is set to UTF-8.
\end{troubleshooting}
\begin{troubleshooting}
-Another typical error when using \babel{} is the
- following:\footnote{In old versions the error read ``You haven't
- loaded the language LANG yet''.}
+Another typical error when using \babel{} is the following:
\trouble{Unknown language `LANG'}
\begin{verbatim}
! Package babel Error: Unknown language `#1'. Either you have
@@ -546,11 +545,10 @@ Package babel Warning: No hyphenation patterns were preloaded for
\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:\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}
+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}
! Package babel Error: You are loading directly a language style.
(babel) This syntax is deprecated and you must use
@@ -778,6 +776,37 @@ Vietnamese: \prefacename, \alsoname, \today.
\end{verbatim}
\end{note}
+\subsection{Multilingual documents: the ‘modern’ way}
+
+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}
+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[dutch,ngerman,thai,provide=*]{babel}
+\babelfont{rm}{Norasi}
+\end{verbatim}
+\end{example}
+
+More complex combinations can be handled with |\babelprovide|,
+explained below.
+
\subsection{Languages supported by \babel{} in the ‘classical’ mode}
(To be updated.) In the following table most of the languages supported
@@ -988,7 +1017,6 @@ they are ‘bare minimum locales’. They are set in
\bigskip\hrule\nobreak
\makeatletter
-\def\tag#1{\par\@hangfrom{\makebox[1em][l]{#1}}\ignorespaces}
\def\tag#1#2#3{\par
\hspace{-2em}\textcolor{thered}{\texttt{#1}}#2\enspace
\mbox{\footnotesize(#3)}}
@@ -1078,6 +1106,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}
@@ -1086,7 +1115,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}
@@ -1104,6 +1132,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}
@@ -1176,7 +1205,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}
@@ -1261,7 +1289,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}
@@ -1334,10 +1361,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}
@@ -1393,7 +1422,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}
@@ -1451,11 +1479,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}
@@ -1559,14 +1586,19 @@ 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}
+ 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}
+
\Describe\babelfont{\oarg{language-list}\marg{font-family}%
\oarg{font-options}\marg{font-name}}
-% \begin{note}
-% See the note in the previous section about some issues in
-% specific languages.
-% \end{note}
-
The main purpose of |\babelfont| is to define at once the fonts
required by the different languages, with their corresponding language
systems (script and language). So, if you load, say, 4 languages,
@@ -1591,10 +1623,11 @@ 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). 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
@@ -1653,8 +1686,20 @@ 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 language and
-script.
+\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}
@@ -1904,6 +1949,66 @@ environment of |\foreignlanguage|, except when the package option
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 \xetex{} and \luatex, 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
@@ -1999,7 +2104,7 @@ 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.}
+|fontenc| (with it, encoded strings may not work as expected).
A couple of examples:
\begin{verbatim}
\babelensure[include=\Today]{spanish}
@@ -2287,10 +2392,10 @@ be the same as the option name as set in |\usepackage|!).
\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|.
+ An alternative method to execute some code just after an |ldf| file
+ is loaded is with |\AddToHook| and the hook
+ |file/<language>.ldf/after|. You can also execute some code before
+ with |file/<language>.ldf/before|.
\end{note}
\begin{warning}
@@ -2331,29 +2436,23 @@ lack of suitability of some features.
\babel).
\end{example}
-\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| and |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}
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:
+ 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}
@@ -2522,8 +2621,8 @@ This section describes the general tools provided by the \babel{} core.
\subsection{Captions}
-In the case of caption names a specific macro is provided,
-because this is perhaps the most frequent change.
+This is perhaps the most frequent change, so a specific macro is
+provided.
\Describe{\setlocalecaption}{%
\marg{language-name}\marg{caption-name}\marg{string}}
@@ -2550,8 +2649,8 @@ redefined behave with the ‘new way’ described in the following note.
(In this particular case, instead of the |captions| group you may need
to modify the |captions.licr| one.)
-\item The ‘old way’ to redefine a caption, still valid for many
-languages but discouraged in general, 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}%
@@ -2564,7 +2663,7 @@ languages but discouraged in general, is the following:
\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}
@@ -2891,6 +2990,55 @@ 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
@@ -2934,7 +3082,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}
@@ -3649,9 +3797,9 @@ the manual for Greek) |;|
\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.}
+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}}
@@ -4388,8 +4536,8 @@ 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}
@@ -4918,6 +5066,8 @@ options (like paragraph direction with |bidi.text|).
\section{Relation with other packages}
+\subsection{Compatibility}
+
There are compatibility issues with the following packages.
\begingroup
@@ -4941,33 +5091,46 @@ 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
+\subsection{Related packages}
+
The following packages can be useful in multilingual contexts (the list
-is far from complete):
+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}
-For multilingual indexing, see \textsf{upmendex} and \textsf{xindex}.
+\subsection{Indexing}
+
+For multilingual indexing, see \textsf{upmendex} and \textsf{xindex},
+currently preferred to \textit{xindy}.
\section{Tentative and experimental code}
@@ -5017,11 +5180,11 @@ the data so that it works as expected.
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
@@ -5038,9 +5201,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
@@ -5117,8 +5279,8 @@ Some recommendations:
\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}
@@ -5203,7 +5365,8 @@ two parameters. For example:
\renewcommand\spanishhyphenmins{34}
\end{verbatim}
(Assigning |\lefthyphenmin| and |\righthyphenmin| directly in
-|\extras<language>| 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
@@ -5611,9 +5774,7 @@ 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.
@@ -5796,8 +5957,8 @@ wouldn’t exist.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=24.11>>
-%<<date=2024/10/05>>
+%<<version=24.12>>
+%<<date=2024/10/20>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -6200,8 +6361,10 @@ wouldn’t exist.
%
% \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 tools, and then define macros for
@@ -6466,7 +6629,6 @@ wouldn’t exist.
\def\bbl@opt@provide{#2}%
\fi}
\fi
-%
% \end{macrocode}
%
% If there is no |shorthands=<chars>|, the original \textsf{babel}
@@ -6585,6 +6747,8 @@ 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
@@ -6595,15 +6759,12 @@ wouldn’t exist.
<@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>
-% \end{macrocode}
-%
% \section{\texttt{babel.sty} and \texttt{babel.def} (common)}
%
% \begin{macrocode}
@@ -6720,38 +6881,6 @@ wouldn’t exist.
\fi
\fi\fi}
\let\bbl@initoload\relax
-%</package|core>
-%<*package>
-\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}
-%</package>
-%<*package|core>
% \end{macrocode}
%
% \macro{\iflanguage}
@@ -6975,9 +7104,6 @@ wouldn’t exist.
\let\bbl@restorelastskip\relax
\let\bbl@savelastskip\relax
%
-\newif\ifbbl@bcpallowed
-\bbl@bcpallowedfalse
-%
\def\select@language#1{% from set@, babel@aux, babel@toc
\ifx\bbl@selectorname\@empty
\def\bbl@selectorname{select}%
@@ -7500,20 +7626,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
@@ -7561,66 +7809,6 @@ wouldn’t exist.
\fi}
% \end{macrocode}
%
-% 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}
-%
-% \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}
-%
-% \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{Hooks}
%
% Admittedly, the current implementation is a somewhat simplistic and
@@ -7673,90 +7861,12 @@ wouldn’t exist.
\fi
% \end{macrocode}
%
-% \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.
+% 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}
%
% \subsection{Setting up language files}
@@ -7911,31 +8021,12 @@ wouldn’t exist.
\immediate\write\@mainaux{\string\@nameuse{bbl@beforestart}}%
\fi
\expandafter\selectlanguage\expandafter{\bbl@main@language}%
-%</package|core>
-%<*package>
- \ifx\bbl@normalsf\@empty
- \ifnum\sfcode`\.=\@m
- \let\normalsfcodes\frenchspacing
- \else
- \let\normalsfcodes\nonfrenchspacing
- \fi
- \else
- \let\normalsfcodes\bbl@normalsf
- \fi
-%</package>
-%<*package|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}
-%</package|core>
-%<*package>
-\AddToHook{begindocument/before}{%
- \let\bbl@normalsf\normalsfcodes
- \let\normalsfcodes\relax} % Hack, to delay the setting
-%</package>%
-%<*package|core>
+%
\ifcase\bbl@engine\or
\AtBeginDocument{\pagedir\bodydir}
\fi
@@ -7955,6 +8046,19 @@ wouldn’t exist.
%
% \subsection{Shorthands}
%
+% 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
@@ -7968,7 +8072,6 @@ wouldn’t exist.
% done with |\nfss@catcodes|, added in 3.10.
%
% \begin{macrocode}
-\bbl@trace{Shorhands}
\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}}%
@@ -8844,7 +8947,7 @@ wouldn’t exist.
\AtBeginDocument{\bbl@clear@ttribs}
% \end{macrocode}
%
-% \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
@@ -8876,15 +8979,14 @@ wouldn’t exist.
% \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{%
@@ -8905,15 +9007,62 @@ wouldn’t exist.
\bbl@exp{\def\\\originalTeX{\the\toks@\the#1\relax}}}
% \end{macrocode}
%
+% \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}
+%
+% \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{%
@@ -8924,6 +9073,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}%
@@ -8954,32 +9110,6 @@ wouldn’t exist.
\fi\fi\fi}
% \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}
-\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}
-%
% \subsection{Hyphens}
%
% \macro{\babelhyphenation}
@@ -9045,10 +9175,10 @@ wouldn’t exist.
%
% \macro{\bbl@allowhyphens}
%
-% This macro makes hyphenation possible. Basically its definition
-% is nothing more than |\nobreak| |\hskip| \texttt{0pt plus
-% 0pt}\footnote{\TeX\ begins and ends a word for hyphenation at a
-% glue node. The penalty prevents a linebreak at this glue node.}.
+% This macro makes hyphenation possible. Basically its definition is
+% nothing more than |\nobreak| |\hskip| \texttt{0pt plus 0pt}. \TeX\
+% begins and ends a word for hyphenation at a glue node. The penalty
+% prevents a linebreak at this glue node.
%
% \begin{macrocode}
\def\bbl@allowhyphens{\ifvmode\else\nobreak\hskip\z@skip\fi}
@@ -9989,43 +10119,6 @@ wouldn’t exist.
% \begin{macrocode}
\bbl@trace{Bidi layout}
\providecommand\IfBabelLayout[3]{#3}%
-%</package|core>
-%<*package>
-\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}}{}
-%</package>
-%<*package|core>
% \end{macrocode}
%
% \subsection{Load engine specific macros}
@@ -10075,7 +10168,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
@@ -10084,7 +10177,10 @@ wouldn’t exist.
\global\let\bbl@extend@ini\@gobble
\global\let\bbl@included@inis\@empty
\gdef\bbl@key@list{;}%
- \bbl@forkv{#1}{%
+ \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
@@ -10101,6 +10197,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
@@ -10198,121 +10298,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}}}%
- \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 ==
- \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
@@ -10328,6 +10319,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) ==
@@ -11206,17 +11198,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.
@@ -11512,6 +11527,11 @@ wouldn’t exist.
% 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}%
@@ -11584,36 +11604,6 @@ wouldn’t exist.
\@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.<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). The argument is the prefix to
-% tag.bcp47. Can be prece
-\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}
-%
% With version 3.75 |\BabelEnsureInfo| is executed always, but there is
% an option to disable it.
%
@@ -11667,6 +11657,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
@@ -11952,11 +12003,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
@@ -11966,6 +12012,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}}%
@@ -12062,6 +12110,44 @@ wouldn’t exist.
\fi
% \end{macrocode}
%
+% \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}
%
% \macro{\markright}
@@ -12724,6 +12810,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}{}}
@@ -12763,16 +12850,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 \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.
+% \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
@@ -12816,11 +12913,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)
@@ -12833,21 +12930,24 @@ wouldn’t exist.
\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*{}
@@ -12867,7 +12967,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}
@@ -12891,7 +12991,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)
@@ -13514,7 +13616,8 @@ wouldn’t exist.
%
% 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>>
@@ -13761,7 +13864,7 @@ wouldn’t exist.
%
% \macro{\BabelFootnote}
%
-% Footnotes
+% Footnotes.
%
% \begin{macrocode}
%<<*Footnote changes>>
@@ -13890,7 +13993,7 @@ wouldn’t exist.
\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
@@ -14457,6 +14560,22 @@ wouldn’t exist.
callback.register('process_input_buffer',Babel.callback)
end
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 ''
@@ -14523,9 +14642,9 @@ 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
@@ -14630,25 +14749,6 @@ end
% not touched. See Unicode UAX 14.
%
% \begin{macrocode}
-% TODO - to a lua file -- or a logical place
-\directlua{% DL5
- 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.intraspaces = Babel.intraspaces or {}
@@ -15901,6 +16001,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
diff --git a/macros/latex/required/babel/base/babel.ins b/macros/latex/required/babel/base/babel.ins
index 649fdcfb09..54ab523887 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/10/05}
+\def\filedate{2024/10/20}
\def\batchfile{babel.ins}
\input docstrip.tex
@@ -174,9 +174,6 @@
% Compatibility files
-\let\minusOption\bblMinus
-\let\plusOption\bblPlus
-
\def\compatfile#1{\file{#1.sty}{\from{bbcompat.dtx}{styfile,#1}}}
\generate{%
diff --git a/macros/latex/required/babel/base/babel.pdf b/macros/latex/required/babel/base/babel.pdf
index 6642653c91..974e278377 100644
--- a/macros/latex/required/babel/base/babel.pdf
+++ b/macros/latex/required/babel/base/babel.pdf
Binary files differ
diff --git a/macros/latex/required/babel/base/bbcompat.dtx b/macros/latex/required/babel/base/bbcompat.dtx
index 44813fd170..806907fc07 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/10/05 v24.]
+\ProvidesFile{bbcompat.dtx}[2024/10/20 v24.]
%</dtx>
%
%% File 'bbcompat.dtx'