Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I recently decided I wanted a caption for the top table, so I placed it in a table environment. When I did this, the \vspace*{-2.5cm} before the second table seemed to be ignored for some reason. Does anyone know why? How I can overcome this problem?

\begin{center}
\begin{table}
\caption{My Table}
\begin{tabular}
...
\end{tabular}
\end{table}
\end{center}

\newpage
\vspace*{-2.5cm}
\begin{center}
\begin{tabular}
...
\end{tabular}
\end{center}

If I remove the table environment then the \vspace*{-2.5cm} works again.

share|improve this question
3  
Never put a center environment around a table environment; instead, put \centering after \begin{table} –  egreg Apr 24 '12 at 20:30
    
@egreg thanks, but can you explain why? Also, this seems to have centered the table vertically now. –  Alex Apr 24 '12 at 20:34
    
The table environment defines a "floating object". Every LaTeX guide describes them. –  egreg Apr 24 '12 at 20:36
    
@egreg I see. So the tabular environment is not a floating object and this is why the vspace no longer works? –  Alex Apr 24 '12 at 20:39
    
@Alex See tex.stackexchange.com/questions/2651/… –  lockstep Apr 24 '12 at 20:42
show 2 more comments

1 Answer

up vote 2 down vote accepted

If I understand your code correctly, you want to have the first part of some tabular material set on one page and the remaining tabular material at the very top of the next page. To force LaTeX to typeset the pending table float on the current page rather than defer it to some later point in the document that LaTeX's float-placement algorithm may deem to be appropriate, you should use \clearpage rather than \newpage, as \clearpage instructs LaTeX to "flush out" all pending floats (as well as start a new page). I take it that you've already ascertained that the first tabular enviroment -- the one that's currently encased in a table environment -- does fit on the intended page. You want to specify [htb!] as the placement directive for the table to give LaTeX maximum flexibility.

Or are you maybe looking to create a table that can span more than one page? If so, do check out the longtable, supertabular, and xtab environments. Unlike the standard LaTeX table environment, which can not cross page boundaries, these environments can all span multiple pages.

Addendum. As @egreg already suggested in a comment, don't use \begin{center} ... \end{center}; instead, use \centering after the \caption command and before the \begin{tabular}{...} command. The center environment inserts extra vertical whitespace, which is probably not what you want to achieve; the \centering macro centers everything in its scope but does not insert extra vertical whitespace.

share|improve this answer
    
Thanks for your reply. I've tried using \clearpage, but it seems to be inserting a blank page and the \vspace is still being ignored. –  Alex Apr 24 '12 at 20:55
    
@Alex: Having a MWE would be helpful as there are many possibilities as to what may be going on. Regarding the matter of where the tabular material starts on the second page, have you tried \vspace*{-2.5cm} instead of \vspace{-2.5cm}? At least when I use the \vspace* instruction between \clearpage and \begin{tabular}..., LaTeX dutifully moves the tabular stuff up by the specified amount.- –  Mico Apr 24 '12 at 21:07
    
Would I not have to post a table large than a page to provide a MWE? I think if I can simply alter the top margin for the second table page then it should work. Yes I have, that's what's in my code at the moment. –  Alex Apr 24 '12 at 21:08
    
Thank you for your help, it's fixed now. Adding \clearpage and then putting \vspace*{-2.5cm} after \begin{center} worked perfectly. If you look at my original code the \vspace*{-2.5cm} was before the \begin{center} which was not working. –  Alex Apr 24 '12 at 21:15
    
I'm glad you're all set! –  Mico Apr 24 '12 at 21:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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