Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a caption on top of Latex table

Tags:

latex

pdflatex

I want to put a caption on top of the following table in Latex.

\begin{center}

\begin{tabular}{ | l | l | l | l | l | l | l | l | l | p{5cm} |}
\hline
GT & MT & PT & ML & FP & FN & ID & FM & Rc & Pr \\ \hline
abc & abc & abc & abc & abc & abc & abc & abc & abc & abc \\ \hline

\hline
\end{tabular}

\end{center}
like image 862
Mazhar Mohsin Avatar asked Jun 14 '16 09:06

Mazhar Mohsin


1 Answers

You do not make a table, but only a tabular (which cannot have a caption). You have to make a table first, and then a tabular:

\begin{table}[htb]

    \centering % instead of \begin{center}
    \caption{Here you can type in your caption}
    \vspace{10mm} % Adjust the height of the space between caption and tabular

    \begin{tabular}{ | l | l | l | l | l | l | l | l | l | p{5cm} |}
        \hline
        GT & MT & PT & ML & FP & FN & ID & FM & Rc & Pr \\ \hline
        abc & abc & abc & abc & abc & abc & abc & abc & abc & abc \\ \hline
         \hline
    \end{tabular}

\end{table}

Further explanation: "The table environment merely holds our other environments and allows to add a caption to our table. The actual data is contained in the tabular environment and we center the table on the page using the center environment."

like image 137
Nander Speerstra Avatar answered Nov 12 '22 04:11

Nander Speerstra