I'm having trouble understanding part of the documentation for the soul package. I want to know the exact lower and upper positions of the produced colored rectangle when highlighting text via the \hl command. The documentation states that highlighting "is nothing else than overstriking with very thick lines" apparently of box height 2.5ex. I've been looking at sections 8.7-8.8 of the documentation.

When I compare highlighting via soul and blackouting via the censor package, the censor package blackouts text with default height and depth of 2.1 ex and -0.3ex respectively with a total box height of 2.4 ex.

I feel like there should be a way to highlight text with custom upper and lower bounds of the colored rectangle similar to how you can set the height and depth of the black box when blackouting via censor. E.g. \highlight{depth}{height}{text to be highlighted}.

Edit: I'm testing the following:


1 Answer 1


If you trace through the source code, you'll be able to find out that \SOUL@hlpreamble uses \SOUL@stpreamble, which in turns calculates the depth by

    \advance\[email protected]\dimen@

which means the box is made so that the center is 0.5ex above the baseline. Given that the box height is 2.5ex, this would mean the top is 0.5ex+1.25ex above the baseline and the bottom is 1.25ex-0.5ex below the baseline.

As for customizing the height, you could do something like

%! TEX program = lualatex

\ul{test test test}

\ul{test test test}

output image

where the first -2ex is the depth (the top of the box is 2ex above the baseline) and the second 2ex is the height.

Alternatively if you just want to change the height of the box you could use How to customize the highlight height with soul - TeX - LaTeX Stack Exchange or math mode - Customizing highlighting from soul - TeX - LaTeX Stack Exchange

You must log in to answer this question.

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