2

How to handle Cyrillic ymbols with soul package?

\documentclass[a4paper,10pt]{book}
\usepackage{polyglossia}
    \defaultfontfeatures{Ligatures={TeX}}
    \setmainfont{Liberation Serif}
    \setmonofont{Liberation Mono}
    \setmainlanguage{ukrainian}
\usepackage{soulutf8}
\begin{document}
    \mainmatter
    Короткий зміст\par
    Brief content\par
    \so{Короткий зміст}\par
    \so{Brief content}
\end{document}

Compile with

xelatex test.tex

enter image description here

I assume that this is caused by the absence of Cyrillic characters in the internal font used by soul package. It is possible to set this font with \font\SOUL@tt= but I don't know how I can use a font with this command.

I added \tracinglostchars=2 and saw this:

Missing character: There is no К in font ectt1000!
Missing character: There is no о in font ectt1000!
...
Missing character: There is no с in font ectt1000!
Missing character: There is no т in font ectt1000!
5
  • Is XeLaTeX a hard requirement or would you consider changing to LuaLaTeX? For the latter the excellent lua-ul package handles underlining flawlessly.
    – Skillmon
    Dec 12, 2021 at 18:16
  • And instead of \so you could use \textls provided by the microtype package in LuaTeX.
    – Skillmon
    Dec 12, 2021 at 18:23
  • @Skillmon I use XeTeX because I have a book typeset in XeTeX and I can't easily change to another system.
    – Yola
    Dec 12, 2021 at 18:38
  • Are you sure that LuaTeX doesn't work (the two are similar enough that most things should out of the box)? It should be possible to make soul work for you: You'll have to find a monospaced font that contains all characters you need.
    – Skillmon
    Dec 12, 2021 at 18:46
  • 1
    see here
    – Robert
    Dec 12, 2021 at 18:47

2 Answers 2

4

You can locally add the LetterSpace feature.

\documentclass[a4paper,10pt]{book}
\usepackage{polyglossia}

%\defaultfontfeatures{Ligatures={TeX}} % not needed
\setmainfont{Liberation Serif}
\setmonofont{Liberation Mono}
\setmainlanguage{ukrainian}

\NewDocumentCommand{\so}{m}{%
  {\addfontfeatures{LetterSpace=10,Ligatures=NoCommon}#1}%
}

\begin{document}

\mainmatter

Короткий зміст

Brief content ffi ffl

\so{Короткий зміст}

\so{Brief content ffi ffl}

Короткий зміст

Brief content ffi ffl

\end{document}

enter image description here

The Ligatures=NoCommon is necessary with fonts having ligatures, as the following example with Libertinus Serif instead of Liberation shows:

enter image description here

Beware that stealing sheep is not considered good practice. 😉

I know that it's common with Cyrillic to letter space also lower case for emphasis, but letter spacing Latin letters is not considered good typography.

1
  • I'm looking into sources of soul and see \let\so\textso where \textso is defined via \sodef so it has not only \SOUL@soletterskip but also \SOUL@soinnerskip and \SOUL@soouterskip. Seems like I need to know how to convert 3 \sodef parameters into LetterSpace,, maybe WordSpace, something else.
    – Yola
    Dec 13, 2021 at 2:39
2

Using LuaLaTeX and the microtype package you could use \textls instead of \so. If you also need highlighting, underlining or strike through of soul you could instead use the lua-ul package in LuaLaTeX.

\documentclass[a4paper,10pt]{book}
\usepackage[letterspace=200]{microtype}
\usepackage{polyglossia}
    \defaultfontfeatures{Ligatures={TeX}}
    \setmainfont{Liberation Serif}
    \setmonofont{Liberation Mono}
    \setmainlanguage{ukrainian}
\begin{document}
    \mainmatter
    Короткий зміст\par
    Brief content\par
    \textls{Короткий зміст}\par
    \textls{Brief content}
\end{document}

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.