9

I want to write a document that will contain only Hebrew text (and some diagrams). I understand that babel is probably the best way to do it but I am getting utterly confused and haven't been able to attain Hello World level yet.

So I am asking for a minimal working example of a Hello World in Hebrew.

If that matters, I work in TeXnicCenter but am ready to switch anything else that runs under windows if necessary.

EDIT:

This is the file that produces the 100 errors:

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{hebrew} 
\newfontfamily{\hebrewfont}{New Peninim MT}
\setmainfont{New Peninim MT}

\begin{document}
\maketitle
\end{document}
  • 1
    My suggestion is to try XeLaTeX and Polyglossia, instead. Installing the Hebrew support for babel is rather painful. – egreg Oct 15 '13 at 17:00
  • @egreg Can you give me a MWE, please? – Felix Goldberg Oct 15 '13 at 17:13
  • Felix, you have some commented-out parts in your "file producing 100 errors"; please remove them from the example. – einpoklum - reinstate Monica Oct 15 '13 at 20:31
  • @einpoklum done - does that help? – Felix Goldberg Oct 15 '13 at 20:36
  • It does in that it's clear what the file has. However, it's not clear how this example is related to your question. I answered the first part of your question below. – einpoklum - reinstate Monica Oct 15 '13 at 20:42
8

I suggest you to try XeLaTeX and Polyglossia; in my experience, installing full Hebrew for babel has been painful. Not that I know any Hebrew, but I had to typeset some text in that language.

Here's an example. You may need to change the font name; what font to use depends on your operating system, but any OpenType or TrueType system font supporting Hebrew should be good. The \newfontfamily{\hebrewfont}{...} may be needed or not, depending on how the font advertises its support for Hebrew.

The text has been taken from the page on Jerusalem in the Hebrew Wikipedia, http://he.wikipedia.org/wiki/ירושלים

If http://translate.google.com is not mistaken, the title should mean “Hello world”.

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\setmainfont{New Peninim MT}
\newfontfamily{\hebrewfont}{New Peninim MT}
\begin{document}
\title{שלום עולם}
\author{שלום עולם}
\maketitle

העיר מקודשת ליהדות, לנצרות ולאסלאם, והיוותה מרכז חיי העם היהודי בימי
קדם ומושא געגועיו בזמן שהייתו בגלות. משום מרכזיותה בעולמם של המאמינים,
הייתה העיר מוקד למלחמות וסכסוכים הנמשכים עד עצם היום הזה. מאז סוף המאה
ה-19 התפתחו סביב העיר העתיקה שכונות העיר החדשה, המהוות כיום את רובה
המוחלט של העיר. במרכזה של ירושלים השלמה עומד הר הבית, שמפריד בין מערב
ירושלים למזרח ירושלים.

בשנת 1981 הוכרזה העיר העתיקה של ירושלים כאתר מורשת עולמית על ידי ארגון
אונסק"ו של האומות המאוחדות, והיא נמצאת ברשימת האתרים בסיכון.


\end{document}

enter image description here

  • I get an error about a missing expl3.sty file - can you help me with that? Many thanks! – Felix Goldberg Oct 15 '13 at 17:43
  • @FelixGoldberg What TeX distribution are you using? – egreg Oct 15 '13 at 17:46
  • Miktex 2.9 - should I upgrade or something? – Felix Goldberg Oct 15 '13 at 18:13
  • Okay, I updated miktex using the admin tool and now I get 100 (one hundred!) errors of the "Text line contains an invalid character" variety - even after I deleted all Hebrew text from the file. This is getting creepy and very very frustrating.... :( – Felix Goldberg Oct 15 '13 at 19:44
  • 2
    @FelixGoldberg Ensure you're saving your file as UTF-8 – egreg Oct 15 '13 at 21:01
3

Babel is not really the best choice for using Hebrew with LaTeX, but it was about the only choice for a very long time, and the XeLaTeX+polyglossia combination has still not caught on widely enough to supplant it. (Specifically, I wrote my Ph.D. thesis' Hebrew parts with eLaTeX and Babel, in 2011.)

So, here's the MWE you asked for:

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

\begin{document}
\selectlanguage{hebrew}
שלום, עולם.
\end{document}

The file needs to be in UTF-8 encoding (note it's utf8x up there, not utf8). If you want windows codepage 1255 encoding (single byte), use

\usepackage[cp1255]{inputenc}

instead of the utf8x line. Also, your TeX distribution should have the necessary packages/files installed to support compiling and rendering documents with Babel and Hebrew.

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.