Using babel with Hebrew in texlive

Many articles say that to use Hebrew with LaTeX, you should use xelatex instead of Tex Live (which is default on Ubuntu). It IS possible to write Hebrew using Tex Live, here is how. Working minimal example:

\documentclass{article}
\usepackage[utf8x]{inputenc} 
\usepackage[hebrew,english]{babel} 

\begin{document}
test
 \sethebrew
שלום
\end{document}

On my Ubuntu 12.10 installation this fails with this error (even though I have the packages ‘culmus’ and ‘texlive-lang-hebrew’):

kpathsea: Running mktextfm jerus10
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input jerus10
This is METAFONT, Version 2.718281 (TeX Live 2012/Debian)
kpathsea: Running mktexmf jerus10
! I can't find file `jerus10'.

Solution:

  1. Get the ‘jerus10.mf’ file from the hebtex LaTeX package (available on CTAN). Don’t install the package, it is deprecated (as in REALLY old).
  2. Put the ‘jerus10.mf’ file in the folder ~/texmf/fonts/source/hebrew/
  3. In terminal, run the command ‘texhash’. If it says ‘done’ without error, everything is fine.

The above file should work. It’s not particularily pretty and there are some compatibility issues with some packages that I might address another time. There are two possible error sources if you didn’t copy/paste carefully enough:

1. Enable UTF8X input

! Package inputenc Error: Keyboard character used is undefined
(inputenc)                in inputencoding `8859-8'.

or

! Package inputenc Error: Unicode char \u8:ש not set up for use with LaTeX.

If you want to write unicode Hebrew or copy-paste Hebrew from somewhere, you need to define the input encoding [utf8x], not only [utf8]:

\usepackage[utf8x]{inputenc} 

2. Be sure to change the language to Hebrew

! LaTeX Error: Command \hebshin unavailable in encoding OT1.

Fix this by declaring that the following text is Hebrew with

\sethebrew
This entry was posted in LaTeX and tagged , , , , by swk. Bookmark the permalink.

About swk

I am a computational linguist, teacher of computer science and above all a huge fan of LaTeX. I use LaTeX for everything, including things you never wanted to do with LaTeX. My latest love is lilypond, aka LaTeX for music. I'll post at irregular intervals about cool stuff, stupid hacks and annoying settings I want to remember for the future.