Friday, December 31, 2010

Using Unicode in Latex/Tex

To use Hindi Unicode, do the following -

In the .tex file include the line -
\font\texthi="Lohit Hindi:script=deva,mapping=tex-text" at 11pt.
(Remember to exclude the full stop at the end!)
Enter Hindi unicode text in the document as -
Some English text {\texthi हिन्दी...} more English text...
Compile the document using Xetex or XeLatex.

More information -

"texthi" is the name of the command we just defined to indicate Unicode text. You can give any other name, e.g. \font\abcd="...".

"Lohit Hindi" (remember the space between Lohit and Hindi) is the name of an Open Truetype Font (OTF) installed in the system. You can specify any other font that is installed. In Ubuntu, you can see what fonts are installed as follows -
Goto Main Taskbar -> System -> Preferences -> Appearance -> (Popup opens) -> Click 'Fonts' tab -> Try to change any of the fonts e.g. Application font. You get another popup where the fonts are listed under 'Family'. You can use any of these fonts instead of "Lohit Hindi".

"deva" is a tag that specifies which script (and hence which unicode range) should be used. Hindi uses the devanagari script. For other scripts, find out which script tag to use.

"mapping=tex-text" - I don't know what this. If you do, please tell me.

2 comments:

  1. I am writing a thesis and have to use some hindi word...I tried your above method...but an error is coming that font texthi is not loadable...can u plz help me

    ReplyDelete
  2. Please post the code, the command used, and the output you got. Also, try a different font to see if that works (you need to choose from among the fonts installed in your system).

    ReplyDelete