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.

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.

share|improve this question
    
possible duplicate of How can I inhibit LaTeX to float a table across a section boundary? –  TH. Apr 11 '11 at 7:12
    
Maybe tex.stackexchange.com/questions/9485/how-to-fix-table-position was a better match for a duplicate. There are many to choose from. –  TH. Apr 11 '11 at 7:16
add comment

1 Answer

up vote 5 down vote accepted

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}
share|improve this answer
3  
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) –  Herbert Apr 12 '11 at 12:35
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.