5

I'm looking for a way to use enumerate from package enumitem with a custom alphabet. For starting, I just wanted to use letters instead of numbers, so I renewed the command that outputs item labels. I did:

\renewcommand{\labelenumi}{\alph{enumi}}

before \begin{enumerate}. But soon after I realised that I need letters č, š and ž, and that my alphabet has 25 characters, so I decided to create a command that would output a letter corresponding to a number. I did:

\newcommand*{\xslalph}[1]{%
    \ifcase#1\or a\or b\or c\or \v{c}\or d\or e\or f\or g\or h\or i%
    \or j\or k\or l\or m\or n\or o\or p\or r\or s\or \v{s}%
    \or t\or u\or v\or z\or \v{z}%
    \else\@ctrerr\fi
}

That would work if I wanted to get a character from this alphabet in the middle of text, for example in a sentence, I'd write \xslalph{3} and I'd get "c". But this didn't work in the above situation. Both \renewcommand{\labelenumi}{\xslalph{enumi}}, \renewcommand{\labelenumi}{\xslalph{\value{enumi}}} and \renewcommand{\labelenumi}{\xslalph{\theenumi}} would output "Missing number, treated as zero. \item" in the error log and no text would appear as the label of the item.

What would be the appropriate way to "pass" some number into my \xslalph command from the enumi counter? I'm sorry for misunderstanding, but I come from the world of C-like languages and am not used to LaTeX.

6

First of all, welcome to TeX.SX!

enumitem allows to do use other numbering systems in enumerate environments with the \AddEnumerateCounter command. It is described in section 8.1 of the documentation.

Here's an implementation of the counter using your \xslalph command.

\documentclass{article}
\usepackage{enumitem}
\makeatletter
\newcommand{\xslalph}[1]{\expandafter\@xslalph\csname c@#1\endcsname}
\newcommand{\@xslalph}[1]{%
    \ifcase#1\or a\or b\or c\or \v{c}\or d\or e\or f\or g\or h\or i%
    \or j\or k\or l\or m\or n\or o\or p\or r\or s\or \v{s}%
    \or t\or u\or v\or z\or \v{z}%
    \else\@ctrerr\fi%
}
\AddEnumerateCounter{\xslalph}{\@xslalph}{m}
\makeatother
\begin{document}
\begin{enumerate}[label=\xslalph*)]
    \item test
    \item test
    \item test
    \item test
\end{enumerate}
\end{document}

5
  • Thank you very much, can confirm this works as expected with latest TeX and enumitem on TeXStudio.
    – A4L
    Apr 12 '20 at 15:00
  • +and I am very sorry for not RTFDing and letting myself be spoon-fed. :D
    – A4L
    Apr 12 '20 at 15:08
  • I want to do something similar with labels from Georgian language. But I can not figure out how to do it. What should I use instead of \xslalf and \@xslalph from above? May 21 '20 at 5:35
  • @EvgenyKuznetsov It should work with these commands if you change the alphabet used in the definition of \@xslalph. So you should replace a,b,c,\vc{c}, etc. with the letters of the alphabet that you want to use, placed in correct order.
    – Vincent
    May 21 '20 at 14:07
  • I did what you suggest but do not why but it did not work. Then I tried example from package documentation and it worked fine. Thank you for attention. May 21 '20 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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