I am using the following customization from make soul highlight span lines for the \hl
from soul
to get rid of the gaps between the highlighted zones:
\documentclass[a8paper, landscape]{scrartcl}
\usepackage{soul}
\usepackage[svgnames]{xcolor}
\sethlcolor{LightBlue}
\makeatletter
\def\SOUL@hlpreamble{%
\setul{\dp\strutbox}{\dimexpr\ht\strutbox+\dp\strutbox\relax}
\let\SOUL@stcolor\SOUL@hlcolor
\SOUL@stpreamble
}
\makeatother
\begin{document}
This is some \hl{highlighted text with a formula $q=\frac{p}{r}$.
Notice how nicely it is highlighted.}
Writting something more fancy, say, \hl{$|a|=\inf_{\overline{f}=a}|f|$,
gives an obvious gap problem.}
\end{document}
Which produces
However, if there are symbols that extend below/above too much, the \hl
does not fully highlight the gap, as the above example shows. I tried to fiddle with the \setul
part but nothing seems to give a good result. I also tried to \smash
the inf construction, but then the line below just overlaps with the one above.
What would be the right setup to highlight that gap?
Best Answer
Add some more to the depth (and the thickness), also setting
\lineskip
to zero. Note that this changes the interline space, but there's no way that I know for convincingsoul
and\hl
to cover something that exceeds the stated depth for the underline (the background color is realized as underlining with a very thick rule).Don't use
\hl
in your final document.