2

Can anyone help me with \hl function. How to use it for a paragraph if the text contains Lithuanian letters "ą","į" etc. If the letter is in the middle of the word then it is ok, but some strange things happen when the letter is at the end of word. Thank You.

\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}

The code does not work with XeLaTex and TexMaker. Can anyone help me?

Rasa
  • 71
  • I am quite raw in latex. If the problem is very similar so what in my code should be added to solve the problem. I do not use \usepackage{fontspec} \setmainfont[Ligatures = TeX]{TeX Gyre Pagella} – Rasa Nov 26 '16 at 12:39
  • Dear reviewers eager to close this posting: The other thread may identify the problem, but I don't see how the answer supplied there solves this problem, at least not in a direct way without requiring additional knowledge about available and used fonts. Maybe the next one voting for closure could post a solution before? – gernot Nov 26 '16 at 13:19
  • @Rasa Just add the four lines in my answer after the loading of soul (and before \begin{document}), you're done. Depending on your font setup you may need to change TeX Gyre Cursor into texgyrecursor-regular.otf – egreg Nov 26 '16 at 13:31
  • @egreg On TexLive 2016, last updated today, I can verify the issue with xelatex as well as lualatex: ė vanishes (though not ę). Adding the four lines from the other thread does not solve the problem, even after changing the font name: Both processors yield the error Package soul Error: Reconstruction failed. So I'd not consider this issue as resolved. – gernot Nov 26 '16 at 14:45
  • @gernot I agree – egreg Nov 26 '16 at 14:46
  • 1
    @gernot I think soul is fundamentally broken with XeLaTeX – egreg Nov 26 '16 at 15:07
  • Depending on how important it is to use soul, consider switching to pdflatex (instead of xelatex or lualatex) using the preamble \usepackage[utf8]{inputenc} \usepackage[L7x]{fontenc} \usepackage[english,lithuanian]{babel} \usepackage{soulutf8,color} (instead of polyglossia etc). – gernot Nov 26 '16 at 15:37
  • I added four lines as suggested, changed to texgyrecursor-regular.otf. Nothing good with xelatex (Xelatex is necessary for my fonts). Maybe there is any other idea how to highlight the new inserts or changes made in documents? – Rasa Nov 26 '16 at 16:01

1 Answers1

2

With lmmono and if I add the code to reset the width of the hyphen your example compile:

\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}

Your example also compile for me with lualatex. Imho this looks like a rounding problem.

Ulrike Fischer
  • 327,261
  • But if I want to add for example \citep{Bernstein2001} in \hl{...} it says "error that there is extra '}'". So a new problem occurs. – Rasa Nov 27 '16 at 12:32
  • That's not specific to xelatex. A lot commands are problematic in a soul command. Put it in a box. – Ulrike Fischer Nov 27 '16 at 15:18
  • Thank You, it worked. The \hl function is just for marking the changes. It's a pity that many things I will have to delete to eliminate the markings. – Rasa Nov 28 '16 at 08:01
  • This is a hideous hack, but it seems to work with LuaLaTeX… Thanks! :-) – Júda Ronén Jun 25 '17 at 14:48