jbezos / enumitem

Customize enumerate, itemize and description
MIT License
48 stars 5 forks source link

Defining Russian Asbuk counters and redirecting Alph to Asbuk respecting the (max) width #26

Open ivankokan opened 3 years ago

ivankokan commented 3 years ago

Hi, motivated by the https://github.com/latex3/babel/issues/144 issue, I want to get your expert/author's opinion on the following MWE in which I want to properly specify two new variants of enumitem's counters, respecting the widest ones and redirecting all alph/Alph formats to use them by default:

\documentclass{article}

\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}

\usepackage{enumitem}

\makeatletter
\AddEnumerateCounter{\asbuk}{\russian@alph}{ж}
\AddEnumerateCounter{\Asbuk}{\russian@Alph}{Ж}
\makeatother

\makeatletter
\addto\extrasrussian{
\babel@save{\alph}
\babel@save{\Alph}
\let\alph\asbuk
\let\Alph\Asbuk
}
\makeatother

\newcounter{counter}
\setcounter{counter}{7}

\begin{document}

English: \alph{counter}/\Alph{counter}
\begin{enumerate}[label=\alph*]
\item  1 \item  2 \item  3 \item  4 \item  5 \item  6 \item  7 \item  8 \item  9 \item 10
\item 11 \item 12 \item 13 \item 14 \item 15 \item 16 \item 17 \item 18 \item 19 \item 20
\end{enumerate}

\selectlanguage{russian}
\fontencoding{T2A}\selectfont
Russian: \alph{counter}/\Alph{counter}
\begin{enumerate}[label=\alph*]
\item  1 \item  2 \item  3 \item  4 \item  5 \item  6 \item  7 \item  8 \item  9 \item 10
\item 11 \item 12 \item 13 \item 14 \item 15 \item 16 \item 17 \item 18 \item 19 \item 20
\end{enumerate}

\selectlanguage{english}
\fontencoding{T1}\selectfont
English: \alph{counter}/\Alph{counter}
\begin{enumerate}[label=\alph*]
\item  1 \item  2 \item  3 \item  4 \item  5 \item  6 \item  7 \item  8 \item  9 \item 10
\item 11 \item 12 \item 13 \item 14 \item 15 \item 16 \item 17 \item 18 \item 19 \item 20
\end{enumerate}

\end{document}

Do you find the following lines

\makeatletter
\addto\extrasrussian{
\babel@save{\alph}
\babel@save{\Alph}
\let\alph\asbuk
\let\Alph\Asbuk
}
\makeatother

the most appropriate to achieve such a goal?

As far as I understand the documentation, \babel@save puts the control sequence on the stack and automatically restores (pops) the value when the language is unselected, so nothing has to be added to \noextrasrussian?

Regards, Ivan

EDIT: Enriched MWE to present the multi-language context.