4

beamer class loads enumerate package that allow us to use key 1,a,A,i,I. In my purpose, I want to add two more keys called m and k for Khmer (Cambodian) numeral and alphabet respectively. My attempt is to redefine the \@enloop@ where I have found the existing keys defined. Here is my MWE

\documentclass[12pt,serif]{beamer}
%TODO: Khmer (Cambodian)
\usepackage[no-math]{fontspec}% no math font
\setmainfont{Khmer OS System}% roman font
\setsansfont{Khmer OS Bokor}% sans serif font
\setmonofont{Khmer OS Freehand}% typewriter font
\XeTeXlinebreaklocale "khm"% line break rule
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.5pt% line break skip
%TODO: Khmer number
\def\khmer#1{\expandafter\@khmer\csname c@#1\endcsname}
\def\@khmer#1{\expandafter\@@khmer\number#1\@nil}
\def\@@khmer#1{%
    \ifx#1\@nil% terminate when encounter @nil
    \else%
    \ifcase#1 ០\or ១\or ២\or ៣\or ៤\or ៥\or ៦\or ៧\or ៨\or ៩\fi%
    \expandafter\@@khmer% recursively map the following characters
    \fi}
\def\khmernumeral#1{\@@khmer#1\@nil}
%TODO: khmer alphabet
\def\alpkh#1{\expandafter\@alpkh\csname c@#1\endcsname}
\def\@alpkh#1{%
    \ifcase#1% zero -> none
    \or ក\or ខ\or គ\or ឃ\or ង%
    \or ច\or ឆ\or ជ\or ឈ\or ញ%
    \or ដ\or ឋ\or ឌ\or ឍ\or ណ%
    \or ត\or ថ\or ទ\or ធ\or ន%
    \or ប\or ផ\or ព\or ភ\or ម%
    \or យ\or រ\or ល\or វ\or ស%
    \or ហ\or ឡ\or អ%
    \else%
    \@ctrerr% otherwise, counter error!
    \fi}
%TODO: try to add 2 more key to `enumerate' called [m] and [k]
\makeatletter
\def\@enloop@{%
    \ifx A\@entemp \def\@tempa{\@enLabel\Alph  }\else
    \ifx a\@entemp \def\@tempa{\@enLabel\alph  }\else
    \ifx i\@entemp \def\@tempa{\@enLabel\roman }\else
    \ifx I\@entemp \def\@tempa{\@enLabel\Roman }\else
    \ifx 1\@entemp \def\@tempa{\@enLabel\arabic}\else
    \ifx k\@entemp \def\@tempa{\@enLabel\alpkh }\else% added
    \ifx m\@entemp \def\@tempa{\@enLabel\khmer }\else% added
    \ifx \@sptoken\@entemp \let\@tempa\@enSpace \else
    \ifx \bgroup\@entemp \let\@tempa\@enGroup \else
    \ifx \@enum@\@entemp \let\@tempa\@gobble \else
    \let\@tempa\@enOther
    \@enhook
    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% 2 \fi added
    \@tempa}
\makeatother
%
\setbeamertemplate{items}[circle]
%
\begin{document}
    \begin{frame}
        \begin{enumerate}[k]
            \item add enumerate key
            \item for use with Khmer alphabets and numerals
        \end{enumerate}
    \end{frame}
    \begin{frame}
        \begin{enumerate}[m]
            \item add enumerate key
            \item for use with Khmer alphabets and numerals
        \end{enumerate}
    \end{frame}
\end{document}

It seems work, but it does not. Need help!

2
  • 2
    Move \makeatletter before \def\khmer
    – cgnieder
    Commented Feb 23, 2020 at 0:16
  • 1
    Oh, it is my simple mistake. Thank for pointing out.
    – Say OL
    Commented Feb 23, 2020 at 1:43

1 Answer 1

2

The problem is solved by just moving the makeatletter to a line before \def\khmer pointed out in comment by @cgnieder.

\documentclass[12pt,serif]{beamer}
%TODO: Khmer (Cambodian)
\usepackage[no-math]{fontspec}% no math font
\setmainfont{Khmer OS System}% roman font
\setsansfont{Khmer OS Bokor}% sans serif font
\setmonofont{Khmer OS Freehand}% typewriter font
\XeTeXlinebreaklocale "khm"% line break rule
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.5pt% line break skip
%TODO: Khmer number
\makeatletter
\def\khmer#1{\expandafter\@khmer\csname c@#1\endcsname}
\def\@khmer#1{\expandafter\@@khmer\number#1\@nil}
\def\@@khmer#1{%
    \ifx#1\@nil% terminate when encounter @nil
    \else%
    \ifcase#1 ០\or ១\or ២\or ៣\or ៤\or ៥\or ៦\or ៧\or ៨\or ៩\fi%
    \expandafter\@@khmer% recursively map the following characters
    \fi}
\def\khmernumeral#1{\@@khmer#1\@nil}
%TODO: khmer alphabet
\def\alpkh#1{\expandafter\@alpkh\csname c@#1\endcsname}
\def\@alpkh#1{%
    \ifcase#1% zero -> none
    \or ក\or ខ\or គ\or ឃ\or ង%
    \or ច\or ឆ\or ជ\or ឈ\or ញ%
    \or ដ\or ឋ\or ឌ\or ឍ\or ណ%
    \or ត\or ថ\or ទ\or ធ\or ន%
    \or ប\or ផ\or ព\or ភ\or ម%
    \or យ\or រ\or ល\or វ\or ស%
    \or ហ\or ឡ\or អ%
    \else%
    \@ctrerr% otherwise, counter error!
    \fi}
%TODO: try to add 2 more key to `enumerate' called [m] and [k]
\def\@enloop@{%
    \ifx A\@entemp \def\@tempa{\@enLabel\Alph  }\else
    \ifx a\@entemp \def\@tempa{\@enLabel\alph  }\else
    \ifx i\@entemp \def\@tempa{\@enLabel\roman }\else
    \ifx I\@entemp \def\@tempa{\@enLabel\Roman }\else
    \ifx 1\@entemp \def\@tempa{\@enLabel\arabic}\else
    \ifx k\@entemp \def\@tempa{\@enLabel\alpkh }\else% added
    \ifx m\@entemp \def\@tempa{\@enLabel\khmer }\else% added
    \ifx \@sptoken\@entemp \let\@tempa\@enSpace \else
    \ifx \bgroup\@entemp \let\@tempa\@enGroup \else
    \ifx \@enum@\@entemp \let\@tempa\@gobble \else
    \let\@tempa\@enOther
    \@enhook
    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% 2 \fi added
    \@tempa}
\makeatother
%
\setbeamertemplate{items}[circle]
%
\begin{document}
    \begin{frame}
        \begin{enumerate}[k]
            \item add enumerate key
            \item for use with Khmer alphabets and numerals
        \end{enumerate}
    \end{frame}
    \begin{frame}
        \begin{enumerate}[m]
            \item add enumerate key
            \item for use with Khmer alphabets and numerals
        \end{enumerate}
    \end{frame}
\end{document}

Khmer alphabets

Khmer numerals

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .