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}
% <-this % stops an unwanted space
\thanks{Manuscript received mm dd, 20xx; revised mm dd, 20xx.
}
}

{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}

• Hyperref does nothing for printed documents (except change colors). Why would you use it with IEEEtran? – John Kormylo Jan 7 '18 at 18:06
• To add links to the citations and referencing – Sari Jan 7 '18 at 18:10
• Citations and references do not require hyperlinks. See the url package. – John Kormylo Jan 7 '18 at 21:36

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}

\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}
% <-this % stops an unwanted space
\thanks{Manuscript received mm dd, 20xx; revised mm dd, 20xx.
}
}

{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: