Graphics, Figures & Tablesregarding multicolumn tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
upani1982
Posts: 43
Joined: Wed May 12, 2010 11:42 am

regarding multicolumn tables

Post by upani1982 »

Dear All,

I am new to the latex. I am facing a problem to create a multicolumn table with the following code

Code: Select all

\begin{sidewaystable}
\centering A table
\caption{A caption}
\begin{tabular}{@{}lllllllllllll@{}} \toprule
\multicolumn{1}{c}{\multirow{2}{*}{Commodity Groups}} & \multicolumn{2}{c}{2006-07}  & \multicolumn{2}{c}{2007-08}  & \multicolumn{2}{c}{2008-09} & \multicolumn{2}{c}{2009-10} \\ 
\cmidrule(r){2-3} & \cmidrule(r){4-5} & \cmidrule(r){6-7} & \cmidrule(r){8-9} & \cmidrule(r){10-11} & \cmidrule(r){12-13} \\
\multicolumn{1}{c} & Volume & Value & Volume & value & Volume & value & Volume & value & Volume & value & Volume & value \\ \midrule
Bullions and Other Metals &       2.72 &   179671.1 &      58.45 &  779398.35 &     190.88 &  2128985.2 &     451.92 &    2623667 &     440.36 &  3592450.2 &     648.25 &    3388371 \\


Agriculture &    1939.38 &   390188.4 &     5818.8 &  1192226.9 &    5023.92 &  1317125.2 &   3,139.03 &   941283.3 &    2309.35 &  627303.14 &    2910.05 &   902209.3 \\

Energy &          0 &    1900.14 &     908.96 &  181882.64 &     914.34 &  230711.92 &    1976.22 &   500942.1 &    3938.17 & 1026442.05 &    4088.36 &    1232613 \\

Others &          0 &          0 &      2.505 &    1614.16 &       0.15 &     104.36 &       6.25 &      97.22 &     175.62 &    2760.78 &       2.12 &    3103.36 \\

Total &     1942.1 &   571759.6 &   6788.715 &    2155122 &    6129.29 &    3676927 &    5573.42 &    4065989 &     6863.5 &  5248956.2 &    7648.78 &    5526296 \\ \bottomrule
\end{tabular}
\end{sidewaystable}
I know this is a very complicated table for a beginner but i want to learn the mistake i am committing here. I have attached the table with the excel format.

With Sincere regards,
Upananda

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

regarding multicolumn tables

Post by frabjous »

The table with the excel format? That's not Excel format. Did you mean to attach another file?

Please read the Post on Avoidable Mistakes: you need to submit a fully compiliable minimal working example. From this snippet, there is no way to guess what packages you're loading, and hence, no way to troubleshoot the problem.
upani1982
Posts: 43
Joined: Wed May 12, 2010 11:42 am

regarding multicolumn tables

Post by upani1982 »

Hi Frabjous,

Thanks for your helping hand. I got the answer by tweaking the code. The code follows here.

Code: Select all

\begin{landscape}
\begin{table*}\centering
\caption{Total Volume}
\begin{tabular}{@{}lrrrrrrrrrrrr@{}} \toprule
\multicolumn{1}{l}{\multirow{2}{*}{Commodity Groups}} & \multicolumn{2}{c}{2004-05} &\multicolumn{2}{c}{2005-06} & \multicolumn{2}{c}{2006-07} & \multicolumn{2}{c}{2007-08} & \multicolumn{2}{c}{2008-09} & \multicolumn{2}{c}{2009-10} \\ 
\cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-7} \cmidrule(r){8-9} \cmidrule(r){10-11} \cmidrule(r){12-13} 
 & Volume & Value & Volume & value & Volume & value & Volume & value & Volume & value & Volume & value \\ \midrule
Bullions and Other Metals &       2.72 &   179671.1 &      58.45 &  779398.35 &     190.88 &  2128985.2 &     451.92 &    2623667 &     440.36 &  3592450.2 &     648.25 &  3388371 \\


Agriculture &    1939.38 &   390188.4 &     5818.8 &  1192226.9 &    5023.92 &  1317125.2 &   3,139.03 &   941283.3 &    2309.35 &  627303.14 &    2910.05 &  902209.3 \\

Energy &          0 &    1900.14 &     908.96 &  181882.64 &     914.34 &  230711.92 &    1976.22 &   500942.1 &    3938.17 & 1026442.05 &    4088.36 &    1232613 \\

Others &          0 &          0 &      2.505 &    1614.16 &       0.15 &     104.36 &       6.25 &      97.22 &     175.62 &    2760.78 &       2.12 &    3103.36 \\

Total &     1942.1 &   571759.6 &   6788.715 &    2155122 &    6129.29 &    3676927 &    5573.42 &    4065989 &     6863.5 &  5248956.2 &    7648.78 &    5526296 \\ \bottomrule
\end{tabular}
\end{table*}
\end{landscape}
Now the table is coming in the perfect format but it is too wide for the page in landscape format as well. Could you please guide me what has to be done now for this problem. I have attached the output in the .png format.

Thanks a lot for helping me.

With sincere regards,
Upananda
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

regarding multicolumn tables

Post by frabjous »

Nothing is attached in .png format. Moreover, you didn't read the links I posted last time, nor pay any attention to what I wrote, since your code snippet still isn't compiliable as is. Please actually read the pages I linked to, and you will know what I mean.
upani1982
Posts: 43
Joined: Wed May 12, 2010 11:42 am

regarding multicolumn tables

Post by upani1982 »

Hi Frabjous,

I am sorry for the mistake. Please find the code as follwos.

Code: Select all

\documentclass[12pt,a4paper]{article}
\usepackage[round,sort,numbers]{natbib}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage[top=2.5cm,bottom=1.5cm,left=2.5cm,right=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[breaklinks]{hyperref}
\usepackage{fancyhdr}
\usepackage{booktabs, multirow,rotating}
\usepackage{pdflscape}
\bibpunct{(}{)}{,}{a}{,}{,}\thispagestyle{plain}
\begin{landscape}
\begin{table*}\centering
\caption{Total Volume}
\begin{tabular}{@{}lrrrrrrrrrrrr@{}} \toprule
\multicolumn{1}{l}{\multirow{2}{*}{Commodity Groups}} & \multicolumn{2}{c}{2004-05} &\multicolumn{2}{c}{2005-06} & \multicolumn{2}{c}{2006-07} & \multicolumn{2}{c}{2007-08} & \multicolumn{2}{c}{2008-09} & \multicolumn{2}{c}{2009-10} \\ 
\cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-7} \cmidrule(r){8-9} \cmidrule(r){10-11} \cmidrule(r){12-13} 
 & Volume & Value & Volume & value & Volume & value & Volume & value & Volume & value & Volume & value \\ \midrule
Bullions and Other Metals &       2.72 &   179671.1 &      58.45 &  779398.35 &     190.88 &  2128985.2 &     451.92 &    2623667 &     440.36 &  3592450.2 &     648.25 &  3388371 \\


Agriculture &    1939.38 &   390188.4 &     5818.8 &  1192226.9 &    5023.92 &  1317125.2 &   3,139.03 &   941283.3 &    2309.35 &  627303.14 &    2910.05 &  902209.3 \\

Energy &          0 &    1900.14 &     908.96 &  181882.64 &     914.34 &  230711.92 &    1976.22 &   500942.1 &    3938.17 & 1026442.05 &    4088.36 &    1232613 \\

Others &          0 &          0 &      2.505 &    1614.16 &       0.15 &     104.36 &       6.25 &      97.22 &     175.62 &    2760.78 &       2.12 &    3103.36 \\

Total &     1942.1 &   571759.6 &   6788.715 &    2155122 &    6129.29 &    3676927 &    5573.42 &    4065989 &     6863.5 &  5248956.2 &    7648.78 &    5526296 \\ \bottomrule
\end{tabular}
\end{table*}
\end{landscape}
Some part of the rules is not clear. I will try to read it again. Please find the
the table which is on the third page of the registration.pdf.

With sincere regards,
Upananda
Attachments
registration2.pdf
The table is located on the third page of the file.
(33.62 KiB) Downloaded 177 times
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

regarding multicolumn tables

Post by frabjous »

A minimal working example is just that:
  • minimal: This means that you don't include anything in the example that isn't related to the problem being discussed. Look at the example you posted. You are, for example, loading packages like natbib, and including commands about formatting the bibliography. These have nothing do with with the problem about multicolumn tables and should be removed.
  • working: It should be possible for me to copy the code into my editor and click "Compile" and immediately see the problem you're having, and not generate any errors apart from the one(s) you want help with. The sample code you posted doesn't even have \begin{document} or \end{document} -- obviously it doesn't work as is.
I don't see how those things could have been unclear if you had read the links I posted. If anything else is unclear, ask about it.

Without a proper minimal working example, it is very hard to try to give someone help. Seeing the output does not allow me to try things on my own to suggest.

But I assume the problem is just that the table doesn't fit on the page. If you're unwilling or can't for some reason rearrange how you present these data, then, as is, the best I can suggest would be to load the graphicx package, and add

Code: Select all

\scalebox{0.8}{
right before \begin{tabular} with a matching:

Code: Select all

}
right after \end{tabular}. This will scale the table down to 80% of (0.8 times) its current size. Change 0.8 up or down to make it larger or smaller.
upani1982
Posts: 43
Joined: Wed May 12, 2010 11:42 am

Re: regarding multicolumn tables

Post by upani1982 »

Hi Frabjous,

I am grateful to you for your prompt advice regarding to the problem. Now i am clear regarding the forum rules.

With sincere regards,
Upananda
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

regarding multicolumn tables

Post by frabjous »

Apparently not ;) , because according to the forum rules, when a problem is solved, you put the checkmark to mark it solved on the first post (by editing it), not the last one.
Post Reply