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 am trying to end my table with a \hline.

My tex is as follows

\begin{center}
\begin{tabular}{ l | c || r }
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\caption{ Result }
\label{tab:a}
\end{tabular}
\end{center}

However the resultant image is as follows:

enter image description here

As you can see an empty row gets added below the end. Can somebody tell me how to correct it?

share|improve this question
    
Now you can upvote ;-) –  Harish Kumar Jan 3 '13 at 15:26
add comment

1 Answer

up vote 4 down vote accepted

\caption and \label must be placed outside the tabular environment.

\documentclass{article}

\begin{document}

\begin{table}
\centering
\begin{tabular}{ l | c || r }
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\end{tabular}
\caption{Result}
\label{tab:a}
\end{table}

\end{document}

Note: The use of \caption indicates that you're placing your tabular inside a (floating) table environment; in that case, I recommend to replace the center environment with \centering.

share|improve this answer
    
could'nt vote up ! but thanks :) –  anon Jan 3 '13 at 15:05
    
@anon You're welcome -- and you may add your upvote once you reach 15 rep points. ;-) –  lockstep Jan 3 '13 at 15:06
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.