\textitis canceled by\textup\itshapeis canceled by\upshape\textbfis canceled by\textmd\bfseriesis canceled by\mdseries\normalfontcancels everything
What cancles \underline?
\documentclass{article}
\usepackage[LY1]{fontenc}
\renewcommand{\rmdefault}{ptm}
\renewcommand{\ttdefault}{pcr}
\begin{document}
\setlength\parindent{0pt}\ttfamily
\textit{Some italic and some \textup{upright} text.}\\
{\itshape Some italic and some {\upshape upright} text.}\\
\textbf{Some bold and some \textmd{non-bold} text.}\\
{\bfseries Some bold and some {\mdseries non-bold} text.}\\
\underline{Some underlined and some {\normalfont non-underlined} text.}
\end{document}
Inspired by question “How to set not italic or not bold?”

\emphcommand, which works in a "nested" way: Inabc \emph{def \emph{ghi} jkl} mno, the "inner" emphasized string ("ghi") is typeset using the upright font shape by default. Theulem("underline emphasis"?) package does something interesting to\emph(unless the optionnormalemis set): an "outer"\emphgenerates underlined text, and an "inner"\emphgenerates double-underlined text. One could probably hack the package so that inner\emphmaterial is typeset without underlining; this might look weird, though. – Mico May 02 '18 at 14:09ulempackage also provides the command\uline, which is much more useful thanunderline: The former command allows line-breaking between words (but not hyphenation within words), whereas the latter doesn't allow any line-breaking. – Mico May 02 '18 at 14:12\underlineis a quick fix added in LaTeX that uses\hboxand the math underbar. The box doesn't end until the braces are closes, so everything in between is underlined (and linebreaks are prevented.) – erik May 02 '18 at 14:13\underlinequestion, if you switch fonts you can easily switch to a different font within that region. But\underlineis more like\fboxif you box a run of text there is no particularly easy way to break out of that box, so you would have to redefine the underlining command to just underline your outer phrases and not underline the middle section. You can't from inside\underlinestop the rule being drawn. – David Carlisle May 02 '18 at 14:45l3regex/expl3. – u17 May 02 '18 at 17:23