[Tex/LaTex] Tabular Caption

tables

I have a table that I would like to put a caption below the table. I used the code \caption{}, but it shows an error. I have done the code as below. How can add the caption below?

\begin{center}
    \begin{tabular}{|l|r|r|r|r|r|r|}
            \hline
        Topic & 
        \multicolumn{2}{c|}
        {\centering $ Z_{1} $ }
        & \multicolumn{2}{c|}{\centering $ Z_{2} $ }
        & \multicolumn{2}{c|}{\centering $ Z_{3} $ }\\
        \hline

    \multicolumn{1}{|c|}{Document}  
    & \multicolumn{1}{|c|}{$ \vartheta_{d,1} $}    
    & \multicolumn{1}{|c|}{ words}
    & \multicolumn{1}{|c|}{$ \vartheta_{d,2} $}
    & \multicolumn{1}{|c|}{ words}
    & \multicolumn{1}{|c|}{$ \vartheta_{d,3} $}
    & \multicolumn{1}{|c|}{ words}\\


    \hline
    \hline
    $ d_{1} $   & 0.6    & $  w_{1} $,$  w_{2} $,$  w_{3} $,$  w_{2} $,$  w_{1} $ 
    & 0.2 & $  w_{1} $, $  w_{9} $ , $  w_{8} $
    & 0.2 & $  w_{7} $,$  w_{10} $,$  w_{10} $\\
    $ d_{2} $   & 0.2   & $  w_{2} $,$  w_{4} $,$  w_{4} $ & 0.5 & $  w_{7} $,$  w_{8} $,$  w_{1} $,$  w_{8} $,$  w_{8} $
    & 0.3 & $  w_{1} $,$  w_{11} $,$  w_{12} $\\
    $ d_{3} $   & 0.3   & $  w_{2} $,$  w_{1} $,$  w_{7} $,$  w_{5} $ & 0.3 & $  w_{7} $,$  w_{3} $,$  w_{3} $,$  w_{2} $ & 0.4 & $  w_{4} $,$  w_{7} $,$  w_{10} $,$  w_{11} $\\
    $ d_{4} $   & 0.3   & $  w_{2} $,$  w_{7} $,$  w_{6} $ & 0.4 & $  w_{9} $,$  w_{8} $,$  w_{1} $ & 0.3 & $  w_{1} $,$  w_{11} $,$  w_{10} $\\

    \hline
    \end{tabular}
    \caption{This is my one big figure\label{fig:somefig}}
\end{center}

Best Answer

You need to provide a table environment that encases the tabular environment as well as the \caption and \label statements.

% \documentclass statement and preamble
\begin{document}

\begin{table}
  \centering
  \begin{tabular}{|l|r|r|r|r|r|r|}
    % body of tabular environment 
  \end{tabular}
  \caption{This is my one big table} \label{tab:sometab}
\end{table}

\end{document}

P.S If you want to add the table inside your own .text file you don't need to use these:

\begin{document}

\end{document}
Related Question