# How to type Hindi words in LaTeX

I am writing a thesis and have to write some Hindi words using LaTeX. When I use

\usepackage{devanagari}
removed. For example:
{\dn school}


the output generated is

I want output to be like this: स्कूल

• Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
– user31729
Sep 6 '14 at 5:36
• A tip: If you indent lines by 4 spaces or enclose words in backticks , they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).
– user31729
Sep 6 '14 at 5:36

You are probably not using the right Roman characters for the transliteration to work. As far as I have been able to figure out, in order to write "स्कूल" you would have to enter {\dn-\8{k}l} .

\documentclass{article}
\usepackage{devanagari}
\begin{document}
{\dn -\8{k}l}
\end{document}


outputs स्कूल. Make sure you get the capitalisation right.

This link might be of further help.

You might want to consider using unicode.

I use XeLaTeX with unicode source to produce multilingual documents with latex. It has the advantage of having the native characters in your source.

You'll need to change to using polyglossia, rather than babel, if you move in this direction.

\documentclass{article}
\usepackage{devanagari}
\begin{document}
{\dn skuula}
\end{document}


compile it using "devnag" compiler Results in following:

{\dn -\8{k}l}


and then run the generated ".tex" file in latex you will get the output required.

output:

स्कूल


Old question, but it could use an updated answer. LuaLaTeX can automatically detect which language you’re typing in, and change the font:

\documentclass[english]{article}
\usepackage[bidi=basic]{babel}
\usepackage{unicode-math}

\babelprovide[import, onchar=ids fonts]{hindi}

\defaultfontfeatures{ Scale=MatchUppercase,
Ligatures=TeX,
Renderer=HarfBuzz }
\babelfont{rm}
[Ligatures=Common, Scale=1.0]{Libertinus Serif}
\babelfont[hindi]{rm}
{Shobhika}
\babelfont{sf}
[Ligatures=Common]{Libertinus Sans}
\babelfont{tt}
{Libertinus Mono}
\setmathfont{Libertinus Math}

\begin{document}
... removed, for example: स्कूल.
Neat!
\end{document}


In XeLaTeX, you can type in Devanagari with the (buggy) package ucharclasses:

\documentclass[english]{article}
\usepackage[bidi=default]{babel}
\usepackage{unicode-math}
\usepackage{ucharclasses}

\babelprovide[import]{hindi}

\defaultfontfeatures{ Scale=MatchUppercase,
Ligatures=TeX }
\babelfont{rm}
[Ligatures=Common, Scale=1.0]{Libertinus Serif}
\babelfont[hindi]{rm}
{Shobhika}
\babelfont{sf}
[Ligatures=Common]{Libertinus Sans}
\babelfont{tt}
{Libertinus Mono}
\setmathfont{Libertinus Math}

\setDefaultTransitions{\selectlanguage{english}}{}
\setTransitionsFor{Devanagari}{\selectlanguage{hindi}}{\selectlanguage{english}}
\setTransitionsFor{DevanagariExtended}{\selectlanguage{hindi}}{\selectlanguage{english}}

\begin{document}
... removed, for example: स्कूल.
Neat!
\end{document}


You’ve already gotten several solutions for PDFTeX. Another one is to compile a word or short phrase as a standalone PDF and include it in your PDFTeX document. This allows you to embed a Unicode font that you can search and copy.

For example, I wanted to type disha.

1. Create a temporary document named temp.dn with the following contents

\documentclass{article}
\usepackage{devanagari}
\begin{document}
{\dn di"saa}
\end{document}

2. Depending on the word you want, try out some mapping from the document below. Save temp.dn https://drive.google.com/folderview?id=0B2SIfLcmTaRuX3lfWm5RZ2QyUzA&usp=sharing

3. devnag temp.dn

4. Above command produces temp.tex
5. pdflatex temp.tex
6. Above command generates a pdf.
7. Check if the pdf has the hindi word that you wanted.
8. Once you arrive at the word that you wanted, look at temp.tex file
9. You will see {\dn EdfA}
10. Copy this piece of code to your original tex file.

I tried many methods but most of them fail because of the custom \documentclass that I was using (ACM paper format). I did a little ablation and found out that \documentclass was the issue. So the thing that worked for me (on Overleaf) was:

1. Use XeLaTeX (by clicking on "Menu")
2. Use \newenvironment{myhindi}{\newfontfamily\devanagarifont[Script=Devanagari]{Lohit Devanagari}\setmainfont{Lohit Devanagari}}{\par}
3. Then \begin{myhindi} अगर बच्चे का स्कूल \end{myhindi}

And now you can just copy-paste whatever Hindi text you like.

If you are not able to use bold or italics non-Hindi text because of this method, then use \setmainfont[Mapping=tex-text, Ligatures=TeX]{Latin Modern Roman} above the newenvironment` command.

DISCLAIMER: Editing Hindi text in Overleaf editor is very difficult. So open a notepad from which you can edit and copy-paste.