diff options
author | Karl Berry <karl@freefriends.org> | 2022-02-24 20:55:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-02-24 20:55:39 +0000 |
commit | bc5ed4f3a9e7ab2e27842c931b8b945a2d22d616 (patch) | |
tree | 2b4f201ca0933118924a855cb490c21e34514c50 /Master/texmf-dist/source/latex/babel/babel.dtx | |
parent | a376a4dd47279e493eb5c5b3130ccf92598b1504 (diff) |
babel (24feb22)
git-svn-id: svn://tug.org/texlive/trunk@62166 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/babel/babel.dtx | 175 |
1 files changed, 80 insertions, 95 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index d5706cdaf13..b8b3ce531d6 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -32,7 +32,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2022/02/13 v3.71 The Babel package] +\ProvidesFile{babel.dtx}[2022/02/24 v3.72 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -2567,20 +2567,22 @@ line breking mode that allows spaces to be stretched to arbitrary amounts. (thus overriding that set when \babel\ is loaded). Only in newly defined languages. \begin{example} - Let's assume your document is mainly in Polytonic Greek, but with some - sections in Italian. Then, the first attempt should be: + Let's assume your document (\xetex{} or \luatex{}) is mainly in + Polytonic Greek with but with some sections in Italian. Then, the + first attempt should be: \begin{verbatim} \usepackage[italian, greek.polutonic]{babel} \end{verbatim} - But if, say, accents in Greek are not shown correctly, you can try: + But if, say, accents in Greek are not shown correctly, you can try \begin{verbatim} -\usepackage[italian]{babel} -\babelprovide[import, main]{polytonicgreek} +\usepackage[italian, polytonicgreek, provide=*]{babel} \end{verbatim} Remerber there is an alternative syntax for the latter: \begin{verbatim} -\usepackage[italian, polytonicgreek, provide=*]{babel} +\usepackage[italian]{babel} +\babelprovide[import, main]{polytonicgreek} \end{verbatim} + Finally, also remember you might not need to load |italian| at all if there are only a few word in this language (see~\ref{mostlymono}). @@ -3813,13 +3815,14 @@ options are also used (eg, |\ProsodicMarksOn| in \textsf{latin}). events. Some hooks are predefined when \luatex{} and \xetex{} are used. -% \New{3.62} 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/|\marg{name}, 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. +\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}} @@ -3903,26 +3906,26 @@ ones, they only have a single hook and replace a default definition. 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/|\marg{hook-name}|/|\marg{language-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} -% \ProvideHook{babel/afterextras/bengali} -% \AddToHook{babel/afterextras/bengali}{\frenchspacing} -% \end{verbatim} -% \end{example} +\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 @@ -4096,7 +4099,7 @@ direction with |bidi.text|). 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 |\foreinglanguage|, the apostrophes might not be taken into + 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 @@ -5100,8 +5103,8 @@ help from Bernd Raichle, for which I am grateful. % \section{Tools} % % \begin{macrocode} -%<<version=3.71>> -%<<date=2022/02/13>> +%<<version=3.72>> +%<<date=2022/02/24>> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They @@ -5364,7 +5367,7 @@ help from Bernd Raichle, for which I am grateful. % \end{macrocode} % \end{macro} % -% Two further tools. |\bbl@samestring| first expand its arguments and +% Two further tools. |\bbl@ifsamestring| first expand its arguments and % then compare their expansion (sanitized, so that the catcodes do not % matter). |\bbl@engine| takes the following values: 0 is pdf\TeX, 1 % is \luatex, and 2 is \xetex. You may use the latter it in your @@ -9735,6 +9738,8 @@ help from Bernd Raichle, for which I am grateful. % == onchar == \ifx\bbl@KVP@onchar\@nil\else \bbl@luahyphenate + \bbl@exp{% + \\\AddToHook{env/document/before}{{\\\select@language{#2}{}}}}% \directlua{ if Babel.locale_mapped == nil then Babel.locale_mapped = true @@ -12133,6 +12138,10 @@ help from Bernd Raichle, for which I am grateful. \fi \fi}% \fi +\else + \bbl@info{Main language set with 'main='. Except if you have\\% + problems, prefer the default mechanism for setting\\% + the main language. Reported} \fi % \end{macrocode} % @@ -14478,19 +14487,8 @@ end % \ifnum\bbl@bidimode>\z@ \def\bbl@insidemath{0}% - \def\bbl@mathboxdir{% - \ifcase\bbl@thetextdir\relax - \everyhbox{\bbl@mathboxdir@aux L}% - \else - \everyhbox{\bbl@mathboxdir@aux R}% - \fi} - \def\bbl@mathboxdir@aux#1{% - \@ifnextchar\egroup{}{\textdir T#1T\relax}} \def\bbl@everymath{\def\bbl@insidemath{1}} - \def\bbl@everydisplay{% - \bbl@mathboxdir - \def\bbl@everymath{\bbl@mathboxdir}% - \def\bbl@insidemath{2}} + \def\bbl@everydisplay{\def\bbl@insidemath{2}} \frozen@everymath\expandafter{% \expandafter\bbl@everymath\the\frozen@everymath} \frozen@everydisplay\expandafter{% @@ -14571,69 +14569,56 @@ end \fi \else % amstex \ifx\bbl@noamsmath\@undefined - \edef\bbl@tempa{% - \catcode58=\the\catcode58\relax - \catcode95=\the\catcode95\relax}% - \catcode58=11 - \catcode95=11 + \@ifpackagewith{amsmath}{leqno}% + {\let\bbl@ams@lap\hbox}% = leqno + {\let\bbl@ams@lap\llap}% = default + \ExplSyntaxOn \bbl@sreplace\intertext@{\normalbaselines}% {\normalbaselines \ifx\bbl@eqnodir\relax\else\bbl@pardir\@ne\bbl@eqnodir\fi}% - \bbl@tempa - \def\bbl@ams@tagbox#1#2{#1{\bbl@eqnodir#2}}% #1=\hbox|ams@lap - \def\bbl@ams@eqtagbox#1{% - \setbox\z@\hbox{\bbl@eqnodir#1}% - \hbox to 0.01pt{% - \ifx\bbl@ams@lap\hbox - \hbox to\displaywidth{\hss\box\z@}\hss - \else - \hss\hbox to\displaywidth{\box\z@\hss}% - \fi}} + \ExplSyntaxOff + \def\bbl@ams@tagbox#1#2{#1{\bbl@eqnodir#2}}% #1=hbox|@lap|flip + \ifx\bbl@ams@lap\hbox % leqno + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hss\hbox to\displaywidth{{#1}\hss}}}% + \else % eqno + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hbox to\displaywidth{\hss{#1}}\hss}}% + \fi \def\bbl@ams@preset#1{% \ifnum\bbl@thetextdir>\z@ \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% - \chardef\bbl@thetextdir\z@ \bbl@sreplace\textdef@{\hbox}{\bbl@ams@tagbox\hbox}% \bbl@sreplace\maketag@@@{\hbox}{\bbl@ams@tagbox#1}% - \fi} - \@ifpackagewith{amsmath}{leqno}% - {\let\bbl@ams@lap\hbox}% = leqno - {\let\bbl@ams@lap\llap}% = default - % + \fi}% + \AddToHook{env/equation/begin}{% + \ifnum\bbl@thetextdir>\z@ + \ifx\bbl@ams@lap\llap\hrule\@height\z@\fi + \bbl@ams@preset\bbl@ams@flip + \fi}% + \AddToHook{env/equation*/begin}{\bbl@ams@preset\bbl@ams@flip}% \AddToHook{env/cases/begin}{\bbl@ams@preset\bbl@ams@lap}% \AddToHook{env/multline/begin}{\bbl@ams@preset\hbox}% \AddToHook{env/gather/begin}{\bbl@ams@preset\bbl@ams@lap}% \AddToHook{env/gather*/begin}{\bbl@ams@preset\bbl@ams@lap}% \AddToHook{env/align/begin}{\bbl@ams@preset\bbl@ams@lap}% \AddToHook{env/align*/begin}{\bbl@ams@preset\bbl@ams@lap}% - % Hackish, for proper alignment-don’t ask me why it works! :-) - \bbl@exp{% - \\\AddToHook{env/align*/end}{\<iftag@>\<else>\\\tag*{}\<fi>}}% + \AddToHook{env/eqnalign/begin}{\bbl@ams@preset\hbox}% + % Hackish, for proper alignment. Don’t ask me why it works!: + \AddToHook{env/align*/end}{\iftag@\else\tag*{}\fi}% \AddToHook{env/flalign/begin}{\bbl@ams@preset\hbox}% \AddToHook{env/split/before}{% \ifnum\bbl@thetextdir>\z@ - \def\bbl@tempa{equation}% - \ifx\@currenvir\bbl@tempa - \def\bbl@ams@eqtagbox#1{% - \ifx\bbl@ams@lap\hbox - \hbox to0.01pt{\hss\bbl@eqnodir#1}% leqno - \else - \hbox to0.01pt{\bbl@eqnodir#1\hss}% eqno - \fi} - \fi - \fi} - \AddToHook{env/equation/begin}{% - \ifnum\bbl@thetextdir>\z@ - \ifx\bbl@ams@lap\llap\hrule\@height\z@\fi - \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% - \bbl@sreplace\maketag@@@{\hbox}{\bbl@ams@eqtagbox}% + \bbl@ifsamestring\@currenvir{equation}% + {\ifx\bbl@ams@lap\hbox % leqno + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hbox to\displaywidth{{#1}\hss}\hss}}% + \else + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hss\hbox to\displaywidth{\hss{#1}}}}% + \fi}% + {}% \fi}% - \AddToHook{env/equation*/begin}{% - \ifnum\bbl@thetextdir>\z@ - \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% - \bbl@sreplace\maketag@@@{\hbox}{\bbl@ams@eqtagbox}% - \fi}% - \fi \fi} \fi \ifx\bbl@opt@layout\@nnil\endinput\fi % if no layout |