Initial problem:
I want to underline the text with a continuous line with the following code:
\uline{No underlining for \colorbox{lightgray}{everything} inside the colorbox.}
Workaround:
A solution to get a continuous line for the text inside \colorbox as well, is to do:
\sbox0{\uline{\hspace{\fboxsep}everything\hspace{\fboxsep}}}
\uline{No underlining for \colorbox{lightgray}{\hspace{-\fboxsep}\usebox0\hspace{-\fboxsep}} inside the colorbox.}
Question:
How can I redefine \uline, so every \colorbox inside \uline is locally defined as shown above in the workaround to have underlined text, too?
MCVE:
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage[normalem]{ulem}
\begin{document}
\uline{No underlining for \colorbox{lightgray}{everything} inside the colorbox.}
\end{document}




