diff options
author | Karl Berry <karl@freefriends.org> | 2013-12-04 00:01:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-12-04 00:01:59 +0000 |
commit | f077be0a1cb84cd0031d4d47104a836f7cf255be (patch) | |
tree | 0096f7c448cdbba23e9e70d171ccb5e41389dddc /Master/texmf-dist/source/latex | |
parent | 20f40b1b909d575836f8af15228fbbbc9566a0b5 (diff) |
babel (3dec13)
git-svn-id: svn://tug.org/texlive/trunk@32311 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/babel/babel.dtx | 253 |
1 files changed, 160 insertions, 93 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index ba29be7792f..1b004611f5c 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -44,7 +44,7 @@ % %% File 'babel.dtx' %\fi -%%\ProvidesFile{babel.dtx}[2013/10/10 v3.9g The Babel package] +%%\ProvidesFile{babel.dtx}[2013/12/03 v3.9h The Babel package] %\iffalse % % Babel DOCUMENT-STYLE option for LaTeX version 2.09 or plain TeX; @@ -185,8 +185,8 @@ \vspace{2cm}\hspace{1.5cm} \begin{minipage}{5cm} \Large -Version 3.9g\newline -2013/10/10 +Version 3.9h\newline +2013/12/03 \vspace{1cm} \textit{Original author}\newline @@ -287,12 +287,6 @@ Attributes (described below) are considered modifiers, ie, you can set an attribute by including it in the list of modifiers. However, modifiers is a more general mechanism. -Currently \babel{} provides no standard interface for -scripts. Languages sharing the same non-Latin script may define macros -to switch them (eg, |\textcyrillic|), but be aware they may also set -the language to a certain default. (Future versions might add such an -interface.) - Because of the way \babel{} has evolved, ``language'' can refer to (1) a set of hyphenation patters as preloaded into the format, (2) a package option, (3) an |ldf| file, and (4) a name used in the document @@ -313,15 +307,31 @@ old interface to call babel'', not very helpful.} (babel) \usepackage[language]{babel}. \end{verbatim} +Another typical error when using \babel{} is the +following:\footnote{In former versions the error read ``You haven't +loaded the language LANG yet''.} +\begin{verbatim} +! Package babel Error: Unknown language `LANG'. Either you have misspelled +(babel) its name, it has not been installed, or you requested +(babel) it in a previous run. Fix its name, install it or just +(babel) rerun the file, respectively +\end{verbatim} +The most frequent reason is, by far, the latest (for example, you +included |spanish|, but you realized this language is not used after +all, and therefore you removed it from the option list). In most cases, +the error vanishes when the document is typeset again, but in more +severe ones you will need to remove the |aux| file. In Plain, load languages styles with |\input| and then use |\begindocument| (the latter is defined by \babel): -\begin{verbatim} +\begin{verbatim}[morekeywords={[0]{\input,\begindocument}}] \input estonian.sty \begindocument \end{verbatim} Note not all languages provide a |sty| file and some of them are -not compatible with Plain. +not compatible with Plain.\footnote{Even in the \babel{} kernel there +were some macros not compatible with plain. Hopefully these issues will +be fixed soon.} \subsection{Selecting languages} @@ -437,6 +447,25 @@ the actions to take if the result of the test is true or false respectively. The advice about |\languagename| also applies here -- use \textsf{iflang} instead of |\iflanguage| if possible. +\subsection{Selecting scripts} + +Currently \babel{} provides no standard interface to select +scripts, because they are best selected with either |\fontencoding| +(low level) or a language name (high level). Even the Latin script may +require different encodings (ie, sets of glyphs) depending on the +language, and therefore such a switch would be in a sense +incomplete.\footnote{The so-called Unicode fonts does not improve the +situation either. So, a font suited for Vietnamese is not necessarily +suited for, say, romanization of Indic languages, and the fact it +contains glyphs for Modern Greek does not mean it includes them for +Classic Greek. As to directionality, it poses special challenges +because it also affects individual characters and layout elements.} + +Note however some languages sharing the same script define macros to +switch it (eg, |\textcyrillic|), but be aware they may also set the +language to a certain default. Even the \babel{} core defines +|\textlatin|, but its use is now discouraged. + \subsection{Shorthands} A \textit{shorthand} is a sequence of one or two characters that @@ -557,7 +586,7 @@ However, behaviour of hyphens is language dependent. For example, in languages like Polish and Portugese, a hard hyphen inside compound words are repeated at the beginning of the next line. You could then set: -\begin{verbatim} +\begin{verbatim}[morekeywords={[1]{polish,portugese}}] \defineshorthand[*polish,*portugese]{"-}{\babelhyphen{repeat}} \end{verbatim} Here, options with |*| set a language-dependent user shorthand, which @@ -580,7 +609,7 @@ character must \textit{not} have been declared before as shorthand (in such case, |\aliashorthands| is ignored). The following example shows how to replace a shorthand by another -\begin{verbatim} +\begin{verbatim}[morekeywords={[0]{\aliasshorthand}}] \aliasshorthand{~}{^} \AtBeginDocument{\shorthandoff*{~}} \end{verbatim} @@ -745,7 +774,8 @@ $\string|$ \texttt{select} $\string|$ \texttt{other} $\string|$ \texttt{other*}} \New{3.9g} Sets the behaviour of case mapping for hyphenation, -provided the language defines it. It can take the following values: +provided the language defines it.\footnote{Turned off in plain.} It +can take the following values: \begin{description} \renewcommand\makelabel[1]{% \hspace\labelsep\normalfont\ttfamily\color{thered}#1} @@ -954,7 +984,7 @@ documents). Language exceptions take precedence over global ones. It can be used only in the preamble, and exceptions are set when the language is first selected, thus taking into account changes of -|\lccodes|'s done in |\extras|\m{lang} as well as the script specific +|\lccodes|'s done in |\extras|\m{lang} as well as the language specific encoding (not set in the preamble by default). Multiple |\babelhyphenation|'s are allowed. For example: \begin{verbatim} @@ -1119,9 +1149,9 @@ Then you preprocess it with |devnag| \m{file}, which creates |"8000|) as a shorthand can make \TeX{} enter in an infinite loop. (Another issue in the `to do' list, although there is a partial solution.) -\item Also in the `to do' list is a common interface to switch - scripts, to avoid the current problem of languages trying to define - |\text|\m{script} in different ways. +\item Also in the `to do' list is a user interface to set the way + scripts are switched, to avoid the current problem of languages + trying to define |\text|\m{script} in different ways. \end{itemize} The following packages can be useful, too (the list is still @@ -1136,7 +1166,10 @@ far from complete): \item[siunitx] Typesetting of numbers and physical quantities. \item[biblatex] Programmable bibliographies and citations. \item[bicaption] Bilingual captions. -\item[babelbib] Multilingual bibliographies +\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. \end{description} \subsection{Future work} @@ -1159,7 +1192,7 @@ the style for Hebrew, but it is somewhat unsatisfactory and internally replaces some hardwired commands by other hardwired commands (generic changes would be much better). -Handling of Unicode fonts is also problematic. There is +Handling of ``Unicode'' fonts is also problematic. There is \textsf{fontspec}, but special macros are required (not only the NFSS ones) and it doesn't provide ``orthogonal axis'' for features, including those related to the language (mainly language and @@ -1307,7 +1340,13 @@ Some recommendations: and friends, |\bbl@deactivate|, |\bbl@(non)frenchspacing|, and language specific macros. Use always, if possible, |\bbl@save| and |\bbl@savevariable| (except if you still want to have access to the - previous value). + previous value). Do not reset a macro or a setting to a hardcoded + value. Never. Instead save its value in |\extras|\m{lang}. +\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 discouraged and will be very likely deprecated + in the future.\footnote{But not removed, for backward compatibility.} \end{itemize} @@ -1441,7 +1480,7 @@ explained in in sec. \ref{s:strings} (\babel{} 3.9 and later). \begin{verbatim} \ProvidesLanguage{<language>} - [2013/10/10 v0.0 <Language> support from the babel system] + [2013/12/03 v0.0 <Language> support from the babel system] \LdfInit{<language>}{captions<language>} \ifx\undefined\l@<language> @@ -1608,9 +1647,9 @@ it. Furthermore, it must be activated explicitly, with the package option |strings|. If there is no |strings|, these blocks are ignored, except -|\SetCase|s (and except if forced with |\UseStrings|, see -below). In other words, the old way of defining/switching strings still -works and it's used by default. +|\SetCase|s (and except if forced as described below). In other words, +the old way of defining/switching strings still works and it's used by +default. It consist is a series of blocks started with |\StartBabelCommands|. The last block is closed with @@ -2095,6 +2134,12 @@ help from Bernd Raichle, for which I am grateful. \bibitem{ilatex} Joachim Schrod, \emph{International \LaTeX\ is ready to use}, \emph{TUGboat} 11 (1990) \#1, p.~87--90. + \bibitem{ilatex} Apostolos Syropoulos, Antonis Tsolomitis and Nick + Sofroniu, + \emph{Digital typography using \LaTeX}, + Springer, 2002, p.~301--373. + \bibitem{FE} Yannis Haralambous, + \emph{Fonts \& Encodings}, O'Reilly, 2007. \end{thebibliography} \end{document} %</filedriver> @@ -2198,12 +2243,12 @@ help from Bernd Raichle, for which I am grateful. % ``pseudo-guards'' to set ``variables'' used at installation time. % They are used with |<||@name@>| at the appropiated places in the % source code and shown below with -% $\langle\langle$\textit{name}$\rangle\rangle$. That brings a little bit of -% literate programming. +% $\langle\langle$\textit{name}$\rangle\rangle$. That brings a +% little bit of literate programming. % % \begin{macrocode} -%<<version=3.9g>> -%<<date=2013/10/10>> +%<<version=3.9h>> +%<<date=2013/12/03>> % \end{macrocode} % % We define some basic which just make the code cleaner. |\bbl@add| is @@ -3148,7 +3193,8 @@ help from Bernd Raichle, for which I am grateful. % \changes{babel~3.6i}{1997/03/15}{Macro added, moved from % \file{.ldf} files} % Then we can define the command |\latintext| which is a -% declarative switch to a latin font-encoding. +% declarative switch to a latin font-encoding. Usage of this macro +% is discouraged, except if understood as a switch to ASCII. % \begin{macrocode} \DeclareRobustCommand{\latintext}{% \fontencoding{\latinencoding}\selectfont @@ -3173,7 +3219,7 @@ help from Bernd Raichle, for which I am grateful. \fi % \end{macrocode} % -% The second version of this macro takes two arguments. The first +% The second version of |\LdfInit| macro takes two arguments. The first % argument is the name of the language that will be defined in the % language definition file; the second argument is either a control % sequence or a string from which a control sequence should be @@ -4000,7 +4046,8 @@ help from Bernd Raichle, for which I am grateful. The character `\string #1' should be made a shorthand character;\\% add the command \string\useshorthands\string{#1\string} to the preamble.\\% - I will ignore your instruction}{}} + I will ignore your instruction}% + {You may proceed, but expect unexpected results}} % \end{macrocode} % \end{macro} % @@ -5101,39 +5148,41 @@ help from Bernd Raichle, for which I am grateful. % % The command to be used in the |ldf|. % +% \changes{babel~3.9h}{2013/11/08}{Use \cs{bbl@encstrings} - they +% should be defined always, even if no `strings'} % \begin{macrocode} %<<*Define SetCase>> \newcommand\SetCase[3][]{% \bbl@patchuclc \bbl@forlang\bbl@tempa{% - \expandafter\bbl@stringdef + \expandafter\bbl@encstring \csname\bbl@tempa @bbl@uclc\endcsname{\reserved@a##1}% - \expandafter\bbl@stringdef + \expandafter\bbl@encstring \csname\bbl@tempa @bbl@uc\endcsname{##2}% - \expandafter\bbl@stringdef + \expandafter\bbl@encstring \csname\bbl@tempa @bbl@lc\endcsname{##3}}}% %<</Define SetCase>> % \end{macrocode} % % Now we define |\SetStringLoop|. The current definition is -% somewhat complicated because we need a count, but |\count@| and -% the like are not under our control (remember |\SetString| may -% call hooks). +% somewhat complicated because we need a count, but |\count@| is +% not under our control (remember |\SetString| may call hooks). +% +% \changes{babel~3.9h}{2013/10/16}{Tidied up and bug fixed - first +% element expanded prematurely.} % % \begin{macrocode} %<<*Define SetStringLoop>> -\def\SetStringLoop{\afterassignment\bbl@sclp\def\bbl@templ####1}% - \def\bbl@sclp##1{% - \def\bbl@tempk{\@ne}% - \@for\bbl@tempm:=##1\do{% - \count@\bbl@tempk\relax % Because of stringprocess event - \toks@\expandafter{\bbl@tempm}% - \edef\bbl@tempn{% - \expandafter\noexpand - \csname\bbl@templ{\romannumeral\count@}\endcsname{\the\toks@}}% - \advance\count@\@ne - \edef\bbl@tempk{\the\count@}% - \expandafter\SetString\bbl@tempn}}% +\def\SetStringLoop##1##2{% + \def\bbl@templ####1{\expandafter\noexpand\csname##1\endcsname}% + \count@\z@ + \@for\bbl@tempa:=\@empty##2\do{% \@empty "undoes" \expandafter + \advance\count@\@ne + \toks@\expandafter{\bbl@tempa}% + \edef\bbl@tempb{% + \bbl@templ{\romannumeral\count@}{\the\toks@}% + \count@=\the\count@\relax}% + \expandafter\SetString\bbl@tempb}}% %<</Define SetStringLoop>> % \end{macrocode} % @@ -5210,6 +5259,8 @@ help from Bernd Raichle, for which I am grateful. % parameters. % \changes{babel~3.9g}{2013/08/04}{Use \cs{ProvideTextCommand}, which % does with encoded strings what the manual says.} +% \changes{babel~3.9h}{2013/11/08}{Tidied up code related to +% \cs{bbl@scswitch}} % % \begin{macrocode} \newcommand\bbl@startcmds@ii[1][\@empty]{% @@ -5247,20 +5298,25 @@ help from Bernd Raichle, for which I am grateful. \@expandtwoargs \in@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}% \fi - \bbl@scswitch{% - \ifx\bbl@opt@strings\@nnil % ie, no strings - \let\bbl@stringdef\bbl@encstring % for \SetCase - \else\ifx\bbl@opt@strings\relax % ie, strings with no value - \let\AfterBabelCommands\bbl@aftercmds - \let\SetString\bbl@setstring - \let\bbl@stringdef\bbl@encstring - \else % ie, strings=value - \bbl@sctest - \ifin@ - \let\AfterBabelCommands\bbl@aftercmds - \let\SetString\bbl@setstring - \let\bbl@stringdef\bbl@provstring - \fi\fi\fi}% + \ifx\bbl@opt@strings\@nnil % ie, no strings -> defaults + \else\ifx\bbl@opt@strings\relax % ie, strings with no value + \let\AfterBabelCommands\bbl@aftercmds + \let\SetString\bbl@setstring + \let\bbl@stringdef\bbl@encstring + \else % ie, strings=value + \bbl@sctest + \ifin@ + \let\AfterBabelCommands\bbl@aftercmds + \let\SetString\bbl@setstring + \let\bbl@stringdef\bbl@provstring + \fi\fi\fi + \bbl@scswitch + \ifx\bbl@G\@empty + \def\SetString##1##2{% + \bbl@error{Missing group for string \string##1}% + {You must assign strings to some category, typically\\% + captions or extras, but you set none}}% + \fi \ifx\@empty#1% \@expandtwoargs \bbl@usehooks{defaultcommands}{}% @@ -5270,25 +5326,25 @@ help from Bernd Raichle, for which I am grateful. \fi} % \end{macrocode} % -% There are two versions of |\bbl@scswitch|. The first version -% is used when |ldf|s are read, and with it blocks not intented for -% the current language (as set in |\CurrentOption|) are ignored; it -% also makes sure |\|\m{group}\m{language} is reset, but only once -% (|\bbl@screset| is used to keep track of this). The second version -% is used in the preamble and packages loaded after \babel{} and -% defines strings for all known languages. The macro |\bbl@forlang| -% loops |\bbl@L| but its body is executed only if the value is in -% |\BabelLanguages| (inside \babel) or |\date|\m{language} is -% defined (after \babel{} has been loaded). +% There are two versions of |\bbl@scswitch|. The first version is +% used when |ldf|s are read, and it makes sure +% |\|\m{group}\m{language} is reset, but only once (|\bbl@screset| +% is used to keep track of this). The second version is used in the +% preamble and packages loaded after \babel{} and does nothing. The +% macro |\bbl@forlang| loops |\bbl@L| but its body is executed only +% if the value is in |\BabelLanguages| (inside \babel) or +% |\date|\m{language} is defined (after \babel{} has been loaded). +% There are also two version of |\bbl@forlang|. The first one skips +% the current iteration if the language is not in |\BabelLanguages| +% (used in |ldf|s), and the second one skips undefined languages +% (after \babel{} has been loaded) . % % \begin{macrocode} \def\bbl@forlang#1#2{% \bbl@for#1\bbl@L{% \@expandtwoargs\in@{,#1,}{,\BabelLanguages,}% - \ifin@#2\fi}} -\def\bbl@scswitch#1{% - #1\relax - \bbl@scswitch@i + \ifin@#2\relax\fi}} +\def\bbl@scswitch{% \bbl@forlang\bbl@tempa{% \ifx\bbl@G\@empty\else \ifx\SetString\@gobbletwo\else @@ -5300,16 +5356,9 @@ help from Bernd Raichle, for which I am grateful. \fi \fi \fi}} -\def\bbl@scswitch@i{% - \ifx\bbl@G\@empty - \def\SetString##1##2{% - \bbl@error{Missing group for string \string##1}% - {You must assign strings to some category, typically\\% - captions or extras, but you set none}}% - \fi} \AtEndOfPackage{% - \def\bbl@scswitch#1{#1\relax\bbl@scswitch@i}% - \def\bbl@forlang#1#2{\bbl@for#1\bbl@L{\@ifundefined{date#1}{}{#2}}}} + \def\bbl@forlang#1#2{\bbl@for#1\bbl@L{\@ifundefined{date#1}{}{#2}}}% + \let\bbl@scswitch\relax} \@onlypreamble\EndBabelCommands \def\EndBabelCommands{% \bbl@usehooks{stopcommands}{}% @@ -6130,7 +6179,9 @@ help from Bernd Raichle, for which I am grateful. % encoding-independent} % Because documents may use font encodings other than one of the % latin encodings, we make sure that the logos of \TeX\ and -% \LaTeX\ always come out in the right encoding. +% \LaTeX\ always come out in the right encoding (note, however, +% encodings not rendering the logos correctly do not conform the +% LICR). % \begin{macrocode} \bbl@redefine\TeX{\textlatin{\org@TeX}} \bbl@redefine\LaTeX{\textlatin{\org@LaTeX}} @@ -6804,8 +6855,9 @@ help from Bernd Raichle, for which I am grateful. % the help of \cs{BabelContentsFiles}} % \changes{babel~3.9a}{2013/03/08}{Don't write to aux if language is % unknown} +% \changes{babel~3.9h}{2013/11/20}{Error with a more helpful text } % \begin{macrocode} -\def\BabelContentsFiles{toc,lof,lot}% +\def\BabelContentsFiles{toc,lof,lot} \def\bbl@set@language#1{% \edef\languagename{% \ifnum\escapechar=\expandafter`\string#1\@empty @@ -6826,13 +6878,16 @@ help from Bernd Raichle, for which I am grateful. \bbl@iflanguage\languagename{% \expandafter\ifx\csname date\languagename\endcsname\relax \bbl@error - {You haven't loaded the language #1\space yet}% + {Unknown language `#1'. Either you have\\% + misspelled its name, it has not been installed,\\% + or you requested it in a previous run. Fix its name,\\% + install it or just rerun the file, respectively}% {You may proceed, but expect unexpected results}% \else \let\bbl@select@type\z@ \expandafter\bbl@switch\expandafter{\languagename}% \fi}} -% A bit of optmization: +% A bit of optimization: \def\select@language@x#1{% \ifcase\bbl@select@type \bbl@ifsamestring\languagename{#1}{}{\select@language{#1}}% @@ -6909,6 +6964,8 @@ help from Bernd Raichle, for which I am grateful. % `none' before switching on the extras} % \changes{babel~3.9a}{2012/08/14}{Make sure the save counter is reset % even in \cs{originalTeX} is used in other contexts} +% \changes{babel~3.9h}{2013/11/29}{Use \cs{def} instead of +% \cs{renewcommand} for \cs{BabelLower}} % \begin{macrocode} \def\bbl@switch#1{% \originalTeX @@ -6925,7 +6982,7 @@ help from Bernd Raichle, for which I am grateful. \csname extras#1\endcsname\relax \bbl@usehooks{afterextras}{}% \ifcase\bbl@hymapopt\or - \renewcommand\BabelLower[2]{\lccode##1=##2\relax}% + \def\BabelLower##1##2{\lccode##1=##2\relax}% \ifnum\bbl@hymapsel>4\else \csname\languagename @bbl@hyphenmap\endcsname \fi @@ -7050,6 +7107,8 @@ help from Bernd Raichle, for which I am grateful. % environment. First we need to store the name of the language and % check that it is a known language. Then it just calls % |bbl@switch|. +% \changes{babel~3.9h}{2013/11/29}{The warning shows the language +% actually selected (with fixed case)} % \begin{macrocode} \def\foreign@language#1{% \edef\languagename{#1}% @@ -7057,7 +7116,7 @@ help from Bernd Raichle, for which I am grateful. \bbl@iflanguage\languagename{% \expandafter\ifx\csname date\languagename\endcsname\relax \bbl@warning - {You haven't loaded the language #1\space yet\\% + {You haven't loaded the language \languagename\space yet\\% I'll proceed, but expect unexpected results.\\% Reported}% \fi @@ -7957,6 +8016,7 @@ help from Bernd Raichle, for which I am grateful. % \changes{bbplain-1.0n}{1998/06/10}{Added \cs{@secondoftwo}} % \changes{bbplain-1.0q}{1999/09/16}{Added \cs{@ifundefined}} % \changes{bbplain-1.0t}{2013/04/10}{Added \cs{@expandtwoargs}} +% \changes{babel~3.9h}{2013/12/02}{Added \cs{zap@space}} % \begin{macrocode} \long\def\@firstofone#1{#1} \long\def\@firstoftwo#1#2{#1} @@ -7986,6 +8046,10 @@ help from Bernd Raichle, for which I am grateful. \fi} \def\@expandtwoargs#1#2#3{% \edef\reserved@a{\noexpand#1{#2}{#3}}\reserved@a} +\def\zap@space#1 #2{% + #1% + \ifx#2\@empty\else\expandafter\zap@space\fi + #2} % \end{macrocode} % \LaTeXe\ has the command |\@onlypreamble| which adds commands to % a list of commands that are no longer needed after @@ -8024,12 +8088,15 @@ help from Bernd Raichle, for which I am grateful. % We also have to mimick \LaTeX's |\AtEndOfPackage|. Our % replacement macro is much simpler; it stores its argument in % |\@endofldf|. +% \changes{babel~3.9h}{2013/11/28}{Set \cs{bbl@hymapopt} to 0 - we +% presume hyphenmap=off in plain} % \begin{macrocode} \def\AtEndOfPackage#1{\g@addto@macro\@endofldf{#1}} \@onlypreamble\AtEndOfPackage \def\@endofldf{} \@onlypreamble\@endofldf \let\bbl@afterlang\@empty +\chardef\bbl@hymapopt\z@ % \end{macrocode} % \LaTeX\ needs to be able to switch off writing to its auxiliary % files; plain doesn't have them by default. |