Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am new to LaTeX and was wondering if it is possible to use another language for page numbers (and any other automatic numbering).

I read here: http://www.personal.ceu.hu/tex/pagestyl.htm

\pagenumbering

\pagenumbering{num_style}

Specifies the style of page numbers. Possible values of num_style are:

arabic: Arabic numerals
roman: Lowercase roman numerals
Roman: Uppercase roman numerals
alph: Lowercase letters
Alph: Uppercase letters 

But is there a way to specify my own locale numbering (Khmer, the language of Cambodia in my case)? Khmer is in Unicode, and the numbers 1-10 are as follows: ១ ២ ៣ ៤ ៥ ៦ ៧ ៨ ៩ ១០

And if this is possible, will it work in any distribution of LaTeX or only some?

After looking around some, I found this solution for Thai: http://thailatex.wordpress.com/2010/07/12/thai-number-for-xetex/

Perhaps it can be re-written for Khmer...

Thanks for your help, Nathan

share|improve this question
add comment

5 Answers

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".

share|improve this answer
add comment

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}.

share|improve this answer
    
Thanks Martin, could you direct me to a place I could learn how to create a macro to typeset the Khmer numbers - I am VERY new to all of this. Thanks for your help, and I'm glad to learn it is possible! –  Nathan May 10 '11 at 15:03
    
@Nathan: The conversion is not that difficult (for people which now a little about TeX programming) and I could provide some code. The main issue is to get the symbols. You need a font which provides them, at best at the correct positions, i.e. where 0-9 are located. Then you just need to display the page number as normal using that font. –  Martin Scharrer May 10 '11 at 15:15
    
I'm not totally sure I understand you - do you mean I need a font with Khmer numbers "mapped" to arabic number positions? I do have some fonts like that (they are old and called legacy fonts), but I would rather use Khmer Unicode, and the Khmer numbers in Khmer Unicode are not mapped to the same location as English numbers...again, not sure if I understood you in regard to "at the correct positions, i.e. where 0-9 are located" - can you elaborate? Thanks for your help. –  Nathan May 10 '11 at 15:43
    
@Nathan: Yes, "a font with Khmer numbers "mapped" to arabic number positions", was what I meant. It would be the simplest and most universal way. If you only have TTF (or similar) fonts you would need to use XeLaTeX AFAIK. But I'm not an expert for that. I mainly wanted to point out that you can redefine \thepage by yourself to use a custom format. –  Martin Scharrer May 10 '11 at 15:48
    
So am I right in assuming there is no easy way to integrate Unicode fonts (of the complex script type - such as Thai or Khmer) into LaTeX to use a local numbering system? –  Nathan May 11 '11 at 1:07
show 1 more comment

Many thanks to egreg

I finally did it

\documentclass[a4paper]{book}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{blindtext}
\usepackage{fontspec}

\setmainfont[Script=Khmer]{Khmer OS}
\XeTeXlinebreaklocale "KHM"

\makeatletter
\def\@khmernumer#1{\expandafter\@@khmernumer\number#1\@nil}
\def\@@khmernumer#1{%
  \ifx#1\@nil
  \else
  \char\numexpr#1+"17E0\relax
  \expandafter\@@khmernumer\fi}
\def\khmercounter#1{\expandafter\@khmernumer\csname c@#1\endcsname}
\def\thainumeral#1{\@@khmernumer#1\@nil}
\makeatother

\def\contentsname{មាតិការ}
\def\partname{ផ្នែក}
\def\thepart{\khmercounter{part}}
\def\theequation{\khmercounter{equation}}
\def\chaptername{ជំពូក}
\def\thechapter{\khmercounter{chapter}}
\def\thesection{\khmercounter{section}}
\def\thesubsection{\khmercounter{section}.\khmercounter{subsection}}
\def\theenumi{\khmercounter{enumi}}
\def\thepage{\khmercounter{page}}
\newtheorem{theorem}{ទ្រឹស្ដីបទ}[chapter]
\newtheorem{lemma}[theorem]{បទគន្លឹះ}
\newtheorem{corollary}[theorem]{ស្វ័យស័ត្យ}
\newtheorem{remark}{សម្គាល់}[chapter]
\newtheorem{exercise}{លំហាត់}[chapter]
\def\theremark{\khmercounter{chapter}.\khmercounter{remark}}
\def\theexercise{\khmercounter{chapter}.\khmercounter{exercise}}
\def\thetheorem{\khmercounter{chapter}.\khmercounter{theorem}}
\def\proofname{សម្រាយ}

\begin{document}

\tableofcontents

\part{ចំណងជើងផ្នែក}

\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{ផ្នែករង}

\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{ផ្នែករង}
\Blindtext
\Blindtext

\subsection{ផ្នែករង}
\Blindtext
\Blindtext

\chapter{ចំណងជើងជំពូក}

\section{ផ្នែក}

\subsection{ផ្នែករង}
\Blindtext
\Blindtext

\subsection{ផ្នែករង}
\Blindtext
\Blindtext  

\part{ចំណងជើងផ្នែក}

\chapter{ចំណងជើងជំពូក}

\section{ផ្នែក}

\subsection{ផ្នែករង}
\Blindtext
\Blindtext

\subsection{ផ្នែករង}
\Blindtext
\Blindtext  

\chapter{ចំណងជើងជំពូក}

\section{ផ្នែក}

\subsection{ផ្នែករង}

\Blindtext
\Blindtext

\subsection{ផ្នែករង}

\Blindtext
\Blindtext

\end{document}

Reference

Numbering sections

share|improve this answer
1  
Sorry, is this an answer or an thank you? An Answer to who? BTW: Welcome to TeX.SE! –  Kurt Aug 5 '13 at 15:44
    
Sorry! Thanks to all above! –  OL SAY Aug 5 '13 at 15:55
    
Anyway, I am a younger learner, so only real code that I can only follow :) –  OL SAY Aug 5 '13 at 15:56
    
No problem, you are welcome! –  Kurt Aug 5 '13 at 15:57
add comment

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}
share|improve this answer
add comment

With XeTeX, you can create a mapping file, say khmerdigits.map:

LHSName "Digits"
pass(Unicode)
U+0030 <> U+17E0 ;
U+0031 <> U+17E1 ;
U+0032 <> U+17E2 ;
U+0033 <> U+17E3 ;
U+0034 <> U+17E4 ;
U+0035 <> U+17E5 ;
U+0036 <> U+17E6 ;
U+0037 <> U+17E7 ;
U+0038 <> U+17E8 ;
U+0039 <> U+17E9 ;

run teckit_compile khmerdigits.map to get khmerdigits.tec. Now your LaTeX document:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Mapping=khmerdigits]{<font name>}
\begin{document}
0123456789
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.