Graphics, Figures & Tableswrapfig: prevent wrapping from running to next page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm

wrapfig: prevent wrapping from running to next page

Post by yiorgosb »

As the documentation itself of the package states
The environment should be placed so as to not run over a page boundary.

In such case the result would be an empty space of unpredictable length at the next page as if the figure was been continued to the next page.
The question is how to prevent that i.e. how to "stop" wrapping at some specific line.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

wrapfig: prevent wrapping from running to next page

Post by localghost »

As always, you will have to present a full but minimal example.


Thorsten
yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm

wrapfig: prevent wrapping from running to next page

Post by yiorgosb »

You are right.
I apologize

Code: Select all

\documentclass[12pt]{book}
\begin{document}

Lorem Ipsum Lorem Ipsum ...

Lorem Ipsum Lorem Ipsum ...

\begin{wrapfigure}{r}{0.8\textwidth}
	\vspace{-20pt}
	 \begin{center}
	    \includegraphics[width=1\textwidth]{image}
	 \end{center}
	 \vspace{-20pt}
	 \caption{foobar}
	 \vspace{-15pt}
\end{wrapfigure}
Last paragraph of current page

First paragraph of next page, wrapping will occur here too leaving a blank page to the right.

\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

wrapfig: prevent wrapping from running to next page

Post by localghost »

Please check your examples for functionality before posting them [1]. The problem is still not comprehensible with what you provided because the code is not compilable as is.

But looking at your code, there are some strange things. You try to include an external image file and specify its width to \textwidth. Why then use wrapfig? Furthermore you specify the width of the wrapfigure environment to 0.8\textwidth, which doesn't make any sense if the width of the included image occupies the full text width.

Finally the advice to replace the center environment with the \centering declaration to avoid unwanted vertical space (which you then don't have to balance with negative vertical spaces).

[1] View topic: Avoidable mistakes
Post Reply