# Type/Write in Hindi and Sanskrit with Latex

(No Ratings Yet)

Typing in Hindi or Sanskrit using LaTeX has been made simple with Devanagari. If you are already familiar with LaTeX then including text in Hindi, Sanskrit or several other Indian languages is relatively easy. This article describes how to go about doing that.

Linux users would need to install the following packages to get you started with creating documents using LaTeX with support for Devanaragi script, Ubuntu 9.10 users would like to do:

sudo apt-get install texlive-latex-base texlive-lang-indic texlive-fonts-recommended
sudo apt-get install ttf-devanagari-fonts

Now you need to create a document with extension .dn using you favourite word processor. Using this approach you type in Roman and the output would be in Devanagari. Go ahead and create a file called sample.dn and paste the following sample text in to it.

% Using devanagari in latex

\documentclass[12pt]{article}
\usepackage{devanagari}
\begin{document} Lets display a {\dn sloka} from Bhagwad Gita
\begin{center}
{\dn maa karmaphalaheturbhurmaa te sa”ngo.astvakarma.ni||}
\end{center}
\end{document}

NOTE: Because of auto formatting by WordPress which removes backslashes, I have replaced all “backslashes” with “forward slashes”, after copying the text do replace the forward slash with back slash, else the code won’t work.

Now at command prompt compile the file you just generated using devnag command like this:

devnag sample.dn


Now this is going to spit out a sample.tex file which should be compiled using latex to generate sample.dvi file which can be viewed using xdvi:

latex sample.tex
xdvi sample.dvi &

Finally you can convert .dvi to .pdf by following either of the two approaches:

Approach 1:
dvipdfm sample.dvi
Approach 2:
dvips sample.dvi
ps2pdf sample.ps

The resulting file would show something like this:

Some of the Roman characters for Hindi to English transliteration are not obvious and can be looked up for in the documentation for Devanagari. Windows (Miktex) users can find a similar guide here.

### You might also like

 Solution to Strange Error Thrown By Latex on Ubuntu 10.04 If your latex... All About LaTeX LaTeX is the... Quick Image Labeling using Preview – Snow Leopard Often times... Dabangg – Movie Review Cast: Salman...

## 4 Comments on “Type/Write in Hindi and Sanskrit with Latex”

• Balkrishna wrote on 27 April, 2010, 7:25

Thanks for providing steps to create Devnagari document.

The \ is missing in the beginning of each command in the given example.

Pl. also provide similar for writing Sanskrit document with accent.

Thanks again.

Like or Dislike: 0  0

• Balkrishna wrote on 27 April, 2010, 7:43

Slash is missing in the command

Like or Dislike: 0  0

• lifehacker wrote on 27 April, 2010, 12:43

@Balkrishna
The backslash problem was because of auto removal by WordPress. Thank you for pointing it out. I would try to write out a tutorial for your requirement soon.

Like or Dislike: 0  0

• Narayanan wrote on 28 October, 2016, 12:07

Hello,

This post was helpful. I would like to take it one step higher. This was already asked in Superuser.com as question and some just suggested latex.

http://superuser.com/questions/559287/how-to-type-one-character-over-another-in-microsoft-word

It would be nice if you can help how I can have numbers and other ascii characters over the sanskrit words when i type them in translieration mode?

Thanks.

Like or Dislike: 0  0