This question already has an answer here:

Casual LaTeX user here, so if something seems dumb/obvious, it probably is.

I'm want to use LaTeX (via pandoc) to create PDFs that contain hebrew characters.

I found this answer where someone appears to have solved a similar problem. However, when I create a utf-8 text file (working.tex) with the same content

\setmainfont{Times New Roman}
\newfontfamily{\hebrewfont}{New Peninim MT}
\title{שלום עולם}
\author{שלום עולם}

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

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


and then use pandoc to convert that to a PDF

pandoc --latex-engine=xelatex working.tex -o working.pdf 

and then open the PDF

enter image description here

I get zero hebrew characters.

Is there anything wrong with the above document? Are there common troubleshooting tips for getting hebrew working with LaTeX and pandoc?

marked as duplicate by Martin Schröder, TeXnician, Troy, Andrew Swann, CarLaTeX Jun 18 '17 at 11:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Welcome to TeX.SX! The minimal working example (MWE) you show is a .tex file. It should thus be directly compiled with xelatex. (Have you tried xelatex working.tex ?) Another issue might come from the font. – ebosi Jun 17 '17 at 3:13
  • @ebo Thank you! Invoking xelatex directly and changing the Hebrew font to \newfontfamily{\hebrewfont}{FreeSans} seems to have done it. Happy to marks your as the correct answer if you want to move it out of the comments. Also, and this may be beyond your remit -- do you have any idea why invoking xelatex directly vs. invoking pandoc with --latex-engine=xelatex would produce different results, or how a newbie/casual user might start debugging/understanding that? – Alan Storm Jun 17 '17 at 4:46

Your document is a .tex file. It should thus be directly compiled with xelatex via following command:

xelatex <filename>

(you can ommit the .tex extension)

XeLaTeX means compiling, using the XeTeX engine, a document that uses a set of macros defined in the LaTeX format (on top of the original 'plain TeX').

What pandoc does is first to transform (beyond the hood) a document that is not a .tex file into such one, and then compile it. The first step (convertion) is thus here unnecessary.

Finally, the command \newfontfamily{\hebrewfont}{New Peninim MT} tells XeLaTeX to use the font New Peninim MT. You must ensure this font is installed on your system and that the reference is correct.

  • Thanks agin @ebo! If you have the time and inclination -- I'm still interested in perusing why this doesn't work with pandoc (as part of debugging pandoc converting some HTML files for me) and have opened a new question: tex.stackexchange.com/questions/375380/… – Alan Storm Jun 17 '17 at 6:24

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