Short question is: How to compare two macros containing Cyrillic?

It is not difficult to compare two strings with \ifx for Latin strings

\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi % 1

But what if I want to do the same for Cyrillic strings?

\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi % 

I would like to receive 1 in this case too.

Full MWE:



\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi % 1


\ifx\contentsname\contentsnameinlanguage 1 \else 0 \fi % 0


  • The problem of your comparison is, that the first definition of \contentsname after the \selectlanguage{ukrainian} is {\cyr \CYRZ \cyrm \cyrii \cyrs \cyrt } and not Зміст. – Skillmon Jul 25 '17 at 19:00
  • @Skillmon I realised that – sergiokapone Jul 25 '17 at 19:02
  • Comparing against \def\contentsnameinlanguage{{\cyr\CYRZ\cyrm\cyrii\cyrs\cyrt}} would work. The tokens simply don't match. – Skillmon Jul 25 '17 at 19:03
  • 1
    You can make the compare with \ifx work with \edef\contentsnameinlanguage{{\cyrЗміст}} compared against \edef\contentsnameedef{\contentsname} if that's better for you. – Skillmon Jul 25 '17 at 19:13
  • @Skillmon are you sure? – David Carlisle Jul 25 '17 at 19:50

Your Answer

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

Browse other questions tagged or ask your own question.