1

I use lots of highlights as it is used to mark my revision from each version before I gave to my lecturer. When I highlight lots of texts, I found out that sometimes page restarted in the middle.

After an hour of stress, I found the cause, that is heavy use of highlight as mentioned here. That page mention soul, but I use soulpos. It seems that both packages got the same bug.

Below is my code to make the highlight:

\usepackage{soulpos}
\ulposdef{\hly}{%
  \mbox{%
    \color{yellow}%
    \rule[-.8ex]{\ulwidth}{11pt}%
    \tolerance=1%
    \emergencystretch=\maxdimen}}

Any solution? Why this is happening? Can this kind of bug be fixed? Thanks.

EDIT:

From the comment section, this bug for soul is discussed and solved here. Sadly, soulpos did not use \countdef and the same fix can't be used.

EDIT after more testing:

Okay, now I become more confused:

  1. With separate cls, soulpos did not get this problem. See here
  2. With no separate cls, soulpos can't solve even with the minus. See here

This (No 2) got wrong page numbering, but not if I use .cls (see No 1)

\documentclass{article}
\usepackage{soulpos}

\makeatletter \newcount\SOUL@minus % \newcount\SOULPOS@minus \makeatother

\usepackage{xcolor} \usepackage{blindtext}

\ulposdef{\hly}{% \mbox{% \color{yellow}% \rule[-.8ex]{\ulwidth}{11pt}% \tolerance=1% \emergencystretch=\maxdimen}}

\begin{document}

\Blindtext[4] \blindtext \hl{Closing words

New paragraph!}

\clearpage

\Blindtext[4] \blindtext \hly{Closing words

New paragraph!}

\end{document}

  • 2
    sorry but neither your question nor the page you link too contains any useful information. You only claim that soul is doing something without any proof or code. But if you want to do lots of highlighting, I recommend to switch to lualatex and lua-ul. That is much more stable than soul. – Ulrike Fischer Feb 17 '23 at 15:51
  • As @UlrikeFischer said, switch to lua. You can even make lua-ul backwards compatible to soul: \usepackage[soul]{lua-ul} – DG' Feb 17 '23 at 15:54
  • Does the answers at https://tex.stackexchange.com/questions/25250/bug-with-page-numbers-when-using-soul-package helps you? – quark67 Feb 17 '23 at 16:31
  • 1
    \mbox{% \color{yellow}% \rule[-.8ex]{\ulwidth}{11pt}% \tolerance=1% \emergencystretch=\maxdimen makes yellow rule but why are you setting \tolerance= and \emergencystretch in an \mbox ????? – David Carlisle Feb 17 '23 at 19:50
  • @quark67 thanks a lot, that was the point of my question. Sadly, the fix described there only works for soul. Is a fix possible for soulpos? – Muhammad Yasirroni Feb 18 '23 at 04:32
  • @DavidCarlisle that is required in my document. Remove that line will cause all highlight to be slightly mismatched with other text. – Muhammad Yasirroni Feb 18 '23 at 04:55
  • @MuhammadYasirroni those settings in an mbox do nothing at all. but as you have posted no code showing your problem it will not be possible to answer your question – David Carlisle Feb 18 '23 at 08:58

1 Answers1

1

After some trial and error, based on @quark67 comment, I found out that using this combo solve my issue. I haven't fully tested it, but it works for now.

\usepackage{soulpos}
\newcount\SOUL@minus

EDIT after more testing:

Okay, now I become more confused:

  1. With separate cls, soulpos did not get this problem. See here
  2. With no separate cls, soulpos can't solve even with the minus. See here