TransWikia.com

Tabular Caption?

TeX - LaTeX Asked by Greeshma on December 17, 2020

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 figurelabel{fig:somefig}}
end{center}

2 Answers

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}

Correct answer by Mico on December 17, 2020

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}

Answered by Espoir Murhabazi on December 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP