# Figure overlaps Table

When placing a table then a figure, the figure overlaps half the table.. Here is what the tex looks like:

\begin{table}[h]
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{tabular}{lR{2cm}R{2cm}R{2cm}R{2cm}R{1.5cm}R{2cm}l}
Name & Value1 & Value2 & Value3 & Value4 & Value5 & Value6 \\
\hline\\
\hspace{5mm}Name1 & 100 & 900 & 6 & 2 & 1 & 47 \\
\end{tabular}
\end{table}

\pagebreak
wew

\begin{figure}[h]
\centering
\captionsetup{justification=centering,margin=2cm}
\includegraphics[width=1.0\textwidth]{chart.png}
\caption{label1}
\label{chart}
\end{figure}


I am using a two-column style in \documentclass{sig-alternate} (academic paper). The actual overlapping is odd, it seems like the figure starts halfway through the table and in the second column... So it runs of the page as well.

Any ideas?

Thanks.

• Try \linewidth instead of \textwidth – Johannes_B Feb 27 '14 at 9:03
• create a complete example. That code snippet can't give such a problem. – user2478 Feb 27 '14 at 9:08
• Welcome to TeX.SE! Please provide some information as to where one might obtain the file sig-alternate.cls; it doesn't seem to be on the Comprehensive TeX Archive Network (CTAN). At any rate, you seem to be requiring that the tabular environment be more than 11.5 cm wide; that's going to make it impossible to fit in a single column of a two-column document -- unless your document's paper size is something like A3 or A2... Furthermore, you should probably use \linewidth instead of \textwidth to specify the width of the graphics object that is to be inserted in the figure. – Mico Feb 27 '14 at 9:09
• Hi guys, I tried \linewidth and it just made the chart image smaller. sig-alternate.cls can be found here. – Travis Liew Feb 27 '14 at 9:13
• Your tabular environment has absolutely no chance of fitting in the width of a column. Use the table* environment instead of the table environment -- doing so will have it span both columns instead of just one or the other. And, if you really want the graphic file to be as wide as \textwidth (rather than \columnwidth), use a figure* environment. – Mico Feb 27 '14 at 9:21

The sig-alternate class is set up to produce two-column documents. Given that (a) your table is quite a bit wider than a single column and (b) the figure is supposed to be as wide as \textwidth (rather than as wide as \columnwidth,say), you need to use the environments table* and figure* to create full-width (two columns wide) floats.

By the way, in a two-column LaTeX document full-width floats can only appear at the top of a page. Specifying location directives such as [h] will not affect the placement of table* and figure* floats.

The following example shows the top of page 2 of the document that's produced by an augmented form of the code you provided.

\RequirePackage[demo]{graphicx} % omit in the production version of your document
\documentclass{sig-alternate}
\usepackage{array,caption,lipsum} % lipsum for filler text
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\
\arraybackslash\hspace{0pt}}m{#1}}
\captionsetup{justification=centering,margin=2cm}
\begin{document}
\begin{table*}
\centering
\caption{A table} \label{tab:1}
\begin{tabular}{lR{2cm}R{2cm}R{2cm}R{2cm}R{1.5cm}R{2cm}}
Name & Value1 & Value2 & Value3 & Value4 & Value5 & Value6 \\
\hline\\
\hspace{5mm}Name1 & 100 & 900 & 6 & 2 & 1 & 47 \\
\hline
\end{tabular}
\end{table*}
\lipsum[1-7] % filler text

\begin{figure*}
%\centering %% no point in trying to "center" a full-width graph...
\caption{A figure} \label{chart}
\includegraphics[width=1.0\textwidth]{chart.png}
\end{figure*}

\lipsum[8-30] % more filler text
\end{document}

• Hi, thanks for your answer, it was very helpful. Just one last thing, if I add a caption to the table*, the whole table becomes centered on the page (vertically) and following elements start on the next page. Is there a solution to this? – Travis Liew Feb 28 '14 at 1:53
• @Ubobo - Are you maybe also providing a location specifier such as [p] when setting up the float in question? The reason I ask is that, as the example I provided in the answer demonstrates, it's not the default behavior to typeset a double-wide float on a page by itself. How tall is the float, incidentally? Is it more than half the height of the text block? – Mico Feb 28 '14 at 8:35
• Not specifying [p] when setting up the float. With the caption it's about half the page. – Travis Liew Mar 2 '14 at 1:34
• That was it!! Completely fixed the problem. Thanks Mico! – Travis Liew Mar 2 '14 at 12:48