Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

TeX: Kannada using XeTeX

📅 2010-Jan-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ baraha, kannada, latex, miktex, xetex ⬩ 📚 Archive

 

LaTeX neither supports Windows fonts nor Unicode text. This makes creating documents in Indian languages with LaTeX very hard. But, there is a solution: XeTeX. It extends the TeX implementation to work with Windows fonts and Unicode text.

If you are using MikTeX on Windows, XeTeX is already included in its default installation! Here is how to obtain the Kannada PDF shown above:

  1. Create a kannada.tex file with this text:
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Script=Kannada]{Tunga}
\begin{document}
ಏನಿದು ಲಾಟೆಕ್! ಗೊತ್ತಾ ನಿಮಗೆ?
\end{document}

Script indicates the language (Kannada) and Tunga is the name of a Kannada font on Windows. The Kannada text was typed using the Baraha IME transliteration software.

  1. Make sure to save the file as UTF-8 or any other Unicode encoding.

  2. Compile the file to PDF using xelatex, which is latex built on top of XeTeX:

$ xelatex kannada.tex

That is it, it is that simple! 😊 To create a PDF in a different Indian language, change the respective parameters in \setmainfont.


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧