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.

Please, I have a nice picture without that \ul{...}, but i need that.

\documentclass{article}

\usepackage{wrapfig}
\usepackage{soul}

\begin{document}

\begin{wrapfigure}[3]{l}{30mm}
\Huge 1
\end{wrapfigure}

\ul{Lorem ipsum dolor sit amet}, consectetur adipiscing elit.
Suspendisse nec dolor eget tortor iaculis molestie et ac diam.
Aliquam feugiat tempus orci et suscipit.
Morbi varius dignissim arcu, vitae facilisis metus imperdiet id.
Morbi non mi at neque mollis elementum.
Etiam mauris velit, accumsan in fringilla nec, auctor in eros.
Etiam porta fermentum pretium. 

\end{document}

With that \ul{...} paragraph is being stretched to full width and figure goes away to the left. What is wrong?

Thanks!

ps. Actually there are graphics in wrapfigures and i really need some words to be underlined. Yes, ulem's \emph does the same as \ul. Well, yes, \underline does right thing here, but i am unhappy with \underline.

Update: With this addition:

\usepackage{color}
...
% instead of just \Huge 1:
\fcolorbox[gray]{0.59}{1}{\parbox{30mm}{\Huge 1}}

and after making "just too long word" pdflatex produces this picture: hyphenation does work!

So, paragraph is nicely stretched to \textwidth;

share|improve this question
    
I guess \ul breaks hyphenation. Does adding explicit hyphenation work? \ul{longword\-with\-explicit\-hyphens} –  Seamus Mar 10 '11 at 18:13
    
Huh. It's not that at all. This is weird. If you make the beginning of the text L\ul{orem ipsum...} then it works fine... –  Seamus Mar 10 '11 at 18:22

2 Answers 2

up vote 5 down vote accepted

For wrapfig to work properly it needs to see a paragraph. You can force a paragraph by using \leavevmode.

\documentclass{article}
\usepackage{wrapfig}
\usepackage{soul}

\begin{document}
\begin{wrapfigure}[3]{l}{30mm}
\Huge 1
\end{wrapfigure}
\leavevmode\ul{Lorem ipsum dolor sit amet}, consectetur adipiscing elit.
Suspendisse nec dolor eget tortor iaculis molestie et ac diam.
Aliquam feugiat tempus orci et suscipit.
Morbi varius dignissim arcu, vitae facilisis metus imperdiet id.
Morbi non mi at neque mollis elementum.
Etiam mauris velit, accumsan in fringilla nec, auctor in eros.
Etiam porta fermentum pretium. 

\end{document}

You could also use a noindent or quitvmode or use a rule as per Seamus post.

share|improve this answer
    
So \ul confuses wrapfig into thinking there's no paragraph there? –  Seamus Mar 10 '11 at 18:49
1  
@Seamus \ul makes sure it does not start a new one, otherwise it would break things in other places. –  Yiannis Lazarides Mar 10 '11 at 19:02

I have no idea why this works, or what's going on, but this does make things work:

\documentclass{article}

\usepackage{wrapfig}
\usepackage{soul}

\begin{document}
\begin{wrapfigure}[3]{l}{30mm}
\Huge 1
\end{wrapfigure}
\rule{0pt}{0pt}\ul{Lorem ipsum dolor sit amet}, consectetur adipiscing elit.
Suspendisse nec dolor eget tortor iaculis molestie et ac diam.
Aliquam feugiat tempus orci et suscipit.
Morbi varius dignissim arcu, vitae facilisis metus imperdiet id.
Morbi non mi at neque mollis elementum.
Etiam mauris velit, accumsan in fringilla nec, auctor in eros.
Etiam porta fermentum pretium. 

\end{document}

All I've done is put an invisible rule before your \ul

share|improve this answer
    
Hha-ha!! It looks like it does! I feel like i need to check it more (and would b great to understand what's going on) -- but THANK YOU. I need to check everything, i'll be back .) –  brownian Mar 10 '11 at 18:31
2  
\rule starts with \leavevmode, see Yiannis answer. –  Martin Scharrer Mar 10 '11 at 20:11

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.