[Tex/LaTex] How to use the full page width (\textwidth) while importing a table with \includegraphics

tablestwo-columnwidth

I'm in a 2-column environment. I need to use the entire pagewidth (\textwidth) while importing a table with \includegraphics.

\begin{table}
\centering
\includegraphics[width=\textwidth]{./myfile.pdf}
\caption{Beautiful stuff here}
\label{tab:myfile}
\end{table}

(I have tried tabular* without success.)

Best Answer

The multicols environment doesn't completely support floats; you can

  1. Use the starred version of floats (table* or figure*) but the float will appear on the top of the next page:

    \documentclass{article}
    \usepackage{multicol}
    \usepackage[demo]{graphicx}
    \usepackage{lipsum}
    
    \begin{document}
    
    \begin{multicols}{2}
    \lipsum[4]
    \begin{table*}
    \centering
    \setlength\fboxsep{0pt}
    \includegraphics[width=\textwidth]{./myfile.pdf}
    \caption{Beautiful stuff here}
    \label{tab:myfile}
    \end{table*}
    \lipsum[4]
    \end{multicols}
    
    \end{document}
    
  2. End the multicols, typeset the table inside, for example, a minipage or a center environment (\captionof from the capt-of or caption packages can be used to provide a caption) and then start another multicols:

    \documentclass{article}
    \usepackage{multicol}
    \usepackage{caption}
    \usepackage[demo]{graphicx}
    \usepackage{lipsum}
    
    \begin{document}
    
    \begin{multicols}{2}
    \lipsum[4]
    \end{multicols}
    \begin{center}
    \setlength\fboxsep{0pt}
    \includegraphics[width=\textwidth]{./myfile.pdf}
    \captionof{table}{Beautiful stuff here}
    \label{tab:myfile}
    \end{center}
    \begin{multicols}{2}
    \lipsum[4]
    \end{multicols}
    
    \end{document}
    

enter image description here

Remark:

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.