2

I want to understand the way to enable and use latex to typeset in different languages. Would one just type language glyphs in the latex document, and would one be using utf8 ? Latex does provide the possibility of inserting diacritic marks (e.g. H\^otel), but it would be a strange thing to read when writing in french say.

I am using lualatex. Have encountered fontspec and babel. But what is one to use ?

8
  • 3
    Many questions already on this site: search for the French and babel tags to begin with: tex.stackexchange.com/questions/tagged/…
    – Thérèse
    Commented Mar 5 at 1:09
  • With lualatex your input should be utf-8.
    – Thérèse
    Commented Mar 5 at 1:46
  • 1
    Yes, that’s right. Hôtel.
    – Thérèse
    Commented Mar 5 at 1:52
  • 2
    Yes you just type them any unicode glyph can be rendered provided you have the font(s) that support it.
    – yannisl
    Commented Mar 5 at 2:19
  • 3
    Without lualatex, your input should also be utf-8 if you are using LaTeX and any reasonably recent distribution.
    – cfr
    Commented Mar 5 at 2:32

2 Answers 2

8

I’m afraid the accepted answer isn’t quite correct complete (sorry, @Mico 🙂). There are no line breaks with the CJK scripts and the Hebrew text is reversed (in addition, captions, hyphenation rules and the like aren’t activated). Actually, just setting the font isn’t enough and you need a multilingual package like babel . Here is an example:

\documentclass{article}

\usepackage[spanish, french]{babel}

\babelprovide{chinese}
\babelfont[chinese]{rm}{IPAexMincho}

\begin{document}

Plus ça change, plus c'est la même chose!

\foreignlanguage{spanish}{Español.}

\selectlanguage{chinese}

唯転冷応世黒式歌宿首己政転暮宿領体解。界済省物鯉権検米員燃惑稿。著変国上究初保前訴団婚雄就生術。実辞横掲中載自盗者洋同込迫。読力紙権促事惣者前回選根著都。

\end{document}

enter image description here

For Hebrew, see Can anyone provide s minimal example of Hebrew/English document using Luatex/babel? (MacOS/TeXShop).

6
  • The fact that I didn't mention the babel package in my answer should not be interpreted as me somehow signalling that babel is unimportant when it comes to proper typesetting. I simply interpreted the OP's query narrowly, as asking about how to enter various glyphs; cf. H\^otel vs. Hôtel. Well, the OP subsequent question, "Would you use fontspec rather than babel?", does reveal a degree of confusion on the OP's part that I truly hadn't anticipated.
    – Mico
    Commented Mar 5 at 9:23
  • 1
    @Mico deleted ‘correct’ and added ‘complete’. Commented Mar 5 at 12:23
  • 2
    @Mico Stricty speaking you re both correct, and I have also interpreted the OPs question incorrectly. I have a document where I typeset all current Unicode scripts with only minmal support from Babel. I used fallback fonts The document mostly typesets unicode tables for each script and a few paragraphs of mostly English text, interspersed with some script(s) and IPA pronunciations.
    – yannisl
    Commented Mar 6 at 2:14
  • 2
    @Mico Now and then there is a paragraph for the "other" script as well. So IMHO fontspec for the glyphs of the script + Babel for the typographical conventions, captions, hyphenation rules, occassional maths aand other macros etc. What we are still missing is still proper indexing (I imagine Babel some day generating .ist like files).upmendex is a very promising in this respect.
    – yannisl
    Commented Mar 6 at 2:18
  • 1
    @yannisl My attempts wrt indexing are closely related to one of my packages (namely, esindex). But I’ve never fully developed these ideas (they are in my todo list) and I wonder if it’s a task for babel or for a language aware indexing package. Anyway, as you pointed out, upmendex is very promising, and to a large extent a reality. Suggestions are most welcome. Commented Mar 6 at 16:08
4

Lua(La)TeX's one and only recognized input encoding scheme is utf8. (Aside: ASCII is a subset of utf8.) I suggest you load the fontspec package and choose fonts that contain the glyphs you need for the language, or languages, you're writing in.

enter image description here

% !TEX TS-program = lualatex
\documentclass{article}

\usepackage{fontspec} % for \newfontfamily macro
\newfontfamily{\TC}{Noto Serif TC}
\newfontfamily{\JP}{Noto Serif TC}
\newfontfamily{\KA}{Noto Sans Kannada}

\begin{document} % "Hello World" in various languages...

\TC 
你好世界。

\JP 
こんにちは世界。

\KA 
ಹಲೋ ವರ್ಲ್ಡ್.

\end{document}
7
  • Would you use fontspec rather than babel ?
    – Veak
    Commented Mar 5 at 3:59
  • 2
    @Ragonese - babel and fontspec do completely different things. They are not substitutes, as your question would appear to claim. Please read the first few pages of each package's user guide to familiarize yourself with what these packages do.
    – Mico
    Commented Mar 5 at 5:34
  • @Mico But the OP is about languages, not about fonts. Commented Mar 5 at 6:57
  • @JavierBezos - IMNSHO, the query is about three things: languages that employ glyphs not contained in the basic 26-letter Latin alphabet, ways to generate these glyphs, and fonts that make it easy to access language-specific glyphs. I focused my answer on the how-to-access-various-glyphs subtopic.
    – Mico
    Commented Mar 5 at 9:29
  • 2
    In the image provided, the Hebrew text renders backwards. Commented Mar 5 at 12:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .