0

I am trying to place my table at the top of page but it seems there is something I am missing. First of all here is what my document structure

\documentclass{article}
\begin{document}
\section{Introduction}
4 long paragraphs which take exactly one page with this document class.
% Now the actual table starts
\begin{table}
\centering
\caption{Vertical Alignment Test}
\begin{tabular}[t]{ |m{0.85\textwidth}|c| } \hline
Somewhat 20 rows for this table
\end{tabular}
\end{table}
% Table end here
Immediately after table, Same 4 long paragraphs are copied but without \section.
\end{document}

This results in following output document structure

  • Page-1: 4 paragraphs
  • Page-2: Vertically center aligned table
  • Page-3: 4 paragraphs

Problem: Now my table is not as much long that it should take complete page rather if aligned properly at top of page, 2 paragraphs from bottom can be adjusted on page-2.

Tried Solutions

Here is somewhat related question which discusses the same problem. I tried to understand accepted answer and applied given solutions but no luck.

I tried to move table between paragraphs but it didn't change on output file mean same structure keep on outputting i.e. 4 paragraphs -> table -> 4 paragraphs

I cut some rows and at about half of rows (10) table get positioned at top and I get the effect what I wanted. But I don't want 10 rows I want all 20 rows in one table.

Please let me know if there are any questions regarding my explanation.

Aleem
  • 103
  • do have a good look at this. I guess the problem is your table being larger than what is allowed at the top of a page. As suggested in the link using [!t] should loosen that restriction and allow your table at the top of the page with some text below. – greyshade Aug 11 '14 at 08:56
  • 1
    What happens if you insert the instructions \renewcommand{\topfraction}{0.8} and \renewcommand{\floatpagefraction}{0.8} in the preamble? – Mico Aug 11 '14 at 08:57
  • Well, in any case, the table should not float around if it should be at top of the page, so remove the table environment and use \captionof{table}{your caption here} in conjunction with \usepackage{caption} –  Aug 11 '14 at 09:00
  • Try putting [htb] after \begin{table} In my test, I get this: http://i.stack.imgur.com/g1md3.png –  Aug 11 '14 at 09:06
  • Without a proper example it is hard to answer but presumably the table you have is too large for teh constraints you have set on floats within a text page so it is making a float page. use \begin{table}[!t] to ignore the constraints (or fix teh constraints) – David Carlisle Aug 11 '14 at 09:14
  • 1
    note that your code has a [t] flag on the tabular, which is probably ignored (but remember we don't have a (non-) working document showing all the packages you load). your table environment doesn't have a [t] flag, so will get the default flag set which is inappropriate for you – wasteofspace Aug 11 '14 at 10:17
  • Thanks everyone for helping. I get it solved using @wasteofspace and @HarishKumar answer by adding [!t] with \begin{table}. I was using next to {tabular} which was getting ignored. – Aleem Aug 11 '14 at 11:25
  • The [t] on the tabular wasn't so much ignored as just not important. What it does is place the baseline for the tabular on the baseline of the first row, which is only important if you have something else on the same horizontal line. – John Kormylo Aug 11 '14 at 19:36

1 Answers1

0

Just to close this off

You have to give the position specifiers to the table environment. It is preferrable to give [htb] instead of [!t] so that latex has some room to improve the appearence.

\documentclass{article}
\usepackage{array,kantlipsum}
\begin{document}
\kant[1-4]
\begin{table}[htb]   %%<<--- give it here
\centering
\caption{Vertical Alignment Test}
\begin{tabular}[t]{ |m{0.85\textwidth}|c| } \hline
Somewhat 20 rows for this table
\end{tabular}
\end{table}
\kant[1-5]
\end{document}

enter image description here