May 8, 2016

Using Devanagari within latex

  1. Using Devanagari within Latex
    1. Setup
      1. On Windows
      2. On Linux
    2. Calling Devanagari within latex
    3. Example

Using Devanagari within Latex

This is a small Tutorial on how to setup Latex with Devanagari output.

Setup

What you need before is a working latex environment.

On Windows

First of all you need to download and install the great Sanskrit2003 font, which is part of Omkarananda Ashram's Itranslator : Click here to do so, just unzip the file, right-click on the file Sanskrit2003.ttf and select 'install'.

On Linux

Extract the zip and copy the files to your truetype-folder.On Ubuntu/Debian systems, this is done with the following command:
sudo cp -rf Sanskrit2003.ttf /usr/share/fonts/truetype/

Calling Devanagari within latex

Next step is to create a new latex file or edit an existing one and add the following lines to the header:
\setdefaultlanguage{english}
\setotherlanguage{hindi}
\newfontfamily\devanagarifont[Script=Devanagari,Mapping=harvardkyoto]{Sanskrit 2003}  

Now we should be able to create Devangari output with the foreignlanguage-command anywhere in the body of the latex-file:

\foreignlanguage{hindi}{ahaM siMHaH}

If you wish to use a different mapping instead of harvard kyoto, just change the Mapping parameter:

\setdefaultlanguage{english}
\setotherlanguage{hindi}
\newfontfamily\devanagarifont[Script=Devanagari,Mapping=iast]{Sanskrit 2003}   

Inside the document:

\foreignlanguage{hindi}{ahaṃ siṃhaḥ}

For velthuis it goes like this:

\setdefaultlanguage{english}
\setotherlanguage{hindi}
\newfontfamily\devanagarifont[Script=Devanagari,Mapping=velthuis]{Sanskrit 2003}  

Inside the document:

\foreignlanguage{hindt}{aha.m si.mha.h}

Example

A full working minimal example is the following file (just copy and paste it to your editor and run):
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}  
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{hindi}
\newfontfamily\devanagarifont[Script=Devanagari,Mapping=harvardkyoto]{Sanskrit 2003}
\begin{document}
\foreignlanguage{hindi}{ahaM siMhaM}
\end{document}

Have fun! :)

Tags: latex sanskrit devangari