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: स्कूल
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI 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: स्कूल
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.
Improving on Manjunath's answer.
For example, I wanted to type disha.
Create a temporary document named temp.dn
with the following contents
\documentclass{article}
\usepackage{devanagari}
\begin{document}
{\dn di"saa}
\end{document}
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
devnag temp.dn
temp.tex
pdflatex temp.tex
temp.tex
file{\dn EdfA}
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:
\newenvironment{myhindi}{\newfontfamily\devanagarifont[Script=Devanagari]{Lohit Devanagari}\setmainfont{Lohit Devanagari}}{\par}
\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.
reference: this template, this answer
Taken from Overleaf docs
\usepackage[english]{babel} % English as the main language
\babelprovide[import]{hindi}
\babelprovide[import]{sanskrit}
%\babelfont[*devanagari]{rm}{Lohit Devanagari}
\babelfont[*devanagari]{rm}{BABEL Unicode}
...
Hindi: \foreignlanguage{hindi}{हिन्दी}
Sanskrit: \foreignlanguage{sanskrit}{संस्कृतम्}
We have to use XeLaTex engine instead of PdfLatex.
\documentclass{...}
and ending with\end{document}
.`
, 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).