I want to write LaTeX where the main body of text is in Hebrew. The example here works fine. In fact, this is the only way I managed writing in Hebrew so far.

If I want the source code to present nicely in my editor (emacs 27), I need to use bidirectional unicode characters (such as LEFT-TO-RIGHT ISOLATE (u+2066)), which gives the error:

ERROR: Package ucs Error: Unknown Unicode character 8294 = U+2066

In order to deal with this, I thought about using newunicodechar to replace the bidirectional unicode with nothing when compiling the document.

The problem is that newunicodechar only works with \usepackage[utf8]{inputenc} and not with \usepackage[utf8x]{inputenc}, and Hebrew only works with \usepackage[utf8x]{inputenc} and not with \usepackage[utf8]{inputenc}.

How can I write in Hebrew and still have the special unicode characters in my file?

(I am using latexmk version 4.67.)

  • Remark, the ucs package may be incompatible with several packages... tex.stackexchange.com/questions/13067/utf8x-vs-utf8-inputenc/…
    – user202729
    Commented Mar 27, 2022 at 11:30
  • 1
    there is no reason to use utf8x really apart from some legacy compatibiliy uses, and no reason to explicily load inputnc at all as uf8 is the default Commented Mar 27, 2022 at 11:31
  • also you would not need newunicodechar you could use \DeclareUnicodeCharacter{2066}{} without needing any package. Commented Mar 27, 2022 at 11:32
  • @DavidCarlisle When I remove \usepackage[utf8x]{inputenc}, I get ERROR: Package inputenc Error: Keyboard character used is undefined, and if I replace it with \usepackage[utf8]{inputenc}, the Hebrew text simply does not render.
    – Erran
    Commented Mar 27, 2022 at 11:35
  • you have shown no code so it's hard to know what you have done wrong but babel should support hebrew (and I think in luatex should support automatic bidi detection) as I say using \usepackage[utf8]{inputenc} will do nothing unless you have very old latex as it is the default. Commented Mar 27, 2022 at 11:39


Browse other questions tagged .