1

I have the following code in soul to allow underlines for letters with descenders.

\usepackage{xcolor}
\usepackage{xparse}
\usepackage{soul}
\makeatletter
\ExplSyntaxOn
\cs_new:Npn \white_text:n #1
  {
    \fp_set:Nn \l_tmpa_fp {#1 * .01}
    \llap{\textcolor{white}{\the\SOUL@syllable}\hspace{\fp_to_decimal:N \l_tmpa_fp em}}
    \llap{\textcolor{white}{\the\SOUL@syllable}\hspace{-\fp_to_decimal:N \l_tmpa_fp em}}
  }
\NewDocumentCommand{\whiten}{ m }
    {
      \int_step_function:nnnN {1}{1}{#1} \white_text:n
    }
\ExplSyntaxOff

\NewDocumentCommand{ \varul }{ D<>{5} O{0.2ex} O{0.1ex} +m } {%
\begingroup
\setul{#2}{#3}%
\def\SOUL@uleverysyllable{%
   \setbox0=\hbox{\the\SOUL@syllable}%
   \ifdim\dp0>\z@
      \SOUL@ulunderline{\phantom{\the\SOUL@syllable}}%
      \whiten{#1}%
      \llap{%
        \the\SOUL@syllable
        \SOUL@setkern\SOUL@charkern
      }%
   \else
       \SOUL@ulunderline{%
         \the\SOUL@syllable
         \SOUL@setkern\SOUL@charkern
       }%
   \fi}%
    \ul{#4}%
\endgroup
}
\makeatother

I've tried using it for the pinyin syllable xiě but it just doesn't print the ě, resulting in this:

\begin{document}
\varul{xiě}
\end{document}

enter image description here

The code works fine with the character set áàéèíìóòú} but not āǎēěīǐōǒūǔǖǘǚǜ. This more or less makes sense, and I'd nonrmallyjust assume it's an ASCII thing or something. However, it works fine for actual Chinese, like so:

\begin{document}
\varul{绿} se pronuncia \varul{lǜ}
\end{document}

enter image description here

Why is this? And how do I fix it? Thanks!!

  • 2
    soul is quite a pain. Can't you use lualatex and lua-ul? – Ulrike Fischer Apr 12 '21 at 14:28
  • beside this: you didn't provide a complete example, but to use soul you need to setup its font correctly, see e.g. https://tex.stackexchange.com/a/298025/2388 – Ulrike Fischer Apr 12 '21 at 14:40
  • 1
    You could try using ulem instead of soul if for some reason LuaLaTeX and lua-ul isn't an option. ulem is a bit more robust, but doesn't allow automatic hyphenation (instead, you can use \- to provide hyphenation points which still works). – Skillmon Apr 12 '21 at 18:45

0 Answers0