# Hebrew with English in a multicol setting

I'm trying to write a cheat sheet for a physics course, so the document is to be divided to 3 columns or so, using multicol. I've managed to get through the configuration of Hebrew and of the multi-columns (using a template I found).
Still, some problems persist despite an effort to resolve them myself:

1. The english words are reversed in my current configuration. For example, when I write in the source code English words reversed it is presented in the output/PDF as reversed words English.
2. Failure to use some fonts, such as Nachlieli CLM (I'm using it with LibreOffice all the time).

The tex code is (some code omitted for brevity. You can also see some of my attempts to resolve the problem - to no avail..):

\documentclass[10pt]{article}

\usepackage{multicol}
\usepackage{calc}
\usepackage{ifthen}
\usepackage{geometry}
\usepackage{hyperref}

%%\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setmainlanguage{hebrew}

%\setmainfont{Arial}
%\newfontfamily{\hebrewfont}{Arial}
\setmainfont{DejaVu Sans}
\newfontfamily{\hebrewfont}{DejaVu Sans}
%\setmainfont{Nachlieli CLM}
%\newfontfamily{\hebrewfont}{Nachlieli CLM}

%%% The next block of code is a COMMENT
\iffalse
\usepackage{polyglossia}

\setdefaultlanguage{hebrew}
\setmainlanguage{english}
%\setotherlanguage{hebrew}

\usepackage{fontspec}
\setmainfont{DejaVu Sans}
\fi

% This sets page margins to .5 inch if using letter paper, and to 1cm
% if using A4 paper. (This probably isn't strictly necessary.)
% If using another size paper, use default 1cm margins.
\ifthenelse{\lengthtest { \paperwidth = 11in}}
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
{\geometry{top=0.4cm,left=0.4cm,right=0.4cm,bottom=0.4cm} }
{\geometry{top=0.4cm,left=0.4cm,right=0.4cm,bottom=0.4cm} }
}

% Turn off header and footer
\pagestyle{empty}

% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%x
{\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
{-1explus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%
{\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{1ex plus .2ex}%
{\normalfont\small\bfseries}}
\makeatother

% Don't print section numbers
\setcounter{secnumdepth}{0}

\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}

% -----------------------------------------------------------------------

\begin{document}

%\raggedright
\title{שלום עולם}
\author{Dor}
%\maketitle

%\raggedright
\footnotesize
\begin{multicols}{3}

% multicol parameters
% These lengths are set only within the two main columns
%\setlength{\columnseprule}{0.25pt}
\setlength{\premulticols}{1pt}
\setlength{\postmulticols}{1pt}
\setlength{\multicolsep}{1pt}
\setlength{\columnsep}{2pt}

\begin{center}
\Large{\textbf{שלום עולם}} \\
\end{center}

\section{English words reversed}
כוח לורנץ
$\int_0^\infty x d x$
העיר מקודשת ליהדות, לנצרות ולאסלאם, והיוותה מרכז חיי העם היהודי בימי
קדם ומושא געגועיו בזמן שהייתו בגלות. משום מרכזיותה בעולמם של המאמינים,
הייתה העיר מוקד למלחמות וסכסוכים הנמשכים עד עצם היום הזה. מאז סוף המאה
ה-19 התפתחו סביב העיר העתיקה שכונות העיר החדשה, המהוות כיום את רובה
המוחלט של העיר. במרכזה של ירושלים השלמה עומד הר הבית, שמפריד בין מערב
ירושלים למזרח ירושלים.

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

\end{multicols}
\end{document}

The execution of xelatex produces the following output/PDF:

I have tried a lot of suggestions that I saw on the net but none were helpful. I've also tried using Lyx instead, but it has it's own problems..

The "ideal" document for me is one which:

1. Allows writing a document with UTF8 encoding.
2. Recognizes the direction (RTL/LTR) by the language that is written - which is exactly what happens with LibreOffice and every normal program.
3. Allows the usage of fonts which are already installed in my system.
• TeX has no module that does text analysis and guesses your current language, so you have to tell it what is English and what Hebrew, as you don't, it assumes everything is Hebrew which gives you the current result.. – Frank Mittelbach Apr 27 '16 at 6:19
• @FrankMittelbach Haven't anyone thought of that ?! It seems one of the most basic modules. Why should anyone get complicated with commands that set the direction (RTL/LTR) instead of simply recognizing the language and setting the direction appropriately ... Packages like bidi "shouldn't exist" or at least shouldn't be used as extensively as nowadays. – Dor Apr 27 '16 at 9:16
• Too late, but it worth noting babel now provides a bidi mode (for luatex) switching the direction depending on the script, without explicit markup. It is almost finished, but should be considered beta. See the sample on github.com/latex3/latex2e/blob/master/required/babel/samples/… . – Javier Bezos May 3 '18 at 13:56

To fix issue 1, get rid this:

\setdefaultlanguage{hebrew}
\setmainlanguage{hebrew}

%\setmainfont{Arial}
%\newfontfamily{\hebrewfont}{Arial}
\setmainfont{DejaVu Sans}
\newfontfamily{\hebrewfont}{DejaVu Sans}
%\setmainfont{Nachlieli CLM}
%\newfontfamily{\hebrewfont}{Nachlieli CLM}

%%% The next block of code is a COMMENT
\iffalse
\usepackage{polyglossia}

\setdefaultlanguage{hebrew}
\setmainlanguage{english}
%\setotherlanguage{hebrew}

\usepackage{fontspec}
\setmainfont{DejaVu Sans}
\fi

and replace it with this:

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont[Script=Hebrew]{DejaVu Sans}
\newfontfamily\englishfont[Ligatures=NoCommon]{Linux Libertine O}

And then write \section{\textenglish{English words reversed}} instead of \section{English words reversed}. Now the English is LTR.

As for issue 2, you probably just don't have those fonts on your system, which is what XeLaTeX needs. Download them and put them in your font folder.

AML already gave a good answer to the bidirectional problem Use \textenglish{hello} or \texthebrew{שלום} for short phrases, \begin{english} or \begin{hebrew} for sections of a paragraph or longer. These are optional for your main language, but will make it easier to copy-and-paste into a document with a different main language.

For the font, make sure you’ve installed the culmus package with your package manager, or download the files from SourceForge. (As a regular user on Linux, you would want to copy the .otf files to ~/.fonts/ to install fonts only for yourself. On other OSes, double-click on the .otf files to launch a preview and installer.) You might need to use the name Nachlieli CLM Light or NachlieliCLM-Light.otf. The following might work for you:

\newfontfamily\hebrewfont{NachlieliCLM-Light.otf}[
BoldFont = NachlieliCLM-Bold.otf,
ItalicFont = NachlieliCLM-LightOblique.otf,
BoldItalicFont = NachlieliCLM-BoldOblique.otf,
Script = Hebrew,
Scale = MatchUppercase
]

You also probably want to configure polyglossia with \setmainlanguage and \setotherlanguage, not \setdefaultlanguage.

If you’re sure the font is installed, and you’re on Linux, try find /usr -iname "Nachlieli*.otf" -print to find the font files. If there’s some directory that’s not currently in your font path, but you want to make the fonts there available to all applications, you can put a symbolic link to it under /usr/local/share/fonts.