0

I have a longtable spanning multiple pages but the verticle alignment is forced at the pagebreak, so the first page is pushed down to the bottom while the second page is glued to the top. How can i force both to the top of the page (or to the center for that matter).

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{pdflscape}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{longtable}


\begin{document}


\section{Title}

\tiny
\
\vfill
\begin{longtable}[!htb]{>{\raggedright}p{0.5cm}>{\raggedright}p{3.5cm}>{\raggedleft}p{1.5cm}>{\raggedleft}p{1cm}>{\raggedleft}p{1cm}>{\raggedleft}p{1cm}>{\raggedleft}p{1cm}p{1cm}<{\raggedleft}}
\caption[Correlations]{This table displays x}\\\\

\toprule
\multicolumn{1}{l}{No} &
\multicolumn{1}{l}{Company Name} &
\multicolumn{1}{r}{Constituent} &
\multicolumn{1}{r}{1} &
\multicolumn{1}{r}{2} &
\multicolumn{1}{r}{3} &
\multicolumn{1}{r}{4} &
\multicolumn{1}{r}{N}\\
\midrule
\endfirsthead

\multicolumn{8}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous
page}}\\

\toprule
\multicolumn{1}{l}{No} &
\multicolumn{1}{l}{Company Name} &
\multicolumn{1}{r}{Constituent} &
\multicolumn{1}{r}{1} &
\multicolumn{1}{r}{2} &
\multicolumn{1}{r}{3} &
\multicolumn{1}{r}{4} &
\multicolumn{1}{r}{N}\\
\midrule
\endhead

\midrule
\multicolumn{8}{r}{{Continued on next page}} \\\\
\midrule
\endfoot
\bottomrule
\endlastfoot
\input{"input.tex"}
 \label{table:grid_dailyaverages}
\end{longtable}
\vfill
\
\end{document}

Result of compilation (data obfuscated) input.tex contains data (8 columns) with \pagebreak at 30th line number which breaks the page to the next

  • 1
    Please provide a Minimum Working Example (small compilable document) illustrating the problem. – cfr Aug 7 '14 at 23:36
  • MWE provided. Look at alignment of first part at the bottom and second part at the top. – BigChief Aug 8 '14 at 0:33
  • 1
    What is input.tex? – user11232 Aug 8 '14 at 1:01
  • Isn't tabularx incompatible with longtable or am I confusing it with something else? – cfr Aug 8 '14 at 1:09
  • You have a \vfill before the table so obviously it is at the bottom of the page. Am I missing something? – cfr Aug 8 '14 at 1:12
3

\vfill instructs TeX to insert vertical space as necessary to, well, fill when appropriate. What this means depends on the context but, in this case, you are telling TeX that if it needs to, it is perfectly fine to put such space before and after the table, effectively pushing the first page of the table to the bottom and the final page to the top. If you would prefer TeX not do this, do not tell TeX it is OK to do so. That is, remove the \vfill commands.

  • thanks input.tex is just 8 columns of data, nothing special there!! – BigChief Aug 9 '14 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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