# Tables and sections get misplaced

These are my tables:

 \section{The status of respondents}
\begin{center}
\begin{table}
\begin{tabular}{|l|l|l|l|}
\hline
\textbf{Sl.No.} & \textbf{Grouping of Respondents} & \textbf{Respondents} & \textbf{Percentage} \\
\hline
1 & Students & 38 & 76\% \\
\hline
2 & Employees & 12 & 24\% \\
\hline
& \textbf{Total} & 50 & 100\% \\
\hline
\end{tabular}
\caption{The status of respondents}
\end{table}
\end{center}

Among the 50 respondents 38 were students and 12 were employees.
\section{Some section}
\begin{center}
\begin{table}
\begin{tabular}{|l|l|l|l|}
\hline
\textbf{Sl.No.} & \textbf{Options} & \textbf{Respondents} & \textbf{Percentage} \\
\hline
1 & Getting it without making payment & 29 & 58\% \\
\hline
2 & Free to use it for any purpose & 10 & 20\% \\
\hline
3 & Free to distribute copies & 11 & 22\% \\
\hline
& \textbf{Total} & 50 & 100\% \\
\hline
\end{tabular}
\caption{Opinion about something}
\end{table}
\end{center}


When I compile into a pdf the tables appear together, and section names and other writing in the middle will appear separately after the tables.

## 1 Answer

do not put the tables inside a center environment.

\listfiles
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\begin{document}

\section{The status of respondents}
\begin{table}[!htb]
\centering
\begin{tabular}{|l|l|l|l|}\hline
\textbf{Sl.No.} & \textbf{Grouping of Respondents} & \textbf{Respondents} & \textbf{Percentage} \\
\hline
1 & Students & 38 & 76\% \\
\hline
2 & Employees & 12 & 24\% \\
\hline
& \textbf{Total} & 50 & 100\% \\
\hline
\end{tabular}
\caption{The status of respondents}
\end{table}

Among the 50 respondents 38 were students and 12 were employees.
\section{Some section}
\begin{table}[!htb]
\centering
\begin{tabular}{|l|l|l|l|}\hline
\textbf{Sl.No.} & \textbf{Options} & \textbf{Respondents} & \textbf{Percentage} \\
\hline
1 & Getting it without making payment & 29 & 58\% \\
\hline
2 & Free to use it for any purpose & 10 & 20\% \\
\hline
3 & Free to distribute copies & 11 & 22\% \\
\hline
& \textbf{Total} & 50 & 100\% \\
\hline
\end{tabular}
\caption{Opinion about something}
\end{table}

\end{document}

• You know this is a duplicate question; it comes up over and over. Just vote to close and give duplicate as the reason. – TH. Apr 11 '11 at 7:13
• I used your solution and it worked. Among 8 tables the last table gets misplaced. Last table comes first section name later. Any solution? – nixnotwin Apr 11 '11 at 11:25
• if you do not want that your tables should placed by TeX, then don't use a table environment, use \captionof{table}{...} instead (needs package caption) – user2478 Apr 12 '11 at 12:35