# Text not spanning full page after wraptable

I wonder why latex doesn't go back to full textwidth after a table that was added in a wraptable?

The actual code where I experience this problem is here: http://pastebin.com/CRjHMZdT

I would expect, that after the table has been rendered to the right side of the page, the then following text is able to span the whole width of the page. Instead, this is what happens:

((On the following page, the text is set across the whole width again.))* I compile using

latex "${FILE}.tex" dvips -Ppdf -o "${FILE}-pics.ps" "${FILE}.dvi" ps2pdf -dAutoRotatePages=/None "${FILE}-pics.ps" "${FILE}-pics.pdf" pdflatex "${FILE}.tex"


EDIT Ok, this* is not true, on the following pages, the text can't take up full textwidth, too.

EDIT 2 Ok, I tried to make a MWE from my original code which shows the same problem. This code now shows the same problem (and another one, something seems to be really wrong)

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{wrapfig}
\begin{document}
\begin{wraptable}{r}{5cm}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
$i$ & $NW_{i1}$ & $NW_{i2}$ & $NW_{i3}$ \\\hline\hline
0 & 0 & 0 & 0 \\\hline
1 & 0 & 0 & 1 \\\hline

\end{tabular}
\caption{Some table}
\end{wraptable}

\section*{A section}
\subsection*{subsections are nice}
Some text.

\begin{wraptable}{l}{5cm}
\centering
\begin{tabular}{|c|c|}
\hline
$NW_i$ & $CW_i$ \\\hline\hline
000 & 00000 \\\hline
001 & 10111 \\\hline
010 & 10010 \\\hline
011 & 00101 \\\hline
100 & 01100 \\\hline
101 & 11011 \\\hline
110 & 11110 \\\hline
111 & 01001 \\\hline
\end{tabular}
\caption{table two}
\end{wraptable}

\subsection*{the next subsection}
text.

\begin{wraptable}{r}{8cm}
\centering
%\renewcommand\arraystretch{1.3}% (MyValue=1.0 is for standard spacing)
\begin{tabular}{|c|c|}
\hline
$w$ & $A(w)$ \\\hline\hline
0 & $\frac{0}{8}$ \\\hline
1 & $\frac{4}{8}$ \\\hline

\end{tabular}
\caption{table 3}
\end{wraptable}

\subsection*{another subsection}
even more text.

\subsection*{yeah}
i want more more more more more more more more more more more more more more
more more more more more more more more more more more more more more more more
more and even more more more more more more more more more more more more more
more more more text.

\section*{another section in the wall}
text

\subsection*{yeah}
i want more more more more more more more more more more more more more more
more more more more more more more more more more more more more more more more
more and even more more more more more more more more more more more more more
more more more text.
\end{document}


(Pasting code here is not much fun, btw)

It doesn't matter if I change the tables ordering, e.g. moving the second table to the third tables position and the third table up the the former second tables position doesn't change anything.

EDIT 3 Ok, making the example more minimal (stripping out math mode, babel package, centering, caption) is possible, too. Also compiling with pdflatex AND latex gives the same result. What is wrong here?

EDIT 4 Not using the star version of section and subsection "solves" the issue. I don't think that this is a feature, it seems more like a bug to me?

-
Welcome to TeX.sx! This is a lot of code. In order to help people who'll help you, could you please remove everything from the code that's not related to your problem and add a little document, a so-called minimal working example (MWE), that people can copy and compile to reproduce your problem? Otherwise, your question might be in danger of being closed as too localized. Also, please paste the code directly here by editing your question. – doncherry Nov 18 '12 at 19:07
Hi :) Ok, I'll try to make a MWE from my original code, it's just that I fear the problem won't reproduce with a simple example. The problem seems to be with the third table on the page ... which means, I should include 3 tables in my MWE. But give me a second, I'll try ... – Daniel Jour Nov 18 '12 at 19:24
You can include dummy text via lipsum,kantlipsum or blindtext packages. That way your code will be very concise but still reproducing many pages. – percusse Nov 18 '12 at 19:48

wrapfigure/wraptable works inside section* also. But one should note the following from wrapfig manual

Hence you should add enough text just below the wraptable environment.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{wrapfig,lipsum}
\begin{document}
\begin{wraptable}{r}{5cm}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
$i$ & $NW_{i1}$ & $NW_{i2}$ & $NW_{i3}$ \\\hline\hline
0 & 0 & 0 & 0 \\\hline
1 & 0 & 0 & 1 \\\hline

\end{tabular}
\caption{Some table}
\end{wraptable}
\lipsum[4-5]

\section*{A section}
\subsection*{subsections are nice}
Some text.

\begin{wraptable}[13]{r}{5cm}
\centering
\begin{tabular}{|c|c|}
\hline
$NW_i$ & $CW_i$ \\\hline\hline
000 & 00000 \\\hline
001 & 10111 \\\hline
010 & 10010 \\\hline
011 & 00101 \\\hline
100 & 01100 \\\hline
101 & 11011 \\\hline
110 & 11110 \\\hline
111 & 01001 \\\hline
\end{tabular}
\caption{table two}
\end{wraptable}
\lipsum[1-2]

\subsection*{the next subsection}
text.

\begin{wraptable}[7]{r}{8cm}
\centering
%\renewcommand\arraystretch{1.3}% (MyValue=1.0 is for standard spacing)
\begin{tabular}{|c|c|}
\hline
$w$ & $A(w)$ \\\hline\hline
0 & $\frac{0}{8}$ \\\hline
1 & $\frac{4}{8}$ \\\hline

\end{tabular}
\caption{table 3}
\end{wraptable}
\lipsum[3-4]

\subsection*{another subsection}
even more text.

\subsection*{yeah}
i want more more more more more more more more more more more more more more
more more more more more more more more more more more more more more more more
more and even more more more more more more more more more more more more more
more more more text.

\section*{another section in the wall}
text

\subsection*{yeah}
i want more more more more more more more more more more more more more more
more more more more more more more more more more more more more more more more
more and even more more more more more more more more more more more more more
more more more text.
\end{document}


Please read the first three pages of the wrapfig` manual.

-
This is indeed working. I read the wrapfig manual and assumed it had something to do with \linewidth, which it does (given its correct that more text around the wraptable puts it in its own paragraph) because this width can only be set once per paragraph. Thank you! :) – Daniel Jour Nov 18 '12 at 23:11
Even though it's tedious cleaning up the copy-paste from a pdf, I think it's considered better practice to insert passages from a manual as text, in order to make them accessible and indexable. – doncherry Nov 19 '12 at 6:55