Getting Hebrew Support Working with Pandoc

Your pandoc command expects a .html file as input*. It is thus normal that is does not work when you use a .tex file as input.

Indeed pandoc principle is the following:

.html-file -->[html-to-latex]--> .tex-file -->[(xe)latex compiling]--> .pdf-file
              |___________________________________________________|
                               pandoc, as a black-box

For example the following html document:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>My title</title>
  </head>
  <body>
    <h1>Lorem</h1>
    Ipsum dolor sit amet
  </body>
</html>

would be converted into such a tex document (this is a dummy example, just to explain the principle. I'm not sure the -->[html-to-latex]--> would give exactly the same output):

\documentclass{article}
   %<automatically loaded packages>
   \title{My title}
\begin{document}
   \section{Lorem}
   Ipsum dolor sit amet
\end{document}

Pandoc might include some packages in the preable (e.g. inputenc, etc.) but it is not smart enough to know that you want some specific package or settings (in your case \setmainlanguage{hebrew}, \setmainfont{Times New Roman}, and \newfontfamily{\hebrewfont}{New Peninim MT}). You should thus check pandoc's documentation to know how to include these settings in the preamble of your document.


* Well, it's a bit over-simplified, as pandoc as a much broader range of application. This simplification is for explanation purpose only.


Pandoc can work with unicode hebrew text, if the font configuration is right (the readers are omitting font info since they are not represented in pandoc's AST).

1. Configure fonts in pandoc explicitly

So you have to tell pandoc explicitly, which font to use: -V mainfont:"Times New Roman" And if you want to set the text direction to right-to-left you can use: -V dir:rtl

Which yields:

pandoc --latex-engine=xelatex \
        -V mainfont:"Times New Roman" \
        -V dir:rtl \
simple.tex -o test.pdf

enter image description here

pandoc --latex-engine=xelatex \
        -V mainfont:"Times New Roman" \
        -V dir:rtl \
simple.html -o test.pdf

enter image description here

2. Add the font configuration to the template:

You need a new file include.tex:

% include.tex
\setmainfont{Times New Roman}
\newfontfamily{\hebrewfont}{New Peninim MT}

also tell pandoc to use hebrew as main language: -V lang:he

Which yields:

pandoc --latex-engine=xelatex \
        -V lang:he \
        -H include.tex \
simple.tex -o test.pdf

enter image description here

pandoc --latex-engine=xelatex   
        -V lang:he \
        -H include.tex \
simple.html -o test.pdf

enter image description here