LaTeX forum ⇒ Graphics, Figures & TablesStrange 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

Postby JeffR » Thu Aug 29, 2013 6:54 pm

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:
  1. \documentclass[t]{beamer}
  2. \usepackage{wrapfig}
  3.  
  4. \begin{document}
  5. \begin{frame}
  6.  
  7. \begin{wrapfigure}[7]{r}[0pt]{4.2 true cm}
  8. \includegraphics[height=3 true cm]{iclicker}
  9. \end{wrapfigure}
  10.  
  11. For class participation, you should
  12. obtain (and, later, register) an iClicker device.
  13.  
  14. \end{frame}
  15. \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 330 times
iclicker.jpg
Image file
iclicker.jpg (81.77 KiB) Viewed 6563 times

Tags:

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

Postby localghost » Thu Aug 29, 2013 7:34 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).
  1. \documentclass[t]{beamer}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{fix-cm}
  4. \usepackage{microtype}
  5.  
  6. \begin{document}
  7.  
  8. \begin{frame}
  9. \begin{columns}[t]
  10. \begin{column}{0.5\linewidth}
  11. For class participation, you should obtain (and, later, register) an iClicker device.
  12. \end{column}
  13. \begin{column}[T]{0.5\linewidth}
  14. \includegraphics[width=\linewidth]{iclicker}
  15. \end{column}
  16. \end{columns}
  17.  
  18. \bigskip
  19. Some more text on the frame that shall only demonstrate how columns work and that you can switch back easily to a single column.
  20. \end{frame}
  21.  
  22. \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 6558 times
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby JeffR » Thu Aug 29, 2013 7:59 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

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

Postby localghost » Thu Aug 29, 2013 8:14 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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby JeffR » Fri Aug 30, 2013 3:23 am

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
  1. \setlength{\rightskip}{0pt plus 200pt}
, and that seems to work fairly well. Thanks everyone!


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests