4

I am writing a document mainly in English but with words and sometimes sentences and paragraphs in Urdu - how do I do it in latex? Similarly if I am writing a document mainly in Urdu but with words, sentences, and paragraphs in English - how do I do it in latex?

1 Answer 1

3

This is possible by using a multilingual typesetting package called polyglossia which is usually used together with the font interfacing package fontspec. The documents must be processed using XeLaTeX engine instead of LaTex. Here are the MWEs and their outputs for both scenarios. This can be easily extended for different language combinations and for more than two languages in a single document. The only tricky bit is the interfacing to the relevant Urdu font. In my case I mostly work with Nastaleeq and have it installed on my computer. All I have to do is just add its name and location to make the document work.

% Must process/compile with XeLaTex
\documentclass[12pt]{article}

\usepackage{polyglossia}
\usepackage{fontspec}

\setmainlanguage{english} % the document is in English
\setotherlanguage{urdu}   % with some bits in Urdu
 % the following line specifies Urdu font and its location
\setmainfont{Jameel Noori Nastaleeq.ttf}[Path=/Users/ghalib/Library/Fonts/]

\begin{document}
\title{Introduction to Urdu Poetry}
\author{Roshan Dil}
\maketitle

A document mainly in English has Urdu words 
(\texturdu{ جملے کے درمیان میں اردو الفاظ}) within a sentence.
But  also has Urdu paragraphs like below,

\begin{urdu}
اردو کے مشہور شعرا میں میرتقی میر، غالب،جوش ملیح ٓابادی، شکیل بدایونی،
 اقبال اور فیض کا نام سر فہرست آتا ہے۔  اردو کے بارے میں اردو کا  ایک مشہور شعر
\begin{center}
اردو ہے جس کا نام ، ہمیں جانتے ہیں داغ \\
سارے جہاں میں دھوم ہماری زباں کی ہے\\
\hspace{6cm} (داغ دھلوی)
\end{center}

\end{urdu}
Returning  back to our writing in English.

\end{document}

enter image description here

And when the main document is in Urdu but has text in English:

\documentclass[12pt]{article}

\usepackage{polyglossia}
\usepackage{fontspec}

\setmainlanguage{urdu}
\setotherlanguage{english}
\setmainfont{Jameel Noori Nastaleeq.ttf}[Path=/Users/ghalib/Library/Fonts/]

\begin{document}
\title{غلام عباس کے افسانے}
\author{روشن دل}
\maketitle

غلام عباس کے افسانوں اور ان کے موضوعات کا ایک فکری مطالعہ پیش ہے۔

  ان موضوعات کی آفاقیت  ( \textenglish{Universality} )   ایک اہم ادبی پہلو ہے۔
 آنندی کے انگریزی ترجمے سے ایک اقتباس،
\par
\begin{english}
``Another  member  of  the  Council,  an  aged  pensioner  who  was  the
patron of an extensive family and who had by now already seen the hot
and cold of the world, who now had become weary of life’s struggles and
who  desired  only  to  relax  for  his  remaining  years  and  to  see  his 
family
prosper under his benign shadow, rose to speak."
\end{english}
\par
 اگرچہ یہ موضوع نیا نہیں ہے مگر غلام عباس نے اسے ایک مختلف انداز سے پیش کیا ہے۔
\end{document}

enter image description here

1
  • 1
    This comment is mainly to express how thankful I am to you, but since SX policy discourages such comments, here is a question: Is there a way to increase the spaces between words in Urdu? I love the Jameel Noori Nastaleeq font, but I need bigger spaces. Also btw, this technique works on overleaf as well. :)
    – Danyal
    Commented Jun 28, 2022 at 21:07

You must log in to answer this question.

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