1

Here what I am using

  \begin{table}[h]
        \resizebox{\columnwidth}{!}{%
        
    \begin{tabular}{c c c c}
        
        
        \hline
        Dataset&Number of Speakers& Total utterances&Emotions\\
        \hline
        Berline Emotional Speech Database&10(5M,5F)&535&Angry, Boredom, Disgust, Fear, Happy, Sadness, Neutral\\
        
        
        
    \end{tabular}
}
\end{table}

And the output is enter image description here

But I want this enter image description here

please guide.

After Mico's answer, I am getting this. Just need to add separation between these three items without adding any extra col for serial number. Also How to increase the width of the first and last col? Actually I need to understand this whole line\begin{tabularx}{\textwidth}{@{} *{3}{C{0.8}} C{1.6} @{}} Here what I am guessing : 3 means first 3 col widths of 0.8 and last of 1.6? plz, guide. regards enter image description here

6
  • 1
    never use resizebox with tables. c columns are single line use p{6cm} or whatever width you need in each case. if you use array package you can use >{\centering\arraybackslash}p{6cm} to get centred entries Jul 15, 2021 at 7:07
  • Thanks for the reply, actually I was using resize to fit the table on the page otherwise it's crossing the column, is there any other way for this? Also after using p{} it's not looking arranged, by so many adjustments in length. I wish I cud paste the output here. Jul 16, 2021 at 18:58
  • you have not provided a usable test file but see Mico's answer here. There is no way to get reasonable output of you scale tables to fit, you should use consistent font sizes in teh document not scale to an arbitrary size. Jul 16, 2021 at 19:00
  • Yes, I know that, I am saying it's not looking similar to what I have pasted in my question. But thanks again :) Jul 16, 2021 at 19:03
  • you have not provided code in your question that we can run, but your table there uses c column types which does not allow line breaking in cells. Other than that I do not understand your comment, sorry. Jul 16, 2021 at 19:05

1 Answer 1

1

Remark: I wrote this answer to address the OP's initial query. Some time after I posted this answer, the OP changed the query more or less completely. I'm afraid that, as a result, my answer has become pretty much unintelligible to future readers, since it continues to address a query which is now no longer there.

I'd like to suggest that you employ a tabularx environments, with four centered versions of the X column type, and set the overall width to \columnwidth.

Alternatively, you could let the table occupy the width of both columns by using a table* environment and setting the width of the tabularx environment equal to \textwidth.

enter image description here

enter image description here

\documentclass[twocolumn]{elsarticle}
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{C}[1]{>{\Centering\hsize=#1\hsize}X}
\begin{document}
\begin{table}[h] % all columns have same width
\begin{tabularx}{\columnwidth}{@{} *{4}{C{1}} @{}}
        \toprule
        Dataset & Number of speakers & Total utterances & Emotions\\
        \midrule
        Berlin Emotional Speech Database & 10 (5M,~5F) & 535 & Angry, Boredom, Disgust, Fear, Happy, Sadness, Neutral\\
        \bottomrule
\end{tabularx}
\end{table}

\begin{table*}[h] % final column is twice as wide as first three
\begin{tabularx}{\textwidth}{@{} *{3}{C{0.8}} C{1.6} @{}}
    \toprule
    Dataset & Number of speakers & Total utterances & Emotions\\
    \midrule
    Berlin Emotional Speech Database & 10 (5M,~5F) & 535 & Angry, Boredom, Disgust, Fear, Happy, Sadness, Neutral\\
    \bottomrule
\end{tabularx}
\end{table*}

\end{document} 

Addendum to address one of the OP's follow-up queries:

I need to understand this whole line \begin{tabularx}{\textwidth}{@{} *{3}{C{0.8}} C{1.6} @{}}

Let's start with the definition of the C column type:

\newcolumntype{C}[1]{>{\Centering\hsize=#1\hsize}X}

Here, the X column type is defined by the tabularx package and \Centering is a macro defined by the ragged2e package. If one or more columns of type X are present, their width is calculated as a residual, i.e., after subtracting the widths of all other columns from the first argument of the \tabularx environment. For instance,

\begin{tabularx}{\columnwidth}{@{} *{4}{C{1}} @{}}

means that the overall width (the first arg. of the tabularx environment) is equal to \columnwidth, while *{4}{C{1}} means "4 columns of type C, all equally wide". (The @{} particles serve to suppress whitespace padding at the edges of the table.) The argument of C is a relative width, where "relative" is in reference to the case of equal-width X-type columns. The main rule to follow here is that sum of the relative column widths (here: 1+1+1+1=4) must be equal to the number of X-type columns (here: 4).

We may now turn to the second tabularx environment:

\begin{tabularx}{\textwidth}{@{} *{3}{C{0.8}} C{1.6} @{}}

Its overall width is \textwidth (which is more than twice as large as \columnwidth, and it consists of 4 columns overall. The first three are centered X-type columns with relative widths equal to 0.8, while the fourth is also a centered X-type column, with relative width of 1.6. Observe that 3*0.8+1.6 = 2.4+1.6 = 4 = number of X-type columns. In words: the usable width of the final column is twice that of the usable width of the first three columns." If you want to increase the relative widths of the first and last columns, you must also decrease the relative width of the second and third columns. E.g.,

\begin{tabularx}{\textwidth}{@{} C{0.9} C{0.7} C{0.7} C{1.7} @{}}

would be a syntactically correct specification.

7
  • Thanks a ton I think this two col is the best solution, Let me see if the editor allow me to do so. Regards Jul 16, 2021 at 19:00
  • After your answer, I am getting the picture in edit section. Just need to add separation between these three items without adding any extra col for serial number. Also How to increase the width of the first and last col? Actually I need to understand this whole line\begin{tabularx}{\textwidth}{@{} *{3}{C{0.8}} C{1.6} @{}} Here what I am guessing : 3 means first 3 col widths of 0.8 and last of 1.6? plz, guide. regards Jul 20, 2021 at 7:46
  • @KRISHNACHAUHAN - Please clarify what you mean by "add separation between three items". Which "items" are you referring to? Separately, are you looking to modify the table/\columnwidth version or the table*/\textwidth version?
    – Mico
    Jul 20, 2021 at 9:10
  • @KRISHNACHAUHAN - Please also see the addendum I just posted, in which I attempt to explain (hopefully successfully...) what \begin{tabularx}{\textwidth}{@{} *{3}{C{0.8}} C{1.6} @{}} means.
    – Mico
    Jul 20, 2021 at 9:30
  • Thanks a lot for this explanation. Now My query was by separation of items I meant the gap between three datasets information like I have given in the example. where I wrote I want this :) actually in same format. Jul 20, 2021 at 15:31

You must log in to answer this question.

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