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 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.

share|improve this question
1  
Is this a problem of where the table appears (float placement) or of referencing it? You can influence the placement of the table with a modifier \begin{table}[h]. (I believe the \label should go inside the \caption.) –  Christian Lindig Feb 27 '11 at 10:24
4  
@Christian: The \label just needs to go after the \caption. I can't think of any good reason to put it inside it. –  TH. Feb 27 '11 at 10:34
1  
possible duplicate of Why is my table displayed at the top of the page? –  TH. Feb 27 '11 at 10:35
    
@Christian. I want the table to be referenced before and place the table immediately after the text. –  Vinod Feb 27 '11 at 10:37

2 Answers 2

up vote 8 down vote accepted

use it this way:

\begin{table}[!htb]
    \centering
        \begin{tabular}{lrc}\hline
        ....
    \caption{Class Mark List}\label{tab:a}
\end{table}
share|improve this answer
    
Thanks.[h] is also working. –  Vinod Feb 27 '11 at 10:41
    
@Vinod: I know, but in other situations not and it is already modified internally to [ht] –  Herbert Feb 27 '11 at 10:42
\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}
share|improve this answer
1  
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Could you provide some explanations? Also, it would be better to have a full compilable code instead of just a snippet. –  henrique Aug 24 '13 at 15:32

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.