Graphics, Figures & TablesStrange Line Breaks in Text wrapping a Figure

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

Strange Line Breaks in Text wrapping a Figure

Post by JeffR »

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:

Code: Select all

\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 should
obtain (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
(98.63 KiB) Downloaded 593 times
Image file
Image file
iclicker.jpg (81.77 KiB) Viewed 12378 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Strange Line Breaks in Text wrapping a Figure

Post by localghost »

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).

Code: Select all

\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
beamer-split-frame.png (76.63 KiB) Viewed 12373 times
JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm

Re: Strange Line Breaks in Text wrapping a Figure

Post by JeffR »

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
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Strange Line Breaks in Text wrapping a Figure

Post by localghost »

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.
JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm

Strange Line Breaks in Text wrapping a Figure

Post by JeffR »

Update: Donald Arseneau kindly pointed me to some related discussion at https://groups.google.com/forum/?hl=en# ... rlvG155Ilw and https://groups.google.com/forum/?hl=en# ... DAmn5r8ikk 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

Code: Select all

\setlength{\rightskip}{0pt plus 200pt}
, and that seems to work fairly well. Thanks everyone!
Post Reply