3

I have a similar problem to this question:

\usepackage[turkish]{babel} and \includegraphics inconcistency

But I am trying to do the same in hebrew. I get an error, and the solution offered in that question - setting \shorthandoff{=} doesn't seem to work with hebrew babel.

Minimal not working example:

\documentclass[12pt]{article}
\usepackage{culmus}
\usepackage[utf8x]{inputenc}
\usepackage[hebrew,english]{babel}

\usepackage{amssymb,amsmath}

\usepackage{graphicx}

\begin{document}


\R{

 שלום

\includegraphics[scale=0.5]{test}

שלום

}
\end{document}

Any ideas?

the L
  • 133
  • 2
    Welcome to TeX.SX! – Heiko Oberdiek Nov 19 '16 at 10:22
  • Thanks! I should add that replacing the include graphics line with: \includegraphics{test} (i.e, without the scaling) the result does compile. – the L Nov 19 '16 at 10:32
  • I cannot run the example: Package culmus is not in TeX Live and the found culmus.sty seems to be wrong, because it requires \usepackage[utf8]{inputenc} before \usepackage{culmus} because of \DeclareUnicodeCharacter. Also, TeX Live seems to miss the Hebrew fonts (automatic TFM generation fails). – Heiko Oberdiek Nov 19 '16 at 10:40
  • hebrew.ldf does not seem to use = as shorthand, thus the cause seems different to turkish.ldf. If it is a category code problem, then the command can be put into a macro, e.g.: \newcommand*{\TestImage}{\includegraphics[scale=0.5]{test}}\documentclass[12pt]{article}...\begin{document}...\R{...\TestImage...}...\end{document}. If this fixes the issue, then the cause can be a category problem, and the test also provides a workaround. – Heiko Oberdiek Nov 19 '16 at 10:45
  • Thanks for the suggestion. Putting it into a macro did not help unfortunately. – the L Nov 19 '16 at 10:48
  • Then it does not seem to be related to the category code problem of = in turkish.ldf. Are there any warnings or errors? Which TeX compiler (latex, pdflatex, lualatex, xelatex) is used? Is package culmus necessary for the problem (where can it be downloaded)? – Heiko Oberdiek Nov 19 '16 at 10:53
  • culmus is not nessecery, it just contains the font I am using (I think). I am using pdflatex, and the error I get is: pdfTex warning: pdflatex.exe: \pdfrestore missing \pdfsafe !pdfTex error: pdflatex.exe: 1 unmatched \pdfsave after page shipout – the L Nov 19 '16 at 10:58
  • 1
    Then left-to-right writing mode should be used with \includegraphics. – Heiko Oberdiek Nov 19 '16 at 11:18

1 Answers1

4

Short summary from the comments:

  • It is not a category code problem of =, because the equals sign is not a shorthand of hebrew.ldf.

  • The TeX compiler pdflatex is used.

  • The warning and error:

    pdfTeX warning: pdflatex: \pdfrestore: missing \pdfsave
    !pdfTeX error: pdflatex: 1 unmatched \pdfsave after page shipout
    

The order of \pdfsave and \pdfrestore is important. Obviously, the order get messed up by right-to-left-writing mode. This can be fixed by using left-to-right for \includegraphics:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[hebrew,english]{babel}
\usepackage{graphicx}

\begin{document}
\R{
  \L{\includegraphics[scale=0.5]{example-image-a}}
}
\end{document}
Heiko Oberdiek
  • 271,626