12

Possible Duplicate:
How to influence the position of float environments like figure and table in LaTeX?

I am trying to create a table after some text:

Some text. foobar foobar \\

\begin{table}[t]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
 & a & c & & &  \\
\hline
$\{X, X', Y\}$ & & b &  & &  \\
\hline
\hline
\end{tabular}
\end{table}

However, the table is appearing before the text even though I type if after I type the text. Why?

4
  • 6
    You are using a floating environment, table. Remove that and the tabular will appear where you place it. Oct 29 '12 at 23:21
  • See also the general reference: tex.stackexchange.com/q/39017/8057
    – krlmlr
    Oct 29 '12 at 23:23
  • 1
    I'd actually say this question is a duplicate of the one @user946850 pointed to?
    – doncherry
    Oct 29 '12 at 23:24
  • @doncherry agreed, voting to close; David, this helps to keep the site tidy :)
    – cmhughes
    Oct 30 '12 at 0:02
13

If you don't need to use a caption, don't use table environment which is a floating object. Further, you have mentioned the option [t] which means the table will be at the top of the page. Use [htb] as the option as in this code:

\documentclass{book}
\usepackage{lipsum}

\begin{document}
 \lipsum[1]

\begin{table}[htb]
\centering
\caption{This is a table}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
 & a & c & & &  \\
\hline
$\{X, X', Y\}$ & & b &  & &  \\
\hline
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

For more details on the control of float placements refer to this question and answers.

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