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?

\hlin your final document" ? Is there a better method to do this kind of highlighting without usingsoul? – Lukas Jan 17 '17 at 13:56