\hl
包中的命令在加载soul
时会使用背景颜色突出显示文本跨度color
。当用于较长的文本跨度时,一些行间间距仍未着色,这对我来说相当不愉快。
\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}
我已经尝试修改\setul
,但增加那里的高度和深度只会扩大行高,而中间的间距保持不变。
有没有办法让结果看起来像这样?
答案不必局限于软件包。(soul
也欢迎无意义的答案。;)
答案1
非灵魂方法可以发现于换行较长的行并添加背景颜色
另请参阅列表的背景颜色没有正确换行
但不可能用几个宏来重新创建灵魂.(*) 这里是对突出显示驱动程序的定制soul
,它似乎获得了所需的内容:
(*)此外,上面链接的解决方案似乎只使用单型字体。
\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}