9

I use Sanskrit 2003 for my bilingual document. But the English so generated result in a very uneven and poorly looking document. I can not modify the text in between \begin{document} and \end{document} as it is generated by a software. So I can modify the preamble of a template only.

How can I use Bookman or Garamond for English and Sanskrit 2003 for Hindi? I am at present using folllowing lines in preamble

\setmainfont[Script=Devanagari]{Sanskrit 2003}
\setsansfont[Script=Devanagari]{Sanskrit 2003}
\setmonofont[Script=Devanagari]{Sanskrit 2003}
4
  • 2
    I believe that the ucharclasses package is precisely what you're looking for. Can you add some text in Hindi and English to play with?
    – egreg
    Jul 29, 2013 at 11:23
  • I am getting following error in file gloss-english.ldf line 6: \do undefined. }
    – Vaibhav
    Jul 30, 2013 at 5:23
  • You should upgrade your TeX distribution; that error has been recently corrected.
    – egreg
    Jul 30, 2013 at 9:14
  • When I type दिन तिन on tex file , the pdf generated showed दनि तनि. Why is it happeninig ? I used Sanskrit 2003 and Mangal as font.
    – Vaibhav
    Jul 30, 2013 at 9:42

1 Answer 1

11

The ucharclasses package makes this possible.

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage[Latin,Devanagari]{ucharclasses}

\setmainfont{Devanagari MT}

% Maybe Sanskrit 2003 doesn't need the following line;
% in this case change \devanagarifont in the \setTransitions
% commands to \normalfont
\newfontfamily{\devanagarifont}{Devanagari MT}

% choose the font for English
\newfontfamily{\englishfont}[Ligatures=TeX]{TeX Gyre Pagella}

\setmainlanguage{hindi}
\setotherlanguage{english}

\setTransitionsFor{Latin}
  {\hyphenrules{english}\englishfont}
  {\hyphenrules{hindi}\devanagarifont}
\setTransitionsFor{Devanagari}
  {\hyphenrules{hindi}\devanagarifont}
  {\hyphenrules{english}\englishfont}

\begin{document}

नई दिल्ली, भारत की राजधानी है। कुल ४२.७ वर्ग किमी क्षेत्रफल के साथ, नई दिल्ली दिल्ली महानगर 
के भीतर आता है और यहाँ पर भारत सरकार और दिल्ली सरकार के सभी प्रशासनिक भवन स्थित हैं।

New Delhi is the capital of India, and the seat of executive, legislative, and judiciary 
branches of the Government of India. It also serves as the centre of the Government of the 
National Capital Territory of Delhi. New Delhi is situated within the metropolis of Delhi 
and is one of the eleven districts of Delhi National Capital Territory.

नई दिल्ली, भारत की राजधानी है। कुल ४२.७ वर्ग किमी क्षेत्रफल के साथ, नई दिल्ली दिल्ली महानगर 
के भीतर आता है और यहाँ पर भारत सरकार और दिल्ली सरकार के सभी प्रशासनिक भवन स्थित हैं।

\end{document}

enter image description here

Hindi text from hi.wikipedia.org, on the page corresponding to the en.wikipedia.org page for New Delhi.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .