[Tex/LaTex] Table and figure side by side in two column layout without space below

floatstablestwo-column

This is kind of a strange requirement I suppose. I have a table and a figure and I want them to be side by side on top of a page, on the same page, while the table is in the left column and the figure is in the right one.

I know I could put them inside a box or a minipage but the figure is much taller than the table and thus there would be wasted space under the table.

I also heard of the floatrow package but it has the limitation that the two objects need to be of the same type (a table and a figure).

Is there a way to do this or am I doomed to balance the text manually before the final revision?

Best Answer

Here is a solution. we set \setcounter{topnumber}{1} and then restore its value

\documentclass[twocolumn]{article}
\usepackage{mwe}
\edef\mttopnumber{\arabic{topnumber}}
\setcounter{topnumber}{1}
\begin{document}
\begin{table}[tp]
\centering
\caption{A table}
\begin{tabular}{|c|c|}
\hline 
12 & 13 \\ 
\hline 
10 & 11 \\ 
\hline 
\end{tabular} 
\end{table}
\begin{figure}[tp]
\centering
\includegraphics[scale=.5]{example-image}
\caption{Nice figure}
\end{figure}
\setcounter{topnumber}{\mttopnumber}
\lipsum
\begin{table}[tp]
\centering
\caption{A table}
\begin{tabular}{|c|c|}
\hline 
12 & 13 \\ 
\hline 
10 & 11 \\ 
\hline 
\end{tabular} 
\end{table}
\begin{figure}[tp]
\centering
\includegraphics[scale=.5]{example-image}
\caption{Nice figure}
\end{figure}
\lipsum
\end{document}

enter image description here