16

I want to reference a table before it appears.The TeX code is pasted below

\documentclass{article}
\begin{document}
The results given in Table~\ref{tab:a} show the  performance of
the class.

\begin{table}
    \begin{center}
        \begin{tabular}{lrc}\hline
        Name & Mark & Grade \\
        \hline
        Prasad & 99 & A+ \\
        Prakash & 51 & C\\
        Shine & 5 & F\\ \hline
        \end{tabular}
        \caption{Class Mark List}\label{tab:a}
    \end{center}
\end{table}
\end{document}

But the text

The results given in Table~\ref{tab:a} show the  performance of
    the class.

is coming after the table. How can I put the table immediately after the text.

David Carlisle
  • 757,742
Vinod
  • 1,351
  • 2
  • 11
  • 12

2 Answers2

24

use it this way:

\begin{table}[!htb]
    \centering
        \begin{tabular}{lrc}\hline
        ....
    \caption{Class Mark List}\label{tab:a}
\end{table}

However, from typographers view the caption of a table should be above the tabular.

  • @Vinod: I know, but in other situations not and it is already modified internally to [ht] –  Feb 27 '11 at 10:42
1
\begin{table}[htdp]
\vskip 0.25cm
\begin{center}
\begin{tabular}{| c| c |c |}
\hline\hline
{\textcolor{blue}{Plasma Parameter} & {\textcolor{blue}{PIC code parameters }& { \textcolor{blue}{MHD code parameters}}&\\
\hline
{\bf B$_z$}& 0.2&6.5 (nT)\\
\hline
{\bf V$_x$}& 0.25 & 500 (km.sec$^-^1$)\\
\hline
{\bf V$_A$}& 0.028 & 63 (km.sec$^-^1$)\\
\hline
$\frac{V_{A}}{V_{SW}}$&0.11&0.12\\
\hline
{\bf M$_A$}&8.9&7.8\\
\hline
{M$_S_C$}&5.5&5.2\\
\hline
\beta&1.6&2.7\\
\hline
\end{tabular}
\end{center}

\caption{ PIC and MHD simulations}\label{Tab:1}
\end{table}
ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
SMB
  • 19
  • 1