1

In my LaTeX document, I want to add Urdu, Arabic and Hindi characters. I have successfully added Arabic and Urdu text like this:

\setmainlanguage{english} 
\setotherlanguage{urdu} 
\setotherlanguage{arabic}

\newfontfamily\arabicfont[Script=Arabic,Scale=1, Path=font/]{Scheherazade-R.ttf} 
\newfontfamily\urdufont[Script=Urdu,Scale=1, Path=font/]{jameel_noori_nastaleeq.ttf} 

In my document, I put Urdu and Arabic characters like this:

\texturdu{ایک سو تئیس}     
\textarabic{١}

This works perfectly. Problem is that after searching a lot, I am unable to find a proper soultion for Hindi (Devangari). I have tried almost every solution found on TX.SX but non of them worked for me. Below are the solutions which I tried:

  1. Solution that is mentioned in link.

here is the code:

\documentclass{report}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{sanskrit}

\usepackage{fontspec}
\setmainfont{Times New Roman}
\newfontfamily\devanagarifont[Scale=MatchUppercase]{Devanagari MT}
\newfontfamily\devtransl[Mapping=DevRom]{Times New Roman}

\begin{document}
bollywood or \foreignlanguage{sanskrit}{बॉलीवुड}
\end{document}
  1. The solution mentioned in link.

here is the code:

\documentclass[12pt]{article}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainlanguage{english}
\setotherlanguages{sanskrit} %% or other languages

\newfontfamily\devanagarifont[Script=Devanagari]{Lohit Devanagari}

\begin{document}
The main text is in English, and you can add sanskrit quote...

\begin{sanskrit}
सर्वधर्मान् परित्यज्य मामेकं शरणं व्र्ज

अहं त्वां सर्वपापेभ्यो मोक्षयिष्यामि मा शुचः
\end{sanskrit}
\end{document}\documentclass[12pt]{article}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainlanguage{english}
\setotherlanguages{sanskrit} %% or other languages

\newfontfamily\devanagarifont[Script=Devanagari]{Lohit Devanagari}

\begin{document}
The main text is in English, and you can add sanskrit quote...

\begin{sanskrit}
सर्वधर्मान् परित्यज्य मामेकं शरणं व्र्ज

अहं त्वां सर्वपापेभ्यो मोक्षयिष्यामि मा शुचः
\end{sanskrit}
\end{document}
  1. I also tried to use solution in link but did not work either.

The only thing that work is using package devangari that works like this:

\documentclass{article}
\usepackage{devanagari}
\begin{document}
{\dn di"saa}
\end{document} 

The problem is that when I use devagari package, my references in bibiliography starts distorting. Normally my references appears like this.

enter image description here

But when I add use devangari package, my references starts appearing like this. enter image description here

and with this, page title "Bibliography" also disappears from document. Kindly tell me how can I add Hindi text in my document.

Note: I am using xelatex and biber.

naphaneal
  • 2,614

1 Answers1

2

You don't say what "does not work" means, did you get an error (such as font not found) or the wrong characters?

If you haven't got the font, or it is not available under that name you can use a different font, for example let your browser choose a font then use the same one,

I get

enter image description here

If I change your example to

\documentclass[12pt]{article}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainlanguage{english}
\setotherlanguages{sanskrit} %% or other languages

\newfontfamily\devanagarifont[Script=Devanagari]{Lohit-Devanagari.ttf}

\begin{document}
The main text is in English, and you can add sanskrit quote...

\begin{sanskrit}
सर्वधर्मान् परित्यज्य मामेकं शरणं व्र्ज

अहं त्वां सर्वपापेभ्यो मोक्षयिष्यामि मा शुचः
\end{sanskrit}
\end{document}
David Carlisle
  • 757,742
  • Actually none of them works as no hindi text appears on pdf when I used those solutions. In some cases, only boxes appears. Your solution works. I think problem was in font that i was using. As now it is working ok. Thanks alot. – Muhammad Hassan Jun 10 '18 at 11:10
  • 1
    @MuhammadHassan you should never get "no text" in the pdf without some message in the log file either an error that the font can not be found or a warning that the font does not have the requested character. – David Carlisle Jun 10 '18 at 11:11