# Latex answers package and cyrilic symbols in enumerate environment

I'm using both the answers package for an exercise book and Cyrillic symbols for 2nd level items. Here is my .tex code.

\documentclass[10pt, a4paper, openany]{report}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

\begin{document}

\renewcommand{\theenumii}{\asbuk{enumii}}

\Newassociation{otv}{Otvet}{ans}
\Opensolutionfile{ans}[C1.ans6]

\begin{enumerate}
\item
\begin{enumerate}
\item Excercise 1a)
\begin{otv}
\item Excercise 1b)
\begin{otv}
\end{enumerate}
\end{enumerate}

\Closesolutionfile{ans}

\input{c1.ans6}

\end{document}


and this error occurs

...\c1.ans6.tex:1: Undefined control sequence. [\begin{Otvet}{1.1.\T2A\cyra )}]


\begin{Otvet}{1\T2A\cyra }
\end{Otvet}
\begin{Otvet}{1\T2A\cyrb }
\end{Otvet}


Could anyone help me to deal with this problem?

• Welcome to TeX.SX! Please help us to help you and provide a full (but minimal) compilable document. It's difficult or often impossible to help someone with just some snippets. Reduce your document as much as possible while still getting this error. Thanks. – LaRiFaRi Aug 4 '14 at 13:06

You need an \immediate version of \protected@write, because commands such as \cyra, produced by \asbuk don't survive \write.

The code is like in Replacing some macro tokens in a list before \write ing, then I also patch \Newassociation to use \protected@iwrite instead of \immediate\write.

\documentclass[10pt, a4paper, openany]{report}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage{xpatch}
\makeatletter
% get a copy of \protected@write
\let\protected@iwrite\protected@write
% patch the copy to add \immediate
\xpatchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}

\xpatchcmd{\Newassociation}
{\immediate\write\@nameuse{#3@file}}
{\protected@iwrite{\@nameuse{#3@file}}{}}
{}{}
\makeatother

\begin{document}

\renewcommand{\theenumii}{\asbuk{enumii}}

\Newassociation{otv}{Otvet}{ans}
\Opensolutionfile{ans}[\jobname.ans6]

\begin{enumerate}
\item
\begin{enumerate}
\item Excercise 1a)
\begin{otv}
\end{otv}
\item Excercise 1b)
\begin{otv}

• Note that the current version of answers.sty` (that is, v2.16 released 2014/08/24) implements the change, so there's no need for the patch any more. – egreg Mar 28 '15 at 20:21