如何突出显示包含特殊字符“ą”、“č”、“ė”等的段落(使用 XeLaTex)

如何突出显示包含特殊字符“ą”、“č”、“ė”等的段落(使用 XeLaTex)

有人能帮我实现这个\hl功能吗?如果文本包含立陶宛语字母“ą”、“į”等,该如何将其用于段落?如果字母位于单词中间,则没问题,但当字母位于单词末尾时,会发生一些奇怪的事情。谢谢。

\documentclass[11pt,twoside]{extarticle}
\usepackage{polyglossia}
\setdefaultlanguage{lithuanian}
\setotherlanguage{english}

\usepackage{soul,color}

\makeatletter
\let\SOUL@tt\relax
\newfontface{\SOUL@tt}[Ligatures=TeX]{texgyrecursor-regular.otf}
\makeatother

\begin{document}
\hl{Here is some text in Lithuanian. When the special character is in the middle "sąryšis" of the word then "hl" works good and "mbox" is not necessary but if the word ends with special character "mergaitė glostė katę" then special characters "ė", "ė" and "ę" (and other š, ą, ų, į etc) are omitted and "mbox" fixes that although "mbox" does not break the line.  
  }
\end{document}

该代码不适用于 XeLaTex 和 TexMaker。有人能帮帮我吗?

答案1

使用 lmmono 并且如果我添加代码来重置连字符的宽度,您的示例将编译:

\documentclass[11pt,twoside]{extarticle}
\usepackage{polyglossia}
\setdefaultlanguage{lithuanian}
\setotherlanguage{english}

\usepackage{soul}
\usepackage{color}

\makeatletter
\font\SOUL@tt="LMMono10-Regular"
\setbox\z@\hbox{\SOUL@tt-}
\SOUL@ttwidth\wd\z@ %
\makeatother

\begin{document}

%\tracingmacros=1
\hl{Here is some text in Lithuanian. When the special character is in the middle "sąryšis" of the word then "hl" works good and "mbox" is not necessary but if the word ends with special character "mergaitė glostė katę" then special characters "ė", "ė" and "ę" (and other š, ą, ų, į etc) are omitted and "mbox" fixes that although "mbox" does not break the line.
  }
\end{document}

您的示例也使用 lualatex 为我编译。在我看来,这看起来像是一个舍入问题。

相关内容