Type/Write in Hindi and Sanskrit with Latex

1 Star2 Stars3 Stars4 Stars5 Stars (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

\begin{document} Lets display a {\dn sloka} from Bhagwad Gita
{\dn karma.nyevAdhikaaraste maa phale.su kadaacana|} \\
{\dn maa karmaphalaheturbhurmaa te sa”ngo.astvakarma.ni||}

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...

About the Author

has written 346 posts on this blog.

Meditating towards his "nerdvana", lifehacker is a teacher by the day and a nerdy blogger by the night. He lives to learn and yearns to learn living.

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.

    Your reply will make things advanced for me.

    Thanks again.

    Like or Dislike: Thumb up 0 Thumb down 0


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

    Slash is missing in the command

    Like or Dislike: Thumb up 0 Thumb down 0


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

    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: Thumb up 0 Thumb down 0


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


    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.


    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?


    Like or Dislike: Thumb up 0 Thumb down 0


Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!


Copyright © 2018 Hack Your Life!. All rights reserved.
Proudly powered by WordPress. Developed by Deluxe Themes