2

The MNWE below fails to compile XeLaTeX. Compilation ends with an error because \MakeUppercase is undefined in the english environment.

Uncommenting the commented code permits compilation.

However, this surely should not be required in order to use a formatting command which is provided by the base LaTeX format.

How should the language/font setup be done so that Hebrew is the default document language, but \MakeUppercase works in the english environment?

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont[Script=Hebrew]{Noto Sans Hebrew}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Noto Sans Hebrew}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Noto Sans Hebrew}
\newfontfamily\englishfont[Ligatures=TeX]{Latin Modern Roman}
\setmainfont{Latin Modern Roman}
\setmonofont{Latin Modern Mono}
\setsansfont{Latin Modern Sans}
% \makeatletter
% \newcommand*\restoreuppercase{%
%   \DeclareRobustCommand{\MakeUppercase}[1]{{% from base/latex.ltx
%       \def\i{I}\def\j{J}%
%       \def\reserved@a####1####2{\let####1####2\reserved@a}%
%       \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
%       \protected@edef\reserved@a{\uppercase{##1}}%
%       \reserved@a
%     }%
%   }%
%   \protected@edef\MakeUppercase##1{\MakeUppercase{##1}}%
% }
% \makeatother

\begin{document}
\begin{english}
%   \restoreuppercase
  \MakeUppercase{english}
\end{english}
\end{document}
2

It is a bug in gloss-hebrew.ldf. In \noextras@hebrew it tries to restore \MakeUppercase without ensuring or checking that \MakeUppercase has been stored previously -- and as \noextras@hebrew is called the first time in a setup command at \begin{document} it fails.

\documentclass{article}

\usepackage{polyglossia}


\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont[Script=Hebrew]{FreeSerif}
\newfontfamily\hebrewfontsf[Script=Hebrew]{FreeSans}
\newfontfamily\hebrewfonttt[Script=Hebrew]{FreeMono}
\newfontfamily\englishfont[Ligatures=TeX]{Latin Modern Roman}
\setmainfont{Latin Modern Roman}
\setmonofont{Latin Modern Mono}
\setsansfont{Latin Modern Sans}

\makeatletter
\def\noextras@hebrew{%
   \ifcsname @@MakeUppercase\endcsname
   \let\MakeUppercase\@@MakeUppercase%
   \fi
   }
\makeatother

\begin{document}

\begin{english}
  \MakeUppercase{english}
\end{english}

\MakeUppercase{ירושלים}
\end{document}
2

I'd do it with letltxmacro:

\documentclass{article}
\usepackage{polyglossia}
\usepackage{letltxmacro}

\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont[Script=Hebrew]{FreeSerif}
\newfontfamily\hebrewfontsf[Script=Hebrew]{FreeSans}
\newfontfamily\hebrewfonttt[Script=Hebrew]{FreeMono}
\newfontfamily\englishfont[Ligatures=TeX]{Latin Modern Roman}
\setmainfont{Latin Modern Roman}
\setmonofont{Latin Modern Mono}
\setsansfont{Latin Modern Sans}

\makeatletter
\LetLtxMacro\latex@MakeUppercase\MakeUppercase
\newcommand*\restore@uppercase{%
  \LetLtxMacro\MakeUppercase\latex@MakeUppercase
}
\appto\blockextras@english{\restore@uppercase}
\appto\inlineextras@english{\restore@uppercase}
\makeatother

\begin{document}
\begin{english}
  \MakeUppercase{english}
\end{english}

\MakeUppercase{ירושלים}
\end{document}

enter image description here

  • Thanks! That is considerably more elegant. But is this really supposed to be needed at all? – cfr Aug 8 '16 at 1:22

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.