\textit
is canceled by\textup
\itshape
is canceled by\upshape
\textbf
is canceled by\textmd
\bfseries
is canceled by\mdseries
\normalfont
cancels 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?”
\emph
command, 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 optionnormalem
is set): an "outer"\emph
generates underlined text, and an "inner"\emph
generates double-underlined text. One could probably hack the package so that inner\emph
material is typeset without underlining; this might look weird, though. – Mico May 2 '18 at 14:09ulem
package 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 2 '18 at 14:12\underline
is a quick fix added in LaTeX that uses\hbox
and 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 2 '18 at 14:13\underline
question, if you switch fonts you can easily switch to a different font within that region. But\underline
is more like\fbox
if 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\underline
stop the rule being drawn. – David Carlisle May 2 '18 at 14:45l3regex
/expl3
. – st12 May 2 '18 at 17:23