Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Welcome to TeX.sx! –  Torbjørn T. Jan 5 '12 at 22:06

2 Answers 2

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.

share|improve this answer
    
Oh excellent. Thanks so much. I will let you know how it goes. –  krishnab Jan 13 '12 at 17:37

Yes we do have a package in which transliteration is automaticallyenter image description here done. Try the skt package.

share|improve this answer
    
To make it visually pretty and scroll easily can you crop the .png and update your post. Thanks –  texenthusiast Jan 8 '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, –  Chandrasekhar Jan 9 '13 at 3:00
    
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 9 '13 at 5:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.