[Note: I wrote a follow up post for this blog post which you can find here.]
Since I'm addicted to Latex for preparing all kinds of documents such as letters, presentation slides and research papers, sometimes I find it hard to work on some document if it is given in a file format for a WYSIWYG editor such as Microsoft word. Finally several months ago, I came across an interest to try and prepare some documents on Sinhala (සිංහල) language using Latex since it is my native language. Actually, I got the interest after working on a Wikipedia page translation in to Sinhala. You can find that wiki page which I translated here. However, I didn't have a chance to spend some time on making Latex documents in Sinhala. Today was the right time for that.
Since I'm addicted to Latex for preparing all kinds of documents such as letters, presentation slides and research papers, sometimes I find it hard to work on some document if it is given in a file format for a WYSIWYG editor such as Microsoft word. Finally several months ago, I came across an interest to try and prepare some documents on Sinhala (සිංහල) language using Latex since it is my native language. Actually, I got the interest after working on a Wikipedia page translation in to Sinhala. You can find that wiki page which I translated here. However, I didn't have a chance to spend some time on making Latex documents in Sinhala. Today was the right time for that.
This is how we can prepare a simple Latex document in Sinhala. First of all, we need to have the necessary packages installed. I cannot specifically mention each and every package we need since I used to install the full distribution of texlive package to get everything under a single roof. So, let's go like that.
sudo apt-get install texlive-full
After the installation, open a text editor and enter the following content into it. We can use Google input tools for typing the Sinhala unicode texts and then copy and paste here inside our Latex document.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | \documentclass{article} \usepackage{fontspec} % % This file is a sample tex file to illustrate use of % XeTeX in typesetting a Sinhala document. % Asanka Sayakkara, 2016 % Based on the example from Golam Mortuza Hossain, 2008 % % Define fonts that you want to use % \font\serif="FreeSerif:script=sinh" \font\serifbb="FreeSerif:script=sinh" at 24pt \font\serifsection="FreeSerif:script=sinh" at 16pt \font\deffont="FreeSerif:script=sinh" at 14pt %\font\mukti="Mukti Narrow Bold:script=beng" % % "script=sinh" in above lines ensures that appropriate % complex text rendering engines are used for proper % rendering of Sinhala. % \title{\bf\serifbb මාතෘකාව මෙතන ලියන්න} \author{\bf\serif අසංක සායක්කාර} \date{2016-08-06} \newcommand{\edition}{Second Edition} % Book edition \begin{document} \deffont %Default font used for the document \maketitle \section{\textbf{\serifsection සිංහල}} මේ මම සිංහලෙන් සකස් කල ලිපියක්. මෙය සකස් කිරිඉමට මම ලේටෙක් මෘදුකාංගය පාවිච්චි කලා. එය ඉතාම ප්රයෝජනවත් මෙවලමක් මට. \section{English} Some English here and there. \end{document} |
Let's say you saved this document with the file name sample.tex somewhere in your file system. Now, it's time to compile it and generate our PDF file using it. We should use xelatex tool to do that since latex and pdflatex are not going to work for these kinds of documents with unicode texts.
xelatex sample.tex
Now, there should be a PDF file generated in the same directory and it will have a content like the figure shown in the beginning of this article. Since copying and pasting Latex contents from the above sample content can be hard for people, I added my files to a github repository. You can find it here.
Enjoy preparing documents in Sinhala!
Now, there should be a PDF file generated in the same directory and it will have a content like the figure shown in the beginning of this article. Since copying and pasting Latex contents from the above sample content can be hard for people, I added my files to a github repository. You can find it here.
Enjoy preparing documents in Sinhala!
Dear Asanka, there is another way of directly writing the unicode sinhala in the document without copy paste. Are you familiar with this?
ReplyDeleteHi Lakmal Aiye, yes of course we can directly type in Sinhala. In particular in Linux, we can set the input method to Sinhala and then type anywhere in Sinhala.
ReplyDeleteBut, I prefer typing on Google Input tools window instead :)
This comment has been removed by the author.
ReplyDeleteExcellent. Thank you.
ReplyDeleteSaved a lot of time. Thanks.
ReplyDeleteHow to install packages manually
ReplyDelete