# Latex tables, text follows tables to the next page

I really appreciate your help and cooperation, I'm happy to find replies to all my questions in your platform :) I'm very new to LaTex and have a question: I'm using the tabularx environment and don't know why does the last line of the paragraph preceding any table stick to the table and follow to the next page? It happens with almost all my tables: the preceding page still have empty space but the last line of the page goes to the next page right before the table. What should be done normally is finish text then move only the table to the next page: any clues?

I hope the following code makes it clearer. U may notice that the last line of the text moves to the next page even if there is more room in the first page.

% here is my code: last paragraph from my text and the the table.

\documentclass[12pt,oneside]{scrbook}   %[oneside,draft,openright,twocolumn]
\usepackage[utf8]{inputenc}                     %utf8  latin1
%\usepackage{nomencl}
%\makenomenclature
%\usepackage{hyperref}
\usepackage{makeidx}
%\usepackage[intoc]{nomencl}
%\makenomenclature
\usepackage{hyperref}
\usepackage{lscape}
\usepackage[T1]{fontenc}
\usepackage{longtable}
\usepackage{float}
\restylefloat{table} %to let tables go next page without text
\usepackage[stretch=10]{microtype}      %only works with pdflatex, great

\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{cleveref}
\renewcommand{\textfraction}{0.05}
\usepackage{setspace}                   %for double
\onehalfspacing
%debut diagrams

%fin
\usepackage{enumitem}

\usepackage{comment} %used for commenting out sections

%\usepackage[top=4cm, bottom=6cm, outer=5cm, inner=3cm, heightrounded, marginparwidth=2.5cm, marginparsep=0.7cm]{geometry}

%\marginpar{\footnotesize This is the text of the marginal note} %independent of usepackage
%\usepackage{microtype} %blabla fitting text

\usepackage[authoryear,round]{natbib} %default[authoryear, round], %authoryear,longnamesfirst,

%\usepackage{har2nat}               % what does it do???
\setlength{\bibsep}{0.2pt}          %single line spacing in references

\usepackage[usenames,dvipsnames]{color}
\usepackage{hyperref} %[hyperfootnotes=false]
urlcolor=PineGreen}

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\usepackage{comment}

%\usepackage{emptypage}         %deletes page number on empty pges

\usepackage[flushleft]{threeparttable}      %for tables [para]

\usepackage{array}
\usepackage{dcolumn}                %alignment on the decimal point
\usepackage{tabularx}
\usepackage{blindtext} %added to fit the table wide

%\usepackage{fleqn}                 %formula alignment
%\mathindent=0pt

\usepackage{flafter}
\usepackage{rotating}  %have figures and tables lanscapres
\graphicspath{{Graphics/}} %

\usepackage[font=footnotesize]{caption} %labelfont=bf
\captionsetup[table]{skip=0pt}

%\usepackage{floatrow}
\usepackage{geometry} %used later to adjust the margins

\usepackage[english]{babel}
\hyphenation{hy-phen-a-tion mar-vel-ous-ly}

\usepackage{siunitx}
%\mbox{} to force Latex to go back to the new row. retour a la ligne in paragraphs

\begin{document}
Introduction
An early market economy and an early form of mercantilism, called "Islamic capitalism", were developed between the eighth and twelfth centuries.[6] The monetary economy of the period was based on the widely circulated currency the gold dinar, and it tied together regions that were previously economically independent.

A number of economic concepts and techniques were applied in early Islamic banking, including bills of exchange, partnership (mufawada, including limited partnerships, or mudaraba), and forms of capital (al-mal), capital accumulation (nama al-mal),[7] cheques, promissory notes,[8] trusts (see Waqf),[9] transactional accounts, loaning, ledgers and assignments.[10] Organizational enterprises independent from the state also existed in the medieval Islamic world, while the agency institution was also introduced during that time.[11][12] Many of these early capitalist concepts were adopted and further advanced in medieval Europe from the 13th century onwards.[7]

The word "riba" means interest, usury, excess, increase or addition, which according to Shariah terminology, implies any excess compensation without due consideration (consideration does not include time value of money). The definition of riba in classical Islamic jurisprudence was "surplus value without counterpart", or "to ensure equivalency in real value", and that "numerical value was immaterial."

By 1995, 144 Islamic financial institutions had been established worldwide, including 33 government-run banks, 40 private banks, and 71 investment companies.[17] The involvement of institutions, governments, and various conferences and studies on Islamic banking (Conference of the Finance Ministers of the Islamic Countries held in Karachi in 1970, the Egyptian study in 1972, The First International Conference on Islamic Economics in Mecca in 1976, and the International Economic Conference in London in 1977) were the instrumental in applying the application of theory to practice for the first interest-free banks.[18][19]

There are several other approaches used in business transactions. Islamic banks lend their money to companies by issuing floating rate interest loans. The floating rate of interest is pegged to the company's individual rate of return.

\begin{threeparttable}
\caption{\footnotesize  Difference in concept of interest and tax under Islamic finance}
\label{tab:diffriba}
\small
\singlespacing
\begin{tabularx}{\textwidth}{lXX}
\toprule
& \multicolumn{1}{c}{Islamic Banking} & \multicolumn{1}{c}{Conventional Banking}\\ \midrule
I- & Profit & Riba\\ \cmidrule{2-3}
& Determined a posteriori , pro rata of the profit. It is a percentage of the profit generated by the project outcome. & Defined a priori, and is guaranteed to the lender regardless of the outcome of the project financed. \\ \midrule
II- & Zakat & Tax \\ \cmidrule(l){2-2} \cmidrule(r){3-3}
& Means clean and growth                  & Mean Debt, burden.\\
& Paid to poor only                       & Finance the government spending.\\
& Yearly basis                            & Yearly basis\\
& The wealth exceeding certain threshold. & Net Income. \\
& Fixed to 2.5\%                          & Differs according to the tranche.\\
& Imposed based to productive Assets.     & All assets \\
\bottomrule
\end{tabularx}
\end{threeparttable}

\end{document}

• Welcome to TeX SE. Always post a complete small document demonstrating your problem. This makes it a lot easier and less frustrating to help! I put your code in a document, guessed what packages were needed and compiled. But, of course, it does not reproduce the issue for me as the document is only one page long and the table fits nicely. Always check the code reproduces the issue before posting... – cfr Apr 3 '14 at 3:12
• Thank you cfr for your quick reply, actually it's part of my thesis with {scrbook} as document class, what is weird is when i put the preamble with the text and the table it fits nicely just as your output, but in my main document the problem persists: the last part of the paragraph will join the table in the next page enven tough there is still space in the previous page >_<! many thanks again! – Hind Linna Apr 3 '14 at 10:16
• You need to produce a Minimal (non-)Working Example you can post which reproduces the problem. You can do this by commenting out parts of your document to figure out which parts are required for the issue to manifest. Otherwise, there is not much anybody can do but guess. – cfr Apr 3 '14 at 14:00
• hey cfr, I've added a code with some text and my preambule, hope I made it clearer now! rgds! – Hind Linna Apr 5 '14 at 6:47

It looks like you're using the threeparttable environment in a somewhat unusual way. To quote from the user guide of the threeparttable package:

This package facilitates tables with titles (captions) and notes. The title and notes are given a width equal to the body of the table (a tabular environment). By itself, a threeparttable does not float, but you can put it in a table or a table* or some other floating environment.

I think there are two ways to fix the problems you're encountering:

• Encase the threeparttable environment in a table environment. Once you prefix \begin{table} to \begin{threeparttable} and append \end{table} to \end{threeparttable}, the problems you've been encountering are no longer present.

• Since you're not actually using the tablenotes facility of the threeparttable environment, just replace \begin{threeparttable} with \begin{table}, and \end{threeparttable} with \end{table}. This approach also gets rid of the problem.

Separately, I can't help but comment on the fact that your document's preamble is a bit of a mess. For instance, the hyperref package is loaded no fewer than three times, and the inputenc package is loaded twice. While this issue doesn't directly affect the compilability of the MWE you've posted, it may cause problems in your real, presumably much longer, document. In particular, do remember to load the hyperref and cleveref pacakges last, i.e., after all other packages have been loaded.

• Dear Mico, Thanks a lot :)) Working great! I've got a lot of tables will update them accordingly! and many tks for the other remarks will take them into consideration im still a beginner in Latex thanks again :) – Hind Linna Apr 5 '14 at 13:46

Works fine here:

\documentclass{article}

\usepackage{threeparttable,tabularx,booktabs,kantlipsum}

\begin{document}
\kant[1-3]

\paragraph*{Real interest rate}is the lending rate adjusted for the price level. The inflation adjustment is made via the GDP deflator.

\begin{threeparttable}
\label{varmacro}
\caption{\footnotesize Variables sources}
\begin{tabularx}{\textwidth}{@{}l X X} \toprule
Variables & Transformation & Source\\ \midrule
\textbf{Dependent variable}\\
Efficiency & log(var +1)& Author DEA estimation\\
\textbf{Independent variables}\\
Real GDP growth & (xyz) log(var +1) & Bloomberg\\
Financial openness & log(var +1) & Kaufmansn index\\
Government spending & share of GDP in log form & World bank \\
Trade openness & share of GDP in log form & World bank \\
Foreign Direct Invtment & share of GDP in log form & World bank\\
Rule of law & log(var +1) & The Worldwide Governance Indicators, 2013 Update \\
High school enrollment & logarithm form & World bank and the UNESCO data base\\

\bottomrule
\end{tabularx}
\end{threeparttable}

\end{document}