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've inserted a table in my LaTeX document and have used \center to horizontally align it to the centre of the page. However, it's appearing a page after where it should, is both horizontally and vertically aligned to the centre and appears after some text which it should precede.

What's going wrong?

EDIT: Edited to add a Minimal Working Example (though, given that I don't know what could be causing the problem, I can't guarantee minimality).

\large
\textbf{Section 2}
\\

\normalsize

\textbf{Description of section}.

\begin{figure}[h]
\center
\caption{Sample output}
\includegraphics[width=10cm,height=3cm]{/Users/Matt/Desktop/Figures/2.jpg}
\label{fig:2}
\end{figure}

\textbf{Hello}. Below are the results. \\

\begin{table}[ht]
\caption{Caption} 
\center
\begin{tabular}{c c c}
\hline \hline
A & B & C \\
\hline
1 & a & A \\
2 & b & B \\
3 & c & C \\
4 & d & D \\
5 & e & E \\
6 & f & F \\
7 & g & G \\
\hline
\end{tabular}
\end{table} 

%Section 2 end

\Large
\textbf{Title}

\large
\textbf{Section 3}
\\
share|improve this question
1  
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. –  qubyte Jan 6 '12 at 14:34
3  
Specifically, we need to see what optional arguments you're using if you're using the table environment. Something like \begin{table}[p] (page) could be causing the table to be set on its own page. If you just used [h] (here) then try adding t (top) to it, as if the table runs over a page with just [h] it can default to page. –  qubyte Jan 6 '12 at 14:41
    
Hmm, now the table doesn't appeared centred vertically, but it does appear after "Section 3" –  Matt Jan 6 '12 at 15:04
2  
Correct me if I am wrong but doesn't it need to be \centering instead of just \center?. If you don't want a table to float beyond a certian point use the placeinspackage's command \FloatBarrier where appropriate –  Martin H Jan 6 '12 at 17:10
1  
Your code is not a complete MWE- please append it so that it includes the documentclass & pre-amble, and can be compiled without editing. Also, using \` outside of the tabular` environment in the way you have is not appropriate- I recommend reading The Not so short guide to LaTeX for an overview of the basics. –  cmhughes Jan 6 '12 at 20:34

1 Answer 1

up vote 2 down vote accepted

After adapting the code snippet provided to be compilable by adding the usual preamble: \documentclass{}... \usepackage{}...\begin{document} it still does not show the problem that you mention. I suspect that since the table environment is a float, it ends up on a page by itself, in which case the default is to vertically center it on the page. An excellent discussion can be found at How to influence the position of float environments like figure and table in LaTeX?

To modify this behavior so that the table is at the top of the page, you need to set distance from top of page to first float by adjusting the length defined by \@fptop as per Vertical layout of float pages.

The code below produces a table at the top of Page 2, but if you comment out the \setlength{\@fptop}{5pt} it will display the default behavior and be vertically centered.

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{lipsum}

\makeatletter% Set distance from top of page to first float
\setlength{\@fptop}{5pt}
\makeatother

\begin{document}
\lipsum[1-5]
\begin{table}[ht]
\caption{Caption} 
\center
\begin{tabular}{c c c}
\hline \hline
A & B & C \\
\hline
1 & a & A \\
2 & b & B \\
3 & c & C \\
4 & d & D \\
5 & e & E \\
6 & f & F \\
7 & g & G \\
\hline
\end{tabular}
\end{table} 
\end{document}
share|improve this answer

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.