9

The \hl command from the soul package highlights spans of text with a backround color when color is loaded. When used on longer spans of text, some inter-line spacing remains uncolored, which is rather unpleasant to my eye.

\documentclass[a8paper, landscape]{scrartcl}
\usepackage{color, soul}
\sethlcolor{red}
\begin{document}
  This is some text \hl{of that some part should be highlighted. This part spans multiple lines}, which is easy on a8paper.
\end{document}

current outcome

I already tried to tinker with \setul, but increasing the height and depth there just enlarges the line height, leaving unchanged the spacing in between.

Is there a way to have the result look like this?

sought result

Answers do not have to be restricted to the package. (Meaning soul-less answers are also welcome. ;)

1 Answer 1

7

A non-soul approach can be found in wrapping inline long lines and adding background color

And see also Listing with background color not line breaking correctly

But it is impossible to re-create with a few macros all the job done by soul.(*) Here is a customization of soul's highlighting driver which seems to obtain what is required:

(*) besides the solutions linked to above seem to be using only monotype font.

\documentclass[12pt, a4paper, landscape]{scrartcl}
\usepackage{color, soul}
\sethlcolor{red}
\makeatletter
\def\SOUL@hlpreamble{%
    \setul{\dp\strutbox}{\dimexpr\ht\strutbox+\dp\strutbox\relax}%
    \let\SOUL@stcolor\SOUL@hlcolor
    \SOUL@stpreamble
}
\makeatother

\usepackage[textwidth=10cm]{geometry}
\usepackage{multicol}

\begin{document}
\begin{multicols}{3}\raggedcolumns
  This is some text \hl{of that some part should be highlighted. This part
    spans multiple lines}, which is easy on a8paper.
\columnbreak

  This is some text {of that some part should be highlighted. This part
    spans multiple lines}, which is easy on a8paper.
\columnbreak

  This is some text \hl{of that some part should be highlighted. This part
    spans multiple lines}, which is easy on a8paper.
\end{multicols}
\end{document}

soul highlighting

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .