Hebrew letters in a math equation

1,975

The following .lyx file works for me. I went to Document > Settings > Fonts and clicked on "use non-TeX fonts", then I set the fonts to the Free{Serif,Sans,Mono} fonts. Then I exported to PDF with XeTeX.

#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass article
\use_default_options true
\maintain_unincluded_children false
\language hebrew
\language_package default
\inputencoding auto
\fontencoding global
\font_roman FreeSerif
\font_sans FreeSans
\font_typewriter FreeMono
\font_default_family default
\use_non_tex_fonts true
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_amsmath 1
\use_esint 1
\use_mathdots 1
\use_mhchem 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
\begin_inset Formula $a+b=\text{םולש}$
\end_inset


\end_layout

\end_body
\end_document

The following .tex files is produced from the above .lyx file:

%% LyX 2.1.0dev created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english,hebrew]{article}
\usepackage{amstext}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{FreeSerif}
\setsansfont[Mapping=tex-text]{FreeSans}
\setmonofont{FreeMono}
\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
$a+b=\text{םולש}$  
\end{document}

I get the following output:

enter image description here

Share:
1,975
pazbunis
Author by

pazbunis

Working on the sensing side of Autonomous driving.

Updated on August 01, 2022

Comments

  • pazbunis
    pazbunis over 1 year

    I'm using the Lyx editor.

    Is it possible, in general, to mix Hebrew characters in a math formula ("math-mode" in Lyx)?

    When trying to compile a Lyx file with Hebrew in a math formula I get this kind of error:

    LaTeX Error: Command \hebgimel unavailable in encoding T1.

    LaTeX Error: Command \hebayin unavailable in encoding T1.

    Example of a .Lyx file which gives the mentioned error: http://pastebin.com/UvPTwML1

    Example of a .tex file which gives the mentioned error: http://pastebin.com/61VES9wV

    • barbara beeton
      barbara beeton almost 10 years
      more information would be useful. however, you might try \text{\hebgimel} to temporarily "release" you from math mode constraints while remaining in math mode for the main expression (requires amsmath).
    • scottkosty
      scottkosty almost 10 years
      Can you post both a MWE .lyx file and the exported .tex file please? Does Hebrew work for you outside of math formulas? Are you using XeTeX to compile?
    • pazbunis
      pazbunis almost 10 years
      Hebrew works outside math formulas. I'll add the MWEs to the post.
    • pazbunis
      pazbunis almost 10 years
      @barbarabeeton: which details could help? (the solution you've mentioned is in fact the way I was doing it initially)
    • barbara beeton
      barbara beeton almost 10 years
      @user2190298 -- re details, it's recommended to post the actual (non)compilable example (not just a link; those sometimes go dead, and we like to think of this forum as a "perpetual resource"). that allows readers to make most efficient use of their time in tackling the problem.
    • theHigherGeometer
      theHigherGeometer over 9 years
      What's wrong with plain ol' \gimel in maths mode? Admittedly, only אבגד work this way.
  • pazbunis
    pazbunis almost 10 years
    I tried changing the fonts as you wrote, but that didn't work either. Also, when trying to compile (using TeXworks) the .tex file you produced with XeTex I get this Error: Undefined control sequence. l.3 \documentclass [english,hebrew]{article}
  • scottkosty
    scottkosty almost 10 years
    @user2190298 What about when trying to compile the .lyx file with XeTeX (you put that you tried changing the fonts separately and that you tried compiling the .tex file but not that you tried the .lyx file)? I am on Ubuntu with TeX Live 2013 by the way.
  • pazbunis
    pazbunis almost 10 years
    I tried compiling the .lyx file but that goes into some infinite loop until I get a "stop" message from LyX. I'm using MS Windows so I used MS sans serif (since I don't have the free package). I'm using LyX 2.0.5.1.
  • scottkosty
    scottkosty almost 10 years
    @user2190298 Can you compile the Hebrew splash (open Examples/he/splash.lyx) with XeTeX and those fonts? If not, I would suggest trying different fonts (that support Hebrew).
  • pazbunis
    pazbunis almost 10 years
    I actually have a problem compiling the Hebrew splash screen with XeTex (the pdf is created but with gibberish). When I use ps2pdf or dvipdfm it comes out Okay, though.
  • scottkosty
    scottkosty almost 10 years
    @user2190298 OK then that explains why the XeTeX solution here doesn't work. If you get XeTeX + Hebrew working for you then it will. If you happen to feel adventurous, you can compile your .lyx file with 4 simple (but time-consuming) steps: 1. Install Ubuntu (dual boot or virtual machine). 2. run git clone https://github.com/scottkosty/install-tl-ubuntu 3. cd to the folder and run sudo install-tl-ubuntu --hebrew (this is what will take a few hours) 4. Install LyX: sudo apt-get install lyx. I'm sure you can get it working on Windows also, I just don't know what to suggest for it.
  • pazbunis
    pazbunis almost 10 years
    I've been planning to install Ubuntu as an additional OS, so I will and try what you've said. Thanks for the constructive help!
  • scottkosty
    scottkosty almost 10 years
    @user2190298 sounds good.