1

Here's a minimal working example:

\documentclass[a4paper]{article}
\usepackage{fontspec}
\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}
\newfontfamily{\cyrillicfonttt}{CMU Typewriter Text}
\usepackage{polyglossia}
% \setmainlanguage{ukrainian}
\usepackage{algorithm2e}

\begin{document}

\begin{algorithm}
    \SetKwData{Left}{left}
    \SetKwData{Right}{right}
    \SetKwFunction{Swap}{Swap}

    \For{$i \leftarrow 0$ \KwTo $n$}{
        \If{$\Left_i > 0$ {\bf and} $\Right_i > 0$}{
            \Swap{$\Left_i$, $\Right_i$}\;
        }
    }
\end{algorithm}

\end{document}

This code produces the following output:

Desired output.

Now, if I uncomment the \setmainlanguage{ukrainian} line, the output changes slightly:

Output with undesired emphasis.

As you see, here the keywords to, and, and arguments left and right became emphasized. It's not really that big of a problem, but it still bothers me, italic font here seems out of place. The same result occurs for Russian and Bulgarian, e.g. languages with Cyrillic script. What could be causing this behavior? I'd be really grateful for any advice.

  • 1
    Try adding \renewcommand{\ArgSty}[1]{\textnormal{\upshape #1}\unskip} to your preamble after loading algorithm2e. I'm not sure what else this might mess up... – Werner Apr 4 '14 at 17:05
  • @Werner Thank you, that works. Turns out algorithm2e even has a predefined macro \SetArgSty for that which is set by default to emph. But then, why the arguments are upright with English? I'm confused. – Kona-chan Apr 4 '14 at 17:59

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.