# Is it possible to have italic and bold text, and linebreaks under the \underline{text} command?

I was trying to emphasize text with \textbf, \textit and \underline commands. But the text will not automatically wrap to the next line. I also tried the {ulem} package, and it did not work too. Does anybody know how to have italic, bold, underline and linebreaks for some text?

-
Could you please post a Minimum Working Example demonstrating the problem? It is much easier for people to help if you provide some code they can just copy-paste-and-compile to reproduce the problem you are seeing. – cfr Jan 6 '14 at 2:42
\usepackage{soul} and then \ul{\textbf{\textit{your text here}}}. – jon Jan 6 '14 at 2:42
You are not really doing all three at the same time, are you? That may draw attention to the text but it will also render it extremely difficult to read, as well as looking rather ugly. – cfr Jan 6 '14 at 2:46
I am working on some special documentations requiring all the three together. I must find a way to work it out. :( – Zhou Wang Jan 6 '14 at 3:24

Do the following self explanatory combinations work for you? (Leaving aside aesthetic issues.)

\documentclass{article}

\usepackage{ulem}

\begin{document}

I think computer \uline{viruses should count as life. I think it says
something about human nature} that the only form of life we have
created so far is purely destructive. We've created life in our own
image.

I think computer \uline{viruses should \textit{count as life. I think
it} says something about human nature} that the only form of life
we have created so far is purely destructive. We've created life in
our own image.

I think computer \uline{\textit{viruses should count as life. I think
it} says something about human nature} that the only form of life
we have created so far is purely destructive. We've created life in
our own image.

I think computer \uline{\textit{viruses should count \textbf{as
life. I think} it} says something \textbf{about human} nature}
that the only form of life we have created so far is purely
destructive. We've created life in our own image.

\textit{\textbf{\uline{I think computer viruses should count as
life. I think it says something about human nature that the only
form of life we have created so far is purely destructive. We've
created life in our own image.}}}

\end{document}
\documentclass{article}

\usepackage{ulem}


Tips

Always make \uline the last one to be applied when you need multiple effects on a complete paragraph. It behaves badly (no line wraps) when other font commands are applied after it.

-
Will that work if all three 'characteristics' span multiple lines? – jon Jan 6 '14 at 3:04
@jon Why not? See the updated example where all three have been applied to the last paragraph. – Masroor Jan 6 '14 at 3:12
@ZhouWang See the updated example, the last case. Always make \uline the last one to be applied. It behaves badly (no wraps) when other font commands are applied after it. This is what is happening in the above example in your comment. – Masroor Jan 6 '14 at 3:15
Yes, I got it. Thanks very much NMA. The problem is that I make the \uline the first one!!! Once I make the \uline the last one, it works perfect!!! – Zhou Wang Jan 6 '14 at 3:20
Indeed! I had never tried before and didn't realize ulem had such constraints about the order of usage. – jon Jan 6 '14 at 3:35

It is probably better to stick with ulem if you are already using it. However, if I had to mix and match underline, bold, and italics, I'd be inclined to use soul instead. It does not need as much care about how you nest all these ways of emphasis.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{soul}
\parskip10pt
\parindent0pt
\begin{document}

% all at once:
\ul{\textbf{\textit{I was trying to emphasize text with textbf, textit
and underline commands. But the text will not automatically wrap
to the next line. I also tried the {ulem} package, and it did
not work too. Does anybody know how to have italic, bold,
underline and linebreaks for some text?}}}

% underline, then \emph, then bold
I think computer \ul{viruses \emph{should count \textbf{as life. I
think it says something about human nature that the only form of
life we have created so far is purely destructive. We've created
life in} our} own} image.

% underline, bold, emph
I think computer \ul{viruses \textbf{should count \emph{as life. I
think it says something about human nature that the only form of
life we have created so far is purely destructive. We've created
life in} our} own} image.

% bold, emph, underline
I think computer \textbf{viruses \emph{should count \ul{as life. I
think it says something about human nature that the only form of
life we have created so far is purely destructive. We've created
life in} our} own} image.

% emph, bold, underline
I think computer \emph{viruses \textbf{should count \ul{as life. I
think it says something about human nature that the only form of
life we have created so far is purely destructive. We've created
life in} our} own} image.

% bold, underline, emph
I think computer \textbf{viruses \ul{should count \emph{as life. I
think it says something about human nature that the only form of
life we have created so far is purely destructive. We've created
life in} our} own} image.

% emph, underline, bold
I think computer \emph{viruses \ul{should count \textbf{as life. I
think it says something about human nature that the only form of
life we have created so far is purely destructive. We've created
life in} our} own} image.

\end{document}

-
Thanks, that is also a very good alternative! – Zhou Wang Jan 6 '14 at 3:56
saved my ass. +1 – Kaii Jan 15 '14 at 14:41