Wednesday, February 22, 2017

A LaTeX Report Template for Myanmar Language Using XeTeX

This is a template for LaTeX report in Myanmar language using XeLaTeX. It is available at

https://github.com/yan9a/LaTeX_Myanmar_Language.

To properly render Myanmar fonts using LaTeX, it is necessary to use TeX typesetting engines that support Unicode such as XeTeX. Simple examples for testing XeTex can be found in an older post Myanmar (Burmese) Language with XeTeX and LuaTeX.

A popular editor called TeXstudio is used as an example editor. Click Options menu > Configure TeXstudio... and General > Font choose a Myanmar font for IDE. And at the same pop-up window, for Build > Default Compiler, choose XeLaTeX. In Editor > Font Family, choose a Myanmar font for editor.


The font to be used in the report can be changed in burmese.sty file. For example, to use 'Pyidaungsu' font, you can modifiy
\setmainfont{Myanmar Text}
as
\setmainfont{Pyidaungsu}
.

burmese.sty is shown below.
\ProvidesPackage{burmese}[2017/02/09 Burmese Language Package]

\RequirePackage{fontspec}
%-----------------------------------------------------------------
\DeclareOption{MyanmarText}{
 \setmainfont{Myanmar Text}
}

\DeclareOption{Pyidaungsu}{
 \setmainfont{Pyidaungsu}
}

\DeclareOption{Padauk}{
 \setmainfont{Padauk}
}

\ExecuteOptions{MyanmarText}
\ProcessOptions\relax
%-----------------------------------------------------------------
\makeatletter
\def\@burmesenumber#1{\expandafter\@@burmesenumber\number#1\@nil}
\def\@@burmesenumber#1{%
 \ifx#1\@nil
 \else
 \char\numexpr#1+"1040\relax
 \expandafter\@@burmesenumber\fi}
\def\burmesecounter#1{\expandafter\@burmesenumber\csname c@#1\endcsname}
\def\burmesenumeral#1{\@@burmesenumber#1\@nil}
\makeatother
%-----------------------------------------------------------------
\newcommand{\mmmonthname}[1][]{
 \ifcase 
 #1 
 \or ဇန်နဝါရီ
 \or ဖေဖော်ဝါရီ
 \or မတ်
 \or ဧပြီ
 \or မေ
 \or ဇွန်
 \or ဇူလိုင်
 \or သြဂုတ်
 \or စက်တင်ဘာ
 \or အောက်တိုဘာ
 \or နိုဝင်ဘာ
 \or ဒီဇင်ဘာ
 \fi
}
\makeatletter
\let\c@year\year
\makeatother
%\setcounter{year}{2017}
\renewcommand{\THEYEAR}{\burmesecounter{year}}
\renewcommand{\monthname}{\mmmonthname}
%-----------------------------------------------------------------
\renewcommand{\bibname}{အကိုးအကားများ}%change Bibliography       
\renewcommand{\contentsname}{မာတိကာ}                 
\renewcommand{\listfigurename}{ပုံများ}
\renewcommand{\listtablename}{ဇယားများ} 
\renewcommand{\chaptername}{အခန်း}
\renewcommand{\figurename}{ပုံ}
\renewcommand{\lstlistingname}{စာရင်း}
\renewcommand{\abstractname}{အနှစ်ချုပ်}
%-----------------------------------------------------------------
\renewcommand{\thepage}{\burmesecounter{page}} 
\renewcommand{\thechapter}{\burmesecounter{chapter}}
\renewcommand{\thesection}{\burmesecounter{chapter}.\burmesecounter{section}}
\renewcommand{\thesubsection}{\burmesecounter{chapter}.\burmesecounter{section}.\burmesecounter{subsection}}
\renewcommand{\thefigure}{\burmesecounter{chapter}.\burmesecounter{figure}}
\renewcommand{\thetable}{\burmesecounter{chapter}.\burmesecounter{table}}
%-----------------------------------------------------------------
\let\oldpagenumbering\pagenumbering
\renewcommand{\pagenumbering}[1]{
 \oldpagenumbering{#1}
 \ifthenelse{\equal{#1}{arabic}}{
 \renewcommand{\thepage}{\burmesecounter{page}}
 }{}
}

\endinput


Note: To insert breaking non-space (zero width space - &#x200B in HTML) to indicate a recommended line break, you can use
\hspace{0pt}

No comments:

Post a Comment

Comments are moderated and don't be surprised if your comment does not appear promptly.