0

Since 28 Jan, 2019 (several days ago), I've been trying to get text to wrap around any figure in my document and I have several. I cannot get the package wrapfigure to work. I've tried following all the recommendations in the package pdf, and those I've found here, but they aren't working and I can't figure out why.

Sometimes the figure shows up, in about the right spot, but the text overlaps the image, and sometimes there might be a gap for the image on the next page. Other times the figure doesn’t show up at all and no gap is present.

Below is an MWE, including 2 actual images, that does not work.

I have learned one thing. Somehow the package changes is involved but I don't know how or why. I've tried researching this issue, but haven't found anything yet. Any help or insights are greatly appreciated.

Cheers, SL

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % USAGE: PROBLEMS WITH WRAPFIG % CREATED ON: 2019_01_31 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \documentclass[11pt,oneside]{article} \usepackage{changes} % TRACKS CHANGES \usepackage{wrapfig} \usepackage[margin=.5in]{geometry} \usepackage{lipsum} % \begin{document} \added{\lipsum[2]} \lipsum[1] \added{\lipsum[3]} \begin{wrapfigure}{L}{0.4\textwidth} \includegraphics[scale=.75]{CombinedPic_v2} \caption{\label{Placebo2} ERP} \end{wrapfigure} \added{\lipsum[5]} \lipsum[1] \begin{wrapfigure}[35]{L}{0.35\textwidth} \includegraphics[scale=1.5]{Fig_Network1} \caption{\label{Placebo1} Changes in network connectivity} \end{wrapfigure} \lipsum[5] \added{\lipsum[2]} \lipsum[1] \added{\lipsum[6]} \end{document}

I am working on a deadline so any help is greatly appreciated.

Cheers, SL

first image used above

second image used above

  • 3
    To make it easier for people willing to help, please provide a MWE with the least text and commands that would produce your issue. – hesham Jan 30 at 2:14
  • I'd be happy to as soon as someone tells me what MWE means... Sorry... – Shodan Jan 30 at 2:23
  • 1
    ok, I think I understand what you're asking for now. Minimum Working Example? I'll have to do some cutting and pasting from a couple of docs to get a MWE created. That said, I literally just found out that wrapfigure do not like it when I use \added{some text} from the package changes. I have no idea why, but if I change the color of the text, that problem goes away... – Shodan Jan 30 at 4:59
  • It would help to know which package or document class \added comes from. Memoir has one, but its argument is an id, not text. – John Kormylo Jan 30 at 15:12
  • Ok, I’ve created an MWE which, if used with the two figure above, does not work. I have no idea why but if anyone has any suggestions I would really appreciate some insight. cheers – Shodan Jan 31 at 21:41
3

These are in a sense comments, because without more information about what is going wrong it's hard to diagnose. But it's too long for a comment, so I hope it helps. I can't claim to be an expert in wrapfig, but I think there are quite a few different things happening here: some by accident.

  • \lipsum is inclined to do odd things with wrapfig. I believe it's got something to do with how it deals with paragraphs and grouping, and how wrapfig works, which is by altering the paragraph shape. Although one is supposed to be able to use lipsum in a form that avoids these troubles, I would simply avoid it when trying to get lipsum to work. blindtext is better: but only if you use \blindtext and insert your own paragraphs, not \Blindtext (which can produce some very odd results. Anyway: simplest thing when using wrapfig is to work with actual text!

  • Without your image files, I can't be sure, but I'd be quite sceptical about how you are scaling them. If I were you, I'd set the width of the figure using \wrapfigure{0.4\textwidth} (or whatever), and then scale the graphics with a simple [width=\linewidth] to your \includegraphics. Since wrapfigure sets \linewidth to the appropriate width, that should come out right. Obviously text wrapping is going to fail visually if the image is not the right width. I think I'd get rid of the lines indication too.

  • Even with all these adjustments, you may have to play around to some extent. In my experience, although wrapfigure does its very best, its arcane mechanism is dependent on all sorts of things about where it falls in the text, and it's sometimes necessary to move things around a bit in the source to get a satisfactory outcome.

  • Design-wise, I'd fairly strongly advise you to try to make the two figures the same width, at least if they are going to appear on the same page. I think an already busy page is going to look very muddled otherwise.

  • Your first figure is going to look odd anyway, because it is wider than it is long, and it is bound to end up shrunken. You may be better off floating it anyway.

In terms of alternatives, you can:

  1. Use ordinary floats (i.e. figure). These will move. They will usually be least troublesome if you give LaTeX maximum flexibility to place them. The canonical answer on this is here.

  2. Use the placeins package which has a \FloatBarrier command which forces unplaced floats to be placed there if not earlier. I've never used it, so I'm not sure how effective it is in saving any time. But some people love it.

  3. Don't float at all! There is no divine law that dictates that graphics must be floated. You can just place a graphic where you want it, usually in a minipage environment or something like that. If you need it captioned, the \captionof command from the captions package will help.

  • Thanks for the input. I only used lipsum to make the MWE smaller. I have the same issues with my text. Thanks for tip about scaling the images. I will try that and respond in a few minutes. I try to use only one figure per page. I’ve never used floating. Any recommendations on where to start? – Shodan Feb 1 at 17:30
  • PS. If you are pressed for time, wrapfig is a time hog, and you may be far better advised just to float the figures normally. The best is the enemy of the good, especially with a deadline looming. – Paul Stanley Feb 1 at 17:30
  • To float them, just place them in ordinary figure environments. They will, inevitably, move around of course, so it's still something that requires some thought. I'm afraid a search for float placement will produce a mass of material. – Paul Stanley Feb 1 at 17:32
  • thanks for the tip about wrapfig being a time hog. I had no idea. – Shodan Feb 1 at 17:32
  • I managed to use the float like you suggested, but the text doesn’t wrap around the figure and the caption is in the middle of the page. Is that supposed to happen? – Shodan Feb 1 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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