1

I'm writing a paper now and I have the format problem as shown in the following snip enter image description here

I follow the latex code for the table

\documentclass[sigconf]{acmart}
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
   Brand & community & Neutral\_Average & Negative\_Average & Positive\_Average  \\ \hline
   Apple & NEWS & 1.45 & 2.93 & 2.72 \\ \hline
   Apple & Amazon & 0.069 & 0.39 & 0.71 \\ \hline
   Apple & Twitter & 17.11 & 11.36 & 12.06 \\ \hline
 Huawei & Amazon&0.076 & 0.20 & 1 \\ \hline
 Huawei & Twitter& 13.56 & 5.3 & 10.58 \\ \hline
 Huawei & NEWS&1.034 & 1.73 & 1.75 \\ \hline
  Samsung & NEWS & 1.03 & 1.83 & 3.37 \\ \hline
  Samsung & Twitter & 10.82 & 4.52 & 11.62 \\ \hline
  Samsung & Amazon & 0.093& 0.35& 1.1 \\ \hline
     \end{tabular}
\caption{Average Brand Sentiment Per Community}
\label{brand_senti_community}
\end{table}
koleygr
  • 20,105
Peter
  • 105
  • Please do tell us which document class you employ. – Mico Aug 27 '19 at 09:21
  • \documentclass[sigconf]{acmart} - This is the type of class that proposed by the conference – Peter Aug 27 '19 at 09:22
  • Instead, please update you example to include document class and a small preamble (enough for it to be compilable). Use can use the kantlipsum package and its \kant macro to generate sample text, so we do not need the bibliography. The point is to provide code for those who want to help, in such a way that the code provided can be used as is. – daleif Aug 27 '19 at 09:24
  • Hopefully, you are using twocolumn option in your template, if yes, please use table* instead of table, if this not suits, then provide the MWE (from documentclass{...}...\end{document} – MadyYuvi Aug 27 '19 at 09:27
  • I did the edition of the code, regarding the bibliography it's just for showing how the table affected by the layout – Peter Aug 27 '19 at 09:28
  • Sorry but I can't change the document class because it's part of conference structure – Peter Aug 27 '19 at 09:30
  • @Peter - Your code does not create a two-column layout. Is something missing? – Mico Aug 27 '19 at 09:35
  • @Mico I attach only the code of the table. So do you mean that there should be a specific code for a table that fit the two columns layout ?! – Peter Aug 27 '19 at 09:43
  • 2
    @Peter - It would really help if your code provided sufficient detail to let others (more or less) reproduce the issue you wish to fix. If you don't provide the required detail information, others will have to make some guesses as to what's really going on. Their guesses may be valid, in which case everyone is happy, or they may not be valid, leading to answers which will probably not usable by you. There is more than one way to create a two-column layout: Why force others into pointless guesswork? It's up to you to decide how important it is to you to receive usable and useful answers. – Mico Aug 27 '19 at 09:47

1 Answers1

3

You didn't indicate how your document sets up two-column mode, so I had to make some assumptions, which may or may not be appropriate for your document.

The tabular environment currently exceeds the width of the column because there is unbreakable and long text in three header cells. I suggest that your reorganize the header to give it more structure and to make each individual cell less wide. In the example below, I also employ a tabular* environment and set its overall width to \columnwidth.

I would further like to suggest that you give the table a more open "look" by omitting all vertical rules and by using fewer, but well-spaced horizontal rules. To enhance legibility, I would also align the numbers in the three numeric columns on their respective decimal markers.

\documentclass[sigconf,twocolumn]{acmart} 
\usepackage{lipsum}   % for filler text
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage{siunitx}  % for 'S' column type

\raggedbottom
\begin{document}
\begin{table}[h]
\setlength\tabcolsep{0pt}
%\centering % not needed 

\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} 
        l l 
        S[table-format=2.3] 
   *{2}{S[table-format=2.2]} }
\toprule
   Brand & Community & \multicolumn{3}{c}{Average Brand Sentiment}\\
\cmidrule{3-5}
& & {Neutral} & {Negative} & {Positive}  \\
\midrule
   Apple & NEWS    & 1.45 & 2.93 & 2.72 \\
   Apple & Amazon  & 0.069 & 0.39 & 0.71 \\
   Apple & Twitter & 17.11 & 11.36 & 12.06 \\
\addlinespace
  Huawei & Amazon  &0.076 & 0.20 & 1 \\
  Huawei & Twitter & 13.56 & 5.3 & 10.58 \\
  Huawei & NEWS    &1.034 & 1.73 & 1.75 \\ 
\addlinespace
  Samsung & NEWS   & 1.03 & 1.83 & 3.37 \\
  Samsung & Twitter& 10.82 & 4.52 & 11.62 \\ 
  Samsung & Amazon & 0.093& 0.35& 1.1 \\ 
\bottomrule
\addlinespace
\end{tabular*}
\caption{Average Sentiment, by Brand and Community}
\label{brand_senti_community}
\end{table}

\lipsum % some filler text
\end{document}
Mico
  • 506,678
  • Thanks @Mico This answer works well for me with one error message in S[table-format=2.3] *{2}{S[table-format=2.2]} } which is (illegal charecter in array arg) – Peter Aug 27 '19 at 11:44
  • 1
    @Peter: Did you load the siunitx package? – leandriis Aug 27 '19 at 12:15
  • @leandriis Yes I already load the package but I meet another problem. because I use the same code of above with another table contains countries names instead of numbers so there is a problem in it because maybe siunitx is only for number – Peter Aug 27 '19 at 13:04
  • 1
    @Peter - The purpose of the S column type is definitely to align numbers on their decimal markers. Non-numeric data in cells in a column of type S must be encased in curly braces -- exactly as is already done with {Neutral}, {Negative}, and {Positive} in the code shown above. If a column contains (mostly) country names, you shouldn't be using the S column type for that column. – Mico Aug 27 '19 at 13:46
  • @Mico Thanks a lot, it works with me – Peter Aug 29 '19 at 23:35