0

A weird wrapping of text around the algorithm

Not sure what is happening but here is the code:

\end{minipage} % ends minipage containing algorithm2e

\lipsum[2]
\begin{wrapfigure}{l}{0.3\linewidth}
  \ExecuteMetaData[Chapters/3_Concept/4_PAaP/Algorithms.tex]{alg:shapeEdgy}
\end{wrapfigure}
\lipsum[2]

I would, of course, like to force it down onto the next page instead of whatever it is doing.

EDIT:

Found half an answer shortly after posting sry...

Here is the post I found: Handling of wrapfig pictures in LaTeX

By changing l to L I removed the previous error, but instead the algorithm now is on top of one of my images...

EDIT 2:

I made another change from the earlier link, which for some reason works to some degree:

\begin{wrapfigure}{L}{0.3\linewidth}
  \ExecuteMetaData[Chapters/3_Concept/4_PAaP/Algorithms.tex]{alg:shapeEdgy}
  \vspace{-20pt}
\end{wrapfigure}
XGG
  • 1
  • 2
    Welcome to TeX SX! Could you please post a small, yet complete code, reproducing the problem? – Bernard Nov 15 '19 at 15:04
  • That isn't yet compilable. – Bernard Nov 15 '19 at 15:19
  • 1
    wrapfig and pagebreak don't go well together. IMO it has to do with how Latex generate paragraph. Latex create a paragraph, then see if it fit in the page. Since it doesn't, it places the beginning of the paragraph (including wrapfig) on this page, then prints the rest on the next page. To avoid this, you will have to change the position of the wrapfig. – Alain Remillard Nov 15 '19 at 15:26
  • please always post a complete document that shows the problem (you can use made up text) it is almost impossible to debug anything just from an image and fragments of code – David Carlisle Nov 15 '19 at 18:18
  • This looks like a job for needspace. That or inserting wrapfigure in the middle of a paragraph (it has to be positioned at the end of a line). – John Kormylo Nov 15 '19 at 20:04

1 Answers1

1

This shows how to insert \wrapfigure inside a paragraph. Note that \lipsum and wrapfig are not entirely compatible.

\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
\noindent\rule{\textwidth}{40\baselineskip}

Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi
auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et,
tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna,
vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse
ut massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et
\begin{wrapfigure}{l}{0.3\textwidth}
  \rule{\linewidth}{5cm}
\end{wrapfigure}
magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna.
Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris.

\LipsumPar{2}

\end{document}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120