# vedic symbols in XeTeX

How do I produce the vedic, anudatta and udatta via XeTeX. The one in this links gives

http://mirrors.ctan.org/language/devanagari/velthuis/doc/generic/velthuis/xetex-examples.tex

The normal Sanskrit compilation works but the vedic accents if compiled with similar commands doesn't work.

• Does anyone how we can work with XeTeX for typesetting Vedic Mantras or Texts.
\documentclass[12pt]{article}
\usepackage{ifxetex}
\RequireXeTeX
\usepackage{fontspec}
\newcommand\dn{\catcode\~=12
\fontspec[Script=Devanagari,Mapping=velthuis-sanskrit]{Nakula}}

\let\origlabelitemi\labelitemi
\renewcommand\labelitemi{{\normalfont\origlabelitemi}}

\parindent=0pt

\begin{document}

\section{Examples}

{\dn
\begin{center}
\setlength{\fboxrule}{2pt}
\framebox[3.2cm][s]{.o ga.ne"saaya nama.h}
\end{center}
}
\end{document}


The above command works perfectly for non-vedic sanskrit, but once I start using udatta and anudatta it doesn't work at all.

Commands like this:

• \dn\dnveda _{a} which work well in devanagari doesn't seem to work here.
• Can you post a small example document of what works and what doesn't work for you. See I've just been told I have to write a minimal example, what is that?. – Alan Munn May 20 '12 at 17:00
• @AlanMunn: See the one which I gave in the example has no vedic Macros, so it works for me as well. But the moment i switch to typeset Vedic Macros it doesn't work. – crskhr May 21 '12 at 5:21
• With XeLaTeX you're allowed to type directly in the Devanagari script. – egreg May 23 '12 at 15:50
• @egreg: Sorry i dont understand what exactly you mean – crskhr May 23 '12 at 15:54
• @egreg: with XeLaTex i have to first save a file as test.dn and then do xelatex test.dn to get a output as test.tex and then compile test.tex. The thing is i want to change the devanagari font. – crskhr May 23 '12 at 15:55

I don't know anything of Devanagari and Sanskrit; but here's an example that I obtained first by compiling without the second line, then copying from the PDF and pasting.

% Requires font Nakula by John Smith,
% see http://bombay.indology.info/software/fonts/devanagari/index.html
\documentclass[12pt]{article}
\usepackage{ifxetex}
\RequireXeTeX
\usepackage{fontspec}
\newfontfamily{\sanskritfont}[Script=Devanagari,Mapping=velthuis-sanskrit]{Nakula}
\newcommand\dn{\catcode\~=12 \sanskritfont}

\newfontfamily{\directsanskrit}[Script=Devanagari]{Nakula}

\begin{document}

{\dn .o ga.ne"saaya nama.h}

{\directsanskrit ॐ गणेशाय नमः}

\end{document}


As far as I can see, the two lines are identical.

The lines

\newfontfamily{\sanskritfont}[Script=Devanagari,Mapping=velthuis-sanskrit]{Nakula}
\newcommand\dn{\catcode\~=12 \sanskritfont}


have the same effect as your

\newcommand\dn{\catcode\~=12
\fontspec[Script=Devanagari,Mapping=velthuis-sanskrit]{Nakula}}


but use XeTeX more efficiently.

• I told u this is working. type the vedic accents and see. – crskhr May 23 '12 at 16:20
• just see if this commands are working. {\dn\dnveda tat \|{sa}_{vi}tur-vare.nya.m |}. For me these dont work – crskhr May 23 '12 at 16:21
• @Chandrasekhar This kind of input is not for use with XeLaTeX. As I said, I don't know anything about vedic accents. – egreg May 23 '12 at 16:26
• egreg - I am attaching an image to explain the Vedic accents I hope this would help to address the issue. i.stack.imgur.com/jqZKm.jpg – Aku May 24 '12 at 15:03
• @Aku If I input this स॒व॑ितुर (using the Devanagari MT font) I get the two accents. I don't know if this means anything (I hope nothing bad, at least). – egreg May 24 '12 at 15:14

Note: I don’t know Hindi nor can I read this.

If I input the text as plain Unicode, I always get the vedic accent marks. The following code gives me something which has the accents, as far as I can see.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}

\usepackage{fontspec,xltxtra,xunicode}
\setmainfont[Script=Devanagari,Mapping=velthuis-sanskrit]{Nakula}

\begin{document}

दि॒पदे॑ । शं चतु॑षपदे

\end{document}


If you want to change the Devanagari font, just exchange the Nakula option. Arial Unicode MS and Code2000 had seemnigly correct outputs (although with Code2000 the accents overlapped the vowel marks). Devanagari MT, however, did not work correctly for me.

You can find the vedic accents under:

• U+0951 DEVANAGARI STRESS SIGN UDATTA = Vedic tone svarita
• U+0952 DEVANAGARI STRESS SIGN ANUDATTA = Vedic tone anudatta

Although I don’t know what you meant by “Deergha Swarita” in your posted image, I suspect it might be U+1CDA (VEDIC TONE DOUBLE SVARITA), which I did not have available in any of my fonts.

Also confer the Unicode blocks Devanagari, Vedic Extensions and Devanagari Extended.

• This you are giving input itself in unicode right. What about input in Roman and output in unicode – crskhr May 25 '12 at 12:07
• OK, now I understand your question, sorry. You want to typeset the Vedic intonation marks with ASCII macros (\_, \=, \|, etc.) as in Chapter 10 “Vedic Macros” of the velthuis manual. I will see to it as soon as I get back to my TeX system. – brian-ammon Jun 3 '12 at 14:32
• Yes. Thanks brain. Please reply as soon as possible. I am desperate :( – crskhr Jun 3 '12 at 15:16
• Actually, I think that the question has already been answered by egreg: „This kind of input is not for use with XeLaTeX. […]“ Accordingly, I have only found that the examples in section 10.2 work with LaTeX only and not with XeLaTeX. Why would you like to have the ASCII input in XeLaTeX when you can have the normal Unicode input? It seems to me that you have to use the normal LaTeX typesetting program if you want to input the Vedic intonation marks in ASCII. If there are any specific reasons why you need to use the ASCII input in XeLaTeX, you may need to post a follow-up question. – brian-ammon Jun 5 '12 at 10:50
• Then how can I input vedic accents? – crskhr Feb 13 '13 at 9:02

For the question of typing: The Vedic accents are not available on the standard keyboard layouts, it seems.

Which leaves: (a) direct input individual selection of characters from a character map (e.g., BabelMap); (b) almost-direct input via text editors where the unicode value can be keyed in and pressing Alt-X converts it to the glyph (e.g., LibreOffice Writer; BabelPad); (c) writing custom keyboards (OS dependent); (d) mapping a font in xelatex (here, using a made-up word, which GoogleTrans currently reports as meaning black powder):

Fine detail adjustments in the typesetting might be needed, depending on the actual words used.

(This mapping also implies that direct manipulation via lua code in lualatex should also be possible.)

Experiment shows that Latex macros of the sort \newcommand\myaccenta{\symbol{^^^^0951}} are seen as extraneous boxes at the type-setting stage and interrupt the letter-shaping mechanism.

Also, interesting news: a revision and update of the skt package seems to be in the pipeline. (Typing Sanskrit in TeX)

Code for the mapping example:

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{fontspec}
\setmainfont[Script=Devanagari,Mapping=vedic,Scale=1.5]{Noto Serif Devanagari}

\newfontface\translitd[Mapping=devanagari-to-iastb,Scale=1.1,Colour=red]{Noto Sans}% This is for the IAST-based transliteration only.

\newfontfamily\englishfont{Noto Serif}
\usepackage{polyglossia}
\setdefaultlanguage{hindi}
\setotherlanguages{english}

\begin{document}
\section{\textenglish{Mapping}}
\textenglish{Test text:} कालेमूनि {\translitd कालेमूनि}

\vspace{12pt}
\begin{tabular}{ccccc}
,, & कालेमूनि,,  & कालेमू,,नि & काले,,मूनि & का,,लेमूनि \\
\end{tabular}

\vspace{12pt}
\begin{tabular}{ccccc}
.. & कालेमूनि..  & कालेमू..नि & काले..मूनि & का..लेमूनि \\
\end{tabular}

\vspace{12pt}
\begin{tabular}{ccccc}
(( & कालेमूनि((  & कालेमू((नि & काले((मूनि & का((लेमूनि \\
\end{tabular}

\vspace{12pt}
\begin{tabular}{ccccc}
)) & कालेमूनि))  & कालेमू))नि & काले))मूनि & का))लेमूनि \\
\end{tabular}

का,,ले..मू((नि))
\end{document}


The .map file (to be converted to .tec format with teckit_compile):

; TECkit mapping for TeX input conventions <-> Unicode characters

LHSName "vedic" ;
RHSName "UNICODE"

pass(Unicode)

; ligatures from Knuth's original CMR fonts
U+002D U+002D           <>  U+2013  ; -- -> en dash
U+002D U+002D U+002D    <>  U+2014  ; --- -> em dash

U+0027          <>  U+2019  ; ' -> right single quote
U+0027 U+0027   <>  U+201D  ; '' -> right double quote
U+0022           >  U+201D  ; " -> right double quote

U+0060          <>  U+2018  ;  -> left single quote
U+0060 U+0060   <>  U+201C  ;  -> left double quote

U+0021 U+0060   <>  U+00A1  ; ! -> inverted exclam
U+003F U+0060   <>  U+00BF  ; ? -> inverted question

; additions supported in T1 encoding
;;U+002C U+002C   <>  U+201E  ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C   <>  U+00AB  ; << -> LEFT POINTING GUILLEMET
U+003E U+003E   <>  U+00BB  ; >> -> RIGHT POINTING GUILLEMET

; Here are the Vedic accents
U+002C U+002C <>  U+0951; ॑ ,,
U+002E U+002E <>  U+0952; ॒ ..
U+0028 U+0028 <>  U+0953; ॓ ((
U+0029 U+0029 <>  U+0954; ॔ ))
`

The key to the mapping is to choose combinations of characters that are easy to type and unlikely to be used elsewhere in the text. In this case, double comma ,, double dot .. double left bracket (( and double right bracket )). But other characters can be used, if desired.

As an aside, the font designer designs the font, including the marks. Here's a random sample: