I would like to underline all occurrences of a factor that appears in a text, e. g. all occurrences of aba in text=abaababa

If I use underline, I won't see clearly the three occurrences so what I need is a package which allows me to use overlapping \underline{}.

I did it in the past and it worked well (it's therefore feasible) but I'm getting old now and I don't remember how I did it.


1 Answer 1


I don't know about a package for overlapping underline, but I once solved this by using regular underline and \vphantom{} for lowering parts of the line. With \vphantom{} you can make sure the lines don't overlap, but are spaced underneath each other.




This should give you the right underlining. If necessary you can use \vphantom{p} for more vertical space. Note that you would be 'sticking' two underlines together for the last aba, rather then making one. You will notice that if you replace the underscore with a p.

  • Is ulem package required with \underline{}?
    – pzorba75
    Jun 13, 2016 at 15:32
  • Many thanks, it is exactly what I needed. Laurent
    – LaurentM
    Jun 14, 2016 at 11:46

You must log in to answer this question.

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