typing sanskrit transliterations in Latex

2,179 views
Skip to first unread message

Vladimir Voevodsky

unread,
Jan 14, 2012, 9:46:35 AM1/14/12
to sams...@googlegroups.com
Hello,

is there a way to include sanskrit words typed with the US Extended keyboard into LATEX?

For example if write tā in a latex document (for which I have the encoding set to Unicode-8) I get the message:

***

Package inputenc Error: Unicode char \u8:ā not set up for
use with LaTeX.

See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...

l.533 tā

***


Thanks,
Vladimir.


Shreevatsa R

unread,
Jan 15, 2012, 12:57:20 AM1/15/12
to sams...@googlegroups.com, Vladimir Voevodsky
Hello,

The easiest way is to use XeTeX (xelatex). Just compile the input file by invoking "xelatex file.tex" (instead of "latex file.tex" or "pdflatex file.tex" that you normally use). Nothing else is required.

This will work if you want just the Romanized characters with diacritics. Since you're trying to type "tā" into the document, I guess you know how to enter these characters as input. (Else you can search for transliteration tools, e.g. this or this.) 
If you need characters in the Devanagari script too, you can try the instructions here: http://cikitsa.blogspot.com/2011/10/simplest-sanskrit-xelatex-file.html
If xelatex doesn't work for you for some reason, or you have some other trouble, please reply again and someone will be glad to help.

Regards,
Shreevatsa



--
You received this message because you are subscribed to the Google Groups "samskrita" group.
To post to this group, send email to sams...@googlegroups.com.
To unsubscribe from this group, send email to samskrita+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/samskrita?hl=en.


Nityanand Misra

unread,
Jan 15, 2012, 1:27:43 AM1/15/12
to sams...@googlegroups.com
Vladimir

You chose wisely to post here. I have gone through many painful nights while typesetting Sanskrit in LaTeX and can help you with this [and hopefully any more issues].

Latex can only process ASCII so even if you save the doc in Unicode format, it would not help. To type ā, simply enter the sequence \={a}. All diacritics, be it IAST or French or German can be accomplished in LaTeX using similar commands. For an example with several diacritics, see the attached input LaTeX file and output PDF generated using pdflatex.

If you have to type IAST many times over in LaTeX, this could be very annoying. In that case, you may want to use the "skt" package for LaTeX. Refer this page for more details. Essentially you type in blocks which begin with tags like "{\skt " et cetera, and then pass this document to a preprocessor which outputs a tex file which can be processed using pdflatex or latex. Personally I find the skt package good for IAST rendition, but the devnagari rendition is not very pretty - the glyphs are nowehere near print quality fonts like APS DV Priyanka.

For any other hiccups, feel free to follow up.

Thanks, Nityanand

--
You received this message because you are subscribed to the Google Groups "samskrita" group.
To post to this group, send email to sams...@googlegroups.com.
To unsubscribe from this group, send email to samskrita+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/samskrita?hl=en.




--
Nityānanda Miśra
http://nmisra.googlepages.com

|| आत्मा तत्त्वमसि श्वेतकेतो ||
(Thou art from/for/of/in That Ātman, O Śvetaketu)
     - Ṛṣi Uddālaka to his son, Chāndogyopaniṣad 6.8.7, The Sāma Veda
nityanandmisra.pdf
nityanandmisra.tex

Guru Das S

unread,
Jan 15, 2012, 3:12:02 AM1/15/12
to sams...@googlegroups.com
Hello Vladimir,

Your problem seems to have been addressed in this link: http://en.wikibooks.org/wiki/LaTeX/Accents#Related_issues

Typing diacritics and accents in LaTeX is very easy. Please try the commands as detailed in the above link. From the same link, you may easily identify the accent you're looking for (ā) as the "macron", which is produced by typing \={a}. Hope this answers your question :)

Guru.


vilasatu

unread,
Jan 15, 2012, 4:56:53 AM1/15/12
to samskrita
We have got the same problem 1 year ago. For now didnt find any
solution. I revert to microsoft word, because only this software can
read and works with devanagari without any troubles.

K

Vladimir Voevodsky

unread,
Jan 15, 2012, 6:04:29 AM1/15/12
to Shreevatsa R, sams...@googlegroups.com
Hello,

and thanks for the reply. Unfortunately, XeLaTeX did not produce the right output either, it just ignored ā as if it were not there.

Vladimir.

Shreevatsa R

unread,
Jan 16, 2012, 3:57:56 AM1/16/12
to Vladimir Voevodsky, sams...@googlegroups.com
Dear Prof. Voevodsky,

Sorry for the incomplete answer last time. The problem is that the default font does not contain the ā character.

1. So you have to set the default font to a font that covers the characters you need.
To do this you need the two lines "\usepackage{xltxtra}" and "\setmainfont{DejaVu Serif}" (or some other font that contains the characters). 
I have attached a minimal example as example-1.tex.

2. If you don't want to change the font for the entire document, you can change it for just the Sanskrit transliterations. I have attached an example as example-2.tex.

3. Actually, because there are only a few letters with diacritics in the standard Sanskrit transliteration, you can just use plain LaTeX instead of xelatex; in place of the characters

ā ī ū ṛ ṝ ḷ ṃ ḥ ṅ ñ ṭ ḍ ṇ ś ṣ

use

\={a} \={\i} \={u} \d{r} \d{\={r}} \d{l} \d{m} \d{h} \.{n} \~{n} \d{t} \d{d} \d{n} \'{s} \d{s}

(note the \={\i} instead of \={i}, so that you don't get a dot over i).

Out of these, the \usepackage[utf8]{inputenc} helps only with ñ and ś, so it's not much useful.

I have attached this as example-3.tex. And to save you the trouble of converting from Unicode characters to LaTeX-appropriate input, I've just written http://shreevatsa.appspot.com/transliteration/iast2tex.html where you can enter the Unicode characters on the left and get the corresponding LaTeX input on the right.

Hope this helps,
Shreevatsa
example-1.tex
example-2.tex
example-3.tex
example-1.pdf
example-2.pdf
example-3.pdf

Shreevatsa R

unread,
Jan 16, 2012, 5:08:27 AM1/16/12
to Vladimir Voevodsky, sams...@googlegroups.com
In fact, there is an even easier way with xelatex! Just \usepackage{fontspec} and it should cover all the IAST characters. Also, it's a good idea to put \tracinglostchars=2 in the document (this applies to my earlier examples too), so that warnings about missing characters go to the terminal also, instead of just the log file.

This method misses the "m with dot above", but the standard system of transliteration (IAST) has only "m with dot above", so if you're using transliterations according to that system, you should be fine.

For future reference, you can also ask TeX/LaTeX related questions on http://tex.stackexchange.com where I've found one gets good answers very quickly.

Example document (also attached):

\documentclass{article}
\tracinglostchars=2
\usepackage{fontspec}
\begin{document}

ā ī ū ṛ ṝ ḷ ḹ ṃ ḥ ṁ ṅ ñ ṭ ḍ ṇ ś ṣ

Ā Ī Ū Ṛ Ṝ Ḷ Ḹ Ṃ Ḥ Ṁ Ṅ Ñ Ṭ Ḍ Ṇ Ś Ṣ

\end{document}



example-4.tex
example-4.pdf

Vladimir Voevodsky

unread,
Jan 16, 2012, 6:51:37 AM1/16/12
to Shreevatsa R, sams...@googlegroups.com
This works!
Thank you very much,
Vladimir.


<example-4.tex><example-4.pdf>

Reply all
Reply to author
Forward
0 new messages