In looking at Highlight text with colored underline link to margin notes, I was struck by (to me) the unexpectedly attractive look of text that is both highlighted and underlined -- certainly not recommended in all cases, but in this it would seem useful. I am somewhat familiar with soul and can easily achieve either, but not both. The documentation to soul says that nesting is not possible (which I can confirm :<( ). The code for soul is daunting and I am disinclined to tinker.

Is this possible?

  • well you probably can define your own highlighting style. But it would be easier to use lualatex and lua-ul. Commented Jan 4, 2022 at 13:33
  • Hmmm... lualatex... hmmm...
    – sgmoye
    Commented Jan 4, 2022 at 14:22
  • Besides lua-ul and censor, have a look at soulpos (caveat: I’m the author). Commented Jan 5, 2022 at 18:04
  • @JavierBezos Have looked and am intrigued!
    – sgmoye
    Commented Jan 5, 2022 at 20:18

1 Answer 1


A suitably modified censor package may provide something useful, in this regard. Make sure you get the latest [2021-12-23] version loaded, https://www.ctan.org/pkg/censor.




  \rlap{\censorul{\spacelap}} \llap{\censorrule{\spacelap}}%

\censorruledepth -\dp\strutbox
\censorruleheight \baselineskip
We now have to test this approach.
\xblackout{Testing of a theory is proceeding at this point.
We must see whether line breaking occurs.  I can even include
  expandable macros if I use v 4.0.  See: \expanded{\today}---however, 
  hyphenation will not occur with this approach.}
The test is now complete.

enter image description here


The OP points out an underlying problem, which extends not only to this solution, but to the censor package itself, which I will have to repair. The problem concerns macros like \$, \#, \&, etc., which should be consor-able, but which do not expand (via \expanded) into simple text.

The workaround provided was: \xblackout{...\censor{\$}...}.

A better solution is redefine \xblackout to look for such characters in the first place and, finding them, censor them without extra user intervention. The following code block demonstrates how that might be done. Note, however, a solution such as this will be eventually incorporated into the censor package.

Here is the added code needed to redefine \xblackout and to incorporate such a character check. Other character macros can be added to the \testchars macro:


  • This is excellent and extremely useful! The only problem I can find (by no means a deal breaker) is with \$ which is not obscured, as in \xblackout{ABCD\$EFGH}. Thank you very much.
    – sgmoye
    Commented Jan 5, 2022 at 13:54
  • @sgmoye As a workaround, you can use \xblackout{ABCD\censor{\$}EFGH}, but I will try to find a better way. Commented Jan 5, 2022 at 15:59
  • @sgmoye Please see the supplement to my answer. Commented Jan 5, 2022 at 16:32

You must log in to answer this question.

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