3

I am using ACM conference template sample-sigconf.tex from HERE for an ACM conference. I have a table that is slightly wider than the column width. I have limited space so I do not want to make it in the center using {table*} as this will waste some empty space that I need. This illustrates the issue:

enter image description here

How can I fit the table in a column even if this will shrink it a little bit?

Here is the script:

\documentclass[sigconf]{acmart}
\usepackage[T1]{fontenc} %to solve the font error
\usepackage{lmodern}  %to solve the font error
\usepackage{underscore} %underscores
%-------------------------for the table-----------------------------        
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\newcommand{\head}[1]{\textnormal{\textbf{#1}}}
\newcommand{\normal}[1]{\multicolumn{1}{l}{#1}}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\newcommand*\rot{\rotatebox{90}}
\usepackage{tabularx}
\usepackage{threeparttable, tablefootnote}
%-------------------------end table-----------------------------
\usepackage{lipsum}

% Copyright
%\setcopyright{none}
%\setcopyright{acmcopyright}
%\setcopyright{acmlicensed}
\setcopyright{rightsretained}
%\setcopyright{usgov}
%\setcopyright{usgovmixed}
%\setcopyright{cagov}
%\setcopyright{cagovmixed}


\begin{document}
\title{Title}

\subtitle{Test}

\author{Author}
\affiliation{%
  \institution{XYZ}}
\email{abc@xyz}

\begin{abstract}
Abstract goes here. 
\end{abstract}

\maketitle
\section{Introduction}
\lipsum

\begin{table}[tp]
\caption{Levels.}
\vspace*{-5mm}
\label{table:levels}
\centering
\begin{tabular}{ll}
\\ \toprule
A & B \\ \midrule

AA and BBBB & \begin{tabular}{l} aaaaabbbbccccddddeeeeffffgggghhhhiiiijjjj \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \end{tabular} \\
\hline
AA and BBBB & \begin{tabular}{l} aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \end{tabular} \\

\hline
AA and BBBB & \begin{tabular}{l} aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \\
                                 aaaaabbbbccccddddeeeeffffggggh \end{tabular} \\
\bottomrule
\end{tabular}
\end{table}  

\end{document}
5
  • Is there any particular reason you are nesting tabular environments?
    – Mace
    Aug 2, 2017 at 11:23
  • Yes. I have to make separate lines inside a row. There might be different methods to do this but I found this quite easy. Aug 2, 2017 at 11:34
  • Wide tabulars inside a table behave the same as wide tabulars outside a table. They protrude into the right margin (and generate an overfull \hbox warning). Shrinking the tabular is the writer's responsibility. see tex.stackexchange.com/questions/6237/… Aug 2, 2017 at 13:37
  • @John Kormylo I am sorry I do not understand what you want to say? Do you suggest a solution? or are you saying this can not be solved? or am I doing it the wrong way? Aug 2, 2017 at 14:43
  • There are several ways to get the tabular to fit (see the linked question), but it has nothing to do with the table environment, which just moves it around the document. Aug 2, 2017 at 22:02

1 Answer 1

0

EDIT: I had a closer look at your not so minimal MWE. You're already loading tabularx and multirow anyway. So there you go:

\documentclass[twocolumn]{article}
\usepackage{tabularx,multirow,booktabs,blindtext}
\begin{document}
    \begin{table}
    \centering
    \begin{tabularx}{\linewidth} {lX}
    \toprule
    A & B\\
    \midrule
    \multirow{12}{.3\linewidth}{AA and BBBB }& aaaaa bbbb ccccd ddeeeef fffggggh \\
    &   aaaaa bbbb ccccd ddeeeef fffggggh \\
    &   aaaaabb bbccc cddd deeeefff fggggh \\
    &   aaaaabbb bccccd dddeeee ffffggggh \\
    &   aa aaabbbbccc cddddeeeeffffggggh \\
    &   a aaaa bbbbc cccddddeee effffggggh \\
    a & b\\
    \multirow{12}{.3\linewidth}{CC and DDD }& aaaaa bbbb ccccd ddeeeef fffggggh \\
    &   aaaaa bbbb ccccd ddeeeef fffggggh \\
    &   aaaaabb bbccc cddd deeeefff fggggh \\
    &   aaaaabbb bccccd dddeeee ffffggggh \\
    &   aa aaabbbbccc cddddeeeeffffggggh \\
    &   a aaaa bbbbc cccddddeee effffggggh \\
    \bottomrule
    \end{tabularx}
    \end{table}
\blinddocument
\end{document}

screenshot

3
  • isn't there any possible solution to solve my issue with the \{table} environment? Aug 2, 2017 at 11:35
  • You could use a \resizebox to scale your table to \columnwidth, but it's generally discouraged as it then obviously displays the text of the table in a size that does not make any sense when compared with the surrounding stuff. If you don't like tabu (I have yet to use it myself, actually), maybe you'll prefer tabularx.
    – Alice M.
    Aug 2, 2017 at 18:02
  • Using the tabularx package: \begin{tabularx}{\columnwidth}{l X}\end{tabularx}, and replace every \\ that is not the end of a table row by \newline. The l column takes just the needed space, and the X column takes whatever remains in the allocated width (\columnwidth, in this case).
    – Alice M.
    Aug 2, 2017 at 18:10

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