I am typing a document in both Chinese and Hebrew. When I use the following codes for Chinese, everything works fine:
\documentclass[UTF8]{ctexart}
\begin{document}
\tableofcontents
\begin{abstract}
这是简介及摘要。
\end{abstract}
\section{ 前言 }
\section{关于数学部分}
数学、中英文皆可以混排。You can intersperse math, Chinese and English (Latin script) without adding extra environments.
這是繁體中文。
\end{document}
But when I tried to add Hebrew by adding
\usepackage[utf8x]{inputenc}
\usepackage[hebrew,english]{babel}
It does not compile properly. The error message was
Font LHE/cmr/m/n/10=jerus10 at 10.0pt not loadable: Metric (TFM) file not found. \select@language{hebrew}
Anyone knows how to fix the problem?
Best Answer
Updated Answer
As of July 2020, it is possible to have
babel
select the correct language and font based on the language of the characters in the source. This allows me to post a complete answer to your question, which genuinely requires no explicit language tagging in the body of the document.This example did not really work correctly. I find when I look that the traditional Chinese font overrode simplified Chinese. Only the traditional Chinese font was used in the output, although I believe the simplified Chinese characters used different Unicode codepoints from their traditional counterparts. Be careful when two languages share the same script!
Original Answer
The
[hebrew]
package option ofbabel
does not really work any more. It tries to load a set of legacy fonts in the 8-bit LHE encoding. (In this case, it is not even looking for a Type 1 font, but the Metafont source for a bitmap font.) In theory, there’s a package called ivritex floating out there that’s supposed to provide backwards compatibility for this; in practice, the maintainer says that it’s a lot simpler to switch to Unicode. Using the new toolchain also obviates all the hacks needed to make UTF-8 and Unicode fonts mostly work with an inherently 8-bit TeX engine.The workaround is to load Hebrew with
\babelprovide[import=he]{hebrew}
instead. You must then pass the[bidi=default]
package option tobabel
for bidirectional text to work. To change the output encoding to Unicode, you need to define a set of fonts with\babelfont
.Here’s an example. I changed the
ctexart
document class toarticle
withbabel
, and set all the fonts withbabelfont
, mainly becausectex
has no English documentation. I couldn’t tell you how compatible it is with eitherbabel
orpolyglossia
. If it’s important to write in multiple languages without special markup, you could tryucharclasses
, but you might run into problems with right-to-left languages such as Hebrew or Arabic.“Without adding extra environments” is now a blatant lie. You can make Chinese the
main
language instead of English, but then you will have to localize certain strings such as the Table of Contents. The call togeometry
is solely to make the output fit within the allowed image size here.If you’re writing documents in Chinese and Hebrew, you presumably have fonts for these languages installed on your system already, and can replace the ones I picked with them. You do not need any special TeX fonts with
fontspec
; any modern system font will work. If you want to install the fonts I used in this example, you should do so from one of the following sources, in order. A: an operating-system package, such asfonts-noto-cjk
andculmus
on Ubuntu; B: a CTAN package, such asnotoCJKsc
; C: from the Culmus project and the Noto CJK homepage.This compiles with XeLaTeX, requires Babel 3.27 or later, and is written to work around the bug that
\babelfont
in 3.27 ignores default font features. There’s already a patch to fix this.