[Tex/LaTex] How to put two tables in a table* element so that the tables appear side by side in a two column layout scientific paper

floatssubfloatstwo-column

This is related to How to make a figure span on two columns in a scientific paper?

In a table* element, I want to put two \tabular{} elements, and get them appear side by side. I will then need to caption them as (a) and (b) and create labels (for references in the text) and so forth. If I just use the table* element, the tables appear below each other and are centred across the two columns.

EDIT: In response to TH: This is what I tried. Both tables still appear on the right column.

\begin{table*}
\subfloat[Before processing]{
\begin{tabular}{|c|c|c|c|c|}
\hline 
Year & Month & Country & State & Impressions\tabularnewline
\hline
\hline 
2007 & JAN & IN & TN & 3\tabularnewline
\hline 
2007 & JAN & IN & TN & 1\tabularnewline
\hline 
\end{tabular}
}

\begin{table}
\subfloat[After processing]{
\begin{tabular}{|c|c|c|c|c|}
\hline 
Year & Month & Country & State & Impressions\tabularnewline
\hline
\hline 
2007 & JAN & IN & TN & 7\tabularnewline
\hline 
2007 & FEB & IN & KA & 13\tabularnewline
\hline 
\end{tabular}
}
\caption{overall}
\end{table*}

Best Answer

You should use the subfig package.

\begin{table*}
\subfloat[First caption]{\begin{tabular}{...}...\end{tabular}}
\subfloat[Second caption]{\begin{tabular}{...}...\end{tabular}}
\caption{Overall caption}
\end{table*}

This can be used in conjunction with the floatrow package. See the subfig documentation for an example that aligns captions using floatrow.

EDIT:
Your example has an extra \begin{table} that doesn't belong. It also has a blank line which causes TeX to start a new paragraph which is why one table appears on top of the other.

Here's a complete example where I've also cleaned up your tables following the guidelines given in the documentation to the booktabs package.

\documentclass[twocolumn]{article}
\usepackage{subfig}
\usepackage{booktabs}
\begin{document}
\begin{table*}
\subfloat[Before processing]{
\begin{tabular}{ccccc}
\toprule
Year & Month & Country & State & Impressions\\
\midrule
2007 & JAN & IN & TN & 3\\
2007 & JAN & IN & TN & 1\\
\bottomrule 
\end{tabular}
}%
\hfill
\subfloat[After processing]{
\begin{tabular}{ccccc}
\toprule 
Year & Month & Country & State & Impressions\\
\midrule 
2007 & JAN & IN & TN & 7\\
2007 & FEB & IN & KA & 13\\
\bottomrule 
\end{tabular}
}
\caption{overall}
\end{table*}
\end{document}