[Tex/LaTex] IEEETran error when loading hyperref [TeX capacity exceeded]

errorshyperrefieeetran

When hyperref is loaded I receive the following error:

TeX capacity exceeded, sorry [input stack size=5000].

However, when I remove hyperref package it compiles successfully. I traced it back and found that \maketitle causes the error but don't know how to fix it. Is there any way to use hyperref in my setup.

Code:

    %!TEX TS-program = xelatex
    \documentclass[journal,transmag,]{IEEEtran}

    \usepackage[hyphens]{url}
    \usepackage{hyperref}

    \usepackage{xunicode} 
    \usepackage{fontspec}

    \usepackage{polyglossia}
    \setmainlanguage{english}
    \setotherlanguage{arabic}
    \newfontfamily\arabicfont[Script = Arabic]{Amiri} % Replace 'Simplified Arabic' with a font from your system


    \begin{document}
    \title{A Very Nice Title}

    \author{\IEEEauthorblockN{
            John Doe\IEEEauthorrefmark{1}}%,~\IEEEmembership{Member,~IEEE}
        \IEEEauthorblockA{\IEEEauthorrefmark{1}My address}
        % <-this % stops an unwanted space
        \thanks{Manuscript received mm dd, 20xx; revised mm dd, 20xx. 
             }
    }

    % The paper headers
    \markboth{headers...}%
    {Shell \MakeLowercase{\textit{et al.}}: Bare Demo of IEEEtran.cls for IEEE Transactions on Magnetics Journals}

    \IEEEtitleabstractindextext{%
        \begin{abstract}My Abstract.\end{abstract}

        % Note that keywords are not normally used for peerreview papers.
        \begin{IEEEkeywords}
            Key 1, Key 2
    \end{IEEEkeywords}}

    \maketitle 

    \IEEEdisplaynontitleabstractindextext
    % \IEEEdisplaynontitleabstractindextext has no effect when using
    \IEEEpeerreviewmaketitle


    \section{Introduction}
    English Text

    \begin{Arabic}

    السَلَامُ عَلَيكُمْ
    \end{Arabic}


    \end{document}

Best Answer

I found a similar issue with other document class that was answered by @egreg here

The issue was as I expected with \maketitle.

Working code:

 %!TEX TS-program = xelatex
\documentclass[journal,transmag,]{IEEEtran}

\usepackage[hyphens]{url}

\let\keptmaketitle\maketitle %<------------ADDED THIS LINE

\usepackage{hyperref}

\usepackage{xunicode} 
\usepackage{fontspec}

\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{arabic}
\newfontfamily\arabicfont[Script = Arabic]{Amiri} % Replace 'Simplified Arabic' with a font from your system

\let\maketitle\keptmaketitle %<------------ADDED THIS LINE
\begin{document}
\title{A Very Nice Title}

\author{\IEEEauthorblockN{
        John Doe\IEEEauthorrefmark{1}}%,~\IEEEmembership{Member,~IEEE}
    \IEEEauthorblockA{\IEEEauthorrefmark{1}My address}
    % <-this % stops an unwanted space
    \thanks{Manuscript received mm dd, 20xx; revised mm dd, 20xx. 
         }
}

% The paper headers
\markboth{headers...}%
{Shell \MakeLowercase{\textit{et al.}}: Bare Demo of IEEEtran.cls for IEEE Transactions on Magnetics Journals}

\IEEEtitleabstractindextext{%
    \begin{abstract}My Abstract.\end{abstract}

    % Note that keywords are not normally used for peerreview papers.
    \begin{IEEEkeywords}
        Key 1, Key 2
\end{IEEEkeywords}}

\maketitle 

\IEEEdisplaynontitleabstractindextext
% \IEEEdisplaynontitleabstractindextext has no effect when using
\IEEEpeerreviewmaketitle


\section{Introduction}
English Text \textarabic{مَرحَبَاً}

\begin{Arabic}

السَلَامُ عَلَيكُمْ
\end{Arabic}


\end{document}

Result:

enter image description here

Related Question