## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Strange Line Breaks in Text wrapping a Figure Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm

### Strange Line Breaks in Text wrapping a Figure

Hello,

it seems that when using wrapfig within the beamer class, and aligning an image on the right, it sometimes breaks the text lines to make the last line of a paragraph full width, at the expense of making the first line of the paragraph much too short. A minimal example is:
\documentclass[t]{beamer}\usepackage{wrapfig} \begin{document}\begin{frame} \begin{wrapfigure}[7]{r}[0pt]{4.2 true cm}\includegraphics[height=3 true cm]{iclicker}\end{wrapfigure} For class participation, you shouldobtain (and, later, register) an iClicker device. \end{frame}\end{document}

I used this with the image file "iclicker.jpg" (attached) but I guess any image would do. Anyway, the result is as in the file "wrapfigtst.pdf" (also attached): the first word, "For", is put on a line all by itself which it shouldn't be. I have been plagued by similar problems for a year now -- any help most appreciated!
Attachments
wrapfigtst.pdf
Resulting PDF file
Image file
iclicker.jpg (81.77 KiB) Viewed 7273 times

Tags:

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
The wrapfig package seems not work very good in a presentation. Therefore it's perhaps better to split the frame into columns by the columns environment and distribute the text and image to two column environments. An approach could look like this. The output is attached (as image).
\documentclass[t]{beamer}\usepackage[T1]{fontenc}\usepackage{fix-cm}\usepackage{microtype} \begin{document} \begin{frame}   \begin{columns}[t]     \begin{column}{0.5\linewidth}       For class participation, you should obtain (and, later, register) an iClicker device.     \end{column}     \begin{column}[T]{0.5\linewidth}       \includegraphics[width=\linewidth]{iclicker}     \end{column}   \end{columns}    \bigskip   Some more text on the frame that shall only demonstrate how columns work and that you can switch back easily to a single column.\end{frame} \end{document}

The clear disadvantage of this method is that the text beside the image won't flow around the it automatically. So this might be a solution only for short text. For details please refer to the beamer user guide.

By the way, thanks for the almost perfect minimal example.

Best regards and welcome to the board
Thorsten
Attachments
beamer-split-frame.png (76.63 KiB) Viewed 7268 times
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm
Thanks very much Thorsten. But yes, I do want my text to wrap around the figure if possible -- that is why I have been using wrapfig for the past year -- so I am still hoping there is a way to fix this bug without sacrificing the wrapping. Regards, Jeff

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
I'm not aware of a proper solution. So I suggest to contact the maintainer of wrapfig and ask him for help. His e-mail address can be found in the package manual.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm
Update: Donald Arseneau kindly pointed me to some related discussion at https://groups.google.com/forum/?hl=en#!topic/comp.text.tex/nrlvG155Ilw and https://groups.google.com/forum/?hl=en#!topic/comp.text.tex/ZDAmn5r8ikk with various suggestions involving \raggedright and ragged2e.sty and \RaggedRight and more in an effort to overcome the line-breaking limitations of wrapfig in beamer. So far I've just tried the simplest proposed solution, of adding the line
\setlength{\rightskip}{0pt plus 200pt}
, and that seems to work fairly well. Thanks everyone!