I have a project that is written both in Hebrew and in English, which is compiled with pdfLatex on Overleaf. Since this compiler is not a Unicode engine, one has to declare the Hebrew letters explicitly (as I learned here). This is the reason for the \DeclareUnicodeCharacter{---}{\heb---} commands in the preamble below.

It works fine, up until the moment I wanted to insert an image to my document, with a figure environment.

The main.tex and chapter01.tex files are given below, with the hierarchical file structure:

\documentclass{tufte-book} % Tufte-book format
% Encoding stuff
\usepackage[main=english, hebrew]{babel}

%% Herbew letters declarations %%
% and so on until

\usepackage{subfiles} % Best loaded last in the preamble. Used to break the content of the project into smaller files


כיתוב בעברית.
Some english text, and this is a figure:
% No figure!
root folder
| │ figure01.png
│ │ figure02.png
│ │ figure03.png
| │ chapter01.tex
| │ chapter02.tex
| │ chapter03.tex

The log has the following errors:

Missing \endcsname inserted.
Use of \m@^_ doesn't match its definition.
Missing number, treated as zero.
Extra \endcsname.
Undefined control sequence.   l.10  \includegraphics{figures/figure.png}

Can anyone address me to why it happens and how to fix it?


compilation output

  • If this is too much trouble to make latex work with hebrew alphabet and if as you suggested (tex.stackexchange.com/questions/586500/…) you only need it for the first page, I would suggest to create the first page separately and use pdfpages to include it in your document.
    – nlair
    Mar 16 at 21:13
  • I wasn't aware of this package. Seems correct to me.
    – tush
    Mar 16 at 21:22

This seems to be a clash between the changepage package (which is used by tufte-book) and the babel support for Hebrew, which changes to code for arabic numbers.

It will probably be solved by putting these lines in your preamble:


And the undefined control sequence can be solved by adding

  • Your suggestion helps to some extent. It solves the first four errors I noted in the original post, but Undefined control sequence. l.10 \includegraphics{figures/figure.png} is still there.
    – tush
    Mar 16 at 20:40
  • Actually, when I change the document class from tufte-book to article, for example, there seems to be no need for the \def\thecp@cntr{\@@arabic\c@cp@cntr} command you mentioned, but the "Undefined control sequence" error persists.
    – tush
    Mar 16 at 21:00
  • 1
    That is right, because it is caused by the changepage package and that is not used with the article class. And the undefined control sequence is probably because you forgot \usepackage{graphicx} Mar 17 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.