Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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 at 2:42
    
\usepackage{soul} and then \ul{\textbf{\textit{your text here}}}. –  jon Jan 6 at 2:42
3  
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 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 at 3:24
add comment

2 Answers

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}
share|improve this answer
    
Thanks, that is also a very good alternative! –  Zhou Wang Jan 6 at 3:56
    
saved my ass. +1 –  Kaii Jan 15 at 14:41
add comment

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}

enter image description here


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.

share|improve this answer
    
Will that work if all three 'characteristics' span multiple lines? –  jon Jan 6 at 3:04
    
@jon Why not? See the updated example where all three have been applied to the last paragraph. –  MMA Jan 6 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. –  MMA Jan 6 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 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 at 3:35
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.