13

I wanted to know if there is a way to transliterate devanagari texts within LaTeX itself. I have been using the wonderful polyglossia package, and I am able to enter Unicode devanagari texts into LaTeX and compile them. No problems. However, I was wondering if there is a way for LaTeX to convert Unicode devanagari fonts into romanized transliteration? The rules for devanagari transliteration are pretty well standardized, but I have not seen a package that does the transliteration in LaTeX--so that I don't have to keep making adjustments to both the devanagari and the transliteration each time.

If anyone has any suggestions about doing this in LaTeX, or even best practices outside of LaTeX, I would really appreciate it.

Torbjørn T.
  • 206,688
krishnab
  • 131

2 Answers2

11

You can use xetex input mapping feature. It is used to typeset transliterated devanagari. Other example is RomDev, for input in unicode transliteration. I haven't find any map file for conversion in the opposite direction, but it was not difficult to modify the RomDev map to go in the other way.

Download the file DevRom.map and compile it with

teckit_compile DevRom.map

Copy the resulting file DevRom.tec somewhere xetex can find it and run texhash.

Usage sample:

\documentclass{standalone}
\usepackage{polyglossia} 
\setdefaultlanguage{english} 
\setotherlanguage{sanskrit} 
\usepackage{xltxtra}
\usepackage{fontspec}
\setmainfont{Gentium}
\newfontfamily\devanagarifont[Script=Devanagari]{nakula.ttf}
\newfontfamily\devtransl[Script=Roman,Mapping=DevRom]{Gentium}
\begin{document}
\def\devanagarisample{%
उदु ज्योतिरमृतं विश्वजन्यं विश्वानरः सविता देवो अश्रेत् ।
क्रत्वा देवानामजनिष्ट चक्षुराविरकर्भुवनं विश्वमुषाः ॥ १ ॥
प्र मे पन्था देवयाना अदृश्रन्नमर्धन्तो वसुभिरिष्कृतासः ।
अभूदु केतुरुषसः पुरस्तात्प्रतीच्यागादधि हर्म्येभ्यः ॥ २ ॥ 
}
%\devscript
\noindent\textsanskrit\devanagarisample

\devtransl
\noindent\devanagarisample
\end{document}

Output:

Sample of devangari and transliteration from one source

Important lines are

\newfontfamily\devanagarifont[Script=Devanagari]{nakula.ttf}
\newfontfamily\devtransl[Script=Roman,Mapping=DevRom]{Gentium}

where we define font command for print devanagari using polyglossia and command for printing of the transliteration.

If you want output using another transliteration method, you can easily adjust map method yourself there are lines in the form

U+093D <> U+0027 ;unstyled apostrophe  

where is the input code, then output code and comment after the semicolon. Just swap input and output code.

michal.h21
  • 50,697
  • Oh excellent. Thanks so much. I will let you know how it goes. – krishnab Jan 13 '12 at 17:37
  • @krishnab I have added a mapping file to https://tex.stackexchange.com/questions/502515/reversing-text-mapping-devanagari-to-iast-transliteration?noredirect=1&lq=1 based on the IAST scheme. Perhaps it may be of some use. – Cicada Oct 15 '19 at 12:47
6

Yes we do have a package in which transliteration is automatically done.

screenshot

Try the skt package.

moewe
  • 175,683
C.S.
  • 1,379
  • To make it visually pretty and scroll easily can you crop the .png and update your post. Thanks – texenthusiast Jan 08 '13 at 18:06
  • @texenthusiast its not a .png its a .pdf, and I don't know to crop. In case you are familiar with go ahead and edit it. Regards, – C.S. Jan 09 '13 at 03:00
  • 1
    pdfcrop fileName.pdf at the command line terminal generates cropped pdf fileName-crop.pdf. Other approach might be to use standalone class instead of article class. It generates cropped pdf automatically generally used for Tikz Pictures. – texenthusiast Jan 09 '13 at 05:46
  • 1
    Just make a screenshot. – muk.li Oct 07 '15 at 14:19