'How to type Devanagari using LaTeX (Overleaf)?

I am trying type Devanagari Script in LaTeX using Overleaf. But I am getting some formatting error. The "matras" are not reflecting in the output Devanagari text.

\usepackage{devanagari}
{\dn karma}

Output is as follows:

Word Karma

but it should be

Should be



Solution 1:[1]

You need to pre-process your input data. If you have a file karma.dn

\documentclass{article}

\usepackage{devanagari}

\begin{document}
{\dn karma}

\end{document}

and call

devnag karma.dn

you get karma.tex like this:

\def\DevnagVersion{2.16}\documentclass{article}

\usepackage{devanagari}

\begin{document}
{\dn km\0}

\end{document}

Result:

enter image description here

The devnag program comes with the LaTeX package. It might be easier to use a Unicode capable LaTeX engine like XeLaTeX or LuaLaTeX together with suitable fonts.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1