2

I'm trying to highlight a text written in Russian using soulutf8 package. In the PDF file, rendered with XeLaTeX, instead of highlighted Russian letters, I've got nothing. With English symbols, it works as expected.

My MWE:

\documentclass[a4paper, 11pt]{article}

\usepackage[main=russian, english]{babel}

\usepackage[T2A]{fontenc}
\usepackage[cm-default]{fontspec}
\setromanfont{PT Sans}

\usepackage[usenames,dvipsnames]{xcolor}

\usepackage{soulutf8}
\sethlcolor{red}

\begin{document}
Текст на русском для проверки кириллицы.

\hl{Выделенный русский тест}

\hl{Highlighted English text}
\end{document}

The result I get:

enter image description here

kvaleev
  • 449
  • 1
    you do not want legacy 8-bit encodings such as T2A with xetex, \usepackage[T2A]{fontenc} just use fontspec and Unicode encodings – David Carlisle Dec 01 '18 at 18:14
  • You shouldn't be using soulutf8 with XeLaTeX. On the other hand, soul seems not to be able to deal with Cyrillic characters. – egreg Dec 01 '18 at 21:34

1 Answers1

1

Similar to what was suggested in this answer, and also in this one, the highlighting of Cyrillic font can be achieved by adding the following lines after \usepackage{soulutf8} or \usepackage{soul}:

\makeatletter
\font\SOUL@tt={LiberationMono}
\setbox\z@\hbox{\SOUL@tt-}
\SOUL@ttwidth\wd\z@
\makeatother

or like this:

\makeatletter
\let\SOUL@tt\relax
\newfontface{\SOUL@tt}{LiberationMono}
\setbox\z@\hbox{\SOUL@tt-}
\SOUL@ttwidth\wd\z@
\makeatother

Here LiberationMono is just an axample of TrueType font with support of Cyrillic characters.

v_2e
  • 1,530