0

I would like to have figures with automatic text wrapping around them. I am trying to keep having to tweak figure locations to minimum. I am also not allowed to use two columns for this document.

What I want

What I have already tried: Here is a Minimal Working Example (MWE) that I tried to use. In the MWE, changing the variable \wrapenvironment switches between different wrapping environments like \wrapfig, \wrapstuff, and \floatflt, all of them produce outputs where there are massive blank spaces that could have been filled with text. What should I assign as the value for \wrapenvironment that will give me an output (automatic text wrapping without huge white spaces) similar to the example above?

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{caption}
\captionsetup[figure]{font=small} 
\usepackage[margin=0.25in]{geometry} % Set 0.5-inch margins
\usepackage{fancyhdr} % Required for custom headers and footers
\usepackage{lipsum} % For sample text

\usepackage{wrapstuff} % For wrapping text around figures \usepackage[vflt]{floatflt} \usepackage{wrapfig}

\def\wrapenvironment{wrapstuff}

\title{MWE Figure Wrapping fails} \date{January 2024}

\begin{document}

\maketitle

\lipsum[1-8]

\begin{\wrapenvironment} %{L}{0.5\textwidth} \includegraphics[width=0.48\textwidth]{example-image} \end{\wrapenvironment}

\lipsum[11-14]

\begin{\wrapenvironment} %{L}{0.5\textwidth} \includegraphics[width=0.48\textwidth]{example-image} \end{\wrapenvironment}

\lipsum[1-2]

\begin{\wrapenvironment} %{L}{0.5\textwidth} \includegraphics[width=0.48\textwidth]{example-image}
\end{\wrapenvironment}

\lipsum[15-20]

\end{document}

  • 2
    These are several problems and therefore you should ask questions for each of them including MWEs to make them reproducible. If you only search for alternatives to wrapfig see, e.g., https://ctan.org/topic/text-flow – cabohah Jan 26 '24 at 16:47
  • The package wrapstuff is a possible alternative. A more efficient use of space, please define the term is to have the figures in the margins. So as @cabohah suggested please give some more details about your document. – yannisl Jan 26 '24 at 17:00
  • 1
    A viable alternative is not to use wrapfig at all, but a two column layout or a tufte class like here. This does not allow you to make L-shaped paragraphs, but I don't see much fun on this, sincerely. – Fran Jan 27 '24 at 00:34
  • 1
    Wrapfig is based on \parshape which is line rather than space) oreiented. Wrapfig automatically assumes the lines are spaced \baselineskip apart. When that isn't true, you need to count the number of lines needed. You can use paracol instead, but you will have to manually break the text going in and/or out. See https://tex.stackexchange.com/questions/620345/indentation-problem-with-wrapfigure-and-listings/620404?r=SearchResults&s=2%7C34.8836#620404 for example. – John Kormylo Jan 27 '24 at 17:02
  • Thanks for the suggestions.

    @yannisl wrapstuff seems great, but does not respect margin sizes. @DavidCarlisle I am already using wrapfig's L and R, but then I get huge white spaces next to the first figure when there are two in a row. @Fran I love the idea of using two column layout, but I am not allowed to for this document. @JohnKormylo this seems like quite a bit of manual tweaking?

    – user1992705 Jan 29 '24 at 20:24
  • @DavidCarlisle I have updated the minimum working example using example-image. – user1992705 Feb 01 '24 at 08:57
  • thanks, I removed earlier comments – David Carlisle Feb 01 '24 at 09:01

0 Answers0