# Babel hebrew and koma-script letter

When I try to use babel hebrew together with the KOMA-Script letter class there is a sequence of errors. After looking at the file hebrew.ldf, I think the reason is that babel hebrew checks for a list of document classes like article or letter in order to find out whether commands like \thesection should be redefined. I also found this explanation mentioned on the internet, e.g. https://groups.google.com/forum/#!topic/de.comp.text.tex/_79cjuF_6m0 (in German).

I think this is the same problem as reported in Undefined control sequence Error with moderncv+Hebrew.

For classes like scrartcl there seems to be the easy solution to define these variables to be empty. However in the case of scrlttr2 these would be a lot of variables. So I am looking for a solution which does not include defining all these variables and preferably also does not include changing the babel hebrew files.

My minimal working example:

\documentclass{scrlttr2}
\usepackage[utf8x]{inputenc}
\usepackage[hebrew, english]{babel}
\usepackage{culmus}

\setkomavar{subject}{\foreinglanguage{hebrew}{שלום}}

\begin{document}
\begin{letter}{Example Person}
\opening{Dear Example,}
\ldots
\closing{Best regards,}
\end{letter}

\end{document}


All the errors are of the type "Undefined control sequence", like e.g.

ERROR: Undefined control sequence.

--- TeX said ---
<argument> \thesection

l.174 }

• Well one can fool rlbabel.def to think the document is a letter by using \makeatletter\@namedef{ver@letter.cls}{}\makeatother but then you get other errors (and unwanted changes). Imho the .ldf is simply unusable with newer classes, it would need a complete rewrite. – Ulrike Fischer Dec 6 '15 at 17:44
• Thank you! I tried your suggestion and as expected it resulted in new errors. Do you think that there is a chance that a complete rewrite will happen? – Christian Dec 7 '15 at 19:42
• I have doubts. Imho xelatex or lualatex along with polyglossia is the more promising route. But I don't know much about hebrew. – Ulrike Fischer Dec 7 '15 at 22:36

I would try to use class scrartcl together with package scrletter. So instead of telling hebrew.ldf that class letter has been loaded (see Ulrike's comment to the question) you could fake loading article class. Nevertheless there will still be an error message, because scrletter sets a label \label{\thisletter.lastpage} inside \end{letter}. This results in

\newlabel{\@@number {1}.lastpage}{{\beginL \@@number {1}\endL }{\@@number {1}}


in the aux file. The \beginL here results in an error message. I do not known whether or not \label is a general problem using babel-hebrew but you can use a simple patch to remove the last page feature if you do not need it.

With:

\documentclass{scrartcl}
\usepackage[utf8x]{inputenc}
\makeatletter\@namedef{ver@article.cls}{0000/00/00}\makeatother
\usepackage[hebrew,english]{babel}
\usepackage{scrletter}
\usepackage{culmus}

\setkomavar{subject}{\foreignlanguage{hebrew}{שלום}}
\usepackage{xpatch}
% remove label from \endletter
\xpatchcmd{\endletter}{\label{\thisletter.lastpage}}{}{}{}

\begin{document}
\begin{letter}{Example Person}
\opening{Dear Example,}
\ldots
\closing{Best regards,}
\end{letter}

\end{document}


I get:

I don't know whether or not this is the expected result. And I do not know whether or not this hack can be used for real Hebrew letters.

Indeed best would be to have a better babel-hebrew.