15

I use TexMaker and LyX in Ubuntu. I'd like to typeset Tamil/Telugu/Hindi text, and so far I've been unsuccessful.

Please suggest me a working TeX/LaTeX/variants setup for Indic languages, especially Tamil.

edit: XeTeX seems to have good Unicode support, and I read TexMaker has XeteX support too. I installed all XeTeX, latex-tamil packages etc. But couldn't make them work yet.

Documentations talk about Arabic or Korean text. Nothing mentioned about Tamil/Indic text.

7 Answers 7

7

I will give what I learned by trial and error. This is pertaining to Windows platform.

( I used the material given found here at the XeLaTeX wiki.)

The trick is to

  1. use the fonts available in the system's font directory. (Windows7 provides Latha font for Tamil) and
  2. compile your source file with xelatex, not pdflatex! (For this in Windows platform, 'Texworks' can be used as this is an unicode editor. Check whether your favourite editor can save your file in utf-8 format)

In the preamble include the following

\usepackage{fontspec}

\newfontfamily{\lathatam}{Latha}

The declaration in the first set of parentheses is the command to call Tamil encoding in the body of your document such as:

{\lathatam அய்யா வணக்கம்.} 

I used Microsoft's Indic Tamil Input Method. (For downloading and installation see the relevant web site. You can also use Google's method).

Another Tamil font encoding is 'Arial Unicode MS'. To use this declare

\newfontfamily{\anothertam}{Arial Unicode MS}

in the preamble, and use it by doing:

{\anothertam நான் நலம். நீங்கள் நலமா}

When you compile with xelatex, you will see the difference between these fonts.

2
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.
    – user31729
    May 3, 2015 at 17:28
  • 1
    Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or enclose words in backticks `, 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).
    – Adam Liter
    May 3, 2015 at 17:37
11

As of 2020, both babel and polyglossia support Tamil. This requires either LuaLaTeX with the HarfBuzz renderer (a version from 2020 or later should work) or XeLaTeX. The babel package supports more languages and engines, while the polyglossia package has a somewhat simpler user interface.

Either of these let you use any system font that supports Tamil. Any font you can use in your word processor should work.

Save as UTF-8.

With Babel

\documentclass{article}
\usepackage[english]{babel}
\usepackage{fontspec}

\babelprovide[import]{tamil}

\defaultfontfeatures{Scale=MatchLowercase}
\babelfont{rm}[Scale=1.0]{Latin Modern Roman}
\babelfont[tamil]{rm}{Latha}

\begin{document}
\foreignlanguage{tamil}{தமிழ் அரிச்சுவடி-தமிழ் மொழி}
\end{document}

babel sample

This set-up is for the common case where you want to use a bit of Tamil in a multilingual document. You can also declare Tamil the main language, or set a section in Tamil with \begin{otherlanguage}{tamil}...\end{otherlanguage}. You can define \babelfont[tamil]{sf}{Some Font} to get a sans-serif font and \babelfont[tamil]{tt}{Some Font} to get monospace.

If you get warning messages about the font not supporting the language Tamil for the script Tamil, they’re harmless, but you can suppress them by adding the option \babelfont[tamil]{rm}[Language=Default]{Some Font}. What happened is that the selected font doesn’t add an OpenType language tag.

With Polyglossia

\documentclass{article}
\usepackage{polyglossia}

\setdefaultlanguage{english}
\setotherlanguage{tamil}

\defaultfontfeatures{Scale=MatchLowercase}
\newfontfamily\tamilfont{Latha}[Script=Tamil]

\begin{document}
\texttamil{தமிழ் அரிச்சுவடி-தமிழ் மொழி}
\end{document}

polyglossia sample

You can also use the tamil environment for sections, and define \tamilfontsf and \tamilfonttt similarly to \tamilfont.

If You Cannot Use XeTeX

It would be nice if the last few holdouts added support for XeTeX (and, in the future, HarfTeX). Since some publishers still do not allow it, you might still need to fall back on a workaround such as LianTze Lim’s solution. If you need only a few short words or phrases in Tamil, another workaround is to compile them with XeLaTeX as tiny standalone PDFs, then insert the PDFs as images.

6
  • Instead of \usepackage[bidi=default]{babel} and \babelprovide[main, import]{english}, just write \usepackage[english]{babel} (Tamil is not an RTL script). Jul 7, 2019 at 16:41
  • @JavierBezos I ended up leaving the \babelprovide[import, main] line, because most requests I’ve seen for Tamil, Malayalam, etc. are about multilingual documents. I mentioned a few other use cases. I removed the unnecessary package option. Thanks for pointing that out!
    – Davislor
    Jul 7, 2019 at 18:45
  • There is no reason to load english with \babelprovide. The standard method, as a package option, is still preferred. Jul 8, 2019 at 13:14
  • @JavierBezos I suppose my own preference is to load all my languages by the same method, but if you say [english] is preferred, I’ll change my MWE.
    – Davislor
    Jul 8, 2019 at 19:27
  • Could you update your answer to include luahbtex + luaotfload 3.11? \babelfont[tamil]{rm}[Script=Tamil,Renderer=Harfbuzz]{Latha} should work fine then. See tex.stackexchange.com/a/493185/2388 for installation instructions. Nov 11, 2019 at 10:04
5

[Note added on 7 July 2019] Please disregard this answer and use XeLaTeX/LuaLaTeX with polyglossia/babel instead, as explained in Davislor's answer. I'll leave this answer here for historical interest.

I was able to typeset Tamil using LaTeX on Ubuntu by installing the itrans and itrans-fonts packages via synaptic (or apt-get). It doesn't let you type in Tamil directly, rather you have to key in the ASCII transcription, then process it with itrans from the command prompt, then run (pdf)latex on the resultant file.

Say I have the following file nandri-pre.tex:

\documentclass{minimal}
\usepackage[preprocess]{itrans}

\newfont{\tmlb}{wntml12}
\newfont{\tmls}{wntml10}
\hyphenchar\tmlb=-1 
\hyphenchar\tmls=-1 

#tamilifm=wntml.ifm
#tamilfont=\tmlb

\begin{document}
Hi! {#tamil na^nRi #endtamil}
\end{document}

Process it with itrans:

$ itrans -i nandri-pre.tex -o nandri.tex

Then run (pdf)latex on nandri.tex, which is of course the file to edit if you have further text to add.

1
  • Appreciate the shout-out. Unfortunately, a few important sites still require PDFLaTeX, and might need something like that, or a hack like compiling all the Tamil words to PDF and including them.
    – Davislor
    Jul 8, 2019 at 20:44
3

To use various indic languages in latex with texmaker I recommend following steps to be followed by viewers of this post.

  1. Download latest version of MikTeX. Install it in your system. I use the C:/latex/ directory.

  2. Download devnag developed by velthuis from CTAN. Install it in your system. I use the c:/latex/velthuis directory.

  3. Open mycomputer->all programmes->miktex->miktex settings. Go to root tab and add c:/latex/velthuis directory and click OK.

  4. Install TeXMaker and go to "user" tab and open "user command" and then "edit user command". Enter "devnagari" in menu item and commands

    c:/latex/velthuis/bin/devnag.exe %.dn|c:/latex/miktex/bin/latex.exe -interaction=nonstopmode %.tex|"C:/latex/MiKTex/miktex/bin/yap.exe" %.dvi     
    

    in command field. Click OK.

  5. Now devnagri will appear in dropdown in menu bar after arrow. You can add extra command using | having no space before and after |.

  6. Now copy misspal file from c:/latex/velthuis/doc/generic/ folder in TeXMaker and save it as misspall.dn. Now run devnagri command and you will see out put in DVI preview in devnagari script. If you want write document in tamils then use itrans instead of devnag. It is also working with LaTeX and TeXMaker very well.

  7. Remember %.dn means % denotes to filename without extension and .dn extension of file. Users must read doc or manual of devnag or itrans.

1
  • 3
    While a link to your homepage may be part of your user profile, it should not be included in answers.
    – lockstep
    Apr 10, 2011 at 12:56
2

For Hindi, you can probably use the devanagari package for LaTeX. I've used it for Sanskrit. Just note that the "internal" codes for the script is a bit obtuse, so it is suggested that you follow the documentation and type in a more readable format, and then pass the source file through a preprocessor. (Included in the distribution.)

There are also language packages for Telugu and Tamil, but not having used either I cannot say more about them.

4
  • Thanks Willie. I've installed Tamil packages but couldn't get them work yet. Heard about Xetex's support for Unicode characters. Any idea how to use it in Ubungu? (Guess it should go to another question) Jul 27, 2010 at 21:11
  • Sorry, but I've really limited experience with Xetex, and had never played with the Tamil package myself. Good luck! Jul 27, 2010 at 21:15
  • Will try devanagari first. 'Internal Codes' meaning I should be typing the source with some kind of hex code letter-by-letter? Thanks for the tip. Jul 27, 2010 at 21:30
  • This page has a code example that works (partially)- tug.org/pipermail/xetex/2009-December/015051.html Letters with dot about (க், ல்) are rendered wrong. TexMaker didn't help much. It wouldn't let me type in Tamil, but I could copy-paste unicode text into it. TexMaker, by default, tries to compile with Latex, I had to compile from command line ($ xelatex <source>) Jul 27, 2010 at 21:46
1

For my Ubuntu system I did as Lian Tze Lim suggested. Use the package manager to install the itrans and itrans-fonts packages. No muss No fuss.

For Windows and MiKTex 2.9 the set up process was more involved. Below is the batch file I created to facilitate the copying.

1) Install MiKTeX

2) Use the MiKTeX package manager to install the indic-type1 package and the devanagari packages.

3) download itrans53-win32.zip from http://www.aczoom.com/files/itrans/53/itrans53-win32.zip

4) extract itrans53-win32.zip to some temporary location. I used C:\temp\Tamil\ITRANS53.

5) Open a command window which is running as administrator. (many of the copies are into c:\program files\ and that requires the process be run with elevated privilege)

6) CD to the temporary location of ITrans (e.g. C:\temp\Tamil\ITRANS53)

7) execute the batchfile commands below.

8) close the command window

9) Right click on start->computer and select Properties.

10) Select Advanced System Settings->Environment Variables

11) add new system environment variable named: ITRANSPATH. See the batch file commands below for the exact value for this variable.

12) open a command window

13) The command:

itrans -I <filename>.itx -o <filename>.tex 

will now work and (pdf)latex can resolve the packages, fonts, and commands referenced in the output from itrans.exe.

I can now process LaTeX files in both Ubuntu and Windows 7 and have the source files (.Tex, .ITX, etc.) under revision control

The batch file is:

echo off

rem Record where is MikTeX is installed
set MiktexRoot=C:\Program Files\MiKTeX 2.9

rem copy itrans.exe to a directory already within the path environment variable
rem   namely the path adjustment made by the installer for MiKTeX which puts
rem   all of the MiKTeX installed tools on the PATH variable
rem
rem for 32-bit windows systems remove the x64 suffix
copy ".\bin\*.exe" "%MiktexRoot%\miktex\bin\x64\*.*" /Y /V 

rem Create the directories within the MikTeX structure used or referenced by the itrans package
mkdir "%MiktexRoot%\doc\itrans"
mkdir "%MiktexRoot%\doc\itrans\contrib"
mkdir "%MiktexRoot%\fonts\source\public\itrans"
mkdir "%MiktexRoot%\fonts\type1\public\itrans" 
mkdir "%MiktexRoot%\fonts\tfm\public\itrans" 
mkdir "%MiktexRoot%\fonts\afm\public\itrans" 
mkdir "%MiktexRoot%\fonts\truetype\public\itrans" 
mkdir "%MiktexRoot%\tex\latex\itrans"
mkdir "%MiktexRoot%\tex\latex\itrans\fonts"

rem Copy itrans package files into the MiKTeX structure
rem used http:\\tex.stackexchange.com\questions\1754\tamil-tex-in-windows
rem and the installation script for Tamil-Omega as guides for the copy commands
rem Listed below
rem

rem Copy Documentation files
copy ".\doc\*.*" "%MiktexRoot%\doc\itrans\*.*" /Y /V 
copy ".\contrib\*.*" "%MiktexRoot%\doc\itrans\contrib\*.*" /Y /V 
rem copy Font Files
copy ".\lib\fonts\*.mf"  "%MiktexRoot%\fonts\source\public\itrans\*.*" /Y /V 
copy ".\lib\fonts\*.pfa" "%MiktexRoot%\fonts\type1\public\itrans\*.*" /Y /V 
copy ".\lib\fonts\*.pfb" "%MiktexRoot%\fonts\type1\public\itrans\*.*" /Y /V 
copy ".\lib\fonts\*.pfm" "%MiktexRoot%\fonts\type1\public\itrans\*.*" /Y /V 
copy ".\lib\fonts\*.tfm" "%MiktexRoot%\fonts\tfm\public\itrans\*.*" /Y /V 
copy ".\lib\fonts\*.afm" "%MiktexRoot%\fonts\afm\public\itrans\*.*" /Y /V 
copy ".\lib\fonts\*.ttf" "%MiktexRoot%\fonts\truetype\public\itrans\*.*" /Y /V 
rem copy all of the ITRANS Lib structure into MiKTeX structure.
copy ".\lib\*.*" "%MiktexRoot%\tex\latex\itrans\*.*" /Y /V 
copy ".\lib\fonts\*.*" "%MiktexRoot%\tex\latex\itrans\fonts\*.*" /Y /V 

rem post installation commands to rebuilt the font name database ans to process all of the font MAPping files.    
texhash
updmap

rem
rem With the above copies MikTeX can now find the ITRANS fonts and resolve references created by the itrans.exe preprocessor
rem
rem But the preprocessor cannot be run from the command line because itrans.exe is expecting to find a 
rem specific ITRANS structure somewhere on the disk via the environment variable: ITRANSPATH
rem instruct the user about this environment variable requirement
rem

echo "Set the environment variable: ITRANSPATH"
echo "ITRANSPATH=%MiktexRoot%\tex\latex\itrans;%MiktexRoot%\tex\latex\itrans\fonts"
1
  • The OP did reference assistance on a Linux platform (Ubuntu) and your paths are in reference to a Windows platform... Jul 28, 2015 at 20:11
0

If you're using OverLeaf, you could follow the example at https://www.overleaf.com/latex/examples/how-to-write-multilingual-text-with-different-scripts-in-latex/wfdxqhcyyjxz

\usepackage{fontspec}
\usepackage{xunicode} %% loading this first to avoid clash with bidi/arabic

%%% For language switching -- like babel, but for xelatex
\usepackage{polyglossia}




\setmainlanguage{english}
\setotherlanguages{tamil} %% or other languages


% Main serif font for English (Latin alphabet) text
\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
\setmonofont{Noto Mono}

% define fonts for other languages
\newfontfamily\tamilfont[Script=Tamil]{Noto Serif Tamil}

Write your Tamil text like \begin{tamil}நன்றி, அருமை\end{tamil}.

4
  • Have you tried actually working on a document this way? It doesn't work: the Overleaf code editor, as of 2020 (as long as they're using Ace editor component underneath), is unusable with Indic scripts (just try entering some text and moving the cursor around), but somehow they are not keen on making this clear in their documentation. (What works is typing your text somewhere else and pasting it into Overleaf.) Oct 6, 2020 at 20:17
  • @ShreevatsaR I'm able to do that when I select XeLaTeX as the compiler in Overleaf. Check the text நன்றி used in our paper (still being updated) arxiv.org/abs/2010.03189 I'm able to type in the editor directly (using Firefox in Ubuntu 18.04 env).
    – Oligoglot
    Oct 10, 2020 at 18:18
  • You may not notice a problem when using just one or two words, but you'll notice an issue as long as you have at least one line of text that you're trying to edit. Extending your example: put the following on a line in the Overleaf editor: நன்றி, அருமை, நன்றி, அருமை, நன்றி, அருமை, நன்றி, அருமை, நன்றி, அருமை, நன்றி, அருமை. It will probably wrap onto the next line, that's fine. Now put your cursor after the last comma on the line, and try to backspace to delete the comma: what gets deleted? Put your cursor at the last space on the line, and type some character like “.” — where does it go? Oct 10, 2020 at 18:33
  • I see what you mean, @ShreevatsaR. In fact, I've noticed this problem in some other websites too recently. It's painful.
    – Oligoglot
    Oct 12, 2020 at 5:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .