Summary
This class teaches how to declare the languages of a document and how to choose its fonts. It explains what babel changes when a language is declared (hyphenation, captions, dates and quotation marks) and distinguishes the three ways of switching language: \selectlanguage, \foreignlanguage and the otherlanguage environment. It applies all this to polytonic Greek and to Latin, with a passage in each. It then presents fontspec: the three families of a document, \babelfont for assigning a font to each language, and the most useful OpenType features (old-style figures, small capitals and ligatures). It teaches how to check that a font contains every character of the document, by reading the “Missing character” warnings and by searching for fonts with albatross, and explains why it pays to prefer the fonts that ship with TeX Live when the document must also compile on Overleaf. It ends with a brief mention of right-to-left scripts, of East Asian scripts and of polyglossia.
Learning objectives
- Declare the main language and the secondary languages of a document with babel, and explain what each language decides in the output.
- Choose between
\foreignlanguage,otherlanguageand\selectlanguageaccording to what must change, and predict the resulting date, captions and quotation marks. - Typeset passages in polytonic Greek and in Latin with their own hyphenation and a suitable font.
- Assign fonts with fontspec and babel, and turn on old-style figures, small capitals and ligatures.
- Verify that the chosen fonts contain every character and style the document uses, and interpret the warnings that indicate otherwise.
- Decide between a TeX Live font and a system font according to where the document must be compiled.
What changes with the language
The earlier classes always loaded \usepackage[english]{babel} without pausing over what it does. A language, however, is not just a list of letters: it has its own rules for dividing words at the end of a line, its own names for the parts of a document, its own way of writing dates and its own quotation marks. The babel package gathers these conventions language by language, and declaring a language means asking babel to apply them. Specifically, the language decides:
- hyphenation: which patterns the engine uses to find the points where a word may be broken;
- the captions that LaTeX writes on its own, such as the title of the table of contents or the names of tables and figures;
- the date printed by
\today, which is the day of compilation; - certain keyboard shorthands, such as those some languages define for quotation marks, which this same section will show.
All three paragraphs use the same commands; only the language in which they are read changes. \tablename, \figurename and \contentsname are the captions of tables, of figures and of the table of contents.
\documentclass{article}\usepackage{fontspec}\usepackage[latin, ngerman, english]{babel}\begin{document}Date: \today. Captions: \tablename, \figurename, \contentsname.\begin{otherlanguage}{ngerman}Datum: \today. Bezeichnungen: \tablename, \figurename, \contentsname.\end{otherlanguage}\begin{otherlanguage}{latin}Dies: \today. Tituli: \tablename, \figurename, \contentsname.\end{otherlanguage}\end{document}Latin writes the day and the year in Roman numerals. Note also that babel's english writes the date in the American order, month first; for the British order, the option british prints “14th October 2026”, as in \usepackage[british]{babel}.
Hyphenation
Hyphenation is the least visible effect of the language and the most important one. Each language breaks its words according to its own tradition: English often respects the formation of the word, as in stand-ing; German separates the members of its compounds and the syllables within them; and Latin, according to the tradition its patterns follow, carries an s followed by a consonant over to the next line. If a passage in another language is not marked, the engine hyphenates it with the patterns of the current language, and the breaks it proposes may be wrong in that language.
The command \showhyphens writes to the log the break points the engine would allow in the words it receives, without printing anything in the document. It is a way of checking which patterns are in force at each place.
The source asks for the breaks of two German words and of two Latin ones, first with the patterns of English, the main language, and then with those of their own language.
\documentclass{article}\usepackage{fontspec}\usepackage[latin, ngerman, english]{babel}\begin{document}\showhyphens{Erkenntnistheorie Wissenschaft}\foreignlanguage{ngerman}{\showhyphens{Erkenntnistheorie Wissenschaft}}\showhyphens{nostrum conscientia}\foreignlanguage{latin}{\showhyphens{nostrum conscientia}}\end{document}For each line, the log shows a box warning (harmless: \showhyphens sets the words in a very wide line in order to examine them) followed by the words with their breaks.
Underfull \hbox (badness 10000) in paragraph at lines 5--5[] \TU/lmr/m/n/10 Erken-nt-nis-the-o-rie Wis-senschaftUnderfull \hbox (badness 10000) in paragraph at lines 6--6[] \TU/lmr/m/n/10 Er-kennt-nis-theo-rie Wis-sen-schaftUnderfull \hbox (badness 10000) in paragraph at lines 7--7[] \TU/lmr/m/n/10 nos-trum con-sci-en-tiaUnderfull \hbox (badness 10000) in paragraph at lines 8--8[] \TU/lmr/m/n/10 no-strum con-scien-tiaWith the English patterns, the German words are cut as if they were English, and a break such as Erken-nt would be a glaring error in a German text; with the German patterns, the breaks fall between the members of the compound and between syllables. The same happens with Latin: line 7 breaks as English would, and line 8 as the Latin tradition teaches.
Quotation marks in English
English babel defines no shorthands for quotation marks, because English needs none: the classic forms of LaTeX produce its marks in any language. Two grave accents open double quotation marks and two apostrophes close them; one of each gives the single ones. American usage puts the double marks outside and the single ones inside; British usage often reverses the order. Babel does not alternate the levels: the author writes each mark where it belongs. Other languages do have shorthands: German writes "` and "' for its low and high marks, Portuguese and Latin "< and "> for guillemets, and Spanish goes furthest, with << and >>, which babel turns into guillemets on the outer level and into double marks on the next one.
The first line closes both levels at once, and the thin space \, keeps the single and the double closing marks from running together. The second line shows a coincidence that has nothing to do with English.
That coincidence must be told apart from a shorthand. The font, loaded by fontspec with the TeX ligatures feature discussed below, turns two < signs in a row into a guillemet by itself, in any language; what only Spanish babel does is alternate the marks according to the level. In an English passage, <<a <<b>> c>> prints three guillemets on each side, one pair inside another, whereas in a Spanish passage it prints «a “b” c». The class devoted to notes, quotations and verse will treat quotations in more detail.
Loading the content…
Completed
Sign in to save your progress