How do I use locale numbering for page numbers, footers etc.?
I don't know for Khmer, as I don't have any Khmer font available. But for Thai here is a simple version for printing Thai numerals. The macro \thaicounter
receives as argument a counter name, while \thainumeral
a number in decimal (Western) form:
\documentclass[a4paper]{article}
\makeatletter
\def\@thainumber#1{\expandafter\@@thainumber\number#1\@nil}
\def\@@thainumber#1{%
\ifx#1\@nil
\else
\char\numexpr#1+"E50\relax
\expandafter\@@thainumber\fi}
\def\thaicounter#1{\expandafter\@thainumber\csname c@#1\endcsname}
\def\thainumeral#1{\@@thainumber#1\@nil}
\makeatother
\renewcommand{\thepage}{\thaicounter{page}}
\usepackage{fontspec}
\setmainfont{FreeSerif}
\newcounter{pippo}
\begin{document}
\setcounter{pippo}{1234567890}
\thaicounter{pippo} \thainumeral{1234567890}
\end{document}
For Khmer, apart from changing names, it's sufficient to change "E50
into "17E0
(the code point for KHMER DIGIT ZERO. No negative value are allowed, it should be easy to extend the macros. The macros just scan one by one the digits obtained from the counter value or the explicit number and print the corresponding symbol by adding the digit to "E50"
.
The \pagenumbering{<style>}
simply resets the page
counter and redefines \thepage
to use an internal macro \@<style>
with the current page number as argument, \@arabic
for arabic
.
You can manually redefine \thepage
to a format of your choice. You would need to define a macro which converts the page number into its Khmer representation, e.g. page 123 (an integer) must be converted to something like \khymernum{1}\khymernum{2}\khymernum{3}
(where \khymernum
would be a macro to typeset the Khmer numbers).
This should work for all distributions which support Unicode (in some way) or can insert the symbols in a different way. I would say its easier with XeLaTeX, but should be possible for PDFLaTeX as well (somehow).
If you want to have it even more general you could define \khymer
and \@khymer
macros so you (and other) can say \pagenumbering{khymer}
.
Below is a sample of book which I have experienced so far on typesetting LaTeX in Khmer by using XeLaTeX engine.
Please tell me if any errors in your system are found. Thanks.
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[a4paper,12pt,twoside]{book}
\usepackage[sumlimits]{amsmath}
\usepackage{amssymb,amsthm}
\usepackage{fontspec}
\defaultfontfeatures{Script=khmr,Mapping=tex-text} % to support TeX conventions like ``---''
\newfontscript{Khmer}{khmr}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{hyperref}
\usepackage[title,page,titletoc]{appendix}
\newcommand{\KhOS}{\fontspec[Script=Khmer,Scale=0.92]{Khmer OS}\selectfont}
\newcommand{\KhOSML}{\fontspec[Script=Khmer]{Khmer OS Muol Light} \selectfont}
%\newcommand{\KhMEF}{\fontspec[Script=Khmer]{Khmer MEF2} \selectfont}
\setmainfont[Script=Khmer,Scale=0.95]{Khmer OS Battambang}
%%%%%%% This macro is to produce khmer numbering by adopting the thai numbering method
\makeatletter
\def\@khmernum#1{\expandafter\@@khmernum\number#1\@nil}
\def\@@khmernum#1{%
\ifx#1\@nil
\else
\char\numexpr#1+"17E0\relax
\expandafter\@@khmernum\fi
}
%\def\khmercounter#1{\expandafter\@khmernum\csname c@#1\endcsname}
\renewcommand\@arabic{\@khmernum} % to reset number in \arabic to \khmernum
\makeatother
\theoremstyle{plain}
\newtheorem{theorem}{\KhOSML ទ្រឹស្ដីបទ}[chapter]
\newtheorem{proposition}{\KhOSML សំណើ}[theorem]
\newtheorem{corollary}{\KhOSML កូរ៉ូលែរ}[theorem]
\theoremstyle{definition}
\newtheorem{definition}{\KhOSML និយមន័យ}[chapter]%
\newtheorem{lemma}{\KhOSML ឡែម}[definition]%
\theoremstyle{remark}
\newtheorem{remark}{\KhOSML សម្គាល់}%[theorem]
\newtheorem{example}{\KhOSML ឧទាហរណ៍}[chapter]
\newtheorem{exercise}{\KhOSML លំហាត់}[chapter]
\renewcommand{\figurename}{\KhOSML រូប}
\renewcommand{\proofname}{\KhOSML សម្រាយបញ្ជាក់}
\renewcommand{\contentsname}{មាតិកា}
\renewcommand{\indexname}{លិបិក្រម}
\renewcommand{\chaptername}{ជំពូកទី}
\renewcommand{\partname}{ផ្នែកទី}
\renewcommand{\appendixname}{ជំពូកបន្ថែម}
\renewcommand{\listfigurename}{បញ្ជីរូបភាព}
\renewcommand{\listtablename}{បញ្ជីតារាង}
\renewcommand{\appendixpagename}{\KhOSML ជំពូកបន្ថែម}
%%%% to format part, chapter, section, subsection and subsubsection using titlesec package
\titleformat{\section}[block]
{\large \KhOSML}{{\large\thesection}}{1em}{}
\titleformat{\subsection}[block]
{\normalsize \KhOSML}{{\normalsize\thesubsection}}{1em}{}
\titleformat{\subsubsection}[block]
{\normalsize\KhOSML }{{\normalsize\thesubsubsection}}{1em}{}
\titleformat{\chapter}[display]
{\Huge\KhOSML }{\filright\LARGE\normalfont\chaptername\ \thechapter}{2ex} %sep
{\filcenter}
\titleformat{\part}[display]
{\filcenter\LARGE\KhOSML}{{\large\partname\; \thepart}}{1em}{\thispagestyle{empty}}
\makeatletter
%%% to set khmer calendar
\renewcommand\today{\@khmernum\day\space-\space\ifcase\month\or
មករា\or កុម្ភៈ\or មិនា\or មេសា\or ឧសភា\or មិថុនា\or
កក្កដា\or សីហា\or កញ្ញា\or តុលា\or វិច្ឆិកា\or ធ្នូ\fi
\space-\space\@khmernum\year}
\makeatother
%%%%%%%%%%
\title{\KhOSML ចំណងជើងសៀវភៅ}
\author{ អ្នកនិពន្វ}
\date{\today}
\XeTeXlinebreaklocale "khm" % allow line breaks
\XeTeXlinebreakskip = 0pt plus 1pt minus 1pt % for line breakskip suitable for Khmer Unicode fonts
\begin{document}
\setcounter{secnumdepth}{3} % counter for susubsection
\setcounter{tocdepth}{3} % to view susubsection in toc
\frontmatter
\maketitle
\tableofcontents
\listoffigures
\addcontentsline{toc}{chapter}{បញ្ជីរូបភាព}
\listoftables
\addcontentsline{toc}{chapter}{បញ្ជីតារាង}
\chapter{បុព្វកថា}
\mainmatter
\part{ចំណងជើងផ្នែក}
\chapter{ជំណងជើងជំពូក}
\section{ផ្នែក}
\subsection{ផ្នែករង}
\begin{align}
A^T x &= A^T\left[\lambda x_1 + (1-\lambda)x_2\right] \notag\\
&= \lambda A^T x_1 + (1-\lambda)A^T x_2 =
\lambda b + (1-\lambda)b = b
\end{align}
\subsubsection{ផ្នែករង-រង}
We have ....
\begin{lemma}
ខ្លឹមសារ
\subsection{ផ្នែករង}
\begin{align}
A^T x &= A^T\left[\lambda x_1 + (1-\lambda)x_2\right] \notag\\
&= \lambda A^T x_1 + (1-\lambda)A^T x_2 =
\lambda b + (1-\lambda)b = b
\end{align}
\end{lemma}
\begin{theorem}
ខ្លឹមសារ
\begin{align}
A^T x &= A^T\left[\lambda x_1 + (1-\lambda)x_2\right] \notag\\
&= \lambda A^T x_1 + (1-\lambda)A^T x_2 =
\lambda b + (1-\lambda)b = b
\end{align}
\end{theorem}
\begin{corollary}
ខ្លឹមសារ
\end{corollary}
\begin{theorem}
ខ្លឹមសារ
\end{theorem}
\begin{theorem}
ខ្លឹមសារ
\end{theorem}
\begin{proof}
ខ្លឹមសារ
\end{proof}
\begin{remark}
ខ្លឹមសារ
\end{remark}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
នេះគឺជាអត្ថបទធម្មតាមួយដែលគ្នានអត្ថន័យអ្វីទាល់តែសោះ។ តែទោះជាយ៉ាងណាក៏ដោយ%
ក៏ត្រូវបានគេសរសេរដើម្បីបង្ហាញពីការសរសេរអត្ថបទជាភាសារខ្មែរ។
\chapter{ជំណងជើងជំពូក}
\section{ផ្នែក}
\subsection{ផ្នែករង}
\begin{lemma}
ខ្លឹមសារ
\end{lemma}
\begin{theorem}
ខ្លឹមសារ
\end{theorem}
\begin{corollary}
ខ្លឹមសារ
\end{corollary}
\begin{theorem}
ខ្លឹមសារ
\end{theorem}
\begin{theorem}
ខ្លឹមសារ
\end{theorem}
\begin{proof}
ខ្លឹមសារ
\end{proof}
\begin{remark}
ខ្លឹមសារ
\end{remark}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
\begin{exercise}
ខ្លឹមសារ
\end{exercise}
\chapter{ចំណងជើងជំពូក}
\section{ផ្នែក}
\subsection{ផ្នែករង}
\subsection{ផ្នែករង}
\chapter{ចំណងជើងជំពូក}
\section{ផ្នែក}
\subsection{ផ្នែករង}
\subsection{ផ្នែករង}
\part{ចំណងជើងផ្នែក}
\chapter{ចំណងជើងជំពូក}
\section{ផ្នែក}
\subsection{ផ្នែករង}
\subsection{ផ្នែករង}
\chapter{ចំណងជើងជំពូក}
\section{ផ្នែក}
\subsection{ផ្នែករង}
\subsection{ផ្នែករង}
%%%%% to format appendix chapter
\titleformat{\chapter}[display]
{\Huge\KhOSML }{\filright\LARGE\normalfont ជំពូក\ \thechapter}{2ex}
{}
%%%%%
\begin{appendices}
\chapter{ចំណងជើងជំពូកបន្ថែម}
The contents of appendix...
\section{ចំណងជើងផ្នែក}
\chapter{ចំណងជើងជំពូកបន្ថែម}
The contents of appendix...
\section{ចំណងជើងផ្នែក}
\end{appendices}
\end{document}