17

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}
2
  • 1
    Welcome to TeX.SE. You need to encase the tabular material in a table environment.
    – Mico
    Commented Oct 28, 2015 at 9:43
  • If that does not work, a full MWE that shows the rest of your document setup would be really helpful.
    – moewe
    Commented Oct 28, 2015 at 9:56

2 Answers 2

22

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}
0

for caption get the same problem and after checking others similar issues and solution i decide to use a sidewaystable and I add a caption without any problem:

\begin{sidewaystable} 
    \centering
    \begingroup % make the next setting local
    \captionsetup{type=table} % here we want to caption a table
    \caption{your caption here }
    \label{tab:the table label}
    \begin{tabular}{lrlllllll}
    \toprule
    \midrule

    \bottomrule
\end{tabular}
\endgroup
\end{sidewaystable}

don't forget tp put this lines on the preambule

\usepackage{caption}
\usepackage{booktabs}
5
  • 2
    sorry, how this answer OP question? why someone should use figure environment for table and than do all complication (which works!), as you propose? well, it is possible, we newer know ...
    – Zarko
    Commented Jul 11, 2017 at 15:29
  • Welcome to TeX.SX! Please make sure that your answer fits the question. I think its not a good idea to use figure environment for tables. HAve a look tothe topic minimal working example (MWE) for the future. Thanks
    – Bobyandbob
    Commented Jul 11, 2017 at 15:47
  • Not that the OP asked, but there's sidewaystable as an environment instead of sidewaysfigure, then you wouldn't have to go through the trouble to change the caption type.. My point being, there shouldn't ever arise a need to place a table in a figure environment
    – Troy
    Commented Jul 11, 2017 at 15:50
  • @Troy thanks !! thnik it shlould be sidewaystable instead let me edit the response Commented Jul 11, 2017 at 15:51
  • @EspoirMurhabazi No, that's merely additional fluff. Greeshma's question doesn't necessitate a sidewaystable, so your answer (while it may work), is not relevant, sorry.
    – Troy
    Commented Jul 11, 2017 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .