4

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?

David Carlisle
  • 757,742
anon
  • 43

1 Answers1

4

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

David Carlisle
  • 757,742
lockstep
  • 250,273