1

So I have a very weird problem.

Simply put, when I put a [H] after \begin table, the table cannot fit on the page. I have to put an [H] because Latex is putting the table in the wrong place (about 2 pages further). When I remove the [H], the table can fit on one page perfectly. Unfortunately, I cannot provide an MWE as I cannot replicate it in a MWE environment, however I can provide the basic code:

\documentclass{article}
\usepackage{ragged2e,array,siunitx,longtable,booktabs}
\begin{document}
\begin{table}
\centering
\small
\setlength{\tabcolsep}{3.7pt}
\caption{Descriptive Statistics (\%): Commerce, EBE and Science faculties. Key: \textbf{G}: Graduate, \textbf{AE}: Academically Excluded, \textbf{C}: Censored}      
\label{table:DSCF}
\begin{tabular}{
>{\RaggedRight\arraybackslash}p{.15\textwidth} 
*{12}{S[table-format=2.1]}}
\toprule
{\bfseries Variable} & 
\multicolumn{3}{c}{\bfseries Commerce} &
\multicolumn{3}{c}{\bfseries EBE} &
\multicolumn{3}{c}{\bfseries Science} &
\multicolumn{3}{c}{\bfseries Total} \\
\cmidrule(rl){2-4}
\cmidrule(rl){5-7}
\cmidrule(rl){8-10}
\cmidrule(rl){11-13}
&
{\bfseries G} & {\bfseries AE} & 
{\bfseries C} &
{\bfseries G} & {\bfseries AE} & 
{\bfseries C} &
{\bfseries G} & {\bfseries AE} & 
{\bfseries C} &
{\bfseries G} & {\bfseries AE} & 
{\bfseries C}\\
\midrule
\bfseries Total & 50.1 & 7.5 & 42.4 & 35.8 & 21.6 & 42.7 & 46.4 & 26.1 & 27.5 & 45.8 & 14.9 & 39.3    \\
\addlinespace
\bfseries Gender\\
Male                 & 49.6 & 8.7  & 41.7 & 36.4 & 21.9 & 41.7 & 44.0 & 31.2 & 24.9 & 44.3 & 17.3 & 38.5 \\
Female               & 50.7 & 6.2  & 43.1 & 33.8 & 20.6 & 45.7 & 49.3 & 20.2 & 30.5 & 48.0 & 11.5 & 40.5 \\
\addlinespace
\bfseries Race\\
White & 59.8 & 3.0 & 37.2 & 50.8 & 7.8 & 41.3 & 64.5 & 5.1 & 30.4 &  58.7 & 4.6 & 36.7  \\
Black & 38.7 & 13.1 & 48.2 & 22.2 &34.9& 43.0 & 31.0 & 44.5 & 24.5 & 32.5 & 26.3 &41.2\\
Coloured & 49.8 & 7.4 & 42.8 & 36.4 & 21.9 & 41.6 & 40.2 & 30.6 & 29.2 & 44.5 & 16.1 & 39.5   \\
Indian/Asian & 48.9  & 7.9 & 43.3 & 32.7 & 20.5 & 46.9 & 32.7 & 20.5 & 46.9 & 44.6 & 13.3 & 42.1\\
\addlinespace
\multicolumn{4}{l}{\bfseries Financial Aid}\\
Ineligible& 52.1  & 5.5  & 42.4 & 38.0 & 17.7 & 44.3 & 38.0 & 17.7 & 44.3 & 48.7 & 10.6 & 40.7  \\
Eligible & 40.7 & 17.2 & 42.1 & 26.5 & 37.5 & 36.1 & 33.8 & 42.9 & 23.3 & 35.2 & 30.3 & 34.5 \\
\addlinespace
\multicolumn{4}{l}{\bfseries Programme}\\
Mainstream  & 55.4  & 5.7 & 38.9 & 40.5 & 17.3 & 42.3 & 54.3 & 16.4 & 29.3 & 51.3 & 10.8 & 37.9  \\
Academic Dev. & 32.5 & 13.7 & 53.8 & 14.1 & 41.4 & 44.5 & 25.3 & 51.8 & 22.8 & 27.1 & 28.7 & 44.2 \\
\addlinespace
\multicolumn{4}{l}{\bfseries English Home Language}\\
Yes  & 55.1 & 4.9 & 39.9 & 44.1 & 13.3 & 42.6 & 56.3 & 14.1 & 29.6 & 52.8 & 8.6 & 38.6 \\
No & 38.8 & 13.4  & 47.8 & 22.3 &  35.0 & 42.7 & 32.7 & 42.7 & 24.6 & 32.8 & 26.6 & 40.6 \\
\addlinespace
\multicolumn{4}{l}{\bfseries School Quintile}\\
1  & 34.6 & 30.8 & 34.6 & 14.1 & 49.3 & 36.6 & 34.0 & 45.3 & 20.8 & 26.1 & 42.6 & 31.3  \\
2  & 30.2 & 16.0 & 53.8 & 25.6 & 36.4 & 38.0 & 28.8 & 50.9 & 20.3 & 28.1 & 35.1 & 36.8 \\
3  & 32.0 & 17.5 & 50.5 & 21.7 & 41.9 & 36.5 & 30.0 & 45.8 & 24.2 & 27.7 & 35.3 & 37.0 \\
4  & 37.7 & 17.7 & 44.5 & 17.7 & 38.0 & 44.3 & 30.0 & 46.7 & 23.3 & 29.5 & 32.0 & 38.5 \\
5  & 52.0 & 6.9 & 41.1 & 41.0 & 16.2 & 42.9 & 54.3 & 14.8 & 31.0 & 49.2 & 12.0 & 38.9  \\
Independent  & 52.5 & 5.3 & 42.2 & 40.7 & 13.9 & 45.5 & 54.3 &14.8 & 31.0 & 50.4 & 8.6 & 41.0 \\
\addlinespace
\multicolumn{4}{l}{\bfseries Western cape province}\\
Yes & 55.1 & 5.9 &39.0 & 42.1 &16.2 &41.7 & 52.0 &20.0 & 28.0 & 51.3 & 11.6 &37.0 \\
No &46.8 & 8.6 & 44.6 & 31.6 & 25.1 & 43.3 & 41.5 & 31.5 & 27.1 & 41.9 & 17.2 &41.0\\
\addlinespace
\multicolumn{4}{l}{\bfseries Year of First Registration} \\
{2006} &  87.8 & 11.3 & 0.9 & 70.3 & 29.0 & 0.7 & 69.5 & 28.2 & 2.3 & 79.9 & 18.9 &1.2  \\
{2007} & 88.2 & 10.1 &  1.7 & 68.7 & 30.0 & 1.4 & 68.5 & 30.8 & 0.7 & 79.4 &19.2 &1.4\\
{2008} & 87.1 & 10.3 &  2.6 & 63.6 & 30.6 & 5.8 & 66.2 & 32.3 & 1.6 & 76.7 & 20.3 & 3.0 \\
{2009} & 80.9 & 9.7 & 9.4 & 51.2   & 32.3 &16.5 & 51.9 & 43.9 & 4.2 & 64.9 & 24.9 & 10.2 \\
{2010} & 62.6 & 6.4 & 31.1 & 36.8 & 19.0 & 44.2 & 69.8 & 21.0 & 9.3 & 57.5 & 12.7 & 29.8 \\
{2011} & 15.8 & 7.2 & 77.0 & 0.0 & 18.2  & 81.8 & 37.3 & 23.4 & 39.8 & 15.3 & 12.8 & 71.9 \\
{2012} & 0.0 & 5.4 & 94.6 &  0.0 & 7.5 & 92.5 & 0.0 & 13.4 & 86.6 & 0.0 & 7.5 & 92.5 \\
{2013} & 0.0 & 1.7 & 98.3 & 0.0 & 4.9  & 95.1 & 0.0 & 5.1  & 94.9 & 0.0 & 3.0 & 97.0 \\
\end{tabular}
\end{table}
\end{document}

This code produces this document (good)

enter image description here

Now when I put the [H} after \begin{table} it produces the following:

enter image description here

Here is my exact code (I'm using a main .tex file - this is one of the chapters, hence no packages in this code):

\begin{table} [H]
\centering
\small
\setlength{\tabcolsep}{3.7pt}
\caption{Descriptive Statistics (\%): Commerce, EBE and Science faculties. Key: \textbf{G}: Graduate, \textbf{AE}: Academically Excluded, \textbf{C}: Censored}      
\label{table:DSCF}
\begin{tabular}{
>{\RaggedRight\arraybackslash}p{.15\textwidth} 
*{12}{S[table-format=2.1]}}
\toprule
{\bfseries Variable} & 
\multicolumn{3}{c}{\bfseries Commerce} &
\multicolumn{3}{c}{\bfseries EBE} &
\multicolumn{3}{c}{\bfseries Science} &
\multicolumn{3}{c}{\bfseries Total} \\
\cmidrule(rl){2-4}
\cmidrule(rl){5-7}
\cmidrule(rl){8-10}
\cmidrule(rl){11-13}
&
{\bfseries G} & {\bfseries AE} & 
{\bfseries C} &
{\bfseries G} & {\bfseries AE} & 
{\bfseries C} &
{\bfseries G} & {\bfseries AE} & 
{\bfseries C} &
{\bfseries G} & {\bfseries AE} & 
{\bfseries C}\\
\midrule
\bfseries Total & 50.1 & 7.5 & 42.4 & 35.8 & 21.6 & 42.7 & 46.4 & 26.1 & 27.5 & 45.8 & 14.9 & 39.3    \\
\addlinespace
\bfseries Gender\\
Male                 & 49.6 & 8.7  & 41.7 & 36.4 & 21.9 & 41.7 & 44.0 & 31.2 & 24.9 & 44.3 & 17.3 & 38.5 \\
Female               & 50.7 & 6.2  & 43.1 & 33.8 & 20.6 & 45.7 & 49.3 & 20.2 & 30.5 & 48.0 & 11.5 & 40.5 \\
\addlinespace
\bfseries Race\\
White & 59.8 & 3.0 & 37.2 & 50.8 & 7.8 & 41.3 & 64.5 & 5.1 & 30.4 &  58.7 & 4.6 & 36.7  \\
Black & 38.7 & 13.1 & 48.2 & 22.2 &34.9& 43.0 & 31.0 & 44.5 & 24.5 & 32.5 & 26.3 &41.2\\
Coloured & 49.8 & 7.4 & 42.8 & 36.4 & 21.9 & 41.6 & 40.2 & 30.6 & 29.2 & 44.5 & 16.1 & 39.5   \\
Indian/Asian & 48.9  & 7.9 & 43.3 & 32.7 & 20.5 & 46.9 & 32.7 & 20.5 & 46.9 & 44.6 & 13.3 & 42.1\\
\addlinespace
\multicolumn{4}{l}{\bfseries Financial Aid}\\
Ineligible& 52.1  & 5.5  & 42.4 & 38.0 & 17.7 & 44.3 & 38.0 & 17.7 & 44.3 & 48.7 & 10.6 & 40.7  \\
Eligible & 40.7 & 17.2 & 42.1 & 26.5 & 37.5 & 36.1 & 33.8 & 42.9 & 23.3 & 35.2 & 30.3 & 34.5 \\
\addlinespace
\multicolumn{4}{l}{\bfseries Programme}\\
Mainstream  & 55.4  & 5.7 & 38.9 & 40.5 & 17.3 & 42.3 & 54.3 & 16.4 & 29.3 & 51.3 & 10.8 & 37.9  \\
Academic Dev. & 32.5 & 13.7 & 53.8 & 14.1 & 41.4 & 44.5 & 25.3 & 51.8 & 22.8 & 27.1 & 28.7 & 44.2 \\
\addlinespace
\multicolumn{4}{l}{\bfseries English Home Language}\\
Yes  & 55.1 & 4.9 & 39.9 & 44.1 & 13.3 & 42.6 & 56.3 & 14.1 & 29.6 & 52.8 & 8.6 & 38.6 \\
No & 38.8 & 13.4  & 47.8 & 22.3 &  35.0 & 42.7 & 32.7 & 42.7 & 24.6 & 32.8 & 26.6 & 40.6 \\
\addlinespace
\multicolumn{4}{l}{\bfseries School Quintile}\\
1  & 34.6 & 30.8 & 34.6 & 14.1 & 49.3 & 36.6 & 34.0 & 45.3 & 20.8 & 26.1 & 42.6 & 31.3  \\
2  & 30.2 & 16.0 & 53.8 & 25.6 & 36.4 & 38.0 & 28.8 & 50.9 & 20.3 & 28.1 & 35.1 & 36.8 \\
3  & 32.0 & 17.5 & 50.5 & 21.7 & 41.9 & 36.5 & 30.0 & 45.8 & 24.2 & 27.7 & 35.3 & 37.0 \\
4  & 37.7 & 17.7 & 44.5 & 17.7 & 38.0 & 44.3 & 30.0 & 46.7 & 23.3 & 29.5 & 32.0 & 38.5 \\
5  & 52.0 & 6.9 & 41.1 & 41.0 & 16.2 & 42.9 & 54.3 & 14.8 & 31.0 & 49.2 & 12.0 & 38.9  \\
Independent  & 52.5 & 5.3 & 42.2 & 40.7 & 13.9 & 45.5 & 54.3 &14.8 & 31.0 & 50.4 & 8.6 & 41.0 \\
\addlinespace
\multicolumn{4}{l}{\bfseries Western cape province}\\
Yes & 55.1 & 5.9 &39.0 & 42.1 &16.2 &41.7 & 52.0 &20.0 & 28.0 & 51.3 & 11.6 &37.0 \\
No &46.8 & 8.6 & 44.6 & 31.6 & 25.1 & 43.3 & 41.5 & 31.5 & 27.1 & 41.9 & 17.2 &41.0\\
\addlinespace
\multicolumn{4}{l}{\bfseries Year of First Registration} \\
{2006} &  87.8 & 11.3 & 0.9 & 70.3 & 29.0 & 0.7 & 69.5 & 28.2 & 2.3 & 79.9 & 18.9 &1.2  \\
{2007} & 88.2 & 10.1 &  1.7 & 68.7 & 30.0 & 1.4 & 68.5 & 30.8 & 0.7 & 79.4 &19.2 &1.4\\
{2008} & 87.1 & 10.3 &  2.6 & 63.6 & 30.6 & 5.8 & 66.2 & 32.3 & 1.6 & 76.7 & 20.3 & 3.0 \\
{2009} & 80.9 & 9.7 & 9.4 & 51.2   & 32.3 &16.5 & 51.9 & 43.9 & 4.2 & 64.9 & 24.9 & 10.2 \\
{2010} & 62.6 & 6.4 & 31.1 & 36.8 & 19.0 & 44.2 & 69.8 & 21.0 & 9.3 & 57.5 & 12.7 & 29.8 \\
{2011} & 15.8 & 7.2 & 77.0 & 0.0 & 18.2  & 81.8 & 37.3 & 23.4 & 39.8 & 15.3 & 12.8 & 71.9 \\
{2012} & 0.0 & 5.4 & 94.6 &  0.0 & 7.5 & 92.5 & 0.0 & 13.4 & 86.6 & 0.0 & 7.5 & 92.5 \\
{2013} & 0.0 & 1.7 & 98.3 & 0.0 & 4.9  & 95.1 & 0.0 & 5.1  & 94.9 & 0.0 & 3.0 & 97.0 \\
\end{tabular}
\end{table}
  • 1
    It shouldn't ever overprint the page number if the standard definitions are in place. It will be hard to help unless you can provide an example. Just start with a copy of the bad document and delete everything you can delete while still showing the problem. – David Carlisle Sep 30 '15 at 19:51
  • Doesn't use H option! Instead it rather use h or even better htbp. I you like that table follows immediately after point where you place it and it is to big to be fit on the same page, see if the use of longtable is good solution for you. – Zarko Sep 30 '15 at 19:52
  • @Zarko while H generally isn't always the best option to choose it should never produce the output shown so there is something else in effect in the OPs document, so it isn't clear that other suggestions won't have similar problems. – David Carlisle Sep 30 '15 at 19:54
  • not related: you can't just use \clearpage after this table? – touhami Sep 30 '15 at 19:57
  • @DavidCarlisle, it is really unusual result. Usual figure with option H, which is higher than rest of page, goes to the next page together with text after it. – Zarko Sep 30 '15 at 19:58
  • 3
    @Zarko I know (I wrote that code:-) – David Carlisle Sep 30 '15 at 20:03
  • Hi Zarko I tried [h] and it put it 8 pages after it should be. [htbp] was about 2 pages. @touhami will try that - thanks. I got a funny line at the top of my page (using a template) - could that possibly be the problem when using the [H] option. Will provide a screenshot now. – The Statistician Magician Sep 30 '15 at 20:03
  • Ok fixed. I used a /clearpage before and after the table. Here is my header which now has a line - would like to get rid of it. I am using the \fancyhdr pacakage:http://tinypic.com/view.php?pic=21c5tmh&s=8#.VgxBEeyqpBc – The Statistician Magician Sep 30 '15 at 20:07
  • @Chris that link doesn't seem usable but anyway external links are not good for the site archives, you could edit the question to add extra information. – David Carlisle Sep 30 '15 at 20:09
  • @touhami make that an answer I guess (although it would have been interesting to see why the over-printing occurs) – David Carlisle Sep 30 '15 at 20:11

1 Answers1

1

Following this answer (Frank Mittelbach)

If the end of the document has been reached or if a \clearpage is encountered, LaTeX starts a new page, relaxes all restrictive float conditions, and outputs all floats in the holding queue by placing them on float page(s).

So one can try to use \clearpage just after the table.

touhami
  • 19,520