Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there an way to avoid this behavior of the pictures

enter image description here

This is have is wrap the picture:

\begin{wrapfigure}{r}{0.5\textwidth} 
\vspace{-20pt}
  \begin{center}
    \includegraphics[width=0.4\textwidth]{./pictures/DBuserTabel.png}%{./Pictures/mainscreen1.png}
    \caption{Uklip af User tablen i Databasen}
    \label{fig:databaseUserTable}
  \end{center}
  \vspace{-20pt}
  \vspace{1pt}
\end{wrapfigure} 
share|improve this question
add comment

1 Answer 1

up vote 23 down vote accepted

The behaviour you describe is caused by using the wrapfig environment too close to a page break, as the following example demonstrates:

\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}

\lipsum[1-4]
\begin{wrapfigure}{r}{5cm}
\centering
\rule{3cm}{7cm}
\end{wrapfigure}
\lipsum[1-6]

\end{document}

enter image description here

The wrapfig package documentation explicitly warns about this:

The environment should be placed so as to not run over a page break

so, you need to move your wrapfig environment to guarantee that it won't run over a page break. However, using R (or L) instead of r (or l) your figure will float, so simply changing r to R in the above code, as in

\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}

\lipsum[1-4]
\begin{wrapfigure}{R}{5cm}
\centering
\rule{3cm}{7cm}
\end{wrapfigure}
\lipsum[1-6]

\end{document}

now yields:

enter image description here

share|improve this answer
    
Okay. So LaTeX doesn't have any automation, that does this automatically. So the solution if i understand you correct, is to do it manually replace the pictures? –  mortenstarck May 17 '12 at 2:28
    
@mortenstarck:in this concrete case (wrapfig package), if the environment runs over a page break, I am afraid that you will have to manually move the environment; of course, those changes must be best done when working on the final version of the document. –  Gonzalo Medina May 17 '12 at 2:33
    
Is there another way of doing it, there it does page break in consideration. Because it's an quit big repport, with quit afew pictures? –  mortenstarck May 17 '12 at 2:38
    
@mortenstarck: there are other packages around for wrapping text around elements (cuwin, for example), but I've never used them, so I don't know if they can automatically handle page breaks. Perhaps you should start a fresh new question about this new issue. (Don't forget to revisit this question a little later and accept the answer that best solved the concrte issu of this question). –  Gonzalo Medina May 17 '12 at 2:45
1  
@mortenstarck I've updated my answer giving a simple solution to your problem. –  Gonzalo Medina May 21 '12 at 0:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.