2

The following LaTeX code is saved in the file ~\test.tex:

\documentclass{article}

\usepackage{amsthm} \newtheorem{theorem}{Theorem}

%\usepackage{polyglossia} %\setmainlanguage{hebrew}

\usepackage{cleveref}

\begin{document} \begin{theorem}\label{mythm} A house is not a home. \begin{equation}\label{myeq} x+y=z \end{equation} \end{theorem}

Consider~\cref{mythm}, and compare it with~\cref{myeq}. \end{document}

When the following commands are executed in the Terminal:

cd ~
xelatex test

a PDF file is generated at the path ~\test.pdf. When opened in a PDF viewer, the file displays as follows:

cleveref without polyglossia

If now the two commented lines are uncommented, and the xelatex test command is rerun, the execution fails.

Is there a way to get the cleveref package to work with Hebrew, with eitherpolyglossia or babel as the language package? If not, is there another, similar package that works with Hebrew? If not, is there a simple way to emulate the cleveref package?

Mico
  • 506,678
Evan Aad
  • 11,066

1 Answers1

2

The cleveref package comes with several language modules. Unfortunately, hebrew isn't one of the package's supported languages. A workaround: load cleveref with an explicit language option -- say, english -- and then use the \addtocaptions{hebrew}{...} device to provide various \crefname directives suitable for hebrew. I'm afraid I don't speak or read Hebrew, so I can't be very specific.

enter image description here

% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{amsthm}

\usepackage{polyglossia} \setmainfont{Arial} \setmainlanguage{hebrew}

\usepackage[english]{cleveref} % set an explicit language option \newtheorem{theorem}{Theorem}

\appto{\captionshebrew}{% \crefname{theorem}{משפט}{משפט}% 3rd arg should be plural form of 2nd arg % \crefname{equation}{...}{...}% 3rd arg should be plural form of 2nd arg }

\begin{document} \begin{theorem}\label{mythm} A house is not a home. \end{theorem}

Consider~\cref{mythm}. \end{document}

Mico
  • 506,678
  • Is there a way to make it work for both Hebrew and English? If I use this patch, then Hebrew references work fine, but English references (from otherlanguage environment or \selectlanguage{english}) don't work anymore. If I don't use this patch, then English works and Hebrew doesn't. Is there a way to apply this patch only when the Hebrew language is selected? – Shai Avr Aug 26 '23 at 21:01
  • @ShaiAvr - You ask a really good question! Unfortunately, I don't understand the babel or polyglossia machinery well enough to be able to offer a usable answer. It's not by accident that my answer makes use of the cleveref machinery, which operates independently of the babel/polyglossia machinery. It so happens that I'm very familiar with cleveref. Unfortunately, nobody has so far provide a Hebrew language module for cleveref. – Mico Aug 26 '23 at 21:22
  • I would like to help contribute Hebrew translations for cleveref (I am a native Hebrew speaker). However, I have no experience with the procedure. I tried to read the docs, but I have no experience with dtx files and I don't understand where to find existing definitions to know what needs to be translated and how. – Shai Avr Aug 27 '23 at 10:01
  • @ShaiAvr - That's a wonderful offer! Please contact Toby Cubitt, the author of the cleveref pacakge, directly. I have to warn you, though, that Toby appears to have moved on from the cleveref package to new interests in recent years. The most recent update to cleveref occurred in early 2018, and he doesn't appear to answer cleveref-related emails anymore. (At least, he hasn't answered my emails in a while...) But if you contact him with an offer to provide Hebrew translations of equation, theorem, section, etc, he might respond. Keeping my fingers crossed! – Mico Aug 27 '23 at 10:16