如何添加更多密钥来枚举包

如何添加更多密钥来枚举包

beamer类加载enumerate包允许我们使用 key 1,a,A,i,I。在我的目的中,我想添加两个名为mk的键高棉语(柬埔寨语)数字字母分别。我尝试重新定义\@enloop@我找到的现有键定义。这是我的 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}

看上去有效,但实际上无效。需要帮助!

答案1

只需将 移至@cgnieder 在评论中指出makeatletter之前的一行即可解决问题。\def\khmer

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

高棉字母

高棉数字

相关内容