# Arrows with Text (Using Unicode Devanagari fonts)

\documentclass[fleqn,12pt,a4paper]{article} % normal
\usepackage[utf8x]{inputenc}
\usepackage{fontspec,xltxtra,xunicode}
\usepackage{fontenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{color}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage{microtype}
\usepackage{cmll}
\usepackage{tabularx}
\usepackage{pifont}
\usepackage{amstext, amsmath}
\usepackage{unicode-math}

\setmathfont{Sanskrit2003}

\setmainfont[Script=Devanagari]{Sanskrit2003}

\begin{document}
$A\xleftarrow{n+\mu-1}B \xrightarrow[T]{n\pm i-1}C$  \\
$आज\xleftarrow{कल}अ \xrightarrow{पर्सो}तलवार$

\end{document}

• I tried to use this, the text above written in English works fine, however when I try Unicode devanagari font then I get arrows but no text. Your help would be greatly appreciated.
-
Would it work if you enclosed the devanagari texts in \mbox{}? –  Willie Wong Nov 20 '10 at 16:43
The text worked fine with \mbox however the arrow head was missing, I just got a line instead of an arrow. which is definitely progress however would be nice to get a solid arrow head. –  Aku Nov 20 '10 at 17:44
Hello Joseph, I take my words back. Actually now I can see the arrows instead of a solid line. –  Aku Nov 20 '10 at 17:58
Are you compiling this with XeLaTeX or with PdfTeX or some other engine? It looks … unusual with including inputenc, fontspec and fontenc in the same document. What happens if you exclude inputenc and fontenc? –  Mikael Vejdemo-Johansson Nov 20 '10 at 18:11
I am compiling it with Xelatex –  Aku Jan 18 '11 at 19:40

You should not use normal text directly in math mode, the English text will be treated as math and set in math italic (by default) with math spacing and so on, while other scripts will not be shown at all since default math fonts have only Latin (and some Greek also for math).

Instead you should set inside \text{} from amsmath, eg:

\documentclass{article} % normal
\usepackage{fontspec}
\usepackage{amstext, amsmath}

\setmainfont[Script=Devanagari]{Sanskrit2003}

\begin{document}
$A\xleftarrow{n+\mu-1}B \xrightarrow[T]{n\pm i-1}C$  \\
$\text{आज}\xleftarrow{\text{कल}}\text{अ} \xrightarrow{\text{पर्सो}}\text{तलवार}$

\end{document}


Also there are many issues with your preamble:

• \usepackage[utf8x]{inputenc} makes no sense with xelatex, remove it.
• \usepackage{fontenc} you don't need that one either
• \usepackage{microtype} current versions of microtype does not support xetex, so this one does nothing.
• \usepackage{unicode-math} & \setmathfont{Sanskrit2003} makes no sense too, unicode-math needs special OpenType math fonts and only Latin and Greek math are supported, so \setmathfont{Sanskrit2003} will just give you broken math (and using unicode-math without setting a math font is even more broken.)

Not sure about the rest, but it would be better to make sure you actually need them in your document.

-
+1 for pointing out preamble issues. It's good when someone takes the time to suggest improvements to one's code beyond fixing the issue at hand. –  Martin Tapankov Nov 20 '10 at 18:26
Khaled Wong & Mikael, Thanks a lot for your corrections, I am very new to LaTeX typesetting. –  Aku Nov 20 '10 at 19:16