1

I am using the following code in the class elsarticle, in this table the size of the font(numbers etc) is larger. I want to extend the width of the table to full-text width also. Can anyone suggests how to do that, I tried \small \tiny not working here.

\begin{table}
    
    \caption{The proposed method performance using MNIT-SEHSD Datset}
    \label{mnit_per}
    \resizebox{\columnwidth}{!}{%
        
        \begin{tabular}{l c c c }
    
            \hline
            Emotion&Precision&Recall&F1 Score\\
            \hline
            Neutral&  0.94  & 0.97  & 0.95\\
            Angry  &  0.95  & 0.96  & 0.95\\
            Happy  &  0.95  & 0.95  & 0.95 \\
            Fear   &  0.90  & 0.96  & 0.93\\
            Sad    &  1.00  & 0.90  & 0.95 \\
            \hline
            
            
        \end{tabular}
    }
\end{table}

The output is as follows:

enter image description here

2
  • 1
    Please tell us whether you use the elsarticle document class with the option 1p, 3p, or 5p, and whether you employ a one-column or a two-column layout.
    – Mico
    Oct 31, 2021 at 13:33
  • 1
    Start by removing the \resizebox command. As you discovered, resizing tables leads to inconsistent font sizes throughout the document. If your table is then narrower than the desired width, give \begin{tabular*}{\linewidth}{l @{\extracolsep{\fill}} c c c } a try. (Although personally, I recommend not to stretch a table to a width wider than its natrual width, since it won't improve the readability of the table.)
    – leandriis
    Oct 31, 2021 at 14:21

2 Answers 2

1

For table you may consider to use tabularray and booktabs package (latter is loaded as library) and use X column type for the last three columns. Using them table width will be equal to column width with equal widths of the last three columns:

\documentclass[5p]{elsarticle} % two-column layout
\usepackage[skip=1ex]{caption} % for better control over caption, if needed
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begin{table}[ht]
    \centering
    \caption{The proposed method performance using MNIT-SEHSD Datset}
    \label{mnit_per}

    \begin{tblr}{ l X[c] X[c] X[c] }
        \toprule
    Emotion&Precision&Recall&F1 Score\\
        \midrule
    Neutral&  0.94  & 0.97  & 0.95 \\
    Angry  &  0.95  & 0.96  & 0.95 \\
    Happy  &  0.95  & 0.95  & 0.95 \\
    Fear   &  0.90  & 0.96  & 0.93 \\
    Sad    &  1.00  & 0.90  & 0.95 \\
        \bottomrule
    \end{tblr}
\end{table}
\lipsum
\end{document}

enter image description here

2

If you do not want to change the font size used in the table (and why should you?), don't touch use one of the commands that changes the (relative or absolute) font size. Also, under no circumstance should you touch \resizebox if the goal is to make the table fit inside the allocated space.

Instead, consider replacing the tabular environment with a tabular* environment and setting the overall width of the tabular* environment to \linewidth. (\columnwidth will do too.) The following screenshot shows the outputs of the tabular and tabular* approaches.

enter image description here

\documentclass[5p]{elsarticle} % two-column layout

\begin{document}
\begin{table}
    \centering
    \caption{The proposed method performance using MNIT-SEHSD Datset}
    \label{mnit_per}
    
    \smallskip
    
    \begin{tabular}{ l ccc }
            \hline
            Emotion&Precision&Recall&F1 Score\\
            \hline
            Neutral&  0.94  & 0.97  & 0.95 \\
            Angry  &  0.95  & 0.96  & 0.95 \\
            Happy  &  0.95  & 0.95  & 0.95 \\
            Fear   &  0.90  & 0.96  & 0.93 \\
            Sad    &  1.00  & 0.90  & 0.95 \\
            \hline
    \end{tabular}
    
    \bigskip
    
    \setlength\tabcolsep{0pt}
    \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l ccc }
            \hline
            Emotion&Precision&Recall&F1 Score\\
            \hline
            Neutral&  0.94  & 0.97  & 0.95 \\
            Angry  &  0.95  & 0.96  & 0.95 \\
            Happy  &  0.95  & 0.95  & 0.95 \\
            Fear   &  0.90  & 0.96  & 0.93 \\
            Sad    &  1.00  & 0.90  & 0.95 \\
            \hline
    \end{tabular*}
\end{table}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .