summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/babel
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-03-25 20:46:25 +0000
committerKarl Berry <karl@freefriends.org>2014-03-25 20:46:25 +0000
commita63b337dd75bdef29d3e59f209931b46a96a4a4f (patch)
tree278c437c4afe955fee5d4f1441dcf1aaa8d3b7e3 /Master/texmf-dist/source/latex/babel
parentb1694b996be79022b025714fcb6c142724f222d1 (diff)
babel (25mar14)
git-svn-id: svn://tug.org/texlive/trunk@33283 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel')
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.dtx1330
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.ins55
-rw-r--r--Master/texmf-dist/source/latex/babel/bbunicode.dtx22
3 files changed, 786 insertions, 621 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx
index ec8e82cf0d7..64c7ee45db9 100644
--- a/Master/texmf-dist/source/latex/babel/babel.dtx
+++ b/Master/texmf-dist/source/latex/babel/babel.dtx
@@ -34,17 +34,9 @@
% \let\thisfilename\filename
%
%\iffalse
-% \changes{babel~3.5g}{1996/10/10}{We need at least \LaTeX\ from
-% December 1994}
-% \changes{babel~3.6k}{1999/03/18}{We need at least \LaTeX\ from
-% June 1998}
-% \begin{macrocode}
-%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
-% \end{macrocode}
-%
%% File 'babel.dtx'
%\fi
-%%\ProvidesFile{babel.dtx}[2014/03/17 v3.9j The Babel package]
+%%\ProvidesFile{babel.dtx}[2014/03/24 v3.9k The Babel package]
%\iffalse
%
% Babel DOCUMENT-STYLE option for LaTeX version 2.09 or plain TeX;
@@ -155,6 +147,24 @@
$\langle$\pm@module#2#3>$\rangle$%
\ifx*#2\ $\equiv$\fi}
\endgroup
+\renewcommand*\l@section[2]{%
+ \ifnum \c@tocdepth >\z@
+ \addpenalty\@secpenalty
+ \addvspace{1.0em \@plus\p@}%
+ \setlength\@tempdima{2em}%
+ \begingroup
+ \parindent \z@ \rightskip \@pnumwidth
+ \parfillskip -\@pnumwidth
+ \leavevmode \bfseries
+ \advance\leftskip\@tempdima
+ \hskip -\leftskip
+ #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
+ \endgroup
+ \fi}
+\renewcommand*\l@subsection{\@dottedtocline{2}{2em}{3em}}
+\renewcommand*\l@subsubsection{\@dottedtocline{3}{5em}{4em}}
+\renewcommand*\l@paragraph{\@dottedtocline{4}{9em}{4.5em}}
+\renewcommand\partname{Part}
\makeatother
\begin{document}
\title{Babel, a multilingual package for use with \LaTeX's standard
@@ -186,8 +196,8 @@
\vspace{2cm}\hspace{1.5cm}
\begin{minipage}{5cm}
\Large
-Version 3.9j\newline
-2014/03/17
+Version 3.9k\newline
+2014/03/24
\vspace{1cm}
\textit{Original author}\newline
@@ -227,6 +237,8 @@ Javier Bezos
\tableofcontents
\clearpage
+\part{User guide}
+
\section{The user interface}\label{U-I}
The basic user interface of this package is quite simple. It consists
@@ -268,7 +280,7 @@ Languages may be set as global and as package option at the same
time, but in such a case you should set explicitly the main language
with the package option |main|:
\begin{verbatim}
-\documentclass[italian]{babel}
+\documentclass[italian]{book}
\usepackage[ngerman,main=italian]{babel}
\end{verbatim}
@@ -289,7 +301,7 @@ set an attribute by including it in the list of modifiers. However,
modifiers is a more general mechanism.
Because of the way \babel{} has evolved, ``language'' can refer to (1)
-a set of hyphenation patters as preloaded into the format, (2) a
+a set of hyphenation patterns as preloaded into the format, (2) a
package option, (3) an |ldf| file, and (4) a name used in the document
to select a language or dialect. So, a package option refers to a
language in a generic way -- sometimes it is the actual language name
@@ -583,10 +595,8 @@ use only shorthands provided by languages.
Please, note the following:
\begin{enumerate}
\item Activated chars used for two-char shorthands cannot be followed
- by a closing brace |}| and the spaces following are gobbled
- (\New{3.9i} this
- doesn't applies to \luatex). With one-char shorthands (eg,~|:|),
- they are preserved.
+ by a closing brace |}| and the spaces following are gobbled. With
+ one-char shorthands (eg,~|:|), they are preserved.
\item If on a certain level (system, language, user) there is a
one-char shorthand, two-char ones starting with that
char and on the same level are ignored.
@@ -1258,7 +1268,7 @@ far from complete):
\itemsep=-\parskip
\item[csquotes] Logical markup for quotes.
\item[iflang] Tests correctly the current language.
-\item[hyphsubst] Selects a different set of patters for a language.
+\item[hyphsubst] Selects a different set of patterns for a language.
\item[translator] An open platform for packages that need to be
localized.
\item[siunitx] Typesetting of numbers and physical quantities.
@@ -1578,7 +1588,7 @@ explained in in sec. \ref{s:strings} (\babel{} 3.9 and later).
\begin{verbatim}
\ProvidesLanguage{<language>}
- [2014/04/17 v0.0 <Language> support from the babel system]
+ [2014/03/24 v0.0 <Language> support from the babel system]
\LdfInit{<language>}{captions<language>}
\ifx\undefined\l@<language>
@@ -2317,6 +2327,8 @@ help from Bernd Raichle, for which I am grateful.
% Andrew Young}
% \changes{babel~3.9c}{2013/04/04}{Added the ``modifiers'' mechanism}
% \changes{babel~3.9g}{2013/06/01}{bbplain merged}
+% \changes{babel~3.9k}{2014/03/23}{Code and doc reorganized, and some
+% minor enhancements}
%\begingroup
% \catcode`<=\active%
% \catcode`>=\active
@@ -2329,15 +2341,26 @@ help from Bernd Raichle, for which I am grateful.
% \gdef\bblref##1@>{##1\/\egroup$\rangle\rangle$}}%
%\endgroup
%
+% \part{The code}
+%
% \section{Identification and loading of required files}
%
% \textit{Code documentation is still under revision.}
%
-% The file \file{babel.sty}\footnote{The file described in this
-% section is called \texttt{\filename}, has version
-% number~\fileversion\ and was last revised on~\filedate.} is meant
-% for \LaTeXe, therefore we make sure that the format file used is
-% the right one.
+% The \babel{} package after unpacking it consists of the following files:
+% \begin{description}
+% \itemsep=-\parskip
+% \item[switch.def] defines macros to set and switch languages.
+% \item[babel.def] defines the rest of macros. It has tow parts: a
+% generic one and a second one only for LaTeX{}.
+% \item[babel.sty] is the \LaTeX{} package, which set options and
+% load language styles.
+% \item[plain.def] defines some \LaTeX{} macros required by
+% \file{babel.def} and provides a few tools for Plain.
+% \item[hyphen.cfg] is the file to be used when generating the
+% formats to load hyphenation patterns. By default it also loads
+% \file{suçwitch.def}.
+% \end{description}
%
% The \babel{} installer extends \textsf{docstrip} with a few
% ``pseudo-guards'' to set ``variables'' used at installation time.
@@ -2347,21 +2370,20 @@ help from Bernd Raichle, for which I am grateful.
% little bit of literate programming.
%
% \begin{macrocode}
-%<<version=3.9j>>
-%<<date=2014/03/17>>
+%<<version=3.9k>>
+%<<date=2014/03/24>>
% \end{macrocode}
%
-% We define some basic which just make the code cleaner. |\bbl@add| is
-% now used internally instead of |\addto| because of the
-% unpredictable behaviour of the latter. Used in \file{babel.def}
-% and in \file{babel.sty}, which means in \LaTeX{} is executed
-% twice, but we need them when defining options and
+% We define some basic macros which just make the code cleaner.
+% |\bbl@add| is now used internally instead of |\addto| because of
+% the unpredictable behaviour of the latter. Used in
+% \file{babel.def} and in \file{babel.sty}, which means in \LaTeX{}
+% is executed twice, but we need them when defining options and
% \file{babel.def} cannot be load until options have been defined.
% \changes{babel~3.9i}{2014/02/16}{\cs{@for} didn't work with
-% Plain. Added \cs{bbl@loop}}
+% Plain. Added \cs{bbl@loop}}
% \begin{macrocode}
%<<*Basic macros>>
-\def\bbl@for#1#2#3{\bbl@loopx#1{#2}{\ifx#1\@empty\else#3\fi}}
\def\bbl@add#1#2{%
\@ifundefined{\expandafter\@gobble\string#1}%
{\def#1{#2}}%
@@ -2375,11 +2397,12 @@ help from Bernd Raichle, for which I am grateful.
\ifx\@nnil#3\relax\else
\def#1{#3}#2\bbl@afterfi\bbl@@loop#1{#2}%
\fi}
+\def\bbl@for#1#2#3{\bbl@loopx#1{#2}{\ifx#1\@empty\else#3\fi}}
%<</Basic macros>>
% \end{macrocode}
%
% Some files identify themselves with a \LaTeX{} macro. The following
-% code is placed before it to define (and then undefine) if not in
+% code is placed before them to define (and then undefine) if not in
% \LaTeX.
%
% \begin{macrocode}
@@ -2430,6 +2453,7 @@ help from Bernd Raichle, for which I am grateful.
\ifx\language\@undefined
\csname newcount\endcsname\language
\fi
+%<</Define core switching macros>>
% \end{macrocode}
% \end{macro}
%
@@ -2454,7 +2478,9 @@ help from Bernd Raichle, for which I am grateful.
%
% For formats based on plain version~3.0 the definition of
% |\newlanguage| can be simply copied, removing |\outer|.
+% Plain \TeX\ version 3.0 uses |\count 19| for this purpose.
% \begin{macrocode}
+%<<*Define core switching macros>>
\ifx\newlanguage\@undefined
\csname newcount\endcsname\last@language
\def\addlanguage#1{%
@@ -2465,9 +2491,6 @@ help from Bernd Raichle, for which I am grateful.
\fi
\global\chardef#1\last@language
\wlog{\string#1 = \string\language\the\last@language}}
-% \end{macrocode}
-% Plain \TeX\ version 3.0 uses |\count 19| for this purpose.
-% \begin{macrocode}
\else
\countdef\last@language=19
\def\addlanguage{\alloc@9\language\chardef\@cclvi}
@@ -2477,28 +2500,6 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\ProvidesLanguage}
-% \changes{babel~3.7a}{1997/03/18}{Added macro to prevent problems
-% with unexpected \cs{ProvidesFile} in plain formats because of
-% \babel.}
-% The identification code for each file is something that was
-% introduced in \LaTeXe. When the command |\ProvidesFile| does not
-% exist, a dummy definition is provided temporarily. For use in the
-% language definition file the command |\ProvidesLanguage| is
-% defined by \babel.
-% \changes{babel~3.4e}{1994/06/24}{Redid the identification code,
-% provided dummy definition of \cs{ProvidesFile} for plain \TeX}
-% \changes{babel~3.5f}{1995/07/26}{Store version in \cs{fileversion}}
-% \changes{babel~3.5f}{1995/12/18}{Need to temporarily change the
-% definition of \cs{ProvidesFile} for December 1995 release}
-% \changes{babel~3.5g}{1996/07/09}{Save a few csnames; use
-% \cs{bbl@tempa} instead of \cs{\@ProvidesFile} and store message
-% in \cs{toks8}}
-% \changes{babel~3.9a}{2012/12/09}{Save info about the babel version
-% in the format (switch.def) so that it can be checked later if
-% necessary}
-% \end{macro}
-%
% Identify each file that is produced from this source file.
% \changes{babel~3.4c}{1995/04/28}{lhyphen.cfg has become
% lthyphen.cfg}
@@ -2538,7 +2539,7 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.6a}{1996/11/02}{Removed \cs{babel@core@loaded}, no
% longer needed with the advent of \cs{LdfInit}}
%
-% \section{The Package File}
+% \section{The Package File (\LaTeX)}
%
% In order to make use of the features of \LaTeXe, the \babel\
% system contains a package file, \file{babel.sty}. This file is
@@ -2571,8 +2572,13 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.9a}{2012/10/17}{Hooks started}
% \changes{babel~3.9a}{2013/02/07}{Rejected preset, and replaced by
% base}
+% \changes{babel~3.5g}{1996/10/10}{We need at least \LaTeX\ from
+% December 1994}
+% \changes{babel~3.6k}{1999/03/18}{We need at least \LaTeX\ from
+% June 1998}
% \begin{macrocode}
%<*package>
+\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{babel}[<@date@> <@version@> The Babel package]
\@ifpackagewith{babel}{debug}
{\input switch.def\relax}
@@ -2622,11 +2628,6 @@ help from Bernd Raichle, for which I am grateful.
\expandafter\bbl@tempd\bbl@tempa.\@empty\@nnil}
\expandafter\let\csname opt@babel.sty\endcsname\bbl@tempc
% \end{macrocode}
-%
-% \begin{macrocode}
-\DeclareOption{activeacute}{}
-\DeclareOption{activegrave}{}
-% \end{macrocode}
% The next option tells \babel\ to leave shorthand characters
% active at the end of processing the package. This is \emph{not}
% the default as it can cause problems with other packages, but for
@@ -2643,23 +2644,13 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.9g}{2013/08/07}{Options for hyphenmap}
% \begin{macrocode}
\DeclareOption{KeepShorthandsActive}{}
+\DeclareOption{activeacute}{}
+\DeclareOption{activegrave}{}
\DeclareOption{debug}{}
\DeclareOption{noconfigs}{}
\DeclareOption{showlanguages}{}
\DeclareOption{shorthands=off}{\bbl@tempa shorthands=\bbl@tempa}
-\DeclareOption{strings}{\def\bbl@opt@strings{\BabelStringsDefault}}
-\DeclareOption{strings=encoded}{\let\bbl@opt@strings\relax}
-\def\BabelStringsDefault{generic}
-\DeclareOption{safe=none}{\let\bbl@opt@safe\@empty}
-\DeclareOption{safe=bib}{\def\bbl@opt@safe{B}}
-\DeclareOption{safe=ref}{\def\bbl@opt@safe{R}}
-\DeclareOption{math=active}{}
-\DeclareOption{math=normal}{\def\bbl@mathnormal{\noexpand\textormath}}
-\DeclareOption{hyphenmap=off}{\chardef\bbl@hymapopt\z@}
-\DeclareOption{hyphenmap=first}{\chardef\bbl@hymapopt\@ne}
-\DeclareOption{hyphenmap=select}{\chardef\bbl@hymapopt\tw@}
-\DeclareOption{hyphenmap=other}{\chardef\bbl@hymapopt\thr@@}
-\DeclareOption{hyphenmap=other*}{\chardef\bbl@hymapopt4\relax}
+<@More package options@>
% \end{macrocode}
%
% Handling of package options is done in three passes. (I [JBL] am not
@@ -2675,7 +2666,6 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@opt@shorthands\@nnil
\let\bbl@opt@config\@nnil
\let\bbl@opt@main\@nnil
-\let\bbl@opt@strings\@nnil
\let\bbl@opt@headfoot\@nnil
% \end{macrocode}
% The following tool is defined temporarily to store the values of
@@ -2757,9 +2747,10 @@ help from Bernd Raichle, for which I am grateful.
\edef\bbl@opt@shorthands{%
\expandafter\bbl@sh@string\bbl@opt@shorthands\@empty}%
% \end{macrocode}
-
+%
% The following is ignored with |shorthands=off|, since it is
% intended to take some aditional actions for certain chars.
+%
% \begin{macrocode}
\bbl@ifshorthand{'}%
{\PassOptionsToPackage{activeacute}{babel}}{}
@@ -3088,7 +3079,7 @@ help from Bernd Raichle, for which I am grateful.
%</package>
% \end{macrocode}
%
-% \section{The Kernel of Babel}
+% \section{The kernel of Babel (common)}
%
% The kernel of the \babel\ system is stored in either
% \file{hyphen.cfg} or \file{switch.def} and \file{babel.def}. The
@@ -3131,6 +3122,8 @@ help from Bernd Raichle, for which I am grateful.
% \luatex, and 2 is \xetex. You may use it in your language style
% if necessary.
%
+% \changes{babel~3.9k}{2014/03/24}{Added definition for \cs{uselanguage}}
+%
% \begin{macrocode}
%<*core>
<@Make sure ProvidesFile is defined@>
@@ -3144,25 +3137,19 @@ help from Bernd Raichle, for which I am grateful.
\message{I couldn't find the file language.def}
\else
\closein1
- \def\addlanguage#1#2#3#4#5{%
- \expandafter\ifx\csname lang@#1\endcsname\relax\else
- \global\expandafter\let\csname l@#1\expandafter\endcsname
- \csname lang@#1\endcsname
- \fi}%
- \input language.def
+ \begingroup
+ \def\addlanguage#1#2#3#4#5{%
+ \expandafter\ifx\csname lang@#1\endcsname\relax\else
+ \global\expandafter\let\csname l@#1\expandafter\endcsname
+ \csname lang@#1\endcsname
+ \fi}%
+ \def\uselanguage#1{}%
+ \input language.def
+ \endgroup
\fi
- \chardef\l@english\lang@USenglish
+ \chardef\l@english\z@
\fi
<@Basic macros@>
-\ifx\bbl@opt@strings\@undefined
- \def\bbl@opt@safe{BR}
- \let\bbl@opt@strings\@nnil
- \let\bbl@opt@shorthands\@nnil
-\fi
-\ifx\BabelModifiers\@undefined\let\BabelModifiers\relax\fi
-\ifx\bbl@afterlang\@undefined\let\bbl@afterlang\relax\fi
-\ifx\bbl@language@opts\@undefined\let\bbl@language@opts\@empty\fi
-\providecommand\AfterBabelLanguage[2]{}
\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
\chardef\bbl@engine=%
\ifx\directlua\@undefined
@@ -3194,6 +3181,43 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
% \end{macro}
+%
+% \begin{macro}{\addto}
+% For each language four control sequences have to be defined that
+% control the language-specific definitions. To be able to add
+% something to these macro once they have been defined the macro
+% |\addto| is introduced. It takes two arguments, a \meta{control
+% sequence} and \TeX-code to be added to the \meta{control
+% sequence}.
+%
+% If the \meta{control sequence} has not been defined before it is
+% defined now. The control sequence could also expand to |\relax|,
+% in which case a circular definition results. The net result is a
+% stack overflow. Otherwise the replacement text for the
+% \meta{control sequence} is expanded and stored in a token
+% register, together with the \TeX-code to be added. Finally the
+% \meta{control sequence} is \emph{re}defined, using the contents
+% of the token register.
+%
+% \changes{babel~3.1}{1991/11/05}{Added macro}
+% \changes{babel~3.4}{1994/02/04}{Changed to use toks register}
+% \changes{babel~3.6b}{1996/12/30}{Also check if control sequence
+% expands to \cs{relax}}
+% \begin{macrocode}
+\def\addto#1#2{%
+ \ifx#1\@undefined
+ \def#1{#2}%
+ \else
+ \ifx#1\relax
+ \def#1{#2}%
+ \else
+ {\toks@\expandafter{#1#2}%
+ \xdef#1{\the\toks@}}%
+ \fi
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
% \changes{babel~3.9a}{2012/08/10}{Removed the \cs{peek@token} and
% \textsc{test@token} stuff}
% The macro |\initiate@active@char| takes all the necessary actions
@@ -3277,6 +3301,48 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
%
+% \subsection{Hooks}
+%
+% Note they are loaded in babel.def. switch.def only provides a
+% ``hook'' for hooks (with a default value which is a no-op,
+% below). Admittedly, the current implementation is a somewhat
+% simplistic and does vety little to catch errors, but it is intended
+% for developpers, after all. |\bbl@usehooks| is the commands used by
+% babel to execute hooks defined for an event.
+% \changes{babel~3.9k}{2014/03/23}{Removed a \cs{newcommand},
+% undefined in Plain}
+%
+% \begin{macrocode}
+\def\AddBabelHook#1#2{%
+ \@ifundefined{bbl@hk@#1}{\EnableBabelHook{#1}}{}%
+ \def\bbl@tempa##1,#2=##2,##3\@empty{\def\bbl@tempb{##2}}%
+ \expandafter\bbl@tempa\bbl@evargs,#2=,\@empty
+ \@ifundefined{bbl@ev@#1@#2}%
+ {\bbl@csarg\bbl@add{ev@#2}{\bbl@elt{#1}}%
+ \bbl@csarg\newcommand}%
+ {\bbl@csarg\let{ev@#1@#2}\relax
+ \bbl@csarg\newcommand}%
+ {ev@#1@#2}[\bbl@tempb]}
+\def\EnableBabelHook#1{\bbl@csarg\let{hk@#1}\@firstofone}
+\def\DisableBabelHook#1{\bbl@csarg\let{hk@#1}\@gobble}
+\def\bbl@usehooks#1#2{%
+ \def\bbl@elt##1{%
+ \@nameuse{bbl@hk@##1}{\@nameuse{bbl@ev@##1@#1}#2}}%
+ \@nameuse{bbl@ev@#1}}
+% \end{macrocode}
+% To ensure forward compatibility, arguments in hooks are set
+% implicitly. So, if a further argument is added in the future,
+% there is no need to change the existing code. Note events
+% intended for \textsf{hyphen.cfg} are also loaded (just in
+% case you need them for some reason).
+% \begin{macrocode}
+\def\bbl@evargs{,% don't delete the comma
+ everylanguage=1,loadkernel=1,loadpatterns=1,loadexceptions=1,%
+ adddialect=2,patterns=2,defaultcommands=0,encodedcommands=2,write=0,%
+ beforeextras=0,afterextras=0,stopcommands=0,stringprocess=0,%
+ hyphenation=2,initiateactive=3,afterreset=0}
+% \end{macrocode}
+%
% \begin{macro}{\babelensure}
%
% The user command just parses the optional argument and creates a
@@ -3293,16 +3359,20 @@ help from Bernd Raichle, for which I am grateful.
% |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.
%
% |\bbl@ensured| is the list of macros supposed to be ``ensured''.
% \changes{babel~3.9i}{2014/02/14}{Macro \cs{babelensure} added}
+% \changes{babel~3.9k}{2014/03/23}{Encapsulate \cs{foreignlanguage} in
+% \cs{bbl@ensure@}language, to "protect" strings}
%
% \begin{macrocode}
\newcommand\babelensure[2][]{%
\AddBabelHook{babel-ensure}{afterextras}{%
\ifcase\bbl@select@type
\@nameuse{bbl@e@\languagename}%
- \fi}
+ \fi}%
\begingroup
\let\bbl@ens@include\@empty
\let\bbl@ens@exclude\@empty
@@ -3312,7 +3382,7 @@ help from Bernd Raichle, for which I am grateful.
\edef\bbl@tempa{\bbl@tempb#1\@empty}%
\def\bbl@tempb##1=##2\@@{\@namedef{bbl@ens@##1}{##2}}%
\bbl@for\bbl@tempa\bbl@tempa{\expandafter\bbl@tempb\bbl@tempa\@@}%
- \def\bbl@tempc{\bbl@ensure}
+ \def\bbl@tempc{\bbl@ensure}%
\expandafter\bbl@add\expandafter\bbl@tempc\expandafter{%
\expandafter{\bbl@ens@include}}%
\expandafter\bbl@add\expandafter\bbl@tempc\expandafter{%
@@ -3320,27 +3390,33 @@ help from Bernd Raichle, for which I am grateful.
\toks@\expandafter{\bbl@tempc}%
\edef\x{%
\endgroup
- \noexpand\@namedef{bbl@e@#2}{\the\toks@{\bbl@ens@fontenc}}}
+ \noexpand\@namedef{bbl@e@#2}{\the\toks@{\bbl@ens@fontenc}}}%
\x}
\def\bbl@ensure#1#2#3{%
- \def\bbl@tempb##1{%
+ \def\bbl@tempb##1{% elt for \bbl@ensured list
\ifx##1\@empty\else
\in@{##1}{#2}%
\ifin@\else
\toks@\expandafter{##1}%
+ \edef\bbl@tempa{%
+ \noexpand\DeclareRobustCommand
+ \bbl@csarg\noexpand{ensure@\languagename}[1]{%
+ \noexpand\foreignlanguage{\languagename}%
+ {\ifx\relax#3\else
+ \noexpand\fontencoding{#3}\noexpand\selectfont
+ \fi
+ ########1}}}%
+ \bbl@tempa
\edef##1{%
- \noexpand\foreignlanguage{\languagename}%
- {\ifx\relax#3\else
- \noexpand\fontencoding{#3}\noexpand\selectfont
- \fi
- \the\toks@}}%
+ \bbl@csarg\noexpand{ensure@\languagename}%
+ {\the\toks@}}
\fi
\expandafter\bbl@tempb
\fi}%
\expandafter\bbl@tempb\bbl@ensured\@empty
- \def\bbl@tempa##1{%
+ \def\bbl@tempa##1{% elt for include list
\ifx##1\@empty\else
- \expandafter\in@\expandafter\foreignlanguage\expandafter{##1}%
+ \bbl@csarg\in@{ensure@\languagename\expandafter}\expandafter{##1}%
\ifin@\else
\bbl@tempb##1\@empty
\fi
@@ -3352,11 +3428,12 @@ help from Bernd Raichle, for which I am grateful.
\contentsname\listfigurename\listtablename\indexname\figurename
\tablename\partname\enclname\ccname\headtoname\pagename\seename
\alsoname\proofname\glossaryname\today}
-% \end{macrocode}
+% \end{macrocode}
% \end{macro}
%
% \subsection{Setting up language files}
%
+% \begin{macro}{\LdfInit}
% 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
@@ -3501,7 +3578,7 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
-% \subsection{Support for active characters}
+% \subsection{Shorthands}
%
% \begin{macro}{\bbl@add@special}
% \changes{babel~3.2}{1991/11/10}{Added macro}
@@ -3573,7 +3650,6 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
%
-% \subsection{Shorthands}
%
% \begin{macro}{\initiate@active@char}
% \changes{babel~3.5a}{1995/02/11}{Added macro}
@@ -3845,6 +3921,14 @@ help from Bernd Raichle, for which I am grateful.
\bbl@usehooks{initiateactive}{{#1}{#2}{#3}}}
% \end{macrocode}
%
+% The following package options control the behaviour of shorthands
+% in math mode.
+% \begin{macrocode}
+%<<*More package options>>
+\DeclareOption{math=active}{}
+\DeclareOption{math=normal}{\def\bbl@mathnormal{\noexpand\textormath}}
+%<</More package options>>
+% \end{macrocode}
% Initiating a shorthand makes active the char. That is not
% strictly necessary but it is still done for backward
% compatibility. So we need to restore the original catcode at the
@@ -4252,8 +4336,6 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
-% \subsection{Conditional loading of shorthands}
-%
% \changes{babel~3.9a}{2012/06/16}{Added code}
%
% Note the value is that at the expansion time, eg, in the preample
@@ -4325,6 +4407,24 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
+% Usually the |~| is active and expands to \verb*=\penalty\@M\ =.
+% When it is written to the \file{.aux} file it is written
+% expanded. To prevent that and to be able to use the character |~|
+% as a start character for a shorthand, it is redefined here as a
+% one character shorthand on system level. The system declaration
+% is in most cases redundant (when |~| is still a non-break space),
+% and in some cases is inconvenient (if |~| has been redefined);
+% however, for backward compatibility it is maintained (some
+% existing documents may rely on the \babel{} value).
+% \changes{babel~3.9i}{2014/02/06}{Moved from above, after
+% \cs{bbl@usehook} has been defined}
+% \changes{babel~3.9k}{2014/02/06}{Moved again at the original place}
+% \begin{macrocode}
+\initiate@active@char{~}
+\declare@shorthand{system}{~}{\leavevmode\nobreak\ }
+\bbl@activate{~}
+% \end{macrocode}
+%
% \begin{macro}{\OT1dqpos}
% \begin{macro}{\T1dqpos}
% The position of the double quote character is different for the
@@ -4636,44 +4736,6 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
-% \subsection{Support for extending macros}
-%
-% \begin{macro}{\addto}
-% For each language four control sequences have to be defined that
-% control the language-specific definitions. To be able to add
-% something to these macro once they have been defined the macro
-% |\addto| is introduced. It takes two arguments, a \meta{control
-% sequence} and \TeX-code to be added to the \meta{control
-% sequence}.
-%
-% If the \meta{control sequence} has not been defined before it is
-% defined now. The control sequence could also expand to |\relax|,
-% in which case a circular definition results. The net result is a
-% stack overflow. Otherwise the replacement text for the
-% \meta{control sequence} is expanded and stored in a token
-% register, together with the \TeX-code to be added. Finally the
-% \meta{control sequence} is \emph{re}defined, using the contents
-% of the token register.
-%
-% \changes{babel~3.1}{1991/11/05}{Added macro}
-% \changes{babel~3.4}{1994/02/04}{Changed to use toks register}
-% \changes{babel~3.6b}{1996/12/30}{Also check if control sequence
-% expands to \cs{relax}}
-% \begin{macrocode}
-\def\addto#1#2{%
- \ifx#1\@undefined
- \def#1{#2}%
- \else
- \ifx#1\relax
- \def#1{#2}%
- \else
- {\toks@\expandafter{#1#2}%
- \xdef#1{\the\toks@}}%
- \fi
- \fi}
-% \end{macrocode}
-% \end{macro}
-%
% \subsection{Short tags}
%
% \begin{macro}{\babeltags}
@@ -4698,20 +4760,19 @@ help from Bernd Raichle, for which I am grateful.
\bbl@tempc}%
\bbl@for\bbl@tempa\bbl@tempa{%
\expandafter\bbl@tempb\bbl@tempa\@@}}
-% \end{macrocode}
+% \end{macrocode}
% \end{macro}
%
-% \subsection{Hyphens}
+% \subsection{Hyphens}
%
% \begin{macro}{\babelhyphenation}
%
-% \changes{babel~3.9a}{2012/08/28}{Macro added}
-%
% This macro saves hyphenation exceptions. Two macros are used to
% store them: |\bbl@hyphenation@| for the global ones and
% |\bbl@hyphenation<lang>| for language ones. See |\bbl@patterns|
% above for further details. We make sure there is a space between
% words when multiple commands are used.
+% \changes{babel~3.9a}{2012/08/28}{Macro added}
%
% \begin{macrocode}
\@onlypreamble\babelhyphenation
@@ -4839,6 +4900,409 @@ help from Bernd Raichle, for which I am grateful.
\def\bbl@disc#1#2{\nobreak\discretionary{#2-}{}{#1}\bbl@allowhyphens}
% \end{macrocode}
% \end{macro}
+% \subsection{Multiencoding strings}
+%
+% \changes{babel~3.9a}{2012/09/05}{Added tentative code for string
+% declarations}
+% \changes{babel~3.9a}{2012/12/24}{Added hooks}
+%
+% The aim following commands is to provide a commom interface for
+% strings in several encodings. They also contains several hooks which
+% can be ued by \luatex{} and \xetex. The code is organized here with
+% pseudo-guards, so we start with the basic commands.
+%
+% \paragraph{Tools}
+%
+% But first, a couple of tools. The first one makes global a local
+% variable. This is not the best solution, but it works.
+% \begin{macrocode}
+\def\bbl@toglobal#1{\global\let#1#1}
+\def\bbl@recatcode#1{%
+ \@tempcnta="7F
+ \def\bbl@tempa{%
+ \ifnum\@tempcnta>"FF\else
+ \catcode\@tempcnta=#1\relax
+ \advance\@tempcnta\@ne
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa}
+% \end{macrocode}
+%
+% The second one. We need to patch |\@uclclist|, but it is done
+% once and only if |\SetCase| is used or if strings are encoded.
+% \begin{macrocode}
+\def\bbl@patchuclc{%
+ \let\bbl@patchuclc\relax
+ \@ifundefined{bbl@tolower}{%
+ \g@addto@macro\@uclclist{%
+ \reserved@b{\reserved@b\@gobble}% stops processing the list
+ \let\bbl@encoded\bbl@encoded@uclc
+ \@ifundefined{\languagename @bbl@uclc}% and resumes it
+ {\reserved@a}%
+ {\csname\languagename @bbl@uclc\endcsname}%
+ {\bbl@tolower\@empty}{\bbl@toupper\@empty}}%
+ \gdef\bbl@tolower{\csname\languagename @bbl@lc\endcsname}%
+ \gdef\bbl@toupper{\csname\languagename @bbl@uc\endcsname}}{}}%
+% \end{macrocode}
+%
+% The following package options control the behaviour of |\SetString|.
+%
+% \begin{macrocode}
+%<<*More package options>>
+\let\bbl@opt@strings\@nnil % accept strings=value
+\DeclareOption{strings}{\def\bbl@opt@strings{\BabelStringsDefault}}
+\DeclareOption{strings=encoded}{\let\bbl@opt@strings\relax}
+\def\BabelStringsDefault{generic}
+%<</More package options>>
+% \end{macrocode}
+%
+% \paragraph{Main command} This is the main command. With the
+% first use it is redefined to omit the basic setup in subsequent
+% blocks. We make sure strings contain actual letters in the range
+% 128-255, not active characters.
+% \changes{babel~3.9g}{2013/07/29}{Added starred variant. A bit of
+% clean up. Removed \cs{UseString}, which didn't work.}
+% \changes{babel~3.9g}{2013/08/01}{Now several languages can be
+% processed with \cs{BabelLanguages}, if set in the ldf.}
+% \begin{macrocode}
+\@onlypreamble\StartBabelCommands
+\def\StartBabelCommands{%
+ \begingroup
+ \bbl@recatcode{11}%
+ <@Macros local to BabelCommands@>
+ \def\bbl@provstring##1##2{%
+ \providecommand##1{##2}%
+ \bbl@toglobal##1}%
+ \global\let\bbl@scafter\@empty
+ \let\StartBabelCommands\bbl@startcmds
+ \ifx\BabelLanguages\relax
+ \let\BabelLanguages\CurrentOption
+ \fi
+ \begingroup
+ \let\bbl@screset\@nnil % local flag - disable 1st stopcommands
+ \StartBabelCommands}
+\def\bbl@startcmds{%
+ \ifx\bbl@screset\@nnil\else
+ \bbl@usehooks{stopcommands}{}%
+ \fi
+ \endgroup
+ \begingroup
+ \@ifstar
+ {\ifx\bbl@opt@strings\@nnil
+ \let\bbl@opt@strings\BabelStringsDefault
+ \fi
+ \bbl@startcmds@i}%
+ \bbl@startcmds@i}
+\def\bbl@startcmds@i#1#2{%
+ \edef\bbl@L{\zap@space#1 \@empty}%
+ \edef\bbl@G{\zap@space#2 \@empty}%
+ \bbl@startcmds@ii}
+% \end{macrocode}
+% Parse the encoding info to get the label, input, and font parts.
+%
+% Select the behaviour of |\SetString|. Thre are two main cases,
+% depending of if there is an optional argument: without it and
+% |strings=encoded|, strings are defined
+% always; otherwise, they are set only if they are still undefined
+% (ie, fallback values). With labelled blocks and
+% |strings=encoded|, define the strings, but with another value,
+% define strings only if the current label or font encoding is the
+% value of |strings|; otherwise (ie, no |strings| or a block whose
+% label is not in |strings=|) do nothing.
+%
+% We presume the current block is not loaded, and therefore set
+% (above) a couple of default values to gobble the arguments. Then,
+% these macros are redefined if necessary according to several
+% 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]{%
+ \let\SetString\@gobbletwo
+ \let\bbl@stringdef\@gobbletwo
+ \let\AfterBabelCommands\@gobble
+ \ifx\@empty#1%
+ \def\bbl@sc@label{generic}%
+ \def\bbl@encstring##1##2{%
+ \ProvideTextCommandDefault##1{##2}%
+ \bbl@toglobal##1%
+ \expandafter\bbl@toglobal\csname\string?\string##1\endcsname}%
+ \let\bbl@sctest\in@true
+ \else
+ \let\bbl@sc@charset\space % <- zapped below
+ \let\bbl@sc@fontenc\space % <- " "
+ \def\bbl@tempa##1=##2\@nil{%
+ \bbl@csarg\edef{sc@\zap@space##1 \@empty}{##2 }}%
+ \bbl@for\bbl@tempb{label=#1}{\expandafter\bbl@tempa\bbl@tempb\@nil}%
+ \def\bbl@tempa##1 ##2{% space -> comma
+ ##1%
+ \ifx\@empty##2\else\ifx,##1,\else,\fi\bbl@afterfi\bbl@tempa##2\fi}%
+ \edef\bbl@sc@fontenc{\expandafter\bbl@tempa\bbl@sc@fontenc\@empty}%
+ \edef\bbl@sc@label{\expandafter\zap@space\bbl@sc@label\@empty}%
+ \edef\bbl@sc@charset{\expandafter\zap@space\bbl@sc@charset\@empty}%
+ \def\bbl@encstring##1##2{%
+ \bbl@for\bbl@tempc\bbl@sc@fontenc{%
+ \@ifundefined{T@\bbl@tempc}%
+ {}%
+ {\ProvideTextCommand##1\bbl@tempc{##2}%
+ \bbl@toglobal##1%
+ \expandafter
+ \bbl@toglobal\csname\bbl@tempc\string##1\endcsname}}}%
+ \def\bbl@sctest{%
+ \@expandtwoargs
+ \in@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}%
+ \fi
+ \ifx\bbl@opt@strings\@nnil % ie, no strings key -> defaults
+ \else\ifx\bbl@opt@strings\relax % ie, strings=encoded
+ \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}{}%
+ \else
+ \@expandtwoargs
+ \bbl@usehooks{encodedcommands}{{\bbl@sc@charset}{\bbl@sc@fontenc}}%
+ \fi}
+% \end{macrocode}
+%
+% 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\relax\fi}}
+\def\bbl@scswitch{%
+ \bbl@forlang\bbl@tempa{%
+ \ifx\bbl@G\@empty\else
+ \ifx\SetString\@gobbletwo\else
+ \edef\bbl@GL{\bbl@G\bbl@tempa}%
+ \@expandtwoargs\in@{,\bbl@GL,}{,\bbl@screset,}%
+ \ifin@\else
+ \global\expandafter\let\csname\bbl@GL\endcsname\@undefined
+ \xdef\bbl@screset{\bbl@screset,\bbl@GL}%
+ \fi
+ \fi
+ \fi}}
+\AtEndOfPackage{%
+ \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}{}%
+ \endgroup
+ \endgroup
+ \bbl@scafter}
+% \end{macrocode}
+%
+% Now we define commands to be used inside |\StartBabelCommands|.
+%
+% \paragraph{Strings} The following macro is the actual definition
+% of |\SetString| when it is ``active''
+%
+% First save the ``switcher''. Create it if undefined. Strings are
+% defined only if undefined (ie, like |\providescommmand|). With
+% the event |stringprocess| you can preprocess the string by
+% manipulating the value of |\BabelString|. If there are several
+% hooks assigned to this event, preprocessing is done in the same
+% order as defined. Finally, the string is set.
+% \changes{babel~3.9g}{2013/07/29}{Added \cs{bbl@forlang} to ignore in
+% the preamble unknown languages, as described in the doc.}
+%
+% \begin{macrocode}
+\def\bbl@setstring#1#2{%
+ \bbl@forlang\bbl@tempa{%
+ \edef\bbl@LC{\bbl@tempa\expandafter\@gobble\string#1}%
+ \@ifundefined{\bbl@LC}% eg, \germanchaptername
+ {\global\expandafter
+ \bbl@add\csname\bbl@G\bbl@tempa\expandafter\endcsname\expandafter
+ {\expandafter\bbl@scset\expandafter#1\csname\bbl@LC\endcsname}}%
+ {}%
+ \def\BabelString{#2}%
+ \bbl@usehooks{stringprocess}{}%
+ \expandafter\bbl@stringdef
+ \csname\bbl@LC\expandafter\endcsname\expandafter{\BabelString}}}
+% \end{macrocode}
+%
+% Now, some addtional stuff to be used when encoded strings are
+% used. Captions then include |\bbl@encoded| for string to be
+% expanded in case transformations. It is |\relax| by default, but
+% in |\MakeUppercase| and |\MakeLowercase| its value is a modified
+% expandable |\@changed@cmd|.
+%
+% \changes{babel~3.9i}{2014/03/13}{Added code to expand captions in
+% case transformations.}
+%
+% \begin{macrocode}
+\ifx\bbl@opt@strings\relax
+ \def\bbl@scset#1#2{\def#1{\bbl@encoded#2}}
+ \bbl@patchuclc
+ \let\bbl@encoded\relax
+ \def\bbl@encoded@uclc#1{%
+ \@inmathwarn#1%
+ \expandafter\ifx\csname\cf@encoding\string#1\endcsname\relax
+ \expandafter\ifx\csname ?\string#1\endcsname\relax
+ \TextSymbolUnavailable#1%
+ \else
+ \csname ?\string#1\endcsname
+ \fi
+ \else
+ \csname\cf@encoding\string#1\endcsname
+ \fi}
+\else
+ \def\bbl@scset#1#2{\def#1{#2}}
+\fi
+% \end{macrocode}
+%
+% Define |\SetStringLoop|, which is actually set inside
+% |\StartBabelCommands|. The current definition is
+% 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}
+%<<*Macros local to BabelCommands>>
+\def\SetStringLoop##1##2{%
+ \def\bbl@templ####1{\expandafter\noexpand\csname##1\endcsname}%
+ \count@\z@
+ \bbl@loop\bbl@tempa{##2}{%
+ \advance\count@\@ne
+ \toks@\expandafter{\bbl@tempa}%
+ \edef\bbl@tempb{%
+ \bbl@templ{\romannumeral\count@}{\the\toks@}%
+ \count@=\the\count@\relax}%
+ \expandafter\SetString\bbl@tempb}}%
+%<</Macros local to BabelCommands>>
+% \end{macrocode}
+%
+% \paragraph{Delaying code} Now the definition of
+% |\AfterBabelCommands| when it is activated.
+%
+% \begin{macrocode}
+\def\bbl@aftercmds#1{%
+ \toks@\expandafter{\bbl@scafter#1}%
+ \xdef\bbl@scafter{\the\toks@}}
+% \end{macrocode}
+%
+% \paragraph{Case mapping}
+%
+% The command |\SetCase| provides a way to change the behaviour of
+% |\MakeUppercase| and |\MakeLowercase|.
+%
+% \changes{babel~3.9h}{2013/11/08}{Use \cs{bbl@encstrings} - they
+% should be defined always, even if no `strings'}
+% \begin{macrocode}
+%<<*Macros local to BabelCommands>>
+ \newcommand\SetCase[3][]{%
+ \bbl@patchuclc
+ \bbl@forlang\bbl@tempa{%
+ \expandafter\bbl@encstring
+ \csname\bbl@tempa @bbl@uclc\endcsname{\reserved@a##1}%
+ \expandafter\bbl@encstring
+ \csname\bbl@tempa @bbl@uc\endcsname{##2}%
+ \expandafter\bbl@encstring
+ \csname\bbl@tempa @bbl@lc\endcsname{##3}}}%
+%<</Macros local to BabelCommands>>
+% \end{macrocode}
+%
+% Macros to deal with case mapping for hyphenation. To decide if the
+% document is monolingual or multilingual, we make a rough guess --
+% just see if there is a comma in the languages list, built in the
+% first pass of the package options.
+%
+% \begin{macrocode}
+%<<*Macros local to BabelCommands>>
+ \newcommand\SetHyphenMap[1]{%
+ \bbl@forlang\bbl@tempa{%
+ \expandafter\bbl@stringdef
+ \csname\bbl@tempa @bbl@hyphenmap\endcsname{##1}}}
+%<</Macros local to BabelCommands>>
+% \end{macrocode}
+%
+% There are 3 helper macros which do most of the work for you.
+%
+% \begin{macrocode}
+\newcommand\BabelLower[2]{% one to one.
+ \ifnum\lccode#1=#2\else
+ \babel@savevariable{\lccode#1}%
+ \lccode#1=#2\relax
+ \fi}
+\newcommand\BabelLowerMM[4]{% many-to-many
+ \@tempcnta=#1\relax
+ \@tempcntb=#4\relax
+ \def\bbl@tempa{%
+ \ifnum\@tempcnta>#2\else
+ \@expandtwoargs\BabelLower{\the\@tempcnta}{\the\@tempcntb}%
+ \advance\@tempcnta#3\relax
+ \advance\@tempcntb#3\relax
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa}
+\newcommand\BabelLowerMO[4]{% many-to-one
+ \@tempcnta=#1\relax
+ \def\bbl@tempa{%
+ \ifnum\@tempcnta>#2\else
+ \@expandtwoargs\BabelLower{\the\@tempcnta}{#4}%
+ \advance\@tempcnta#3
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa}
+% \end{macrocode}
+%
+% The following package options control the behaviour of
+% hyphenation mapping.
+%
+% \begin{macrocode}
+%<<*More package options>>
+\DeclareOption{hyphenmap=off}{\chardef\bbl@hymapopt\z@}
+\DeclareOption{hyphenmap=first}{\chardef\bbl@hymapopt\@ne}
+\DeclareOption{hyphenmap=select}{\chardef\bbl@hymapopt\tw@}
+\DeclareOption{hyphenmap=other}{\chardef\bbl@hymapopt\thr@@}
+\DeclareOption{hyphenmap=other*}{\chardef\bbl@hymapopt4\relax}
+%<</More package options>>
+% \end{macrocode}
+%
+% Initial setup to provide a default behaviour if |hypenmap|
+% is not set.
+%
+% \begin{macrocode}
+\AtEndOfPackage{%
+ \ifx\bbl@hymapopt\@undefined
+ \@expandtwoargs\in@{,}{\bbl@language@opts}%
+ \chardef\bbl@hymapopt\ifin@4\else\@ne\fi
+ \fi}
+% \end{macrocode}
%
% \subsection{Macros common to a number of languages}
%
@@ -4873,13 +5337,11 @@ help from Bernd Raichle, for which I am grateful.
%
% \subsection{Making glyphs available}
%
-% The file \file{\filename}\footnote{The file described in this
-% section has version number \fileversion, and was last revised on
-% \filedate.} makes a number of glyphs available that either do not
+% This section makes a number of glyphs available that either do not
% exist in the \texttt{OT1} encoding and have to be `faked', or
% that are not accessible through \file{T1enc.def}.
%
-% \subsection{Quotation marks}
+% \subsubsection{Quotation marks}
%
% \begin{macro}{\quotedblbase}
% In the \texttt{T1} encoding the opening double quote at the
@@ -4978,7 +5440,7 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
%
%
-% \subsection{Letters}
+% \subsubsection{Letters}
%
% \begin{macro}{\ij}
% \begin{macro}{\IJ}
@@ -5061,7 +5523,7 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
%
-% \subsection{Shorthands for quotation marks}
+% \subsubsection{Shorthands for quotation marks}
%
% Shorthands are provided for a number of different quotation
% marks, which make them usable both outside and inside mathmode.
@@ -5176,7 +5638,7 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
-% \subsection{Umlauts and trema's}
+% \subsubsection{Umlauts and tremas}
%
% The command |\"| needs to have a different effect for different
% languages. For German for instance, the `umlaut' should be
@@ -5276,394 +5738,23 @@ help from Bernd Raichle, for which I am grateful.
\DeclareTextCompositeCommand{\"}{OT1}{U}{\bbl@umlauta{U}}%
}
% \end{macrocode}
-% \subsection{Multiencoding strings}
-%
-% \changes{babel~3.9a}{2012/09/05}{Added tentative code for string
-% declarations}
-% \changes{babel~3.9a}{2012/12/24}{Added hooks}
-%
-% The aim following commands is to provide a commom interface for
-% strings in several encodings. They also contains several hooks which
-% can be ued by \luatex{} and \xetex. The code is organized here with
-% pseudo-guards, so we start with the basic commands.
-%
-% The command |\SetCase| provides a way to change the behaviour of
-% |\MakeUppercase| and |\MakeLowercase|. We need to patch
-% |\@uclclist|, but it is done once and only if |\SetCase| is used.
-% \begin{macrocode}
-\def\bbl@patchuclc{%
- \let\bbl@patchuclc\relax
- \@ifundefined{bbl@tolower}{%
- \g@addto@macro\@uclclist{%
- \reserved@b{\reserved@b\@gobble}% stops processing the list
- \let\bbl@encoded\bbl@encoded@uclc
- \@ifundefined{\languagename @bbl@uclc}% and resumes it
- {\reserved@a}%
- {\csname\languagename @bbl@uclc\endcsname}%
- {\bbl@tolower\@empty}{\bbl@toupper\@empty}}%
- \gdef\bbl@tolower{\csname\languagename @bbl@lc\endcsname}%
- \gdef\bbl@toupper{\csname\languagename @bbl@uc\endcsname}}{}}%
-% \end{macrocode}
-%
-% 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@encstring
- \csname\bbl@tempa @bbl@uclc\endcsname{\reserved@a##1}%
- \expandafter\bbl@encstring
- \csname\bbl@tempa @bbl@uc\endcsname{##2}%
- \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@| 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##1##2{%
- \def\bbl@templ####1{\expandafter\noexpand\csname##1\endcsname}%
- \count@\z@
- \bbl@loop\bbl@tempa{##2}{%
- \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}
-%
-% This is the main command. With the first use it is redefined to
-% omit the basic setup in subsequent blocks. We make sure strings
-% contain actual letters in the range 128-255, not active characters.
-% \changes{babel~3.9g}{2013/07/29}{Added starred variant. A bit of
-% clean up. Removed \cs{UseString}, which didn't work.}
-% \changes{babel~3.9g}{2013/08/01}{Now several languages can be
-% processed with \cs{BabelLanguages}, if set in the ldf.}
-% \begin{macrocode}
-\def\bbl@aftercmds#1{%
- \toks@\expandafter{\bbl@scafter#1}%
- \xdef\bbl@scafter{\the\toks@}}
-\def\bbl@toglobal#1{\global\let#1#1}
-\def\bbl@recatcode#1{%
- \@tempcnta="7F
- \def\bbl@tempa{%
- \ifnum\@tempcnta>"FF\else
- \catcode\@tempcnta=#1\relax
- \advance\@tempcnta\@ne
- \expandafter\bbl@tempa
- \fi}%
- \bbl@tempa}
-\@onlypreamble\StartBabelCommands
-\def\StartBabelCommands{%
- \begingroup
- \bbl@recatcode{11}%
- <@Define SetStringLoop@>
- <@Define SetCase@>
- \def\bbl@provstring##1##2{%
- \providecommand##1{##2}%
- \bbl@toglobal##1}%
- \global\let\bbl@scafter\@empty
- \let\StartBabelCommands\bbl@startcmds
- \ifx\BabelLanguages\relax
- \let\BabelLanguages\CurrentOption
- \fi
- \begingroup
- \let\bbl@screset\@nnil % local flag - disable 1st stopcommands
- \StartBabelCommands}
-\def\bbl@startcmds{%
- \ifx\bbl@screset\@nnil\else
- \bbl@usehooks{stopcommands}{}%
- \fi
- \endgroup
- \begingroup
- \@ifstar
- {\ifx\bbl@opt@strings\@nnil
- \let\bbl@opt@strings\BabelStringsDefault
- \fi
- \bbl@startcmds@i}%
- \bbl@startcmds@i}
-\def\bbl@startcmds@i#1#2{%
- \edef\bbl@L{\zap@space#1 \@empty}%
- \edef\bbl@G{\zap@space#2 \@empty}%
- \bbl@startcmds@ii}
-% \end{macrocode}
-% Parse the encoding info to get the label, input, and font parts.
-%
-% Select the behaviour of |\SetString|. Thre are two main cases,
-% depending of if there is an optional argument: without it and
-% |strings=encoded|, strings are defined
-% always; otherwise, they are set only if they are still undefined
-% (ie, fallback values). With labelled blocks and
-% |strings=encoded|, define the strings, but with another value,
-% define strings only if the current label or font encoding is the
-% value of |strings|; otherwise (ie, no |strings| or a block whose
-% label is not in |strings=|) do nothing.
-%
-% We presume the current block is not loaded, and therefore set
-% (above) a couple of default values to gobble the arguments. Then,
-% these macros are redefined if necessary according to several
-% 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]{%
- \let\SetString\@gobbletwo
- \let\bbl@stringdef\@gobbletwo
- \let\AfterBabelCommands\@gobble
- \ifx\@empty#1%
- \def\bbl@sc@label{generic}%
- \def\bbl@encstring##1##2{%
- \ProvideTextCommandDefault##1{##2}%
- \bbl@toglobal##1%
- \expandafter\bbl@toglobal\csname\string?\string##1\endcsname}%
- \let\bbl@sctest\in@true
- \else
- \let\bbl@sc@charset\space % <- zapped below
- \let\bbl@sc@fontenc\space % <- " "
- \def\bbl@tempa##1=##2\@nil{%
- \bbl@csarg\edef{sc@\zap@space##1 \@empty}{##2 }}%
- \bbl@for\bbl@tempb{label=#1}{\expandafter\bbl@tempa\bbl@tempb\@nil}%
- \def\bbl@tempa##1 ##2{% space -> comma
- ##1%
- \ifx\@empty##2\else\ifx,##1,\else,\fi\bbl@afterfi\bbl@tempa##2\fi}%
- \edef\bbl@sc@fontenc{\expandafter\bbl@tempa\bbl@sc@fontenc\@empty}%
- \edef\bbl@sc@label{\expandafter\zap@space\bbl@sc@label\@empty}%
- \edef\bbl@sc@charset{\expandafter\zap@space\bbl@sc@charset\@empty}%
- \def\bbl@encstring##1##2{%
- \bbl@for\bbl@tempc\bbl@sc@fontenc{%
- \@ifundefined{T@\bbl@tempc}%
- {}%
- {\ProvideTextCommand##1\bbl@tempc{##2}%
- \bbl@toglobal##1%
- \expandafter
- \bbl@toglobal\csname\bbl@tempc\string##1\endcsname}}}%
- \def\bbl@sctest{%
- \@expandtwoargs
- \in@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}%
- \fi
- \ifx\bbl@opt@strings\@nnil % ie, no strings key -> defaults
- \else\ifx\bbl@opt@strings\relax % ie, strings=encoded
- \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}{}%
- \else
- \@expandtwoargs
- \bbl@usehooks{encodedcommands}{{\bbl@sc@charset}{\bbl@sc@fontenc}}%
- \fi}
-% \end{macrocode}
-%
-% 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\relax\fi}}
-\def\bbl@scswitch{%
- \bbl@forlang\bbl@tempa{%
- \ifx\bbl@G\@empty\else
- \ifx\SetString\@gobbletwo\else
- \edef\bbl@GL{\bbl@G\bbl@tempa}%
- \@expandtwoargs\in@{,\bbl@GL,}{,\bbl@screset,}%
- \ifin@\else
- \global\expandafter\let\csname\bbl@GL\endcsname\@undefined
- \xdef\bbl@screset{\bbl@screset,\bbl@GL}%
- \fi
- \fi
- \fi}}
-\AtEndOfPackage{%
- \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}{}%
- \endgroup
- \endgroup
- \bbl@scafter}
-% \end{macrocode}
-%
-% First save the ``switcher''. Create it if undefined. Strings are
-% defined only if undefined (ie, like |\providescommmand|). With
-% the event |stringprocess| you can preprocess the string by
-% manipulating the value of |\BabelString|. If there are several
-% hooks assigned to this event, preprocessing is done in the same
-% order as defined. Finally, the string is set.
-% \changes{babel~3.9g}{2013/07/29}{Added \cs{bbl@forlang} to ignore in
-% the preamble unknown languages, as described in the doc.}
-%
-% \begin{macrocode}
-\def\bbl@setstring#1#2{%
- \bbl@forlang\bbl@tempa{%
- \edef\bbl@LC{\bbl@tempa\expandafter\@gobble\string#1}%
- \@ifundefined{\bbl@LC}% eg, \germanchaptername
- {\global\expandafter
- \bbl@add\csname\bbl@G\bbl@tempa\expandafter\endcsname\expandafter
- {\expandafter\bbl@scset\expandafter#1\csname\bbl@LC\endcsname}}%
- {}%
- \def\BabelString{#2}%
- \bbl@usehooks{stringprocess}{}%
- \expandafter\bbl@stringdef
- \csname\bbl@LC\expandafter\endcsname\expandafter{\BabelString}}}
-% \end{macrocode}
-%
-% Now, some addtional stuff to be used when encoded strings are
-% used. Captions then include |\bbl@encoded| for string to be
-% expanded in case transformations. It is |\relax| by default, but
-% in |\MakeUppercase| and |\MakeLowercase| its value is a modified
-% expandable |\@changed@cmd|.
-%
-% \changes{babel~3.9i}{2014/03/13}{Added code to expand captions in
-% case transformations.}
%
+% Finally, the default is to use English as the main language.
+% \changes{babel~3.6c}{1997/01/05}{When \file{hyphen.cfg} is not
+% loaded in the format \cs{l@english} might not be defined; assume
+% english is language 0}
+% \changes{babel~3.9a}{2012-05-17}{Languages are best assigned with
+% \cs{chardef}, not \cs{let}}
% \begin{macrocode}
-\ifx\bbl@opt@strings\relax
- \def\bbl@scset#1#2{\def#1{\bbl@encoded#2}}
- \bbl@patchuclc
-\else
- \def\bbl@scset#1#2{\def#1{#2}}
+\ifx\l@english\@undefined
+ \chardef\l@english\z@
\fi
-\let\bbl@encoded\relax
-\def\bbl@encoded@uclc#1{%
- \@inmathwarn#1%
- \expandafter\ifx\csname\cf@encoding\string#1\endcsname\relax
- \expandafter\ifx\csname ?\string#1\endcsname\relax
- \TextSymbolUnavailable#1%
- \else
- \csname ?\string#1\endcsname
- \fi
- \else
- \csname\cf@encoding\string#1\endcsname
- \fi}
-% \end{macrocode}
-%
-% Macros to deal with case mapping for hyphenation. To decide if the
-% document is monolingual or multilingual, we make a rough guess --
-% just see if there is a comma in the languages list, built in the
-% first pass of the package options.
-%
-% \begin{macrocode}
-\def\SetHyphenMap#1{%
- \bbl@forlang\bbl@tempa{%
- \expandafter\bbl@stringdef
- \csname\bbl@tempa @bbl@hyphenmap\endcsname{#1}}}
-\AtEndOfPackage{%
- \ifx\bbl@hymapopt\@undefined
- \@expandtwoargs\in@{,}{\bbl@language@opts}%
- \chardef\bbl@hymapopt\ifin@4\else\@ne\fi
- \fi}
-% \end{macrocode}
-%
-% There are 3 helper macros which do most of the work for you.
-%
-% \begin{macrocode}
-\newcommand\BabelLower[2]{% one to one.
- \ifnum\lccode#1=#2\else
- \babel@savevariable{\lccode#1}%
- \lccode#1=#2\relax
- \fi}
-\newcommand\BabelLowerMM[4]{% many-to-many
- \@tempcnta=#1\relax
- \@tempcntb=#4\relax
- \def\bbl@tempa{%
- \ifnum\@tempcnta>#2\else
- \@expandtwoargs\BabelLower{\the\@tempcnta}{\the\@tempcntb}%
- \advance\@tempcnta#3\relax
- \advance\@tempcntb#3\relax
- \expandafter\bbl@tempa
- \fi}%
- \bbl@tempa}
-\newcommand\BabelLowerMO[4]{% many-to-one
- \@tempcnta=#1\relax
- \def\bbl@tempa{%
- \ifnum\@tempcnta>#2\else
- \@expandtwoargs\BabelLower{\the\@tempcnta}{#4}%
- \advance\@tempcnta#3
- \expandafter\bbl@tempa
- \fi}%
- \bbl@tempa}
+\main@language{english}
% \end{macrocode}
%
-% \subsection{Hooks}
-%
-% Note they are loaded in babel.def. switch.def only provides a
-% ``hook'' for hooks (with a default value which is a no-op,
-% below). Admittedly, the current implementation is a somewhat
-% simplistic and does vety little to catch errors, but it is intended
-% for developpers, after all. |\bbl@usehooks| is the commands used by
-% babel to execute hooks defined for an event.
+% Now we load definition files for engines.
%
% \begin{macrocode}
-\def\AddBabelHook#1#2{%
- \@ifundefined{bbl@hk@#1}{\EnableBabelHook{#1}}{}%
- \def\bbl@tempa##1,#2=##2,##3\@empty{\def\bbl@tempb{##2}}%
- \expandafter\bbl@tempa\bbl@evargs,#2=,\@empty
- \@ifundefined{bbl@ev@#1@#2}%
- {\bbl@csarg\bbl@add{ev@#2}{\bbl@elt{#1}}%
- \bbl@csarg\newcommand}%
- {\bbl@csarg\renewcommand}%
- {ev@#1@#2}[\bbl@tempb]}
-\def\EnableBabelHook#1{\bbl@csarg\let{hk@#1}\@firstofone}
-\def\DisableBabelHook#1{\bbl@csarg\let{hk@#1}\@gobble}
-\def\bbl@usehooks#1#2{%
- \def\bbl@elt##1{%
- \@nameuse{bbl@hk@##1}{\@nameuse{bbl@ev@##1@#1}#2}}%
- \@nameuse{bbl@ev@#1}}
-% \end{macrocode}
-% To ensure forward compatibility, arguments in hooks are set
-% implicitly. So, if a further argument is added in the future,
-% there is no need to change the existing code. Note events
-% intended for \textsf{hyphen.cfg} are also loaded (just in
-% case you need them for some reason).
-% \begin{macrocode}
-\def\bbl@evargs{,% don't delete the comma
- everylanguage=1,loadkernel=1,loadpatterns=1,loadexceptions=1,%
- adddialect=2,patterns=2,defaultcommands=0,encodedcommands=2,write=0,%
- beforeextras=0,afterextras=0,stopcommands=0,stringprocess=0,%
- hyphenation=2,initiateactive=3,afterreset=0}
\ifcase\bbl@engine\or
\input luababel.def
\or
@@ -5671,6 +5762,8 @@ help from Bernd Raichle, for which I am grateful.
\fi
% \end{macrocode}
%
+% \section{The kernel of Babel (only \LaTeX)}
+%
% \subsection{The redefinition of the style commands}
%
% The rest of the code in this file can only be processed by
@@ -5735,6 +5828,16 @@ help from Bernd Raichle, for which I am grateful.
% |\@newl@bel|. This is needed because we need to make sure that
% shorthand characters expand to their non-active version.
%
+% The following package options control which macros are to be
+% redefined.
+% \begin{macrocode}
+%<<*More package options>>
+\DeclareOption{safe=none}{\let\bbl@opt@safe\@empty}
+\DeclareOption{safe=bib}{\def\bbl@opt@safe{B}}
+\DeclareOption{safe=ref}{\def\bbl@opt@safe{R}}
+%<</More package options>>
+% \end{macrocode}
+%
% First we open a new group to keep the changed setting of
% |\protect| local and then we set the |@safe@actives| switch to
% true to make sure that any shorthand that appears in any of the
@@ -6363,7 +6466,7 @@ help from Bernd Raichle, for which I am grateful.
% encoding. There is a list of non-ASCII encodings. Unfortunately,
% \textsf{fontenc} deletes its package options, so we must guess
% which encodings has been loaded by traversing |\@filelist| to
-% search for \marg{enc}|enc.def|. If a non-ASCII has been loaded, we
+% search for \m{enc}|enc.def|. If a non-ASCII has been loaded, we
% define versions of |\TeX| and |\LaTeX| for them using
% |\ensureascii|. The default ASCII encoding is set, too (in reverse
% order): the ``main'' encoding (when the document begins), the last
@@ -6530,40 +6633,11 @@ help from Bernd Raichle, for which I am grateful.
\endgroup
\if@nobreak\ifvmode\nobreak\fi\fi}
\fi
-% \end{macrocode}
-%
-% Usually the |~| is active and expands to \verb*=\penalty\@M\ =.
-% When it is written to the \file{.aux} file it is written
-% expanded. To prevent that and to be able to use the character |~|
-% as a start character for a shorthand, it is redefined here as a
-% one character shorthand on system level. The system declaration
-% is in most cases redundant (when |~| is still a non-break space),
-% and in some cases is inconvenient (if |~| has been redefined);
-% however, for backward compatibility it is maintained (some
-% existing documents may rely on the \babel{} value).
-% \changes{babel~3.9i}{2014/02/06}{Moved from above, after
-% \cs{bbl@usehook} has been defined}
-% \begin{macrocode}
-\initiate@active@char{~}
-\declare@shorthand{system}{~}{\leavevmode\nobreak\ }
-\bbl@activate{~}
-% \end{macrocode}
-%
-% Finally, the default is to use English as the main language.
-% \changes{babel~3.6c}{1997/01/05}{When \file{hyphen.cfg} is not
-% loaded in the format \cs{l@english} might not be defined; assume
-% english is language 0}
-% \changes{babel~3.9a}{2012-05-17}{Languages are best assigned with
-% \cs{chardef}, not \cs{let}}
-% \begin{macrocode}
-\ifx\l@english\@undefined
- \chardef\l@english\z@
-\fi
-\main@language{english}
%</core>
-% \end{macrocode}
-% \end{macro}
+% \end{macrocode}%
+% \end{macro}
%
+% \section{Internationalizing \LaTeX{} 2.09}
%
% Now that we're sure that the code is seen by \LaTeX\ only, we
% have to find out what the main (primary) document style is
@@ -6572,9 +6646,6 @@ help from Bernd Raichle, for which I am grateful.
% this part of the code can optionally be included in
% \file{babel.def} by specifying the \texttt{docstrip} option
% \texttt{names}.
-% \begin{macrocode}
-%<*names>
-% \end{macrocode}
%
% The standard styles can be distinguished by checking whether some
% macros are defined. In table~\ref{styles} an overview is given of
@@ -6613,6 +6684,7 @@ help from Bernd Raichle, for which I am grateful.
% value~`0'.
% \changes{babel~3.0d}{1991/10/29}{Removed use of \cs{@ifundefined}}
% \begin{macrocode}
+%<*names>
\ifx\@undefined\doc@style
\def\doc@style{0}%
% \end{macrocode}
@@ -6636,8 +6708,6 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.1}{1991/11/05}{Removed definition of
% \cs{if@restonecol}}
%
-% \subsubsection{Redefinition of macros}
-%
% Now here comes the real work: we start to redefine things and
% replace hard-wired texts by macros. These redefinitions should be
% carried out conditionally, in case it has already been done.
@@ -6892,7 +6962,7 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.6o}{1999/04/07}{Moved the rest of the font encoding
% related definitions to their original place}
%
-% \subsection{Multiple languages}
+% \section{Multiple languages}
%
% Plain \TeX\ version~3.0 provides the primitive |\language| that
% is used to store the current language. When used with a pre-3.0
@@ -6977,6 +7047,8 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
%
+% \subsection{Selecting the language}
+%
% \begin{macro}{\selectlanguage}
% The macro |\selectlanguage| checks whether the language is
% already defined before it performs its actual task, which is to
@@ -7525,10 +7597,29 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
%
-% As an alternative for |\ProvidesFile| we define
-% |\ProvidesLanguage| here to be used in the language definition
-% files. Depending on the format, ie, on if the former is defined,
-% we use a similar definition or not.
+% \begin{macro}{\ProvidesLanguage}
+% \changes{babel~3.7a}{1997/03/18}{Added macro to prevent problems
+% with unexpected \cs{ProvidesFile} in plain formats because of
+% \babel.}
+% The identification code for each file is something that was
+% introduced in \LaTeXe. When the command |\ProvidesFile| does not
+% exist, a dummy definition is provided temporarily. For use in the
+% language definition file the command |\ProvidesLanguage| is
+% defined by \babel.
+%
+% Depending on the format, ie, on if the former is defined, we use
+% a similar definition or not.
+% \changes{babel~3.4e}{1994/06/24}{Redid the identification code,
+% provided dummy definition of \cs{ProvidesFile} for plain \TeX}
+% \changes{babel~3.5f}{1995/07/26}{Store version in
+% \cs{fileversion}} \changes{babel~3.5f}{1995/12/18}{Need to
+% temporarily change the definition of \cs{ProvidesFile} for
+% December 1995 release} \changes{babel~3.5g}{1996/07/09}{Save a
+% few csnames; use \cs{bbl@tempa} instead of \cs{\@ProvidesFile}
+% and store message in \cs{toks8}}
+% \changes{babel~3.9a}{2012/12/09}{Save info about the babel
+% version in the format (switch.def) so that it can be checked
+% later if necessary}
% \begin{macrocode}
\ifx\ProvidesFile\@undefined
\def\ProvidesLanguage#1[#2 #3 #4]{%
@@ -7547,6 +7638,7 @@ help from Bernd Raichle, for which I am grateful.
\endgroup}
\fi
% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\LdfInit}
% \changes{babel~3.6a}{1996/10/16}{Macro added}
@@ -7586,6 +7678,8 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
%
+% \subsection{Errors}
+%
% \begin{macro}{\@nolanerr}
% \changes{babel~3.4e}{1994/06/25}{Use \cs{PackageError} in \LaTeXe\
% mode}
@@ -7671,6 +7765,8 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
+% \section{Loading hyphenation patterns}
+%
% The following code is meant to be read by ini\TeX\ because it
% should instruct \TeX\ to read hyphenation patterns. To this end the
% \texttt{docstrip} option \texttt{patterns} can be used to include
@@ -7848,7 +7944,7 @@ help from Bernd Raichle, for which I am grateful.
% as part of the language name}
% \changes{babel~3.9a}{2012/12/10}{Removed \cs{selectfont} (I presume
% it was intended to catch wrong encoding codes, but I don't think
-% this is necessary and as a side effect it might preload fonts)}
+% this is necessary and as a side effect it might preload fonts)}
%
% For some hyphenation patterns it is needed to load them with a
% specific font encoding selected. This can be specified in the
@@ -8315,15 +8411,22 @@ help from Bernd Raichle, for which I am grateful.
\@endofldf}
% \end{macrocode}
%
+% \subsection{General tools}
+%
% A number of \LaTeX\ macro's that are needed later on.
% \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}}
+% \changes{babel~3.9k}{2014/03/22}{Added \cs{@nnil}}
+% \changes{babel~3.9k}{2014/03/22}{Added \cs{@gobbletwo}}
+% \changes{babel~3.9k}{2014/03/22}{Added \cs{protected@edef}}
% \begin{macrocode}
\long\def\@firstofone#1{#1}
\long\def\@firstoftwo#1#2{#1}
\long\def\@secondoftwo#1#2{#2}
+\def\@nnil{\@nil}
+\def\@gobbletwo#1#2{}
\def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}}
\def\@star@or@long#1{%
\@ifstar
@@ -8333,6 +8436,7 @@ help from Bernd Raichle, for which I am grateful.
\def\@car#1#2\@nil{#1}
\def\@cdr#1#2\@nil{#2}
\let\@typeset@protect\relax
+\let\protected@edef\edef
\long\def\@gobble#1{}
\edef\@backslashchar{\expandafter\@gobble\string\\}
\def\strip@prefix#1>{}
@@ -8372,10 +8476,9 @@ help from Bernd Raichle, for which I am grateful.
\def\begindocument{%
\@begindocumenthook
\global\let\@begindocumenthook\@undefined
- \def\do##1{\global\let ##1\@undefined}%
+ \def\do##1{\global\let##1\@undefined}%
\@preamblecmds
- \global\let\do\noexpand
- }
+ \global\let\do\noexpand}
% \end{macrocode}
%
% \changes{bbplain-1.0j}{1997/01/07}{\cs{@begindocumenthook} might
@@ -8443,7 +8546,16 @@ help from Bernd Raichle, for which I am grateful.
\advance\@tempcntb \@ne}%
\let\@hash@##%
\l@ngrel@x\expandafter\def\expandafter#1\reserved@a}
-\let\providecommand\newcommand
+\def\providecommand{\@star@or@long\provide@command}
+\def\provide@command#1{%
+ \begingroup
+ \escapechar\m@ne\xdef\@gtempa{{\string#1}}%
+ \endgroup
+ \expandafter\@ifundefined\@gtempa
+ {\def\reserved@a{\new@command#1}}%
+ {\let\reserved@a\relax
+ \def\reserved@a{\new@command\reserved@a}}%
+ \reserved@a}%
% \end{macrocode}
%
% \begin{macrocode}
@@ -8573,6 +8685,9 @@ help from Bernd Raichle, for which I am grateful.
\long\def\@iwhilenum#1{\ifnum #1\expandafter\@iwhilenum
\else\expandafter\@gobble\fi{#1}}
% \end{macrocode}
+%
+% \subsection{Encoding related macros}
+%
% Code from \file{ltoutenc.dtx}, adapted for use in the plain \TeX\
% environment.
% \begin{macrocode}
@@ -8748,6 +8863,39 @@ help from Bernd Raichle, for which I am grateful.
\ifx\scriptsize\@undefined
\let\scriptsize\sevenrm
\fi
+% \end{macrocode}
+%
+% \subsection{Babel options}
+%
+% \changes{babel~3.9k}{2014/03/22}{Moved code from babel.def, and add
+% some new tools (not yet documented)}
+%
+% The file |babel.def| expects some definitions made in the \LaTeX{}
+% style file. So we must provide them at least some predefined values as
+% well some tools to set them (even if not all options are
+% available). There in no package options, and therefore and alternative
+% mechanism is provided. For the moment, only |\babeloptionstrings| and
+% |\babeloptionmath| are provided, which can be defined before loading
+% \babel. |\BabelModifiers| can be set too (but not sure it works).
+%
+% \begin{macrocode}
+\let\bbl@opt@shorthands\@nnil
+\def\bbl@ifshorthand#1#2#3{#2}%
+\ifx\babeloptionstrings\@undefined
+ \let\bbl@opt@strings\@nnil
+\else
+ \let\bbl@opt@strings\babeloptionstrings
+\fi
+\def\bbl@tempa{normal}
+\ifx\babeloptionmath\bbl@tempa
+ \def\bbl@mathnormal{\noexpand\textormath}
+\fi
+\def\BabelStringsDefault{generic}
+\ifx\BabelModifiers\@undefined\let\BabelModifiers\relax\fi
+\let\bbl@afterlang\relax
+\let\bbl@language@opts\@empty
+\ifx\@uclclist\@undefined\let\@uclclist\@empty\fi
+\def\AfterBabelLanguage#1#2{}
%</plain>
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/babel/babel.ins b/Master/texmf-dist/source/latex/babel/babel.ins
index 539ffba53e9..7da03fc5783 100644
--- a/Master/texmf-dist/source/latex/babel/babel.ins
+++ b/Master/texmf-dist/source/latex/babel/babel.ins
@@ -3,7 +3,7 @@
%% driver files from the doc files in this package when run through
%% LaTeX or TeX.
%%
-%% Copyright 2012-2013 Javier Bezos and Johannes L. Braams.
+%% Copyright 2012-2014 Javier Bezos and Johannes L. Braams.
%% Copyright 1989-2008 Johannes L. Braams and any individual authors
%% listed elsewhere in this file. All rights reserved.
%%
@@ -32,7 +32,7 @@
%%
%% --------------- start of docstrip commands ------------------
%%
-%% Copyright 2012-2013 Javier Bezos and Johannes L. Braams.
+%% Copyright 2012-2014 Javier Bezos and Johannes L. Braams.
%% Copyright 2005-2008 Johannes L. Braams
%%
%% This file is part of the `babel' system.
@@ -42,7 +42,7 @@
%%
%% You are not allowed to modify its contents.
%%
-\def\filedate{2013/10/10}
+\def\filedate{2014/03/24}
\def\batchfile{babel.ins}
\input docstrip.tex
@@ -66,6 +66,12 @@
% Two further pseudo-guards define "block" variables: <<*name>> and
% <</name>> delimite the lines to be retrived with <@name@>. Note
% the verbatim guard is overriden, which it's not used here.
+% It's done in two passes: 1) with saving true, blocks are always
+% read and saved; 2) with saving false, blocks are always ignored,
+% but replacing <@name@>.
+% While <@name@> can be used freely outside <<>>, it is only
+% allowed inside <<>> if previouly defined. Deeper nesting is
+% not allowed.
\def\replaceVar#1<@#2{%
#1%
@@ -87,6 +93,7 @@
\fi}
\newif\ifcollect
+\newif\ifsaving
\def\verbOption<#1#2>>#3{%
\ifx#1*%
@@ -95,21 +102,32 @@
\gdef\varCollect##1{}%
\else\ifx#1/%
\global\collectfalse
- \global\expandafter\let\csname #2Var\endcsname\varCollect
+ \ifsaving
+ \expandafter\ifx\csname #2Var\endcsname\relax
+ \global\expandafter\let\csname #2Var\endcsname\varCollect
+ \else
+ \toks@\expandafter\expandafter\expandafter{%
+ \csname #2Var\expandafter\endcsname\expandafter^^J%
+ \varCollect}%
+ \expandafter\xdef\csname #2Var\endcsname{\the\toks@}%
+ \fi
+ \fi
\else
\varOptionI#1#2>%
\fi\fi}
\def\varOptionI#1=#2>{%
\maybeMsg{<<#1=#2>>}%
- \expandafter\gdef\csname #1Var\endcsname{#2}}
+ \ifsaving
+ \expandafter\gdef\csname #1Var\endcsname{#2}%
+ \fi}
% Preambles
\declarepreamble\mainpreamble
This is a generated file.
-Copyright 2012-2013 Javier Bezos and Johannes L. Braams.
+Copyright 2012-2014 Javier Bezos and Johannes L. Braams.
Copyright 1989-2008 Johannes L. Braams and any individual authors
listed elsewhere in this file. All rights reserved.
@@ -146,7 +164,7 @@ extension .ins) which are part of the distribution.
This file was generated from file(s) of the Babel system.
---------------------------------------------------------
-Copyright 2012-2013 Javier Bezos and Johannes L. Braams.
+Copyright 2012-2014 Javier Bezos and Johannes L. Braams.
Copyright (C) 2008 Johannes Braams. All rights reserved.
To produce the documentation in the way you like you are allowed
@@ -158,7 +176,7 @@ to change this driver file.
This file was generated from file(s) of the Babel system.
---------------------------------------------------------
-Copyright 2012-2013 Javier Bezos and Johannes L. Braams.
+Copyright 2012-2014 Javier Bezos and Johannes L. Braams.
Copyright (C) 2008 Johannes Braams. All rights reserved.
This file is a style file for the MakeIndex program
@@ -171,12 +189,19 @@ This file is a style file for the MakeIndex program
\keepsilent
\askonceonly
-\usepreamble\mainpreamble
\usedir{tex/generic/babel}
\askforoverwritefalse
-\tracingmacros2
+\usepreamble\mainpreamble
+
+% Dummy, it just read "modules" to be used when generating
+% the actual file. There must be a better way.
+\savingtrue
+\generate{\usepreamble\empty
+ \usepostamble\empty
+ \file{babel.aux}{\from{babel.dtx}{dummy}}}
+\savingfalse
\generate{\file{babel.sty}{\from{babel.dtx}{package}}
\file{babel.def}{\from{babel.dtx}{core}}
@@ -184,20 +209,26 @@ This file is a style file for the MakeIndex program
\file{hyphen.cfg}{\from{babel.dtx}{patterns}}
\file{nil.ldf}{\from{babel.dtx}{nil}}
}
+
% Support for plain users
\generate{\file{plain.def}{\from{babel.dtx}{plain}}
\file{bplain.tex}{\from{babel.dtx}{bplain}}
\file{blplain.tex}{\from{babel.dtx}{blplain}}
}
+
% Support for Unicode-based engines
+\savingtrue
+\generate{\usepreamble\empty
+ \usepostamble\empty
+ \file{babel.aux}{\from{bbunicode.dtx}{dummy}}}
+\savingfalse
+
\generate{\file{xebabel.def}{\from{bbunicode.dtx}{xetex}}
\file{luababel.def}{\from{bbunicode.dtx}{luatex}}
}
% compatibility files
-\usepreamble\mainpreamble
-
\def\compatfile#1{\file{#1.sty}{\from{bbcompat.dtx}{#1}}}
\generate{%
diff --git a/Master/texmf-dist/source/latex/babel/bbunicode.dtx b/Master/texmf-dist/source/latex/babel/bbunicode.dtx
index 5df721e33f2..ce94a0cea59 100644
--- a/Master/texmf-dist/source/latex/babel/bbunicode.dtx
+++ b/Master/texmf-dist/source/latex/babel/bbunicode.dtx
@@ -31,7 +31,7 @@
% \iffalse
%<*dtx>
\ProvidesFile{bbunicode.dtx}
- [2014/03/10 v1.0c Babel hooks for Unicode engines]
+ [2014/03/21 v1.0d Babel hooks for Unicode engines]
%</dtx>
%
%% File `bbunicode.dtx'
@@ -182,9 +182,11 @@
% P\'{e}gouri\'{e}-Gonnard. \'{E}lie also improved the code below.
% \changes{bbunicode~1.0b}{2013/04/22}{luatex-hyphen is loaded
% with require. Changes supplied by \'{E}lie Roux.}
-% \changes{bbunicode~1.0c}{2013/04/22}{Defined hook for
+% \changes{bbunicode~1.0c}{2014/03/10}{Defined hook for
% `initiateactive', to fetch the next token and continue only if
% letter or other}
+% \changes{bbunicode~1.0d}{2014/03/21}{Removed the `misfeature' for
+% `initiateactive'}
%
% \begin{macrocode}
%<*luatex>
@@ -239,22 +241,6 @@
'\luatexluaescapestring{\string#2}')
}%
\fi}
-\AddBabelHook{luatex}{initiateactive}{%
- \bbl@csarg\edef{doactive#2}{%
- \futurelet\noexpand\let@token
- \expandafter\noexpand\csname luabbl@doactive#2\endcsname}%
- \def\bbl@tempa##1##2{%
- \@namedef{luabbl@doactive#2}{%
- \ifcat\noexpand\let@token a%
- \expandafter##1%
- \else\ifcat\noexpand\let@token.%
- \expandafter\expandafter\expandafter##1%
- \else
- \expandafter\expandafter\expandafter##2%
- \fi\fi}}%
- \@expandtwoargs\bbl@tempa
- {\expandafter\noexpand\csname user@active#2\endcsname}%
- {\expandafter\noexpand\csname normal@char#2\endcsname}}
\AddBabelHook{luatex}{everylanguage}{%
\directlua{
processnow = (tex.language == 0) or