3

Problems with wrapfig seems to never end.

I want to put a figure on the left and write text on the right. This text doesn't cover all the figure height.

Then I do a vspace and starts to write AFTER the figure fully ended. I expect the text to start from the left margin of the page, instead it is placed just like the figure is still there, with a big space from the left margin of the page. It seems like latex first calculate the text position, and then "vspace" it, instead of doing the viceversa.

MWE:

\documentclass{article}
\usepackage{mwe} % for blindtext and example-image-a in example
\usepackage{wrapfig}
\usepackage{blindtext}
\begin{document}

\begin{wrapfigure}{l}{0.5\textwidth}
\centering
\includegraphics[height=150pt,width=0.5\textwidth]{example-image-a}
\caption{A caption}
\end{wrapfigure}

Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random 

\vspace{150pt}

\blindtext %this should start from the beginning of the page

\end{document}

Picture:

enter image description here

5

Just use the optional argument for the environment:

\begin{wrapfigure}[5]{l}{0.5\textwidth}

enter image description here

2
  • Thanks, I will use that. Isn't a more flexible solution? In this way I have to predict the exact number of lines. I would prefer to add text in that part of the document without remembering to change the optional argument. Why latex does this? – robertspierre Jan 3 '16 at 17:29
  • This is mainly because the first paragraph is shorter than the height of the figure. That said, it can be hard to compute the exact number of shorter lines, because many parameters are involved (the value of \parskip, of topsep and \partopsep for lists, &c. Furthermore some lengths are rubber lengths, i.e. are slightly stretchable. It is very common to make manual adjustments in the final phase of typing. – Bernard Jan 3 '16 at 17:37
3

I solved using WFclear as suggested here by John Kormylo

WFclear is an undocumented function that ends a wrapfig

\documentclass{article}
\usepackage{mwe} % for blindtext and example-image-a in example
\usepackage{wrapfig}
\usepackage{blindtext}
\begin{document}

\begin{wrapfigure}{l}{0.5\textwidth}
\centering
\includegraphics[height=150pt,width=0.5\textwidth]{example-image-a}
\caption{A caption}
\end{wrapfigure}

Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random 

\vspace{150pt}
\WFclear 
\blindtext %this should start from the beginning of the page

\end{document}

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.