[XeTeX] Devanagari Ligature Problem Resolved --- Now Hyphenation

Yves Codet ycodet at club-internet.fr
Mon Oct 5 10:24:03 CEST 2009


Hello.

Le 3 oct. 09 à 11:21, Neal Delmonico a écrit :

> Thanks.  This did the trick.

Glad to hear it works.

> I've found, however, that when I use the \dev{} scheme in a page  
> header or in the table of contents, I get all kinds of errors and  
> the program quits without completing the document.  My solution has  
> been to use both \dev{} and {\dn }, the latter in headings and toc  
> where hyphenation is not that important and the former (\dev{}) when  
> I am typesetting large passages of Sanskrit.  Somehow, {\dn } does  
> not offend xelatex.

This is because \dev{} is short for \begin{sanskrit}...\end{sanskrit},  
an environment defined by Polyglossia for long texts. But you can't  
have an environment in a title, hence the errors. For single words or  
short phrases you have to use \textsanskrit{}, particularly in chapter  
or section titles.

You could dispense of the \dev{} definition and write:

\chapter{\textsanskrit{some title in Sanskrit}}

\begin{sanskrit}
some text in Sanskrit
\end{sanskrit}

But with "\newcommand{\dev}[1]{{\begin{sanskrit}\large  
#1\end{sanskrit}}}" in your preamble you save some typing:

\chapter{\textsanskrit{some title in Sanskrit}}

\dev{
some text in Sanskrit
}

Incidentally, I would prefer \skt{} (you may name your new command the  
way you like) rather than \dev{} since that command is associated to a  
language and its hyphenation patterns, not to a script. But it's a  
detail.

> On another note, is there something comparable for Bengali?  I know  
> there is for Hindi and I shall need to ask about that at some point  
> in the near future.  For now I have a book that uses occasional  
> Bengali script and would like to handle it the way I now do Sanskrit.

It would be rather complicated. If you want to use the Velthuis  
romanisation, you would have to create a velthuis-bengali.tec  
yourself. As Ravi suggested some time ago, things will be simpler if  
you input Sanskrit, Hindi and Bengali directly in Unicode. Polyglossia  
doesn't support Bengali yet, so there's no predefined Bengali  
environment, hence the different definition of the command \ben{} in  
the example below.

%%%%%%%%%%
\documentclass[a4paper,10pt]{book}
\usepackage{xltxtra}
\usepackage{polyglossia}
\setmainfont{Charis SIL}
\newfontfamily\sanskritfont[Script=Devanagari]{Nakula}
\newcommand{\skt}[1]{{\begin{sanskrit} #1\end{sanskrit}}}
\newfontfamily\hindifont[Script=Devanagari]{Nakula}
\newcommand{\hin}[1]{{\begin{hindi} #1\end{hindi}}}
\newfontfamily\bengalifont[Script=Bengali]{Code2000}
\newcommand{\ben}[1]{{\bengalifont{#1}}}
\setdefaultlanguage{english}
\setotherlanguage{sanskrit}
\setotherlanguage{hindi}
\renewcommand{\baselinestretch}{1.2}

\begin{document}

\chapter 
{\textsanskrit{नमस्कारवाक्यानि।}}

\skt{कुशलं किम्} Neal? \\
\hin{आप कैसे हैं} Neal? \\
\ben{কেমন আছেন} Neal?

\tableofcontents

\end{document}
%%%%%%%%%%

As far as I know there are no Bengali nor Hindi hyphenation patterns,  
in Unicode at least. So you would have to insert hyphenations manually  
for those languages.

You would need suitable input methods. Being a Mac user I can't help  
you about this. But there are Windows users around here, who will be  
able to advise you.

Regards,

Yves

> Yves Codet wrote:
>> Hello.
>>
>> Le 30 sept. 09 à 21:58, Neal Delmonico a écrit :
>>
>>> It seems to work, not with MikTeX 2.8 but with TeX Live 2008 which  
>>> I have installed in the meantime.  How do I handle the ligature  
>>> problem (\catcode `\~=12) then?
>>
>> Sorry, I had forgotten about it. You can put that command in your  
>> preamble so that your test file now looks like this:
>>
>> %%%%%%%%%%
>> \documentclass[10pt]{article}
>> \usepackage{polyglossia}
>> \usepackage{xltxtra} % this is enough because xltxtra loads  
>> fontspec and xunicode
>> \setmainfont{Gentium Basic}
>> \setdefaultlanguage{english}
>> \setotherlanguage{sanskrit}
>> \newfontfamily\sanskritfont[Script=Devanagari,Mapping=velthuis- 
>> sanskrit]{Nakula}
>> \newcommand{\dev}[1]{{\begin{sanskrit}\large #1\end{sanskrit}}}
>> \catcode`\~=12
>>
>> \begin{document}
>>
>> \dev{
>>
>> \begin{verse}
>>
>> anyaabhilaa.sitaa"suunya.m j~naanakarmaadyanaav.rtam|\\
>> aanukuulyena k.r.s.naanu"siilana.m bhaktiruttamaa||
>>
>> \end{verse}
>>
>> \noindent asyaartha.h---anyaabhilaa.saj~naanakarmaadirahitaa
>> "sriik.r.s.namuddi"syaanukulyena kaayavaa"nmanobhiryaavatii kriyaa  
>> saa
>> bhakti.h|| 1||
>>
>> }
>>
>> \end{document}
>> %%%%%%%%%%




More information about the XeTeX mailing list