1

I'm just learning LaTeX, and I am having a problem with wrapping an image. When I use the try to use wrapfigure in TexStudio, I get a second column generated in my document, with the wrapped text being pushed into this column, and the image being inserted in-line. Text below the wrapped section is moved up the document to where I would expect the wrapped text to have started.

I've cut everything from my document except the minimum to generated a wrapped image (as per code below). I've also tried changing the paper size, documentclass and removing the specific margin sizes I'm using, all produce the same result.
Searches on the internet unfortunately have given me little insight to this problem.

I get the same result when I set the compiler to PdfLaTeX or LuaLaTeX. I've also tried to compile the document using LuX, with the same result, but I don't know enough yet about LaTeX to rule out the editor as the source of my the problem, based on what I've read about how the wrapfigure tag is supposed to be used.

The desired result I am looking for is to have the image displayed on the right of the page, with the text wrapping around it to the the left, in single column (i.e. typical book or report format)

Anything that can help me understand why I am getting this result instead would be much appreciated.

\documentclass[10pt,legalpaper]{book}
\usepackage[
left=1cm,
right=2cm,
top=3cm,
bottom=4cm,]{geometry}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}


\title{Sandbox}

\begin{document}
    
\chapter{First Chapter}
\subsection{1st Section}
\lipsum[1-1]
\subsection{Wrapped Image}
    \begin{wrapfigure}{r}{5cm}
        \lipsum[1-1]
        \includegraphics[width=3cm]{autumn-tree-1382832}
        \caption{A Tree}
        \label{fig:autumn-tree-1382832}
        %\lipsum[1-1]
    \end{wrapfigure}
\subsection{Last Subsection}    
\lipsum[1-8]    
\end{document}

image of the result I am getting:

enter image description here

1
  • 2
    you have put the lipsum text in the cutout which is legal but rather odd, normally you would just put the image in the wrapfig Oct 29, 2021 at 17:40

1 Answer 1

2

You just want to move the text after the wrapfigure environment:

enter image description here

\documentclass[10pt,legalpaper]{book}
\usepackage[
left=1cm,
right=2cm,
top=3cm,
bottom=4cm,]{geometry}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}


\title{Sandbox}

\begin{document}
    
\chapter{First Chapter}
\subsection{1st Section}
\lipsum[1-1]
\subsection{Wrapped Image}
    \begin{wrapfigure}{r}{5cm}
        \includegraphics[width=3cm]{example-image}
        \caption{A Tree}
        \label{fig:autumn-tree-1382832}
        %\lipsum[1-1]
    \end{wrapfigure}
        \lipsum[1-1]

\subsection{Last Subsection}    
\lipsum[1-8]    
\end{document}
1
  • 1
    Ah, yes, I see now. I somehow got convinced from something that I read that the text I wanted to wrap needed to be within the wrapfigure block. Well that was grand 4 hours of wasted time for an incredibly simple problem. That makes sense though now why I was getting the result I was.. if wrapfigure is really creating a second column in document and putting the image into that column.
    – Douglas
    Oct 29, 2021 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .