Make the table in class elsarticle, which is two column wide

elsarticletables

I am using document class elsarticle for drawing a table which should be both columns wide like this But my table is not going as wide, also how to shift table caption to left like shown in this figure. plz, guide. I am using the following code.

\documentclass[final, 5p, times, twocolumn]{elsarticle}
    %\documentclass[times]{elsarticle}
    \journal{Nuclear Physics B}
    \usepackage{graphicx} 
    \usepackage{multirow}
    \usepackage{fullpage}
    \usepackage{tabularx}
    \usepackage{booktabs}
    \usepackage{hyperref}

\begin{document}
    \begin{table*}[h] 
        \caption{Confusion Matrix for EmoDB Datset}       
            
        \begin{tabular}{l c c c c c cc}
            
            \hline
            &angry&boredom&disgust&fear&happy&sadness&neutral\\
            \hline
            angry&\textbf{0.96}&0.00&0.00&0.01&0.03&0.00&0.00\\
            boredom&0.00&\textbf{0.92}&0.00&0.01&0.00&0.02&0.05\\
            disgust&0.00&0.00&\textbf{100}&0.00&0.00&0.00&0.00\\
            fear&0.00&0.00&0.00&\textbf{0.93}&0.02&0.00&0.05\\
            happy&0.08&0.00&0.00&0.00&\textbf{0.90}&0.00&0.02\\
            sadness&0.00&0.00&0.00&0.00&0.00&\textbf{100}&0.00\\
            neutral&0.00&0.06&0.00&0.00&0.00&0.03&\textbf{0.91}\\
            \hline              
            
        \end{tabular}       
\end{table*}
\end{document}

This is what I am getting.

Best Answer

I guess, you're interested in stretching the table from its natural width, that it currently has, to the entire linewidth. For this you could use tabular* in combination with \extracolsep{\fill}}. Since the table then contains a huge amount of wastes white space which does not really make the table more readable, I included an alternative layout that easily fits into one of the two document columns:

enter image description here

\documentclass[final, 5p, times, twocolumn]{elsarticle}
%\documentclass[times]{elsarticle}
\journal{Nuclear Physics B}
\usepackage{graphicx} 
\usepackage{multirow}
\usepackage{fullpage}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{rotating, makecell}
\usepackage{lipsum} % for dummy text using the \lipsum command, do not use in real document.
\usepackage{hyperref}

\begin{document}
    
    
\begin{table*}[h] 
    \caption{Confusion Matrix for EmoDB Datset}
    \begin{tabular*}{\linewidth}{l @{\extracolsep{\fill}}c c c c c cc}
        \toprule
        &angry&boredom&disgust&fear&happy&sadness&neutral\\
        \midrule
        angry&\textbf{0.96}&0.00&0.00&0.01&0.03&0.00&0.00\\
        boredom&0.00&\textbf{0.92}&0.00&0.01&0.00&0.02&0.05\\
        disgust&0.00&0.00&\textbf{100}&0.00&0.00&0.00&0.00\\
        fear&0.00&0.00&0.00&\textbf{0.93}&0.02&0.00&0.05\\
        happy&0.08&0.00&0.00&0.00&\textbf{0.90}&0.00&0.02\\
        sadness&0.00&0.00&0.00&0.00&0.00&\textbf{100}&0.00\\
        neutral&0.00&0.06&0.00&0.00&0.00&0.03&\textbf{0.91}\\
        \bottomrule
    \end{tabular*}
\end{table*}

\begin{table}
    \renewcommand{\theadfont}{\normalsize}
    \settowidth\rotheadsize{\theadfont boredom}
    \setlength{\tabcolsep}{0pt}
    \caption{Confusion Matrix for EmoDB Datset}
    \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}l c c c c c cc@{}}
        \toprule
        &\rothead{angry} &\rothead{boredom} & \rothead{disgust} & \rothead{fear} & \rothead{happy} & \rothead{sadness} & \rothead{neutral}\\
        \midrule
        angry   & \textbf{0.96}&0.00&0.00&0.01&0.03&0.00&0.00\\
        boredom & 0.00&\textbf{0.92}&0.00&0.01&0.00&0.02&0.05\\
        disgust & 0.00&0.00&\textbf{100}&0.00&0.00&0.00&0.00\\
        fear    & 0.00&0.00&0.00&\textbf{0.93}&0.02&0.00&0.05\\
        happy   & 0.08&0.00&0.00&0.00&\textbf{0.90}&0.00&0.02\\
        sadness & 0.00&0.00&0.00&0.00&0.00&\textbf{100}&0.00\\
        neutral & 0.00&0.06&0.00&0.00&0.00&0.03&\textbf{0.91}\\
        \bottomrule
    \end{tabular*}
\end{table}

\lipsum
\lipsum
\end{document}