% \iffalse % This document requires lualatex %% %% Copyright (C) 2012-2024 Javier Bezos and Johannes L. Braams. %% Copyright (C) 1989-2012 Johannes L. Braams and %% any individual authors listed elsewhere in this file. %% All rights reserved. %% %% %% This file is part of the Babel system. %% -------------------------------------- %% %% It may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.3 or later is part of all distributions of LaTeX %% version 2003/12/01 or later. %% %% This work has the LPPL maintenance status "maintained". %% %% The Current Maintainer of this work is Javier Bezos. %% %% The list of derived (unpacked) files belonging to the distribution %% and covered by LPPL is defined by the unpacking scripts (with %% extension |.ins|) which are part of the distribution. %% % \fi % % \CheckSum{5011} % % \iffalse %<*filedriver> \DocumentMetadata{ % testphase = {sec,toc,text}, lang = en-001, } \ProvidesFile{babel.dtx}% [2024/12/21 v24.15 The multilingual framework for pdfLaTeX, LuaLaTeX and XeLaTeX] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} \setmainfont[ Scale=.88, BoldFont = NotoSerif-Bold.ttf, ItalicFont = NotoSerif-Italic.ttf, BoldItalicFont = NotoSerif-BoldItalic.ttf] {NotoSerif-Regular.ttf} \setsansfont[ Scale=.88, BoldFont = NotoSans-Bold.ttf, ItalicFont = NotoSans-Italic.ttf, BoldItalicFont = NotoSans-BoldItalic.ttf] {NotoSans-Regular.ttf} \setmonofont[Scale=.86, FakeStretch=.97]{DejaVu Sans Mono} \raggedright \setlength{\parindent}{.8em} \frenchspacing \addtolength{\oddsidemargin}{-2em} \addtolength{\textwidth}{25.5pt} \addtolength{\textheight}{3.5cm} \addtolength{\topmargin}{-2cm} \font\manual=logo10 % font used for the METAFONT logo, etc. \newcommand*\MF{{\manual META}\-{\manual FONT}} \newcommand*\babel{\textsf{babel}} \newcommand*\Babel{\textsf{Babel}} \newcommand*\xetex{\textsf{xetex}} \newcommand*\pdftex{\textsf{pdftex}} \newcommand*\luatex{\textsf{luatex}} \newcommand\largetex{T\kern -.1517em\lower .45ex\hbox {E}\kern -.09emX} \newcommand*\nb[1]{} \newcommand*\m[1]{\mbox{$\langle$\normalfont\itshape#1\/$\rangle$}} \newcommand*\langlist{% \meta{language}\texttt{,}\meta{language}\texttt{,}...} \newcommand*\langvar{\m{language}} \newcommand*\Lopt[1]{\textsf{#1}} \newcommand*\Lenv[1]{\texttt{#1}} \newcommand*\menv[1]{\char`\{#1\char`\}} \newcommand*\Eenv[1]{% \quad...\quad \texttt{\color{thered}\string\end\menv{#1}}} \newcommand*\file[1]{\texttt{#1}} \newcommand*\cls[1]{\texttt{#1}} \newcommand*\pkg[1]{\texttt{#1}} \setlength{\leftmargini}{1.5em} \usepackage{framed} \usepackage{multicol} \usepackage{color,colortbl} \usepackage[linkcolor=blue,urlcolor=blue,colorlinks=true]{hyperref} \hypersetup{% pdfsubject={LaTeX Multilingual documents and localization for pdfTeX, LuaTeX and XeTeX.}, pdfauthor={Javier Bezos, Johannes Braams}, pdftitle={Babel}, pdfkeywords={TeX, LaTeX, pdfTeX, LuaTeX, XeTeX, internationalization, localization}} \ExplSyntaxOn \normalmarginpar \newcommand\New[1]{% \regex_extract_once:nnN{(\d\d?)\.(\d\d?)}{#1}\bbltempa \seq_pop_right:NN\bbltempa\bbltempb \seq_pop_right:NN\bbltempa\bbltempa \leavevmode%\marginpar {\scriptsize % \enspace \colorbox[rgb]{.92, .86, .73}% {%New~ #1% \quark_if_no_value:NTF\bbltempb{}% {~ \ifnum\bbltempa>2 \ifnum\bbltempb>34 \href{https://latex3.github.io/babel/news/% whats-new-in-babel-\bbltempa.\bbltempb.html}% {\raisebox{.15ex}{$\oplus$}}% \fi\fi \ifnum\bbltempa>23 \href{https://latex3.github.io/babel/news/% whats-new-in-babel-\bbltempa.\bbltempb.html}% {\raisebox{.15ex}{$\oplus$}}% \fi}}}\enspace\ignorespaces} \ExplSyntaxOff \definecolor{thered}{rgb}{0.65,0.04,0.07} \definecolor{thegrey}{gray}{0.8} \definecolor{thegreyed}{gray}{0.6} \definecolor{shadecolor}{rgb}{1,1,0.97} \definecolor{messages}{rgb}{.66,.13,.27} \makeatletter \def\@seccntformat#1{% \llap{\makebox[1.7cm][l]{\csname the#1\endcsname.}}% \hspace{-.7cm}} \def\@begintheorem#1#2{% \list{}{}% \global\advance\@listdepth\m@ne \item[{\sffamily\bfseries\color{messages}\hspace*{1.4em}%\hspace*{2.8em}% \MakeUppercase{#1}}]}% \makeatother \newtheorem{warning}{Warning} \newtheorem{note}{Note} \newtheorem{example}{Example} \newtheorem{troubleshooting}{Troubleshooting} \let\bblxv\verbatim \let\bblexv\endverbatim \newcommand\setengine{\def\engine} \let\engine\relax \begingroup \catcode`\<=13 \catcode`\>=13 \catcode`\|=13 \AtBeginDocument{% \gdef|{\verb|\def<##1>{$\langle${\rmfamily\itshape##1}$\rangle$}}} \endgroup \def\verbatim{% \fboxsep=.8em \begin{snugshade*}% \ifx\engine\relax\else \vskip-.75\baselineskip \leavevmode\llap{% \fboxsep=2pt\fbox{\scriptsize\textsc{\engine}}\hskip2.8em}% \vskip-1.6\baselineskip \vskip0pt \global\let\engine\relax \fi \bblxv\vskip0pt } \def\endverbatim{% \bblexv\vskip-7.5ex \end{snugshade*}} \catcode`\_=\active \def_{\bgroup\let_\egroup\leavevmode\color{thered}} \def\MacroFont{\fontencoding \encodingdefault \fontfamily\ttdefault \fontseries\mddefault \fontshape\updefault \small \catcode`\_=\active} \definecolor{shadecolor}{rgb}{0.96,0.96,0.93} % \makeatletter \def\Describe#1#2{% \@startsection{subsubsection}{100}{\z@}% {2.5ex\@plus .7ex \@minus .2ex}% {1.5ex \@plus .2ex}% {\hspace{-2cm}\color{thegreyed}\normalsize\ttfamily}*% {\underline{\strut{\color{thered}\string#1}\color{black}#2}}} \def\DescribeOther{\addvspace{-1.5ex}\Describe} \AtBeginDocument{\def\DescribeMacro#1{{\ttfamily\color{thered}\string#1}}} \def\macro#1{% WIP \if@noskipsec\leavevmode\vskip-1.2\baselineskip\vskip0pt\fi \@startsection{paragraph}{101}{\z@}% {3.25ex \@plus1ex \@minus.2ex}% {-1em}% {\sffamily\bfseries\color{thered}}*{\hspace*{-1em}\string#1}} \let\environment\macro \def\optstar{% \kern1pt\relax \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}% \kern1pt} \def\trouble#1{\addcontentsline{tsh}{trouble}{#1}} \def\toclevel@trouble{0} \def\listoftroubles{\section*{Troubleshoooting}\@starttoc{tsh}} \let\l@trouble\l@figure \let\saved@check@percent\check@percent \let\check@percent\relax % Changes to doc.sty (add <<...>> syntax) \def\Module#1{% \mod@math@codes$\langle${\color{thered}$\mathsf{#1}$}$\rangle$} \begingroup \catcode`\<\active \catcode`\>\active \gdef\check@plus@etc{% \let\bbl@next\pm@module \ifx*\next \let\bbl@next\star@module \else\ifx/\next \let\bbl@next\slash@module \else\ifx<\next \let\bbl@next\var@module \fi\fi\fi \bbl@next} \gdef\var@module#1#2#3>>{% $\langle$\pm@module#2#3>$\rangle$% \ifx*#2\ $\equiv$\fi} \endgroup \def\toc@usehook#1#2#3{% \UseHookWithArguments{contentsline/#1}{4}% {\toclevel@section}% {#2}{#3}{\@contentsline@destination}} \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 \toc@usehook{text/before}{#1}{#2}% \csname contentsline@text@1@format\endcsname{#1} \toc@usehook{text/after}{#1}{#2}% \nobreak\hfil\nobreak \hb@xt@\@pnumwidth {\hss \toc@usehook{page/before}{#1}{#2}% #2% \toc@usehook{page/after}{#1}{#2}% \kern-\p@\kern\p@}% \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} \def\@pnumwidth{3em} \makeatother \begin{document} \title{Babel, a multilingual package for use with \LaTeX's standard document classes.} \author{Johannes Braams\\ Javier Bezos} \date{Typeset \today} \begin{titlepage} \begin{minipage}[t][0pt]{30cm} \vspace{-3cm}\hspace{-6cm} \sffamily \begin{tabular}{p{8cm}p{15cm}} \cellcolor[rgb]{.86,.73,.67} &\cellcolor[rgb]{.95,.95,.95} \vspace{3.6cm}% \color[rgb]{.55,.4,.35} \leftskip5mm \sffamily\fontsize{72}{72}\selectfont Babel \vspace{1.8cm} \\ \cellcolor[rgb]{.95,.95,.95} \vspace{2cm}\hspace{1.5cm} \begin{minipage}{5cm} \Huge \ifx\babelcode\undefined User guide \else Code \fi \Large \vspace{1.2cm} Version \csname @gobble\expandafter\endcsname\fileversion\newline \filedate \LARGE \vspace{1.2cm} Javier Bezos\\[-.5ex] {\large Current maintainer} \vspace{.3cm} Johannes L. Braams\\[-.5ex] {\large Original author} \end{minipage} &\cellcolor[rgb]{.92, .86, .73} \vspace{2cm} \leftskip5mm \begin{minipage}{10cm} \fontsize{35}{45}\selectfont \setlength\parskip{3mm}\raggedright Localization and internationalization\\[1cm] Unicode\\ \largetex\\ Lua\largetex\\ pdf\largetex\\ Xe\largetex \vspace{20cm} \end{minipage} \end{tabular} \end{minipage} \end{titlepage} \tableofcontents \ifx\babelcode\undefined \listoftroubles \fi \clearpage \ifx\babelcode\undefined \begin{description} \item[\sffamily\color{messages}What is this document about?] This user guide focuses on internationalization and localization with \LaTeX{} and \pdftex, \luatex{} and \xetex{} with the \babel{} package. There are also some notes on its use with e-Plain and pdf-Plain \TeX. \item[\sffamily\color{messages}I only need learn the most basic features.] The first subsections (1.1-1.6) describe the ways of loading a language, which is usually all you need. \item[\sffamily\color{messages}I don’t like manuals. I prefer sample files.] This manual contains lots of examples and tips, but in GitHub there are many \href{https://github.com/latex3/babel/tree/master/samples}{sample files}. \item[\sffamily\color{messages}What if I’m interested only in the latest changes?] Changes and new features with relation to version 3.8 are highlighted with \New{X.XX}\hspace{-.5em} (\raisebox{.15ex}{$\oplus$} is a link to the \babel{} site), and there are some notes for the latest versions in \href{https://latex3.github.io/babel/}{the \babel{} site}. The most recent features can still be unstable. Remember version 24.1 follows 3.99, because of a new numbering scheme. \item[\sffamily\color{messages}Can I help?] Sure! You can follow the development of \babel{} in \href{https://github.com/latex3/babel}{GitHub} and make suggestions, including requirements for some language or script. Feel free to fork it and make pull requests. If you are the author of a package, send me a few test files which I'll add to mine, so that possible issues can be caught in the development phase. \item[\sffamily\color{messages}It doesn't work for me!] You can ask for help in some forums like \textsf{tex.stackexchange}, but if you have found a bug, I strongly beg you to report it in \href{https://github.com/latex3/babel/issues}{GitHub}, which is much better than just complaining on an e-mail list or a web forum. Remember \textit{warnings are not errors} by themselves, they just warn about possible problems or incompatibilities. Hyphenation rules are maintained separately \href{https://github.com/hyphenation/tex-hyphen}{here}. \item[\sffamily\color{messages}How can I contribute a new language?] See section \ref{contribute} for contributing a language. \item[\sffamily\color{messages}Where is the code?] Run |lualatex --jobname=babel-code \let\babelcode\relax\input{babel.dtx}|. \end{description} \section{The basic user interface}\label{U-I} There are two ways to load a language with babel, namely, the old good ‘classical’ one, based on mostly self-contained declarations in a file with |ldf| extension, and the ‘modern’ one, based on a brand new mechanism based on descriptive |ini| files. ‘Classical’ doesn’t mean outdated or obsolete. In fact, this is the recommended method in most languages where an |ldf| file exists. Below is a list of the supported languages. See also \href{https://latex3.github.io/% babel/guides/which-method-for-which-language.html}{Which method for which language} in the \babel{} site. Basically, what you need is typically: \begin{itemize} \bfseries \item Tell \babel{} which language or languages are required. \item With non-Latin scripts and Unicode engines (\luatex\ is the preferred one), select a suitable font (sec.~\ref{fonts}) \item In multilingual documents, switch the language in the text body (sec.~\ref{selectors}). \end{itemize} You can find basic info and minimal \luatex{} example files for about 300 locales in the \href{https://latex3.github.io/babel/guides/index-locale.html}{GitHub repository}. \subsection{Monolingual documents: the ‘classical’ way} In most cases, a single language is required, and then all you need in \LaTeX{} is to load the package using its standard mechanism for this purpose, namely, passing that language as an optional argument. In addition, you may want to set the font and input encodings. Another approach is making the language a global option in order to let other packages detect and use it. This is the standard way in \LaTeX{} for an option – in this case a language – to be recognized by several packages (in other words, \babel{} doesn’t set the languages, it just recognizes the options passed to the class or the package). Many languages are compatible with \textsf{luatex} and \textsf{xetex}, but a few only work with \pdftex. When these engines are used, the Latin script is covered by default in current \LaTeX{} (provided the document encoding is UTF-8). Other scripts require loading \textsf{fontspec}, although \babel{} provides a higher level interface (see |\babelfont| below). \begin{example} Here is a simple full example for “traditional” \TeX{} engines (see below for \luatex{} and \xetex{}). The package |fontenc| does not belong to \babel, but it is included in the example because typically you will need it. It assumes UTF-8, the default encoding: \setengine{pdftex} \begin{verbatim} \documentclass{article} \usepackage[T1]{fontenc} _\usepackage[french]{babel}_ \begin{document} Plus ça change, plus c'est la même chose! \end{document} \end{verbatim} Now consider something like: \begin{verbatim} _\documentclass[french]{article}_ \usepackage{babel} \usepackage{varioref} \end{verbatim} With this setting, the package \texttt{varioref} will also see the option |french| and will be able to use it. \end{example} \begin{example} Now a simple monolingual document in Russian (text from the Wikipedia) with \luatex{} or \xetex{}. Note neither \textsf{fontenc} nor \textsf{inputenc} is necessary, and a so-called Unicode font must be loaded (in this example with the help of |\babelfont|, described below). \setengine{luatex/xetex} \begin{verbatim} _\documentclass[russian]{article}_ \usepackage{babel} _\babelfont{rm}{DejaVu Serif}_ \begin{document} Россия, находящаяся на пересечении множества культур, а также с учётом многонационального характера её населения, — отличается высокой степенью этнокультурного многообразия и способностью к межкультурному диалогу. \end{document} \end{verbatim} \end{example} \begin{note} Because of the way \babel{} has evolved, ``language'' can refer to (1) 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. Please, read the documentation for specific languages for further info. \end{note} \begin{note} \Babel{} does not make any readjustments by default in font size, vertical positioning or line height. This is on purpose because the optimal solution depends on the document layout and the font, and very likely the most appropriate one is a combination of these settings. \end{note} \begin{note} Although it has been customary to recommend placing |\title|, |\author| and other elements printed by |\maketitle| after |\begin{document}|, mainly because of shorthands, it is advisable to keep them in the preamble. Currently there is no real need to use shorthands in those macros. \end{note} \begin{note} With \textsf{hyperref} you may want to set the PDF document language with something like: \begin{verbatim} \usepackage[_pdflang=es-MX_]{hyperref} \end{verbatim} This is not currently done by \babel{} and you must set it by hand. The PDF document language can also be set with |\DocumentMetadata|, before |\documentclass|; for example: \begin{verbatim} \DocumentMetadata{_lang=es-MX_} \end{verbatim} \end{note} \begin{warning} In the preamble, \textit{no} language has been selected, except hyphenation patterns and the name assigned to |\localename| (and |\languagename|) (in particular, shorthands, captions and date are not activated). If you need to define boxes and the like in the preamble, you might want to use some of the language selectors described below. \end{warning} \begin{troubleshooting} \trouble{Package inputenc Error: Invalid UTF-8 byte ...} \textit{Package inputenc Error: Invalid UTF-8 byte ...} A common source of trouble is a wrong setting of the input encoding. Make sure you set the encoding actually used by your editor, or even better, make sure the encoding in your editor is set to UTF-8. \end{troubleshooting} \begin{troubleshooting} Another typical error when using \babel{} is the following: \trouble{Unknown language 'LANG'} \begin{verbatim} ! Package babel Error: Unknown language 'LANG'. Either you have (babel) misspelled its name, it has not been installed, (babel) or you requested it in a previous run. Fix its name, (babel) install it or just rerun the file, respectively. In (babel) some cases, you may need to remove the aux file \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. \end{troubleshooting} \begin{troubleshooting} \textit{No hyphenation patterns were preloaded...} The following warning is about hyphenation patterns, which are not under the direct control of \babel: \trouble{No hyphenation patterns were preloaded for (babel) the language 'LANG' into the format} \begin{verbatim} Package babel Warning: No hyphenation patterns were preloaded for (babel) the language `LANG' into the format. (babel) Please, configure your TeX system to add them and (babel) rebuild the format. Now I will use the patterns (babel) preloaded for \language=0 instead on input line 57. \end{verbatim} The document will be typeset, but very likely the text will not be correctly hyphenated. Some languages in some system may be raising this warning wrongly (because they are not hyphenated) -- just ignore it. See the manual of your distribution (Mac\TeX, Mik\TeX, \TeX Live, etc.)\ for further info about how to configure it. \end{troubleshooting} \begin{troubleshooting} \textit{You are loading directly a language style.} Loading directly |sty| files in \LaTeX{} (i.e., |\usepackage{}|) was deprecated many years ago and you will get the error: \trouble{You are loading directly a language style} \begin{verbatim} ! Package babel Error: You are loading directly a language style. (babel) This syntax is deprecated and you must use (babel) \usepackage[language]{babel}. \end{verbatim} \end{troubleshooting} \begin{note} You will see an ‘info’ in the log file stating some data is being loaded from an |ini| file. It includes standardized names for language and script used by |\babelfont|, and the BCP 47 tag, required in some cases by |\Makecase|. \end{note} \subsection{Monolingual documents: the ‘modern’ way} When, for whatever reason, the ‘classical’ way with the |ldf| is not suitable for the needs of a document or a document system, you have to resort to a different mechanism, which is activated with the package option |provide=*| (in monolingual documents). \begin{example} Although Georgian has its own \texttt{ldf} file, here is how to declare this language in Unicode engines. Here, as in a previous example, we resort to |\babelfont| to set the font for this language (with the |Harfbuzz| renderer, just to show how to set it, because here the |Node| renderer should be fine). \setengine{luatex/xetex} \begin{verbatim} \documentclass{book} \usepackage[_georgian, provide=*_]{babel} _\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans}_ \begin{document} \tableofcontents \chapter{სამზარეულო და სუფრის ტრადიციები} ქართული ტრადიციული სამზარეულო ერთ-ერთი უმდიდრესია მთელ მსოფლიოში. \end{document} \end{verbatim} And with a global option: \begin{verbatim} \documentclass[_georgian_]{book} \usepackage[_provide=*_]{babel} \babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans} \end{verbatim} \end{example} \begin{note} This option actually loads the language with |\babelprovide| and the |import| option, described below. Instead of an asterisk, you may provide a list of options for |\babelprovide| enclosed in braces (|import| is included by default). \end{note} \begin{example} For a text in Chinese, you can write in the preamble: \setengine{luatex/xetex} \begin{verbatim} \usepackage[_chinese, provide=*_]{babel} _\babelfont{rm}{FandolSong}_ \end{verbatim} The skip between characters is 0 pt plus .1 pt, which can be modified with an option (explained below) in |provide|. For example: \setengine{luatex/xetex} \begin{verbatim} \usepackage[chinese, provide=_{ intraspace=0 .2 0 }_]{babel} \end{verbatim} \end{example} \subsection{Mostly monolingual documents: lazy loading} \label{mostlymono} \New{3.39} Very often, multilingual documents consist of a main language with small pieces of text in another languages (words, idioms, short sentences). Typically, all you need is to set the line breaking rules and, perhaps, the font. In such a case, there is no need to clutter the preamble (particularly the class and package options) because \babel{} does not require declaring these secondary languages explicitly — the basic settings are loaded on the fly when the language is first selected. This is particularly useful in documents with many languages, and also when there are short texts of this kind coming from an external source whose contents are not known beforehand (for example, titles in a bibliography). In this regard, it is worth remembering that |\babelfont| does \textit{not} load any font until required, so that it can be used just in case. \New{3.84} With \pdftex, when a language is loaded on the fly (internally it's loaded with |\babelprovide|) selectors now set the font encoding based on the list provided when loading |fontenc|. Not all scripts have an associated encoding, so this feature works only with Latin, Cyrillic, Greek, Arabic, Hebrew, Cherokee, Armenian, and Georgian, provided a suitable font is found. \begin{example} A trivial document with the default font in English and Spanish, and FreeSerif in Russian is: \setengine{luatex/xetex} \begin{verbatim} \documentclass[english]{article} \usepackage{babel} _\babelfont[russian]{rm}{FreeSerif}_ \begin{document} English. _\foreignlanguage{russian}{Русский}_. _\foreignlanguage{spanish}{Español}_. \end{document} \end{verbatim} If you need the ‘modern’ way to load the main language set as global option, just write: \begin{verbatim} \usepackage[provide=*]{babel} \end{verbatim} \end{example} \begin{note} Instead of its name, you may prefer to select the language with the corresponding BCP 47 tag. This alternative, however, must be activated explicitly, because a two- or three-letter word is a valid name for a language (e.g., |lu| can be the locale name with tag |khb| or the tag for |lubakatanga|). See section \ref{bcp47} for further details. \end{note} \subsection{Multilingual documents: the ‘classical’ way} In multilingual documents, just use a list of the required languages either as package or as class options. The last language is considered the main one, activated by default. Sometimes, the main language changes the document layout (e.g., |spanish| and |french|). To switch the language there are two basic macros, described below in detail: |\selectlanguage| is used for blocks of text, while |\foreignlanguage| is for chunks of text inside paragraphs. \begin{example} In \LaTeX, the preamble of the document: \begin{verbatim} \documentclass{article} \usepackage[dutch,english]{babel} \end{verbatim} would tell \LaTeX{} that the document would be written in two languages, Dutch and English, and that English would be the first language in use, and the main one. \end{example} \begin{example} A full bilingual document with \pdftex{} follows. The main language is |french|, which is activated when the document begins. It assumes UTF-8: \setengine{pdftex} \begin{verbatim} \documentclass{article} \usepackage[T1]{fontenc} _\usepackage[english,french]{babel}_ \begin{document} Plus ça change, plus c'est la même chose! _\selectlanguage{english}_ And an English paragraph, with a short text in _\foreignlanguage{french}{français}_. \end{document} \end{verbatim} \end{example} \begin{example} With \luatex{} and \xetex, the following bilingual, single script document in UTF-8 encoding just prints a couple of ‘captions’ and |\today| in Danish and Vietnamese. No additional packages are required, because the default font supports both languages. \setengine{luatex/xetex} \begin{verbatim} \documentclass{article} _\usepackage[vietnamese,danish]{babel}_ \begin{document} Danish: \prefacename, \alsoname, \today. \selectlanguage{vietnamese} Vietnamese: \prefacename, \alsoname, \today. \end{document} \end{verbatim} \end{example} \begin{note} Although strongly discouraged, languages can 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|, described below: \begin{verbatim} \documentclass[_italian_]{book} \usepackage[ngerman,_main=italian_]{babel} \end{verbatim} \end{note} \begin{note} Once a language is loaded, you can select it with the corresponding BCP 47 tag. See section \ref{bcp47} for further details. \end{note} \begin{note} Documents with several input encodings are not frequent, but sometimes are useful. You can set different encodings for different languages as the following example shows: \begin{verbatim} \addto\extrasfrench{\inputencoding{latin1}} \addto\extrasrussian{\inputencoding{koi8-r}} \end{verbatim} \end{note} \subsection{Multilingual documents: the ‘modern’ way} If lazy loading is not enough for your purposes, you can still tell which languages should be loaded as either class or package options. You can combine the ‘classical’ and the ‘modern’ ways with three options to set which method you want, which cover the most typical cases: \begin{itemize} \item |provide=*| is the option explained above for monolingual documents. If there are more languages, it applies only to the main language, while the rest will be loaded in the ‘classical’ way. \item |provide+=*| loads the main language in the ‘classical’ way, and the rest in the ‘modern’ one. \item |provide*=*| is the same for all languages, i.e., main and secondary ones are loaded in the ‘modern’ way. \end{itemize} More complex combinations can be handled with |\babelprovide|, explained below. \begin{example} Your document is written in Thai with large chunks in Dutch and German, and you want the |ldf| files in the latter because, for example, you need their shorthands. The font is Norasi, which covers the three languages: \setengine{luatex/xetex} \begin{verbatim} \usepackage[dutch,ngerman,thai,_provide=*_]{babel} \babelfont{rm}{Norasi} \end{verbatim} This will load |dutch| and |ngerman| in the classical |ldf| mode, but |thai| in the modern |ini| mode. Other options are: \begin{verbatim} \usepackage[dutch,ngerman,thai]{babel} \end{verbatim} which will use the classical mode for in languages (as decribed in the previous section, but note |thai.ldf| is not supported in Unicode engines), and: \begin{verbatim} \usepackage[dutch,german,thai,_provide*=*_]{babel} \end{verbatim} which will use the modern mode in all languages (note the correct name here is |german|. (The option |\usepackage||[dutch,ngerman,thai,provide+=*]||{babel}| doesn’t make much sense in this case.) \end{example} \subsection{Languages supported by \babel{} in the ‘classical’ mode} (To be updated.) In the following table most of the languages supported by \babel{} with an |ldf| file are listed, together with the names of the options which you can load \babel\ with for each language. Note this list is open and the current options may be different. It does not include |ini| files (see below). Except in a few cases (e.g., |ngerman|, |serbianc|, |acadian|) names are those of the Unicode CLDR (or based on them). Most of them work out of the box, but some may require extra fonts, encoding files, a preprocessor or even a complete framework (like \textsf{CJK} or \textsf{luatexja}). \begingroup \bigskip\hrule\nobreak \makeatletter \def\tag#1#2{\par \hspace{-2em}\textcolor{thered}{\texttt{#1}}#2\enspace} \def\subtag#1#2{\par \hspace{-1em}\texttt{#1}#2\enspace} \def\subtagalt#1#2{\par \hspace{-1em}\textcolor{thered}{\texttt{#1}}#2\enspace} \def\tagmin#1#2{\par \hspace{-2em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace} \def\subtagmin#1#2{\par \hspace{-1em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace} \def\note#1{\par{\footnotesize#1\par}} \small \bigskip \textit{This list is still under revision.}\\ Recommended names are set in \textcolor{thered}{red}.\\ Additional languages are set in \textcolor[gray]{.4}{gray}.\\ Discouraged and deprecated names are not included.\\ There are some notes in a few languages. \bigskip\hrule\nobreak \begin{multicols}{2} \leftskip2em\parindent0pt \tag{afrikaans}{} \tag{albanian}{} \tag{arabic}{} \note{Requires \textsf{arabi}.} \tag{azerbaijani}{} \tag{basque}{} \tag{belarusian}{} \tag{bosnian}{} \tag{breton}{} \tag{bulgarian}{} \tag{catalan}{} \tag{croatian}{} \tag{czech}{} \tag{danish}{} \tag{dutch}{} \tag{english}{} \subtagalt{american}{} \subtag{USenglish}{}{} \subtagalt{australian}{} \subtagalt{british}{} \subtag{UKenglish}{} \subtagalt{canadian}{} \subtagalt{newzealand}{} \tag{esperanto}{} \tag{estonian}{} \tagmin{ethiop}{} %%%%%% \tag{farsi}{} \note{Requires \textsf{arabi}.} \tag{finnish}{} \tag{french}{} \subtagalt{acadian}{} \tag{friulian}{} \tag{galician}{} \tag{georgian}{} \tag{german}{} \note{This block refers to the old ortography. For the modern one, use the names in the block \textsf{ngerman}.} \subtagalt{austrian}{} \subtagalt{swissgerman}{} \note{Swiss High German} \tag{greek}{} % \subtagalt{polutonicogreek}{} \subtagmin{ibycus}{} \subtagmin{bgreek}{} \tag{hebrew}{} \tag{hindi}{} \note{Requires \textsf{velthuis}.} \tag{hungarian}{} \subtag{magyar}{} \tag{icelandic}{} \tag{indonesian}{} \tag{interlingua}{} \tag{irish}{} \tag{italian}{} \tag{japanese}{} \tag{kurmanji}{} \tag{latin}{} % \subtagalt{classiclatin}{} % \subtagalt{medievallatin}{} % \subtagalt{ecclesiasticlatin}{} \tag{latvian}{} \tag{lithuanian}{} \tag{lowersorbian}{} \tag{macedonian}{} \tag{malay}{} \tag{mongolian}{} \tag{ngerman}{} \note{This block refers to the new ortography.} \subtagalt{naustrian}{} \subtagalt{nswissgerman}{} \note{Swiss High German} \tag{northernsami}{} \tag{norwegian}{} \subtag{norsk}{} \tag{nynorsk}{} \tag{occitan}{} \tag{piedmontese}{} \tagmin{pinyin}{} \tag{polish}{} \tag{portuguese}{} \subtagalt{brazilian}{} \tag{romanian}{} \tag{romansh}{} \tag{russian}{} \tag{scottishgaelic}{} \subtag{scottish}{} \tag{serbianc}{} \note{Cyrillic script} \subtagalt{serbian}{} \note{Latin script} \tag{slovak}{} \tag{slovene}{} \tag{slovenian}{} %%%%%% <- and ini \tag{spanglish}{} \tag{spanish}{} \tag{swedish}{} \tag{thai}{} \subtagmin{thaicjk}{} \tag{turkish}{} \tag{turkmen}{} \tag{ukrainian}{} \tag{uppersorbian}{} \tag{vietnamese}{} \tag{welsh}{} \end{multicols} \endgroup \hrule \bigskip % \begin{note} % There are also some deprecated names (a few has been even removed): % \textsf{frenchb} or \textsf{francais}, as well as \textsf{canadien} % (\textsf{french}), \textsf{germanb} (\textsf{german}), % \textsf{bahasa}, \textsf{indon} or \textsf{bahasai} % (\textsf{indonesian}), \textsf{lsorbian} (\textsf{lowersorbian}), % \textsf{bahasam} (\textsf{malay}), \textsf{portuges} % (\textsf{portuguese}), \textsf{brazil} (\textsf{brazilian}), % \textsf{russianb} (\textsf{russian}), \textsf{usorbian} % (\textsf{uppersorbian}), \textsf{vietnam} (\textsf{vietnamese}), % \textsf{samin} (\textsf{northernsami}), \textsf{ukraineb} % (\textsf{ukrainian}). Deprecated names come in many cases from the % times when they had to be shortened to 8 characters. % \end{note} \begin{example} An example of a language requiring a preprocessor and a separate package is \texttt{hindi}. If you have got the \textsf{velthuis/devnag} package, create a file with extension |.dn|: \begin{verbatim} \documentclass{article} \usepackage[hindi]{babel} \begin{document} {\dn devaanaa.m priya.h} \end{document} \end{verbatim} Then preprocess it with |devnag| \m{file}, which creates \m{file}|.tex|; you can then typeset the latter with \LaTeX. \end{example} \subsection{Languages supported by \babel{} in the ‘modern’ mode} Here is the list of the names currently supported with |ini| locale files, with |\babelprovide| (or |provide=|). With these languages, |\babelfont| loads (if not done before) the language and script names (even if the language is defined as a package option with an \textsf{ldf} file). These are also the names recognized by |\babelprovide| with a valueless |import|, which will load the |ini| file with the tag given in parenthesis. Following the current common practice (for example, the Unicode CLDR), all locales are organized in a flat structure. This eases their identification and customization. Many locale are quite usable, provided captions and dates are not required (which is a very frequent case, particularly in ancient languages). So, they are included in the default \babel{} distribution. This can serve to encourage contributions, too. A warning will remember they are ‘bare minimum locales’. They are set in \textcolor[gray]{.4}{gray} in the following list. \begingroup \bigskip\hrule\nobreak \makeatletter \def\tag#1#2#3{\par \hspace{-2em}\textcolor{thered}{\texttt{#1}}#2\enspace \mbox{\footnotesize(#3)}} \def\subtag#1#2#3{\par \hspace{-1em}\texttt{#1}#2\enspace \mbox{\footnotesize(#3)}} \def\subtagalt#1#2#3{\par \hspace{-1em}\textcolor{thered}{\texttt{#1}}#2\enspace \mbox{\footnotesize(#3)}} \def\tagmin#1#2#3{\par \hspace{-2em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace \mbox{\footnotesize(#3)}} \def\subtagmin#1#2#3{\par \hspace{-1em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace \mbox{\footnotesize(#3)}} \def\hascapu{\textsuperscript{u}} \def\hascapl{\textsuperscript{l}} \def\note#1{\par{\footnotesize#1\par}} \small \bigskip Recommended names are set in \textcolor{thered}{red}.\\ In variants with the region or the script name (which are not highlighted), prefer the full forms.\\ Bare minimum locales are set in \textcolor[gray]{.4}{gray}.\\ Discouraged and deprecated names are not included.\\ \hascapu{} means Unicode captions; \hascapl{} means LICR captions.\\ There are some notes in a few locales. \bigskip\hrule\nobreak \begin{multicols}{2} \leftskip2em\parindent0pt \tag{abkhazian}{}{ab} \tag{afar}{}{aa} \tag{afrikaans}{\hascapu\hascapl}{af} \tag{aghem}{}{agq} \tag{akan}{}{ak} \tagmin{akkadian}{}{akk} \tag{albanian}{\hascapu\hascapl}{sq} \tag{amharic}{\hascapu\hascapl}{am} \tagmin{ancientegyptian}{}{egy} \tag{ancientgreek}{\hascapu\hascapl}{grc}\note{It’s a different language from \texttt{greek}.} \tag{arabic}{\hascapu}{ar} \subtag{arabic-algeria}{\hascapu}{ar-DZ} \subtag{arabic-dz}{\hascapu}{ar-DZ} \subtag{arabic-egypt}{\hascapu}{ar-EG} \subtag{arabic-eg}{\hascapu}{ar-EG} \subtag{arabic-iraq}{\hascapu}{ar-IQ} \subtag{arabic-iq}{\hascapu}{ar-IQ} \subtag{arabic-jordan}{\hascapu}{ar-JO} \subtag{arabic-jo}{\hascapu}{ar-JO} \subtag{arabic-lebanon}{\hascapu}{ar-LB} \subtag{arabic-lb}{\hascapu}{ar-LB} \subtag{arabic-morocco}{\hascapu}{ar-MA} \subtag{arabic-ma}{\hascapu}{ar-MA} \subtag{arabic-palestinianterritories}{\hascapu}{ar-PS} \subtag{arabic-ps}{\hascapu}{ar-PS} \subtag{arabic-saudiarabia}{\hascapu}{ar-SA} \subtag{arabic-sa}{\hascapu}{ar-SA} \subtag{arabic-syria}{\hascapu}{ar-SY} \subtag{arabic-sy}{\hascapu}{ar-SY} \subtag{arabic-tunisia}{\hascapu}{ar-TN} \subtag{arabic-tn}{\hascapu}{ar-TN} \tagmin{aramaic}{}{arc} \subtagmin{aramaic-nabataean}{}{arc-nbat} \subtagmin{aramaic-nbat}{}{arc-nbat} \subtagmin{aramaic-palmyrene}{}{arc-palm} \subtagmin{aramaic-palm}{}{arc-palm} \tag{armenian}{\hascapu\hascapl}{hy} \tag{assamese}{\hascapu}{as} \tag{asturian}{\hascapu\hascapl}{ast} \tag{asu}{}{asa} \tag{atsam}{}{cch} \tagmin{avestan}{}{ae} \tag{awadhi}{}{awa} \tagmin{aymara}{}{ay} \tag{azerbaijani}{\hascapu\hascapl}{az} \subtag{azerbaijani-cyrillic}{}{az-Cyrl} \subtag{azerbaijani-cyrl}{}{az-Cyrl} \subtag{azerbaijani-latin}{}{az-Latn} \subtag{azerbaijani-latn}{}{az-Latn} \tag{bafia}{}{ksf} \tagmin{balinese}{}{ban} \tag{baluchi}{}{bal} \tag{bambara}{}{bm} \tag{bangla}{\hascapu}{bn} \subtag{bengali}{\hascapu}{bn} \tag{basaa}{}{bas} \tagmin{bashkir}{}{ba} \tag{basque}{\hascapu\hascapl}{eu} \tagmin{bataktoba}{}{bbc} \tagmin{bavarian}{}{bar} \tag{belarusian}{\hascapu\hascapl}{be} \tag{bemba}{}{bem} \tag{bena}{}{bez} \tag{bhojpuri}{}{bho} \tag{blin}{}{byn} \tag{bodo}{}{brx} \tag{bosnian}{\hascapu\hascapl}{bs} \subtag{bosnian-cyrillic}{}{bs-Cyrl} \subtag{bosnian-cyrl}{}{bs-Cyrl} \subtag{bosnian-latin}{\hascapu\hascapl}{bs-Latn} \subtag{bosnian-latn}{\hascapu\hascapl}{bs-Latn} \tag{breton}{\hascapu\hascapl}{br} \tag{bulgarian}{\hascapu\hascapl}{bg} \tag{buriat}{\hascapu\hascapl}{bua} \tag{burmese}{}{my} \tag{cantonese}{}{yue} \tag{catalan}{\hascapu\hascapl}{ca} \tag{cebuano}{}{ceb} \tag{centralatlastamazight}{}{tzm} \tag{centralkurdish}{\hascapu}{ckb} \subtag{sorani}{\hascapu}{ckb} \subtag{centralkurdish-latin}{\hascapu}{ckb-Latn} \subtag{centralkurdish-latn}{\hascapu}{ckb-Latn} \tag{chakma}{}{ccp} \tag{chechen}{}{ce} \tag{cherokee}{}{chr} \tag{chiga}{}{cgg} \tag{chinese}{\hascapu}{zh} \subtag{chinese-simplified}{\hascapu}{zh-Hans} \subtag{chinese-hans}{\hascapu}{zh-Hans} \subtag{chinese-traditional}{\hascapu}{zh-Hant} \subtag{chinese-hant}{\hascapu}{zh-Hant} \subtag{chinese-simplified-hongkongsarchina}{}{zh-Hans-HK} \subtag{chinese-hans-hk}{}{zh-Hans-HK} \subtag{chinese-simplified-macausarchina}{}{zh-Hans-MO} \subtag{chinese-hans-mo}{}{zh-Hans-MO} \subtag{chinese-simplified-singapore}{}{zh-Hans-SG} \subtag{chinese-hans-sg}{}{zh-Hans-SG} \subtag{chinese-hant-hk}{}{zh-Hant-HK} \subtag{chinese-traditional-hongkongsarchina}{}{zh-Hant-HK} \subtag{chinese-hant-mo}{}{zh-Hant-MO} \subtag{chinese-traditional-macausarchina}{}{zh-Hant-MO} \tag{churchslavic}{\hascapu}{cu} \subtag{churchslavic-cyrs}{\hascapu}{cu-Cyrs} \subtag{churchslavic-glag}{}{cu-Glag} \subtag{churchslavic-glagolitic}{}{cu-Glag} \subtag{churchslavic-oldcyrillic}{\hascapu}{cu-Cyrs} % \tag{churchslavonic}{\hascapu}{cu} \tag{chuvash}{}{cv} \tagmin{classicalmandaic}{}{myz} % \tag{classiclatin}{\hascapu\hascapl}{la-x-classic} \tag{colognian}{}{ksh} \tag{coptic}{}{cop} \tag{cornish}{}{kw} \tag{corsican}{}{co} \tag{croatian}{\hascapu\hascapl}{hr} \tag{czech}{\hascapu\hascapl}{cs} \tag{danish}{\hascapu\hascapl}{da} \tagmin{divehi}{}{dv} \tag{dogri}{}{doi} \tag{duala}{}{dua} \tag{dutch}{\hascapu\hascapl}{nl} \tag{dzongkha}{}{dz} % \tag{ecclesiasticlatin}{\hascapu\hascapl}{la-x-ecclesia} \tagmin{egyptianarabic}{}{arz}\note{Masri or Colloquial Egyptian, with tag \texttt{arz}, different from Standard Arabic as spoken in Egypt, with tag \texttt{ar-EG}.} \tag{embu}{}{ebu} \tag{english}{\hascapu\hascapl}{en} \subtagalt{american}{\hascapu\hascapl}{en-US} \subtag{americanenglish}{\hascapu\hascapl}{en-US} \subtagalt{australian}{\hascapu\hascapl}{en-AU} \subtag{australianenglish}{\hascapu\hascapl}{en-AU} \subtagalt{british}{\hascapu\hascapl}{en-GB} \subtag{britishenglish}{\hascapu\hascapl}{en-GB} \subtagalt{canadian}{\hascapu\hascapl}{en-CA} \subtag{canadianenglish}{\hascapu\hascapl}{en-CA} \subtag{english-australia}{\hascapu\hascapl}{en-AU} \subtag{english-au}{\hascapu\hascapl}{en-AU} \subtag{english-canada}{\hascapu\hascapl}{en-CA} \subtag{english-ca}{\hascapu\hascapl}{en-CA} \subtag{english-unitedkingdom}{\hascapu\hascapl}{en-GB} \subtag{english-gb}{\hascapu\hascapl}{en-GB} \subtag{english-newzealand}{\hascapu\hascapl}{en-NZ} \subtag{english-unitedstates}{\hascapu\hascapl}{en-US} \subtag{english-nz}{\hascapu\hascapl}{en-NZ} \subtag{english-us}{\hascapu\hascapl}{en-US} \tag{erzya}{}{myv} \tag{esperanto}{\hascapu\hascapl}{eo} \tag{estonian}{\hascapu\hascapl}{et} \tag{ewe}{}{ee} \tag{ewondo}{}{ewo} \tag{faroese}{}{fo} \tag{filipino}{}{fil} \tag{finnish}{\hascapu\hascapl}{fi} \tag{french}{\hascapu\hascapl}{fr} \subtagalt{acadian}{\hascapu\hascapl}{fr-x-acadian} \subtag{canadianfrench}{\hascapu\hascapl}{fr-CA} \subtag{swissfrench}{\hascapu\hascapl}{fr-CH} \subtag{french-belgium}{\hascapu\hascapl}{fr-BE} \subtag{french-be}{\hascapu\hascapl}{fr-BE} \subtag{french-canada}{\hascapu\hascapl}{fr-CA} \subtag{french-ca}{\hascapu\hascapl}{fr-CA} \subtag{french-luxembourg}{\hascapu\hascapl}{fr-LU} \subtag{french-lu}{\hascapu\hascapl}{fr-LU} \subtag{french-switzerland}{\hascapu\hascapl}{fr-CH} \subtag{french-ch}{\hascapu\hascapl}{fr-CH} \tag{friulian}{\hascapu\hascapl}{fur} \tag{fulah}{}{ff} \tag{ga}{}{gaa} \tag{galician}{\hascapu\hascapl}{gl} \tag{ganda}{}{lg} \tag{geez}{}{gez} \tag{georgian}{\hascapu}{ka} \tag{german}{\hascapu\hascapl}{de} \note{Note the \texttt{ldf} names differ. See note above.} \subtag{german-traditional}{\hascapu\hascapl}{de-1901} \subtagalt{austrian}{\hascapu\hascapl}{de-AT} \subtag{german-austria}{\hascapu\hascapl}{de-AT} \subtag{german-at}{\hascapu\hascapl}{de-AT} \subtag{german-austria-traditional}{\hascapu\hascapl}{de-AT-1901} \subtagalt{swisshighgerman}{\hascapu\hascapl}{de-CH}\note{\texttt{swissgerman}, with tag \texttt{gsw} is a different language.} \subtag{german-switzerland}{\hascapu\hascapl}{de-CH} \subtag{german-ch}{\hascapu\hascapl}{de-CH} \subtag{german-switzerland-traditional}{\hascapu\hascapl}{de-CH-1901} \tagmin{gothic}{}{got} \tag{greek}{\hascapu\hascapl}{el} \subtag{monotonicgreek}{\hascapu\hascapl}{el} \subtagalt{polytonicgreek}{\hascapu\hascapl}{el-polyton} \tag{guarani}{}{gn} \tag{gujarati}{\hascapu}{gu} \tag{gusii}{}{guz} \tag{haryanvi}{}{bgc} \tag{hausa}{\hascapu\hascapl}{ha} \subtag{hausa-ghana}{}{ha-GH} \subtag{hausa-gh}{}{ha-GH} \subtag{hausa-niger}{}{ha-NE} \subtag{hausa-ne}{}{ha-NE} \tag{hawaiian}{}{haw} \tag{hebrew}{\hascapu\hascapl}{he} \tag{hindi}{\hascapu}{hi} \tag{hmongnjua}{}{hnj} \tag{hungarian}{\hascapu\hascapl\hascapl\hascapl}{hu} \tag{icelandic}{\hascapu\hascapl}{is} \tag{igbo}{}{ig} \tag{inarisami}{}{smn} \tag{indonesian}{\hascapu\hascapl}{id} \tagmin{ingush}{}{inh} \tag{interlingua}{\hascapu\hascapl}{ia} \tag{inuktitut}{}{iu} \tag{irish}{\hascapu\hascapl}{ga} \tag{italian}{\hascapu\hascapl}{it} \tag{japanese}{\hascapu}{ja} \tag{javanese}{}{jv} \tag{jju}{}{kaj} \tag{jolafonyi}{}{dyo} \tag{kabuverdianu}{}{kea} \tag{kabyle}{}{kab} \tag{kaingang}{}{kgp} \tag{kako}{}{kkj} \tag{kalaallisut}{}{kl} \tag{kalenjin}{}{kln} \tag{kamba}{}{kam} \tag{kannada}{\hascapu}{kn} \tag{kashmiri}{}{ks} \tag{kazakh}{}{kk} \tag{khmer}{\hascapu}{km} \tag{kikuyu}{}{ki} \tag{kinyarwanda}{}{rw} \tagmin{komi}{}{kv} \tag{konkani}{}{kok} \tag{korean}{\hascapu}{ko} \subtag{korean-han}{\hascapu}{ko-Hani} \subtag{korean-hani}{\hascapu}{ko-Hani} \tag{koyraborosenni}{}{ses} \tag{koyrachiini}{}{khq} \tag{kwasio}{}{nmg} \tag{kyrgyz}{}{ky} \tagmin{ladino}{}{lad} \tag{lakota}{}{lkt} \tag{langi}{}{lag} \tag{lao}{\hascapu}{lo} \tag{latin}{\hascapu\hascapl}{la} \subtagalt{ecclesiasticallatin}{\hascapu\hascapl}{la-x-ecclesia} \subtagalt{classicallatin}{\hascapu\hascapl}{la-x-classic} \subtagalt{medievallatin}{\hascapu\hascapl}{la-x-medieval} \tag{latvian}{\hascapu\hascapl}{lv} \tagmin{lepcha}{}{lep} \tag{ligurian}{}{lij} \tagmin{limbu}{}{lif} \subtagmin{limbu-limb}{}{lif-limb} \subtagmin{limbu-limbu}{}{lif-limb} \tagmin{lineara}{}{lab} \tag{lingala}{}{ln} \tag{lithuanian}{\hascapu\hascapl\hascapl\hascapl}{lt} \tagmin{lombard}{}{lmo} \tag{lowersorbian}{\hascapu\hascapl}{dsb} \tag{lowgerman}{}{nds} % \tag{lsorbian}{\hascapu\hascapl}{dsb} \tagmin{lu}{}{khb} \tag{lubakatanga}{}{lu} \tag{luo}{}{luo} \tag{luxembourgish}{\hascapu\hascapl}{lb} \tag{luyia}{}{luy} \tag{macedonian}{\hascapu\hascapl}{mk} \tag{machame}{}{jmc} \tag{magyar}{\hascapu\hascapl\hascapl\hascapl}{hu} \tag{maithili}{}{mai} \tagmin{makasar}{}{mak} \subtagmin{makasar-bugi}{}{mak-Bugi} \subtagmin{makasar-buginese}{}{mak-Bugi} \tag{makhuwameetto}{}{mgh} \tag{makonde}{}{kde} \tag{malagasy}{}{mg} \tag{malay}{\hascapu\hascapl}{ms} \subtag{malay-brunei}{}{ms-BN} \subtag{malay-bn}{}{ms-BN} \subtag{malay-singapore}{}{ms-SG} \subtag{malay-sg}{}{ms-SG} \tag{malayalam}{\hascapu}{ml} \tag{maltese}{}{mt} \tag{manipuri}{}{mni} \tag{manx}{}{gv} \tag{maori}{}{mi} \tag{marathi}{\hascapu}{mr} \tag{masai}{}{mas} \tag{mazanderani}{}{mzn} \tag{meru}{}{mer} \tag{meta}{}{mgo} \tag{mongolian}{}{mn} \tag{monotonicgreek}{\hascapu\hascapl}{el} \tag{morisyen}{}{mfe} \tag{mundang}{}{mua} \tag{muscogee}{}{mus} \tag{nama}{}{naq} % \tag{naustrian}{\hascapu\hascapl}{de-AT} \tagmin{navajo}{}{nv} \tag{nepali}{}{ne} \tagmin{newari}{}{new} \tag{newzealand}{\hascapu\hascapl}{en-NZ} % \tag{ngerman}{\hascapu\hascapl}{de} \tag{ngiemboon}{}{nnh} \tag{ngomba}{}{jgo} \tag{nheengatu}{}{yrl} \tag{nigerianpidgin}{}{pcm} \tag{nko}{}{nqo} \tag{northernfrisian}{}{frr} \tag{northernkurdish}{\hascapu\hascapl}{kmr} \subtag{kurmanji}{\hascapu\hascapl}{kmr} \subtag{northernkurdish-arab}{\hascapu}{kmr-Arab} \subtag{northernkurdish-arabic}{\hascapu}{kmr-Arab} \tag{northernluri}{}{lrc} \tag{northernsami}{\hascapu\hascapl}{se} \subtag{samin}{\hascapu\hascapl}{se} \tag{northernsotho}{}{nso} \tag{northndebele}{}{nd} \tag{norwegian}{\hascapu\hascapl}{no} \subtag{norsk}{\hascapu\hascapl}{no} \note{In the CLDR, \texttt{norwegianbokmal} (nb) just inherites from \texttt{norwegian}, so use the latter.} % \tag{norwegianbokmal}{\hascapu\hascapl}{nb} \tag{nswissgerman}{\hascapu\hascapl}{de-CH} \tag{nuer}{}{nus} \tag{nyanja}{}{ny} \tag{nyankole}{}{nyn} \tag{nynorsk}{\hascapu\hascapl}{nn} \subtag{norwegiannynorsk}{\hascapu\hascapl}{nn} \tag{occitan}{\hascapu\hascapl}{oc} \tag{odia}{\hascapu}{or} \tagmin{oldnorse}{}{non} % \tag{oriya}{\hascapu}{or} \tag{oromo}{}{om} \tag{ossetic}{}{os} \tag{papiamento}{}{pap} \tag{pashto}{}{ps} \tag{persian}{\hascapu}{fa} \subtag{farsi}{\hascapu}{fa} \tagmin{phoenician}{}{phn} \tag{piedmontese}{\hascapu\hascapl}{pms} \tag{polish}{\hascapu\hascapl}{pl} \tag{portuguese}{\hascapu\hascapl}{pt} \subtagalt{brazilian}{\hascapu\hascapl}{pt-BR} \subtag{brazilianportuguese}{\hascapu\hascapl}{pt-BR} \subtag{portuguese-brazil}{\hascapu\hascapl}{pt-BR} \subtag{portuguese-br}{\hascapu\hascapl}{pt-BR} \subtag{europeanportuguese}{\hascapu\hascapl}{pt-PT} \subtag{portuguese-portugal}{\hascapu\hascapl}{pt-PT} \subtag{portuguese-pt}{\hascapu\hascapl}{pt-PT} \tag{prussian}{}{prg} \tag{punjabi}{\hascapu}{pa} \subtag{punjabi-arabic}{}{pa-Arab} \subtag{punjabi-arab}{}{pa-Arab} \subtag{punjabi-gurmukhi}{\hascapu}{pa-Guru} \subtag{punjabi-guru}{\hascapu}{pa-Guru} \tag{quechua}{}{qu} \tag{rajasthani}{}{raj} \tag{romanian}{\hascapu\hascapl}{ro} \subtagalt{moldavian}{\hascapu\hascapl}{ro-MD} \subtag{romanian-moldova}{\hascapu\hascapl}{ro-MD} \subtag{romanian-md}{\hascapu\hascapl}{ro-MD} \tag{romansh}{\hascapu\hascapl}{rm} \tag{rombo}{}{rof} \tag{rundi}{}{rn} \tag{russian}{\hascapu\hascapl}{ru} \tag{rwa}{}{rwk} \tag{saho}{}{ssy} \tag{sakha}{}{sah} \tagmin{samaritan}{}{smp} \tag{samburu}{}{saq} \tag{sango}{}{sg} \tag{sangu}{}{sbp} \tag{sanskrit}{}{sa} \subtag{sanskrit-bangla}{}{sa-Beng} \subtag{sanskrit-beng}{}{sa-Beng} % \subtag{sanskrit-bengali}{}{sa-Beng} \subtag{sanskrit-devanagari}{}{sa-Deva} \subtag{sanskrit-deva}{}{sa-Deva} \subtag{sanskrit-gujarati}{}{sa-Gujr} \subtag{sanskrit-gujr}{}{sa-Gujr} \subtag{sanskrit-kannada}{}{sa-Knda} \subtag{sanskrit-knda}{}{sa-Knda} \subtag{sanskrit-malayalam}{}{sa-Mlym} \subtag{sanskrit-mlym}{}{sa-Mlym} \subtag{sanskrit-telugu}{}{sa-Telu} \subtag{sanskrit-telu}{}{sa-Telu} \tag{santali}{}{sat} \tag{saraiki}{}{skr} \tag{sardinian}{}{sc} \tag{scottishgaelic}{\hascapu\hascapl}{gd} \tag{sena}{}{seh} \tag{serbian}{\hascapu\hascapl}{sr} \note{Note the \texttt{ldf} names differ. See note above.} \subtag{serbian-cyrillic}{\hascapu\hascapl}{sr-Cyrl} \subtag{serbian-cyrl}{\hascapu\hascapl}{sr-Cyrl} \subtag{serbian-cyrillic-bosniaherzegovina}{\hascapu\hascapl}{sr-Cyrl-BA} \subtag{serbian-cyrl-ba}{\hascapu\hascapl}{sr-Cyrl-BA} \subtag{serbian-cyrillic-kosovo}{\hascapu\hascapl}{sr-Cyrl-XK} \subtag{serbian-cyrl-xk}{\hascapu\hascapl}{sr-Cyrl-XK} \subtag{serbian-cyrillic-montenegro}{\hascapu\hascapl}{sr-Cyrl-ME} \subtag{serbian-cyrl-me}{\hascapu\hascapl}{sr-Cyrl-ME} \subtag{serbian-latin}{\hascapu\hascapl}{sr-Latn} \subtag{serbian-latn}{\hascapu\hascapl}{sr-Latn} \subtag{serbian-latin-bosniaherzegovina}{\hascapu\hascapl}{sr-Latn-BA} \subtag{serbian-latn-ba}{\hascapu\hascapl}{sr-Latn-BA} \subtag{serbian-latin-kosovo}{\hascapu\hascapl}{sr-Latn-XK} \subtag{serbian-latn-xk}{\hascapu\hascapl}{sr-Latn-XK} \subtag{serbian-latin-montenegro}{\hascapu\hascapl}{sr-Latn-ME} \subtag{serbian-latn-me}{\hascapu\hascapl}{sr-Latn-ME} \subtag{serbian-ijekavsk}{\hascapu\hascapl}{sr-ijekavsk} \subtag{serbian-latn-ijekavsk}{\hascapu\hascapl}{sr-Latn-ijekavsk} % \tag{serbianc}{\hascapu\hascapl}{sr} \tag{shambala}{}{ksb} \tag{shona}{}{sn} \tag{sichuanyi}{}{ii} \tag{sicilian}{}{scn} \tag{silesian}{}{szl} \tag{sindhi}{}{sd} \subtag{sindhi-devanagari}{}{sd-deva} \subtag{sindhi-deva}{}{sd-deva} \subtag{sindhi-khojki}{}{sd-khoj} \subtag{sindhi-khoj}{}{sd-khoj} \subtag{sindhi-khudawadi}{}{sd-sind} \subtag{sindhi-sind}{}{sd-sind} \tag{sinhala}{\hascapu}{si} \tagmin{sinteromani}{}{rmo} \tag{slovak}{\hascapu\hascapl}{sk} \tag{slovenian}{\hascapu\hascapl}{sl} \subtag{slovene}{\hascapu\hascapl}{sl} \tag{soga}{}{xog} \tag{somali}{}{so} \tagmin{southernaltai}{}{alt} \tag{southernsotho}{}{st} \tag{southndebele}{}{nr} \tag{spanish}{\hascapu\hascapl}{es} \subtagalt{mexican}{\hascapu\hascapl}{es-MX} \subtag{mexicanspanish}{\hascapu\hascapl}{es-MX} \subtag{spanish-mexico}{\hascapu\hascapl}{es-MX} \subtag{spanish-mx}{\hascapu\hascapl}{es-MX} \tag{standardmoroccantamazight}{}{zgh} \tag{sundanese}{}{su} \tag{swahili}{}{sw} \tag{swati}{}{ss} \tag{swedish}{\hascapu\hascapl}{sv} \tag{swissgerman}{}{gsw} \note{Different from \texttt{swisshighgerman} (de-CH), which is German as spoken in Switzerland.} \tag{syriac}{}{syr} \tag{tachelhit}{}{shi} \subtag{tachelhit-latin}{}{shi-Latn} \subtag{tachelhit-latn}{}{shi-Latn} \subtag{tachelhit-tifinagh}{}{shi-Tfng} \subtag{tachelhit-tfng}{}{shi-Tfng} \tagmin{tainua}{}{tdd} \tag{taita}{}{dav} \tag{tajik}{}{tg} \tag{tamil}{\hascapu}{ta} \tagmin{tangut}{}{txg} \tag{taroko}{}{trv} \tag{tasawaq}{}{twq} \tag{tatar}{}{tt} \tag{telugu}{\hascapu}{te} \tag{teso}{}{teo} \tag{thai}{\hascapu\hascapl}{th} \tag{tibetan}{\hascapu}{bo} \tag{tigre}{}{tig} \tag{tigrinya}{}{ti} \tag{tokpisin}{}{tpi} \tag{tongan}{}{to} \tag{tsonga}{}{ts} \tag{tswana}{}{tn} \tag{turkish}{\hascapu\hascapl}{tr} \tag{turkmen}{\hascapu\hascapl}{tk} \tag{tyap}{}{kcg} \tag{ukenglish}{\hascapu\hascapl}{en-GB} \tag{ukrainian}{\hascapu\hascapl}{uk} \tag{uppersorbian}{\hascapu\hascapl}{hsb} \tag{urdu}{\hascapu}{ur} \tag{usenglish}{\hascapu\hascapl}{en-US} \tag{usorbian}{\hascapu\hascapl}{hsb} \tag{uyghur}{\hascapu}{ug} \tag{uzbek}{}{uz} \subtag{uzbek-arabic}{}{uz-Arab} \subtag{uzbek-arab}{}{uz-Arab} \subtag{uzbek-cyrillic}{}{uz-Cyrl} \subtag{uzbek-cyrl}{}{uz-Cyrl} \subtag{uzbek-latin}{}{uz-Latn} \subtag{uzbek-latn}{}{uz-Latn} \tag{vai}{}{vai} \subtag{vai-latin}{}{vai-Latn} \subtag{vai-latn}{}{vai-Latn} \subtag{vai-vai}{}{vai-Vaii} \subtag{vai-vaii}{}{vai-Vaii} \tag{venda}{}{ve} \tag{vietnamese}{\hascapu\hascapl}{vi} \tag{volapuk}{}{vo} \tag{vunjo}{}{vun} \tag{walser}{}{wae} \tagmin{waray}{}{war} \tag{welsh}{\hascapu\hascapl}{cy} \tag{westernfrisian}{}{fy} \tag{wolaytta}{}{wal} \tag{wolof}{}{wo} \tag{xhosa}{}{xh} \tag{yangben}{}{yav} \tag{yiddish}{}{yi} \tag{yoruba}{}{yo} \tag{zarma}{}{dje} \tag{zulu}{}{zu} \end{multicols} \endgroup \hrule \bigskip \subsection{Fonts in Unicode engines} \label{fonts} \begin{note} For \textsf{pdflatex} and the standard \textsf{fontenc} mechanism, refer to the \LaTeX{} manuals or \textit{The \LaTeX{} Companion}, vol.~I, ch.~9, and vol.~II, ch.~10. \end{note} \New{3.15} \Babel{} has native support for Unicode fonts (OpenType and TrueType) in \luatex{} and \xetex{} by means of a high level interface on top of |fontspec|. This makes it easier to handle a wide range of languages and scripts, and simplifies the process of typesetting multilingual documents. As described below, with \luatex{} the font can be switched automatically based on the script without explicit markup. There is no need to load \textsf{fontspec} explicitly – \babel{} does it for you with the first |\babelfont|. (See also the package \textsf{combofont} for a complementary approach.) \Describe\babelfont{\oarg{language-list}\marg{font-family}% \oarg{font-options}\marg{font-name}} The main purpose of |\babelfont| is to define at once the fonts required by the different languages, with their corresponding language systems (script and language). So, if you load, say, 4 languages, |\babelfont{rm}{FreeSerif}| defines 4 fonts (with their variants, of course), which are switched with the language by \babel. It is a tool to make things easier and transparent to the user. Here \textit{font-family} is |rm|, |sf| or |tt| (or newly defined ones, as explained below), and \textit{font-name} is the same as in \textsf{fontspec} and the like. If no language is given, then it is considered the default font for the family. On the other hand, if there is one or more languages in the optional argument, the font will be assigned to all of them, overriding the default one. Alternatively, you may set a font for a script -- just precede its name (lowercase) with a star (e.g., |*devanagari|). With the optional argument, the font is \textit{not} yet loaded, but just predeclared. In other words, font loading is lazy, which means you may define as many fonts as you want ‘just in case’, because if the language is never selected, the corresponding |\babelfont| declaration is just ignored. \Babel{} takes care of the font language and the font script when languages are selected (as well as the writing direction). In other words, there is usually no need to set the |Language| and the |Script| explicitly; in fact, it’s even discouraged. In most cases, you will not need \textit{font-options}, which is the same as in \textsf{fontspec}, but you may add further key/value pairs if necessary. |\babelfont| can be used to implicitly define a new font family. Just write its name instead of |rm|, |sf| or |tt|. This is the preferred way to select fonts in addition to the three basic families. \New{24.14} With \luatex, \Babel\ selects the renderer in the following way: \begin{itemize} \item The default renderer in alphabetic scripts, so that the tools provided by \textsf{luaotfload} for ligatures, kerning and the like, which are essential typographical features in these scripts, are directly available: Armenian, Coptic, Cyrillic, Georgian, Glagolitic, Gothic, Greek, Latin, Old Church Slavonic Cyrillic. \item Harfbuzz in the rest of scripts, particularly complex scripts with heavy contextual analysis (like Arabic and Devanagari). \end{itemize} You can still select a different renderer with the \textsf{fontspec} key |Renderer|. Note also the same font can be loaded with different renderers. See \href{https://github.com/latex3/luaotfload/wiki/Comparing-the-modes}{Comparing the modes} for further info. \begin{note} There is a list of fonts in \href{https://latex3.github.io/babel/guides/which-method-for-which-language.html}{Which method for which language}. If you know the codepoint of a character in the script you need, you can find fonts containing it with \textsf{albatross} (requires Java) or with something like \texttt{fc-list :charset=1033C family} in the commands line (in this case, a Gothic character, the script required by the |gothic| language). \end{note} \begin{note} As \babel{} sets the font language system, the following setup is redundant, so avoid it and use only the first line: \begin{verbatim} \babelfont{rm}{DejaVu Serif} \babelfont[armenian]{rm}[Script=Armenian, Language=Armenian]{DejaVu Serif} \end{verbatim} \end{note} \begin{example} Usage in most cases is very simple. Let us assume you are setting up a document in Swedish, with some words in Hebrew, with a font suited for both languages. Here the option |bidi=default| activates a simple (or, rather, simplistic) bidirectional mode. \begingroup % If you are looking at the code to see how it has been written, you % will be disappointed :-). The following example is built ad hoc to % emulate the final result to avoid dependencies, and therefore it's % not "real" code. \catcode`@=13 \def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else \bgroup\textdir TRT \fontspec[Scale=.87,Script=Hebrew]{Liberation Mono} \fi} \setengine{luatex/xetex} \begin{verbatim} \documentclass{article} \usepackage[swedish, bidi=default]{babel} \babelprovide[import]{hebrew} _\babelfont{rm}{FreeSerif}_ \begin{document} Svenska \foreignlanguage{hebrew}{@2עִבְרִית@0} svenska. \end{document} \end{verbatim} \endgroup If on the other hand you have to resort to different fonts, you can replace the red line above with, say: \setengine{luatex/xetex} \begin{verbatim} \babelfont{rm}{Iwona} \babelfont[hebrew]{rm}{FreeSerif} \end{verbatim} \end{example} \begin{example} Thanks to this high level interface to |fontenc|, the roman fonts for all secondary languages in the Cyrillic and Greek scripts can be set at once with the following single line: \setengine{luatex/xetex} \begin{verbatim} \babelfont[_*cyrillic, *greek_]{rm}{NewComputerModern10} \end{verbatim} And if you need, say, Arabic and Devanagari: \begin{verbatim} \babelfont[_*arabic, *devanagari_]{rm}{FreeSerif} \end{verbatim} \Babel{} does the rest for you, including setting the font script \textit{and} language. \end{example} \begin{example} Since each locale is a separate ‘language’, they can be assigned different fonts. In this example, we set Simplified and Tradicional Chinese: \begin{verbatim} \babelfont[chinese-_simplified_]{rm}{Noto Serif CJK _SC_} \babelfont[chinese-_simplified_]{sf}{Noto Sans CJK _SC_} \babelfont[chinese-_traditional_]{rm}{Noto Serif CJK _TC_} \babelfont[chinese-_traditional_]{sf}{Noto Sans CJK _TC_} \end{verbatim} \end{example} \begin{example} Here is how to declare a new family: \setengine{luatex/xetex} \begin{verbatim} \babelfont{_kai_}{FandolKai} \end{verbatim} Now, |\kaifamily| and |\kaidefault|, as well as |\textkai| are at your disposal. \end{example} \begin{note} You may load \textsf{fontspec} explicitly. For example: \setengine{luatex/xetex} \begin{verbatim} \usepackage{fontspec} \newfontscript{Devanagari}{deva} \babelfont[hindi]{rm}{Shobhika} \end{verbatim} This makes sure the OpenType script for Devanagari is |deva| and not |dev2|, in case you need it. \end{note} \begin{note} |\fontspec| is not touched at all, only the preset font families (|rm|, |sf|, |tt|, and the like). If a language is switched when an \textit{ad hoc} font is active, or you select the font with this command, neither the script nor the language is passed. You must add them by hand. This is by design, for several reasons —for example, each font has its own set of features and a generic setting for several of them can be problematic, and also preserving a “lower-level” font selection is useful. \end{note} \begin{note} Directionality is a property affecting margins, indentation, column order, etc., not just text. Therefore, it is under the direct control of the language, which applies both the script and the direction to the text. As a consequence, there is no need to set \texttt{Script} when declaring a font with |\babelfont| (nor \texttt{Language}). In fact, it is even discouraged. \end{note} \begin{note} The keys |Language| and |Script| just pass these values to the \textit{font}, and do \textit{not} set the script for the \textit{language} (and therefore the writing direction). In other words, the |ini| file or |\babelprovide| provides default values for |\babelfont| if omitted, but the opposite is not true. See the note above for the reasons of this behavior. \end{note} \begin{note} |\babelfont| is a high level interface to \textsf{fontspec}, and therefore in \xetex{} you can apply |Mapping|s. For example, there is a set of \href{https://github.com/davidmjones/brahmic-maps}{transliterations for Brahmic scripts} by David M. Jones. After installing them in you distribution, just set the map as you would do with \textsf{fontspec}. \end{note} \begin{warning} Using |\set|\textit{xxxx}|font| and |\babelfont| at the same time is discouraged, but very often works as expected. However, be aware with |\set|\textit{xxxx}|font| the language system will not be set by \babel{} and should be set with |fontspec| if necessary. \end{warning} \begin{troubleshooting} \trouble{Package fontspec Info: Language '' not explicitly supported within font '' with script '