0

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.)

Erran
  • 1
  • 1
  • Remark, the ucs package may be incompatible with several packages... https://tex.stackexchange.com/questions/13067/utf8x-vs-utf8-inputenc/13070#13070 – user202729 Mar 27 '22 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 – David Carlisle Mar 27 '22 at 11:31
  • also you would not need newunicodechar you could use \DeclareUnicodeCharacter{2066}{} without needing any package. – David Carlisle Mar 27 '22 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 Mar 27 '22 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. – David Carlisle Mar 27 '22 at 11:39
  • @DavidCarlisle Using \DeclareUnicodeCharacter{2066}{} (actually \DeclareUnicodeCharacter{8294}{} worked for ignoring the character. – Erran Mar 27 '22 at 11:42
  • the babel manual (texdoc babel has this example which works with lualatex) \documentclass{article} \usepackage[swedish, bidi=default]{babel} \babelprovide[import]{hebrew} \babelfont{rm}{FreeSerif} \begin{document} Svenska \foreignlanguage{hebrew}{‫ } ִעבְ ִרית‬svenska. \end{document} – David Carlisle Mar 27 '22 at 11:45
  • @DavidCarlisle It kind of does, though it's a bit more specific. The DeclareUnicodeCharacter part is what I was looking for. More generally there is still a lot I don't understand regarding usage of hebrew in latex, but I thing going over the links in this thread should help me to start understanding it. – Erran Mar 27 '22 at 12:14
  • OK feel free to ask more questions if you get stuck, but do try to avoid ucs and the utf8x inputenc they were early contribued packages but don't really fit currently maintained latex code. So if you have old documents that were using them they should still work but they shouldn't be used on new documents. – David Carlisle Mar 27 '22 at 12:47

0 Answers0