6

following up on THIS QUESTION, I want to embed the solution in a document (Beamer presentation) I compile (in English) with LuaLaTeX, but I just don't find the way. I just want to include a slide with text in different languages and the code for teaching purposes, but it is the first time I try to write something in a non-latin alphabet... But my document needs LuaLaTeX (and I actually like it!).

Additionally, if someone knows how to include text in a couple of other non-latin alphabets as well, like Arabic and Thai, it would be much appreciated.

So this it the code I want to embed in my document compiled with LuaLaTeX:

\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian, english]{babel}% note - it is recommended to specify the variant of English required to avoid unexpected divergence depending on the version of babel e.g. american or british
\usepackage[encapsulated]{CJK}
\usepackage{setspace}
\doublespacing
\usepackage{natbib}
\begin{document}
\selectlanguage{russian}
слово

\begin{CJK}{UTF8}{gbsn}
你好
\end{CJK}

\selectlanguage{english}
Here is some text in English.

\selectlanguage{russian}
слово

\end{document}
  • 1
    You'll need fontspec commands to select appropriate fonts, unless you have one that covers all these alphabets. – musarithmia Jun 15 '15 at 1:24
  • How can I do that? Which would be the required fonts, and where to get them for Ubuntu? Thanks! – DaniCee Jun 15 '15 at 1:47
  • 2
    Don't load inputenc or fontenc if you are compiling with LuaTeX. (In some cases, you can use fontenc but generally not. You definitely don't want inputenc ever here.) – cfr Jun 15 '15 at 2:12
  • I suspect you ought not load CJK either but I'm not entirely sure. Also if it supports the languages you need, consider polyglossia as a replacement for babel with this engine. – cfr Jun 15 '15 at 2:14
  • 1
    Which solution are you referring to? At least 3 different solutions are mentioned there, none involving LuaTeX. One uses the encapsulated option of CJK. One uses the CJKutf8 package. A third uses XeTeX (and is linked rather than given directly). The first two solutions are for (pdf)TeX - not XeTeX or LuaTeX. XeTeX or LuaTeX should be much easier here but you need to do a little bit of work to set your document up appropriately i.e. a bit of reading so that you understand the basics of switching engines. texdoc fontspec is a great resource. – cfr Jun 15 '15 at 2:22
6

Here I demonstrate only how to use fontspec to select many different fonts for different languages in one document. I use a main font that already covers a wide Unicode range, and then select other fonts as appropriate. I used fonts either available in TeXLive or freely available elsewhere. Compile with lualatex.

Note that for Hebrew and Arabic you have to use \luatextexdir TRT to set the right-to-left text direction, and with Arabic you need [Script=Arabic]. See the fontspec package documentation and other questions on these sites about these languages for more information.

I don't know all these languages, so I have likely gotten some things wrong, and I hope others will correct me.

To this you can add using babel or polyglossia for hyphenation patterns specific to each language, but I leave this up to someone else to demonstrate. With only short excerpts of different languages, that may be overkill anyway.

\documentclass{article}
\usepackage{url} % just to format urls 
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
% Libertine covers Latin, Hebrew, Greek, and Russian

\newfontfamily{\hebrewfont}{Linux Libertine O} 
\newcommand{\texthebrew}[1]{%
    \bgroup\luatextextdir TRT\hebrewfont #1\egroup%
}

\newfontfamily{\chinesefont}{IPAMincho} % in TeXLive
\newcommand{\textchinese}[1]{\bgroup\chinesefont #1\egroup}

\newfontfamily{\arabicfont}[Script=Arabic]{Droid Arabic Naskh} % free with Debian GNU/Linux
\newcommand{\textarabic}[1]{%
     \bgroup\luatextextdir TRT\arabicfont #1\egroup%
}

\newfontfamily{\thaifont}{Norasi} % free with Debian
\newcommand{\textthai}[1]{\bgroup\thaifont #1\egroup}

\begin{document}
\section*{The Tower of Babel, Genesis 11:7}

\subsection*{English}
Come, let us go down and confuse their language so they will not understand each other. 

\subsection*{Hebrew}
\texthebrew{%
הָ֚בָה נֵֽרְדָ֔ה וְנָבְלָ֥ה שָׁ֖ם שְׂפָתָ֑ם אֲשֶׁר֙ לֹ֣א יִשְׁמְע֔וּ אִ֖ישׁ שְׂפַ֥ת רֵעֵֽהוּ׃%
}

\subsection*{Greek}
δεῦτε καὶ καταβάντες συγχέωμεν ἐκεῖ αὐτῶν τὴν γλῶσσαν, ἵνα μὴ ἀκούσωσιν ἕκαστος τὴν φωνὴν τοῦ πλησίον.

\subsection*{Latin}
venite igitur descendamus et confundamus ibi linguam eorum ut non audiat unusquisque vocem proximi sui

\subsection*{Spanish}
Será mejor que bajemos a confundir su idioma, para que ya no se entiendan entre ellos mismos.

\subsection*{Russian}
сойдем же и смешаем там язык их, так чтобы один не понимал речи другого.

\subsection*{Chinese (Simplified)}
\textchinese{%
来,我们下去,在那里混乱他们的语言,使他们听不懂对方的话。%
}

\subsection*{Thai}
\textthai{%
มาเถิด ให้เราลงไปทำให้เขามีภาษาสับสนแตกต่างกันออกไป เพื่อเขาจะได้ไม่เข้าใจกัน%
}

\subsection*{Arabic}
\textarabic{%
هَيَّا نَنْزِلْ إِلَيْهِمْ وَنُبَلْبِلْ لِسَانَهُمْ، حَتَّى لَا يَفْهَمَ بَعْضُهُمْ كَلامَ بَعْضٍ.%
}

\bigskip
\small
Texts from \url{https://www.biblegateway.com}.
Greek Septuagint text from \url{https://www.academic-bible.com/en/online-bibles/septuagint-lxx/read-the-bible-text/}.


\end{document}

enter image description here

  • The Arabic isn’t right (no bidi). You’ll need \newfontfamily\arabicfont[Script=Arabic]{Droid Arabic Naskh}, though that won’t suffice. In the case of Arabic, xetex makes life easier than luatex, though I use luatex for everything else. Haven’t yet had time to update to TeX Live 2015, but when I do I’ll revisit this question if the situation has changed. – Thérèse Jun 16 '15 at 15:14
  • Closer. The letters are joined where they should be now, but the text is backward. (Don’t feel bad: some of my colleagues were proudly displaying an Arabic book upside-down until I pointed it out..) – Thérèse Jun 16 '15 at 19:48
  • @Thérèse How about now? – musarithmia Jun 16 '15 at 20:15
  • 1
    Excellent. You’ve unconfused our language. – Thérèse Jun 16 '15 at 20:19
  • Thank you so much, this is amazing!! I'm just having trouble with the Chinese, cause the IPAMincho font cannot be found... which TeX Live package contains it?? – DaniCee Jun 18 '15 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.