# Problem when bidi & hyperref packages are used with custom document class (XeLaTeX)

There is a problem when bidi & hyperref packages are used together and custom document style is used. For example:

\documentclass[unicode]{myreport}

\usepackage{xltxtra}

\author{Author}
\title{Title}

\usepackage[pagebackref=true, xetex, unicode]{hyperref}
\usepackage{bidi}

\begin{document}

\maketitle

Test

\end{document}

myreport class is the exact copy of standard report class (nothing is changed). Problem is in \maketitle command. Result:

! TeX capacity exceeded, sorry [input stack size=5000].
\@ifnextchar #1#2#3->\let \reserved@d =#1
\def \reserved@a {#2}\def \reserved...
l.14

This error doesn't occur when:

1. hyperref package isn't used, or

2. standard report class is uded, or

3. \maketitle command isn't used

I can't find any information about such behavior neither in bidi nor in hyperref documentation, nor in google.

I see that bidi package uses command \@ifclassloaded and plugs files like report-xetex-bidi.def. Maybe such file should be created for custom docclass. But I saw this file and didn't find anything 'special' in it.

Bidi package is needed, since document will be multilingual with polyglossia and with some text in Arabic (and maybe other) language.

What can be done in this situation?

• I suspect that such behavior started since the last update, as I worked someway a week before. – Basil Peace Jun 24 '12 at 19:35
• Welcome to TeX.SX! There is something special in report-xetex-bidi.def: some commands, in particular \maketitle are redefined to cope with bidirectional input. A recommended practice is to \LoadClass{report} and do the desired modifications after this, instead of writing a class from scratch. – egreg Jun 24 '12 at 23:08
• Yes, \maketitle is redefined, but I don't see anything special in the redefined \maketitle. I see, that, if I don't use RTL characters in title page, all should work without redefinition. – Basil Peace Jun 25 '12 at 7:16
• Well, I do see special things in the redefined \maketitle which are important for allowing RTL in the title. – egreg Jun 25 '12 at 7:28
• This doesn't explain why hyperref package is involved. – Basil Peace Jun 25 '12 at 9:57