diff options
author | Karl Berry <karl@freefriends.org> | 2020-02-28 22:30:49 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-02-28 22:30:49 +0000 |
commit | 36878db7eaaefd0a2f92b7e6c951f3fecda7799c (patch) | |
tree | f2732b147e25de43f5a522e2ea8cf4d2bc2509d5 /Master/texmf-dist/source/latex/babel/babel.dtx | |
parent | 46b6afccfb82f1ff6df7c22ce307fb1902928cba (diff) |
babel (28feb20)
git-svn-id: svn://tug.org/texlive/trunk@53963 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 | 276 |
1 files changed, 236 insertions, 40 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index d0c45fd23cc..37f4e718354 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -31,7 +31,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2020/02/14 v3.40 The Babel package] +\ProvidesFile{babel.dtx}[2020/02/28 v3.41 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -1981,23 +1981,29 @@ also the package \textsf{combofont} for a complementary approach.} \Describe\babelfont{\oarg{language-list}\marg{font-family}% \oarg{font-options}\marg{font-name}} -The main purpose of |\babelfont| is to define at once in a multilingual -document the fonts required by the different languages, with their -corresponding language systems (script and language). So, if you load, -say, 4 languages, |\babelfont{rm}{FreeSerif}| defines 4 fonts (with their -variants, of course), which are switched with the language by \babel. -It is a tool to make things easier and transparent to the user. +The main purpose of |\babelfont| is to define at once in a +multilingual document the fonts required by the different languages, +with their corresponding language systems (script and language). So, if +you load, say, 4 languages, |\babelfont{rm}{FreeSerif}| defines 4 fonts +(with their variants, of course), which are switched with the language +by \babel. It is a tool to make things easier and transparent to the +user. Here \textit{font-family} is |rm|, |sf| or |tt| (or newly defined ones, as explained below), and \textit{font-name} is the same as in \textsf{fontspec} and the like. If no language is given, then it is considered the default font for -the family, activated when a language is selected. On the other hand, -if there is one or more languages in the optional argument, the font -will be assigned to them, overriding the default. Alternatively, you -may set a font for a script -- just precede its name (lowercase) with -a star (eg, |*devanagari|). +the family, activated when a language is selected. + +On the other hand, if there is one or more languages in the optional +argument, the font will be assigned to them, overriding the default one. +Alternatively, you may set a font for a script -- just precede its name +(lowercase) with a star (eg, |*devanagari|). With this optional +argument, the font is \textit{not} yet defined, but just predeclared. +This means you may define as many fonts as you want ‘just in case’, +because if the language is never selected, the corresponding +|\babelfont| declaration is just ignored. \Babel{} takes care of the font language and the font script when languages are selected (as well as the writing direction); see the @@ -2384,7 +2390,7 @@ Currently used only in Southeast Asian scrips, like Thai. Ignored if 0 |ini|-based languages). \end{note} -\subsection{Digits} +\subsection{Digits and counters} \New{3.20} About thirty |ini| files define a field named |digits.native|. When it is present, two macros are created: @@ -2408,12 +2414,42 @@ _\telugucounter{section}_ \end{document} \end{verbatim} -Languages providing native digits in all or some variants are Arabic, -Assamese, Bangla, Tibetar, Bodo, Central Kurdish, Dzongkha, Persian, -Gujarati, Hindi, Khmer, Kannada, Konkani, Kashmiri, Lao, Northern Luri, -Malayalam, Marathi, Burmese, Mazanderani, Nepali, Odia, Punjabi, -Pashto, Tamil, Telugu, Thai, Uyghur, Urdu, Uzbek, Vai, Cantonese, -Chinese. +Languages providing native digits in all or some variants are: +\begin{multicols}{5} +Arabic\\ +Assamese\\ +Bangla\\ +Tibetar\\ +Bodo\\ +Central Kurdish\\ +Dzongkha\\ +Persian\\ +Gujarati\\ +Hindi\\ +Khmer\\ +Kannada\\ +Konkani\\ +Kashmiri\\ +Lao\\ +Northern Luri\\ +Malayalam\\ +Marathi\\ +Burmese\\ +Mazanderani\\ +Nepali\\ +Odia\\ +Punjabi\\ +Pashto\\ +Tamil\\ +Telugu\\ +Thai\\ +Uyghur\\ +Urdu\\ +Uzbek\\ +Vai\\ +Cantonese\\ +Chinese +\end{multicols} \New{3.30} With \luatex{} there is an alternative approach for mapping digits, namely, |mapdigits|. Conversion is based on the language and it @@ -2423,6 +2459,71 @@ bidi and fonts are processed (ie, to the node list as generated by the bidirectional behavior (unlike |Numbers=Arabic| in \textsf{fontspec}, which is not recommended). +\New{4.41} Many `ini` locale files has been extended with information about +non-positional numerical systems, based on those predefined in CSS. +They only work with \xetex{} and \luatex{} and are fully expendable (even +inside an |\edef|). Currently, they are limited to numbers below 10000. + +There are several ways to use them (for the availabe styles in each +language, see the list below): + +\begin{itemize} +\item |\localenumeral|\marg{style}\marg{number}, like + |\localenumeral{abjad}{15}| +\item |\localecounter|\marg{style}\marg{counter}, like + |\localecounter{lower}{section}| +\item In |\babelprovide|, as an argument to the keys |alph| and |Alph|, +which redefine what |\alph| and |\Alph| print. For example: +\begin{verbatim} +\babelprovide[alph=alphabetic]{thai} +\end{verbatim} +\end{itemize} + +The styles are: +\begin{description} +\itemsep=-\parskip +\item[Ancient Greek] |lower.ancient|, |upper.ancient| + +\item[Arabic] |abjad|, |maghrebi.abjad| + +\item[Belarusan, Bulgarian, Macedonian, Serbian] |lower|, |upper| + +\item[Hebrew] |letters| (neither geresh nor gershayim yet) + +\item[Hindi] |alphabetic| + +\item[Armenian] |lower|, |upper| + +\item[Japanese] |hiragana|, |hiragana.iroha|, |katakana|, +|katakana.iroha|, |circled.katakana|, |informal|, |formal|, +|cjk-earthly-branch|, |cjk-heavenly-stem|, f|ullwidth.lower.alpha|, +|fullwidth.upper.alpha| + +\item[Georgian] |letters| + +\item[Greek] |lower.modern|, |upper.modern|, |lower.ancient|, +|upper.ancient| (all with keraia) + +\item[Khmer] |consonant| + +\item[Korean] |consonant|, |syllabe|, |hanja.informal|, +|hanja.formal|, |hangul.formal|, |cjk-earthly-branch|, +|cjk-heavenly-stem|, |fullwidth.lower.alpha|, |fullwidth.upper.alpha| + +\item[Persian] |abjad|, |alphabetic| + +\item[Russian] |lower|, |lower.full|, |upper|, |upper.full| + +\item[Tamil] |ancient| + +\item[Thai] |alphabetic| + +\item[Ukrainian] |lower| , |lower.full|, |upper| , |upper.full| + +\item[Chinese] |cjk-earthly-branch|, |cjk-heavenly-stem|, +|fullwidth.lower.alpha|, |fullwidth.upper.alpha| +\end{description} + \subsection{Accessing language info} \Describe{\languagename}{} @@ -4327,8 +4428,8 @@ help from Bernd Raichle, for which I am grateful. % \section{Tools} % % \begin{macrocode} -%<<version=3.40>> -%<<date=2020/02/14>> +%<<version=3.41>> +%<<date=2020/02/28>> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They @@ -6833,13 +6934,17 @@ help from Bernd Raichle, for which I am grateful. % \end{macro} % % \begin{macro}{\babel@save} +% \begin{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. +% |\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. % % \begin{macrocode} \def\babel@save#1{% @@ -6848,23 +6953,13 @@ help from Bernd Raichle, for which I am grateful. \bbl@exp{% \def\\\originalTeX{\the\toks@\<babel@\number\babel@savecnt>\relax}}% \advance\babel@savecnt\@ne} -% \end{macrocode} -% -% \end{macro} -% -% \begin{macro}{\babel@savevariable} -% -% The macro |\babel@savevariable|\meta{variable} saves the value of -% the variable. \meta{variable} can be anything allowed after the -% |\the| primitive. -% -% \begin{macrocode} \def\babel@savevariable#1{% \toks@\expandafter{\originalTeX #1=}% \bbl@exp{\def\\\originalTeX{\the\toks@\the#1\relax}}} % \end{macrocode} % % \end{macro} +% \end{macro} % % \begin{macro}{\bbl@frenchspacing} % \begin{macro}{\bbl@nonfrenchspacing} @@ -7992,7 +8087,8 @@ help from Bernd Raichle, for which I am grateful. \let\bbl@KVP@intraspace\@nil \let\bbl@KVP@intrapenalty\@nil \let\bbl@KVP@onchar\@nil - \let\bbl@KVP@chargroups\@nil + \let\bbl@KVP@alph\@nil + \let\bbl@KVP@Alph\@nil \bbl@forkv{#1}{% TODO - error handling \in@{/}{##1}% \ifin@ @@ -8037,7 +8133,7 @@ help from Bernd Raichle, for which I am grateful. \bbl@ifunset{bbl@lname@#2}% {\def\BabelBeforeIni##1##2{% \begingroup - \catcode`\[=12 \catcode`\]=12 \catcode`\==12 % + \catcode`\[=12 \catcode`\]=12 \catcode`\==12 \catcode`\;=12 % \let\bbl@ini@captions@aux\@gobbletwo \def\bbl@inidate ####1.####2.####3.####4\relax ####5####6{}% \bbl@read@ini{##1}{basic data}% @@ -8215,6 +8311,32 @@ help from Bernd Raichle, for which I am grateful. }}% \fi \fi + % == alph, Alph == + % What if extras<lang> contains a \babel@save\@alph? It won't be + % restored correctly when exiting the language, so we ignore + % this change with the \bbl@alph@saved trick. + \ifx\bbl@KVP@alph\@nil\else + \toks@\expandafter\expandafter\expandafter{% + \csname extras\languagename\endcsname}% + \bbl@exp{% + \def\<extras\languagename>{% + \let\\\bbl@alph@saved\\\@alph + \the\toks@ + \let\\\@alph\\\bbl@alph@saved + \\\babel@save\\\@alph + \let\\\@alph\<bbl@cntr@\bbl@KVP@alph @\languagename>}}% + \fi + \ifx\bbl@KVP@Alph\@nil\else + \toks@\expandafter\expandafter\expandafter{% + \csname extras\languagename\endcsname}% + \bbl@exp{% + \def\<extras\languagename>{% + \let\\\bbl@Alph@saved\\\@Alph + \the\toks@ + \let\\\@Alph\\\bbl@Alph@saved + \\\babel@save\\\@Alph + \let\\\@Alph\<bbl@cntr@\bbl@KVP@Alph @\languagename>}}% + \fi % == require.babel in ini == % To load or reaload the babel-*.tex, if require.babel in ini \bbl@ifunset{bbl@rqtex@\languagename}{}% @@ -8511,6 +8633,24 @@ help from Bernd Raichle, for which I am grateful. \let\bbl@inikv@typography\bbl@inikv \let\bbl@inikv@characters\bbl@inikv \let\bbl@inikv@numbers\bbl@inikv +\def\bbl@inikv@counters#1=#2\@@{% + \def\bbl@tempc{#1}% + \bbl@trim@def{\bbl@tempb*}{#2}% + \in@{.1$}{#1$}% + \ifin@ + \bbl@replace\bbl@tempc{.1}{}% + \bbl@csarg\xdef{cntr@\bbl@tempc @\languagename}{% + \noexpand\bbl@alphnumeral{\bbl@tempc}}% + \fi + \in@{.F.}{#1}% + \ifin@\else\in@{.S.}{#1}\fi + \ifin@ + \bbl@csarg\xdef{cntr@#1@\languagename}{\bbl@tempb*}% + \else + \toks@{}% Required by \bbl@buildifcase, which returns \bbl@tempa + \expandafter\bbl@buildifcase\bbl@tempb* \\ % Space after \\ + \bbl@csarg{\global\expandafter\let}{cntr@#1@\languagename}\bbl@tempa + \fi} \def\bbl@after@ini{% \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}% \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}% @@ -8680,13 +8820,67 @@ help from Bernd Raichle, for which I am grateful. \def\BabelBeforeIni##1##2{% \begingroup \bbl@add\bbl@secpost@identification{\closein\bbl@readstream }% - \catcode`\[=12 \catcode`\]=12 \catcode`\==12 % + \catcode`\[=12 \catcode`\]=12 \catcode`\==12 \catcode`\;=12 % \bbl@read@ini{##1}{font and identification data}% \endinput % babel- .tex may contain onlypreamble's \endgroup}% boxed, to avoid extra spaces: {\setbox\z@\hbox{\InputIfFileExists{babel-#1.tex}{}{}}}} % \end{macrocode} % +% Alphabetic counters must be converted from a space separated list to +% an |\ifcase| structure. +% +% \begin{macrocode} +\def\bbl@buildifcase#1 {% Returns \bbl@tempa, requires \toks@={} + \ifx\\#1% % \\ before, in case #1 is multiletter + \bbl@exp{% + \def\\\bbl@tempa####1{% + \<ifcase>####1\space\the\toks@\<else>\\\@ctrerr\<fi>}}% + \else + \toks@\expandafter{\the\toks@\or #1}% + \expandafter\bbl@buildifcase + \fi} +% \end{macrocode} +% +% The code for additive counters is somewhat tricky and it's based on +% the fact the arguments just before |\@@| collects digits which have +% been left ‘unused’ in previous arguments, the first of them being the +% number of digits in the number to be converted. This explains the +% reverse set |76543210|. Digits above 10000 are not handled yet. When +% the key contains the subkey |.F.|, the number after is treated as an +% special case. for a fixed form (see |babel-he.ini|, for example). +% +% \begin{macrocode} +\newcommand\localenumeral[2]{\@nameuse{bbl@cntr@#1@\languagename}{#2}} +\def\bbl@localecntr#1#2{\localenumeral{#2}{#1}} +\newcommand\localecounter[2]{% + \expandafter\bbl@localecntr\csname c@#2\endcsname{#1}} +\def\bbl@alphnumeral#1#2{% + \expandafter\bbl@alphnumeral@i\number#2 76543210\@@{#1}} +\def\bbl@alphnumeral@i#1#2#3#4#5#6#7#8\@@#9{% + \ifcase\@car#8\@nil\or % Currenty <10000, but prepared for bigger + \bbl@alphnumeral@ii{#9}000000#1\or + \bbl@alphnumeral@ii{#9}00000#1#2\or + \bbl@alphnumeral@ii{#9}0000#1#2#3\or + \bbl@alphnumeral@ii{#9}000#1#2#3#4\else + \bbl@alphnum@invalid{>9999}% + \fi} +\def\bbl@alphnumeral@ii#1#2#3#4#5#6#7#8{% + \bbl@ifunset{bbl@cntr@#1.F.\number#5#6#7#8@\languagename}% + {\@nameuse{bbl@cntr@#1.4@\languagename}#5% + \@nameuse{bbl@cntr@#1.3@\languagename}#6% + \@nameuse{bbl@cntr@#1.2@\languagename}#7% + \@nameuse{bbl@cntr@#1.1@\languagename}#8% + \ifnum#6#7#8>\z@ % An ad hod rule for Greek. Ugly. To be fixed. + \bbl@ifunset{bbl@cntr@#1.S.321@\languagename}{}% + {\@nameuse{bbl@cntr@#1.S.321@\languagename}}% + \fi}% + {\@nameuse{bbl@cntr@#1.F.\number#5#6#7#8@\languagename}}} +\def\bbl@alphnum@invalid#1{% + \bbl@error{Alphabetic numeral too large (#1)}% + {Currently this is the limit.}} +% \end{macrocode} +% % The information in the identification section can be useful, so the % following macro just exposes it with a user command. % @@ -9521,6 +9715,7 @@ help from Bernd Raichle, for which I am grateful. \else \def\@elt#1{,#1,}% \edef\bbl@tempa{\expandafter\@gobbletwo\@fontenc@load@list}% + \let\@elt\relax \bbl@xin@{,T1,}\bbl@tempa \ifin@ \xdef\latinencoding{\bbl@t@one}% @@ -11822,6 +12017,7 @@ help from Bernd Raichle, for which I am grateful. \endgroup \bbl@trace{Macros for reading patterns files} \def\bbl@get@enc#1:#2:#3\@@@{\def\bbl@hyph@enc{#2}} +% TODO - Harcoded value: \ifx\babelcatcodetablenum\@undefined \def\babelcatcodetablenum{5211} \fi |