# overlapping underline

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.

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.

\documentclass[a5paper]{article}
\usepackage{ulem}
\begin{document}

\underline{aba}\underline{ab\underline{\vphantom{\_}a}}\underline{ba}

\end{document}


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 '16 at 15:32
• Many thanks, it is exactly what I needed. Laurent – LaurentM Jun 14 '16 at 11:46