summaryrefslogtreecommitdiff
path: root/macros/latex/required/babel/base/babel.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-03-30 03:03:36 +0000
committerNorbert Preining <norbert@preining.info>2024-03-30 03:03:36 +0000
commit16a9aadc4ae32ef5d7f20d62a3606b05e20f3405 (patch)
tree4cdbef1301bfdfe766434e49385bd2d251a7827e /macros/latex/required/babel/base/babel.dtx
parent23724df30adf3c6356ee7877833b8096987c643f (diff)
CTAN sync 202403300303
Diffstat (limited to 'macros/latex/required/babel/base/babel.dtx')
-rw-r--r--macros/latex/required/babel/base/babel.dtx146
1 files changed, 95 insertions, 51 deletions
diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx
index ea14d382bb..11b73fef9b 100644
--- a/macros/latex/required/babel/base/babel.dtx
+++ b/macros/latex/required/babel/base/babel.dtx
@@ -32,7 +32,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2024/02/07 v24.2 The Babel package]
+\ProvidesFile{babel.dtx}[2024/03/29 v24.3 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -748,7 +748,9 @@ for the language chosen:
\selectlanguage{german}
\end{verbatim}
-This command can be used as environment, too.
+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
@@ -785,15 +787,18 @@ This command can be used as environment, too.
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). \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).
+ 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}
@@ -851,7 +856,17 @@ is roughly equivalent to:
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.
+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
+ horizonal) is also not changed.
+\end{warning}
\Describe{\begin\menv{otherlanguage*}}%
{\oarg{option-list}\marg{language}\Eenv{otherlanguage*}}
@@ -889,9 +904,10 @@ group.
|\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. Except if there is a reason for
+ 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 to define your own alternatives.
+ selectors or even to define your own alternatives.
\end{warning}
\begin{example}
@@ -2258,19 +2274,11 @@ to select fonts in addition to the three basic families.
\babelfont[hindi]{rm}{Shobhika}
\end{verbatim}
This makes sure the OpenType script for Devanagari is |deva| and not
- |dev2|, in case it is not detected correctly. You may also pass some
- options to \textsf{fontspec}: with |silent|, the warnings about
- unavailable scripts or languages are not shown (they are only really
- useful when the document format is being set up).
-\end{note}
-
-\begin{note}
- Directionality is a property affecting margins, indentation, column
- order, etc., not just text. Therefore, it is under the direct control
- of the language, which applies both the script and the direction to
- the text. As a consequence, there is no need to set \texttt{Script}
- when declaring a font with |\babelfont| (nor \texttt{Language}). In
- fact, it is even discouraged.
+ |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}
@@ -2285,6 +2293,15 @@ to select fonts in addition to the three basic families.
\end{note}
\begin{note}
+ Directionality is a property affecting margins, indentation, column
+ order, etc., not just text. Therefore, it is under the direct control
+ of the language, which applies both the script and the direction to
+ the text. As a consequence, there is no need to set \texttt{Script}
+ when declaring a font with |\babelfont| (nor \texttt{Language}). In
+ fact, it is even discouraged.
+\end{note}
+
+\begin{note}
The keys |Language| and |Script| just pass these values to the
\textit{font}, and do \textit{not} set the script for the
\textit{language} (and therefore the writing direction). In other
@@ -3679,6 +3696,11 @@ the ‘provided’ locale. Currently there is a set of rules for French
named |punctuation.space|, which applies proper spacing with characters
\textit{;:!?«»}.
+\begin{note}
+ You can use |transforms| and |interchar| at the same time. Only the
+ relevant key for the current engine is taken into account.
+\end{note}
+
\subsection{Selection based on BCP 47 tags}
\label{bcp47}
@@ -4461,15 +4483,17 @@ autoload.options\\
autoload.bcp47.prefix\\
autoload.bcp47.options\\
prehyphenation.disable\\
+interchar.disable\\
select.write\\
select.encoding\\
\end{multicols}
Most of them are documented elsewhere. With |select.encoding=off|, the
encoding is not set when loading a language on the fly with \pdftex{}
(only |off|). |prehyphenation.disable| is by default |nohyphenation|,
-which means prehyphenation transforms are not applied if the current
+which means \luatex{} prehyphenation transforms are not applied if the current
hyphenation rules are |nohyphenation|; with |off| they are never
-disabled.
+disabled. |interchar.disable| takes the same values, but for the
+\xetex{} interchar mechanism.
For example, you can set |\babeladjust{bidi.text=off}| if you are using
an alternative algorithm or with large sections not requiring it. Use
@@ -5427,8 +5451,8 @@ wouldn’t exist.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=24.2>>
-%<<date=2024/02/07>>
+%<<version=24.3>>
+%<<date=2024/03/29>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -6588,7 +6612,8 @@ wouldn’t exist.
\chardef\localeid\bbl@cl{id@}}
% \end{macrocode}
%
-% The unprotected part of |\selectlanguage|.
+% The unprotected part of |\selectlanguage|. In case it is used as
+% environment, declare |\endselectlaguage|, just for safety.
%
% \begin{macrocode}
\expandafter\def\csname selectlanguage \endcsname#1{%
@@ -6596,6 +6621,7 @@ wouldn’t exist.
\bbl@push@language
\aftergroup\bbl@pop@language
\bbl@set@language{#1}}
+\let\endselectlanguage\relax
% \end{macrocode}
%
% \end{macro}
@@ -6814,14 +6840,10 @@ wouldn’t exist.
% \end{macrocode}
%
% \begin{environment}{otherlanguage}
-% The \Lenv{otherlanguage} environment can be used as an
-% alternative to using the |\selectlanguage| declarative
-% command. When you are typesetting a document which mixes
-% left-to-right and right-to-left typesetting you have to use this
-% environment in order to let things work as you expect them to.
-%
-% The |\ignorespaces| command is necessary to hide the environment
-% when it is entered in horizontal mode.
+% The \Lenv{otherlanguage} environment 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.
%
% \begin{macrocode}
\long\def\otherlanguage#1{%
@@ -6835,8 +6857,7 @@ wouldn’t exist.
% itself when it is called in horizontal mode.
%
% \begin{macrocode}
-\long\def\endotherlanguage{%
- \global\@ignoretrue\ignorespaces}
+\long\def\endotherlanguage{\@ignoretrue\ignorespaces}
% \end{macrocode}
%
% \end{environment}
@@ -11585,6 +11606,15 @@ wouldn’t exist.
\directlua{ Babel.ignore_pre_char = function(node)
return false
end }}
+\@namedef{bbl@ADJ@interchar.disable@nohyphenation}{%
+ \def\bbl@ignoreinterchar{%
+ \ifnum\language=\l@nohyphenation
+ \expandafter\@gobble
+ \else
+ \expandafter\@firstofone
+ \fi}}
+\@namedef{bbl@ADJ@interchar.disable@off}{%
+ \let\bbl@ignoreinterchar\@firstofone}
\@namedef{bbl@ADJ@select.write@shift}{%
\let\bbl@restorelastskip\relax
\def\bbl@savelastskip{%
@@ -13598,7 +13628,7 @@ wouldn’t exist.
\let\\\bbl@tempfs@nxx\<__fontspec_warning:nxx>%
\let\<__fontspec_warning:nxx>\\\bbl@fs@warn@nxx
\\\renewfontfamily\\#4%
- [\bbl@cl{lsys},%
+ [\bbl@cl{lsys},% xetex removes unknown features :-(
\ifcase\bbl@engine\or RawFeature={family=\bbl@tempb},\fi
#2]}{#3}% ie \bbl@exp{..}{#3}
\bbl@exp{%
@@ -13878,16 +13908,17 @@ wouldn’t exist.
% ‘disabled’ with |\bbl@ic@<label>@<lang>|.
%
% \begin{macrocode}
+\def\bbl@ignoreinterchar{%
+ \ifnum\language=\l@nohyphenation
+ \expandafter\@gobble
+ \else
+ \expandafter\@firstofone
+ \fi}
\newcommand\babelinterchar[5][]{%
\let\bbl@kv@label\@empty
\bbl@forkv{#1}{\bbl@csarg\edef{kv@##1}{##2}}%
\@namedef{\zap@space bbl@xeinter@\bbl@kv@label @#3@#4@#2 \@empty}%
- {\ifnum\language=\l@nohyphenation
- \expandafter\@gobble
- \else
- \expandafter\@firstofone
- \fi
- {#5}}%
+ {\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}}{%
@@ -15540,9 +15571,14 @@ end
local d = node.new(node.id'dir')
d.dir = '+TRT'
node.insert_before(head, node.has_glyph(head), d)
+ local inmath = false
for item in node.traverse(head) do
- node.set_attribute(item,
- Babel.attr_dir, token.get_macro('bbl@thedir'))
+ if item.id == 11 then
+ inmath = (item.subtype == 0)
+ elseif not inmath then
+ node.set_attribute(item,
+ Babel.attr_dir, token.get_macro('bbl@thedir'))
+ end
end
end
end
@@ -15554,6 +15590,14 @@ end
\fi
% \end{macrocode}
%
+% Experimental. Tentative name.
+%
+% \begin{macrocode}
+\DeclareRobustCommand\localebox[1]{%
+ {\def\bbl@insidemath{0}%
+ \mbox{\foreignlanguage{\languagename}{#1}}}}
+% \end{macrocode}
+%
% \subsection{Layout}
%
% Unlike \xetex{}, \luatex{} requires only minimal changes for