# Hebrew sections with cjhebrew (and hyprref)

I sometimes write hebrew words in english or german texts. For this I use cjhebrew. It works fine unless I try to write a section or subsection in hebrew. With

\subsection{\cjRL{kwl}}

I get

aTeX Font Warning: Font shape U/cjheb/bx/n' undefined
(Font)              using U/cjheb/m/n' instead on input line 27.

! Argument of \@sect has an extra }.
<inserted text>
\par
l.27   \subsection{\cjRL{kwl}}

(I tried \<...> before, same result).

The problem turned out to be an interference with hyperref. Which I use to link sections and the toc in the pdf-document. Is there an alternative either for hyperref or the section?

-
Can you produce a minimal working example? On my system (which is, I think, a standard bundle), I don't have this problem. – Daniel Harbour Jun 23 '12 at 17:50

This error message is a typical for a broken command during the conversion of section titles to bookmark strings.

Package cjhebrew uses a 7-bit font encoding for Hebrew that will not work in bookmark strings. Also \cjRL is not expandable and will not work either, even if the font problem could be solved. But the macro can be disabled during bookmark generation:

\pdfstringdefDisableCommands{%
\let\cjRL\@gobble % it can't be supported
}

The occurrences of \cjRL with their arguments are ignored in bookmarks.

To get Hebrew stuff in the bookmarks, hyperref needs option unicode, because PDFDocEncoding does not contain the Hebrew letters. \texorpdfstring allows to specify an alternative for the bookmarks.

The question remains, how to get Hebrew letters in bookmarks?

• If package inputenc is used with option utf8 or utf8x, then the characters can be given directly. Package hyperref uses these characters directly (bypassing the conversion via LICRs).
• Since 2012/07/30 v6.82w: \hebalef, \hebbet, …
• \unichar is supported that expects a numerical Unicode value. Thus U+05D0 HEBREW LETTER ALEF can be addressed as \unichar{"05D0} or \unichar{1488}.

Example file:

\documentclass{article}
\usepackage{cjhebrew}
\usepackage[unicode]{hyperref}
\usepackage{bookmark}

\pdfstringdefDisableCommands{%
\let\cjRL\@gobble % it can't be supported
}
\begin{document}
\cjRL{kwl}
\section{%
\texorpdfstring{\cjRL{kwl}}%
{\unichar{"05DB}\unichar{"05D5}\unichar{"05DC}}%
}

% with hyperref 2012/07/30 v6.82w or later
% \section{\texorpdfstring{\cjRL{kwl}}{\hebkaf\hebvav\heblamed}}
\end{document}
-

[This ought to be a comment, but I can't post it as such, owing to the picture.]

Could it be that you've got some interaction with other packages (if so, re-order), or a non-standard latex distribution? I ask because the following works fine on my system:

\documentclass{article}
\usepackage{cjhebrew}
\begin{document}
\cjRL{kwl}
\section{\cjRL{kwl}}
\subsection{\cjRL{kwl}}
\end{document}

-
Add \tableofcontents to see the (standard) problem with moving arguments ... – Ulrike Fischer Jun 25 '12 at 11:42
@UlrikeFischer Added \tableofcontents. Still no problem. Let me know if it would be useful to have the result posted here. Not sure whether the questioner is still following this. – Daniel Harbour Jun 26 '12 at 20:09
Sorry for the delay, I didn't had the time to solve this problem before. I searched for the package which might interfere and you were right. It turned out to be hyperref. I rephrase my question accordingly. – Nikodemus Jul 3 '12 at 9:15