1

I am trying to use soul to underline a word in a Hebrew document:

% !TEX TS-program = xelatex
\documentclass{beamer}
\usepackage{xcolor,soul}
\setul{0.2ex}{0.1ex}
\setulcolor{red}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\englishfontsf{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\englishfont{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\hebrewfont{Arial}[Script=Hebrew]
\newfontfamily\hebrewfontsf{Arial}[Script=Hebrew]
\newfontfamily\opensansH{Open Sans Hebrew}[Script=Hebrew]

\begin{document} \begin{frame}{הקדמה} קו \ul{תחתון}. \end{frame} \end{document}

I get "Missing character" errors:

Missing character: There is no ת ("5EA) in font ectt1000!
Missing character: There is no ח ("5D7) in font ectt1000!
...

for each letter inside the ul command.

Why is that?

I might abandon it and do italics rather than underlining if it is not possible, but I would like to make sure it is not possible.

tush
  • 1,115

1 Answers1

2

Depending on your definition of "not possible":

Swap to lualatex and use lua-ul package.

lua-ul

MWE

% !TEX TS-program = lualatex
\documentclass{beamer}
%\usepackage{xcolor,soul}
%\setul{0.2ex}{0.1ex}
%\setulcolor{red}
\usepackage{xcolor,luacolor}
\usepackage[soul]{lua-ul}
\LuaULSetHighLightColor{red!12}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\englishfontsf{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\englishfont{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\hebrewfont{Arial}[Script=Hebrew]
\newfontfamily\hebrewfontsf{Arial}[Script=Hebrew]
\newfontfamily\opensansH{Noto Sans Hebrew}[Script=Hebrew]

\begin{document} \begin{frame}{הקדמה} קו \ul{תחתון}.

קו \highLight{תחתון}.

\end{frame} \end{document}

I'll have to read the doc to see how to get a red underline.


Attempt:

Using \newunderlinetype, but I do not know enough about bezier curves at the moment.

red underline

MWE

% !TEX TS-program = lualatex
\documentclass{beamer}
%\usepackage{xcolor,soul}
%\setul{0.2ex}{0.1ex}
%\setulcolor{red}
\usepackage{xcolor,luacolor}
\usepackage[soul]{lua-ul}
\LuaULSetHighLightColor{red!12}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\englishfontsf{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\englishfont{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\hebrewfont{Arial}[Script=Hebrew]
\newfontfamily\hebrewfontsf{Arial}[Script=Hebrew]
\newfontfamily\opensansH{Noto Sans Hebrew}[Script=Hebrew]

\newunderlinetype\myunderlinered{\cleaders\hbox{% \setlength\unitlength{.2ex}% \begin{picture}(5,0)(0,1) \thicklines \color{red}% \qbezier(0,0)(0,0)(5,0)%(0,0)(0.5,0)(1,0) \end{picture}% }}

\newcommand\underLineR[1]{{\myunderlinered{#1}}}

\begin{document} \begin{frame}{הקדמה} קו \ul{תחתון}.

קו \highLight{תחתון}.

קו \underLineR{תחתון}.

\selectlanguage{english} xxx\underLineR{abc}xxx yyy\underLineR{fghp}yyy zzz\underLineR{xyzqj}zzz

\underLineR{b} \underLineR{bb} \underLineR{bbb} \underLineR{bbbb}

\end{frame} \end{document}


Addition based on the comments

Illustrating \rule method:

rule underline

MWE

% !TEX TS-program = lualatex
\documentclass{beamer}
\usepackage{xcolor,luacolor}
\usepackage[soul]{lua-ul}
\LuaULSetHighLightColor{red!12}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\englishfontsf{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\englishfont{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\hebrewfont{Arial}[Script=Hebrew]
\newfontfamily\hebrewfontsf{Arial}[Script=Hebrew]
\newfontfamily\opensansH{Noto Sans Hebrew}[Script=Hebrew]
\newfontface\fsym{Noto Sans Symbols}
%
\newunderlinetype\myunderlinered{\cleaders\hbox{%
    \setlength\unitlength{.2ex}%
    \begin{picture}(5,0)(0,1)
      \thicklines
      \color{red}%
      \qbezier(0,0)(0,0)(5,0)%(0,0)(0.5,0)(1,0)
    \end{picture}%
}}
\newcommand\underLineR[1]{{\myunderlinered{#1}}}
%
\newunderlinetype\myunderlineredb{\color{red}\leaders \vrule height -.65ex depth .75ex}
\newcommand\underLineRb[1]{{\myunderlineredb{#1}}}
%
%\newcommand\underLineRc[1]{\underLine[color=red]{#1}}
\newcommand\underLineRc[1]{{\myunderlineredb{#1}}}

% ⚙ = 9881 %adapted from unisugar package: %make ⚙ an escape character \catcode⚙=11%catcode for letter (unisugar package assigns a unicode char here) \edef\⚙{⚙} \catcode⚙=0%escape character and control sequence

%◇ 9671 begin group %◈ 9672 end group

\catcode◇=1% 9671 begin group \catcode◈=2% 9672 end group

% underline % לָשִׂים דָגֵשׁ % \newcommand⚙לש{\underLineRc}

\begin{document} \begin{frame}{הקדמה} קו \ul{תחתון}.

קו \highLight{תחתון}.

קו \underLineR{תחתון}. \textenglish{cleaders of picture containing bezier curve}

קו \underLineRb{תחתון}. \textenglish{leaders of vrule}

קו ⚙לש{תחתון}.

קו ⚙לש◇תחתון◈. \textenglish{{\fsym \⚙} as escape for \texthebrew{{\fsym \⚙}לש} command}

\end{frame} \end{document}

For input, it is easier to define a direction-neutral control sequence escape character (here, ), begin group () and end group (), and a command ⚙לש which does

\newcommand⚙לש{\underLineRc}

and type קו ⚙לש◇תחתון◈., instead of double-directioned material like

קו \underLineRb{תחתון}.

(Code is OK in TeXWorks; the browser is doing its own interpretation of RTL.)

Cicada
  • 10,129
  • 1
    For the red underline you can avoid bezier curves with e.g. \newunderlinetype\myunderlinered{\color{red}\leaders \vrule height -.65ex depth .75ex}. This also results in better lengths since the length doesn't have to be a multiple of the picture size. – Marcel Krüger Oct 30 '22 at 03:04
  • 1
    Alternatively current versions support \newcommand\underLineR{\underLine[color=red]}. – Marcel Krüger Oct 30 '22 at 03:05
  • @MarcelKrüger Thanks. I've added to answer as visual illustration so people can see. The rule method is much better and practical. – Cicada Oct 30 '22 at 12:00