[Tex/LaTex] How to make the table fit into the column

acmctablefontstables

Hi I have a two columns table with ACM SIG Proceedings template
http://www.acm.org/sigs/publications/proceedings-templates

Here is my latex:

\documentclass{sig-alternate}
\usepackage{ctable}
\begin{document}
\begin{table}[h]
  \centering

    \begin{tabular}{rrrrr}
    \toprule
    \multicolumn{1}{c}{\small{QoS Attribute}} & \small{Sequential} & \small{Parallel} & \small{Loop} & \small{Conditional} \\
    \midrule
    \small{Response Time} & $\sum\limits_{i=1}^n q(s_i)$   & $\max\limits_{i=1}^n q(s_i)$   & k(q(s))   & $\max\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Availablity} & $\prod\limits_{i=1}^n q(s_i)$   & $\prod\limits_{i=1}^n q(s_i)$   & $q(s)^k$   &  $\min\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Throughput} & $\min\limits_{i=1}^n q(s_i)$   & $\min\limits_{i=1}^n q(s_i)$  & $q(s)$  & $\min\limits_{i=1}^n q(s_i)$ \\
    \bottomrule
    \end{tabular}%
\caption{Add caption}
  \label{tab:compositionalStructure}%
\end{table}
This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1

\end{document} 

enter image description here

The problem is the table length cannot fit into the first columns width as shown as the blue color lines. Is there any way to make the table smaller? In particular, how to make the font smaller(i try \small as shown in code, but I do not know how to deal with equation) and the table spacing smaller (I do not know how to do it)?

Best Answer

I am not sure what the exact page width of the sig-alternate class is, but from your image this I appeared to be about 5.0in.

By using a p{} column type for the first column, eliminating the column soacing to the left of the first column and to the right of the last column, and reducing the inter column spacing with a @{\hspace{0.5em}} you can sqeeuze your table to make it fit:

enter image description here

Notes:

  • The showframe option of the geometry package was used to show the frame. And also adjust the page margins.

Code:

\documentclass{article}
\usepackage{ctable}
\usepackage[paperwidth=5.0in,showframe]{geometry}
\begin{document}
\begin{table}[h]
  \centering

    \begin{tabular}{@{}p{0.7in}r@{\hspace{0.5em}}r@{\hspace{0.5em}}r@{\hspace{0.5em}}r@{}}
    \toprule
    \multicolumn{1}{@{}c}{\small{QoS Attribute}} & \small{Sequential} & \small{Parallel} & \small{Loop} & \small{Conditional} \\
    \midrule
    \small{Response Time} & $\sum\limits_{i=1}^n q(s_i)$   & $\max\limits_{i=1}^n q(s_i)$   & k(q(s))   & $\max\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Availablity} & $\prod\limits_{i=1}^n q(s_i)$   & $\prod\limits_{i=1}^n q(s_i)$   & $q(s)^k$   &  $\min\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Throughput} & $\min\limits_{i=1}^n q(s_i)$   & $\min\limits_{i=1}^n q(s_i)$  & $q(s)$  & $\min\limits_{i=1}^n q(s_i)$ \\
    \bottomrule
    \end{tabular}%
\caption{Add caption}
  \label{tab:compositionalStructure}%
\end{table}
This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1 This is line 1

\end{document} 

I downloaded the sig-alternate class (May 2012 version), and both the original and modified table seem to fit fine, so perhaps there are other settings you missed in your MWE:

enter image description here

Notes:

Code:

\documentclass{sig-alternate}
\usepackage{ctable}
\usepackage{showframe}
\begin{document}
\noindent
    \begin{tabular}{rrrrr}
    \toprule
    \multicolumn{1}{c}{\small{QoS Attribute}} & \small{Sequential} & \small{Parallel} & \small{Loop} & \small{Conditional} \\
    \midrule
    \small{Response Time} & $\sum\limits_{i=1}^n q(s_i)$   & $\max\limits_{i=1}^n q(s_i)$   & k(q(s))   & $\max\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Availablity} & $\prod\limits_{i=1}^n q(s_i)$   & $\prod\limits_{i=1}^n q(s_i)$   & $q(s)^k$   &  $\min\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Throughput} & $\min\limits_{i=1}^n q(s_i)$   & $\min\limits_{i=1}^n q(s_i)$  & $q(s)$  & $\min\limits_{i=1}^n q(s_i)$ \\
    \bottomrule
    \end{tabular}%

\bigskip
\noindent
    \begin{tabular}{@{}p{0.7in}r@{\hspace{0.5em}}r@{\hspace{0.5em}}r@{\hspace{0.5em}}r}
    \toprule
    \multicolumn{1}{@{}c}{\small{QoS Attribute}} & \small{Sequential} & \small{Parallel} & \small{Loop} & \small{Conditional} \\
    \midrule
    \small{Response Time} & $\sum\limits_{i=1}^n q(s_i)$   & $\max\limits_{i=1}^n q(s_i)$   & k(q(s))   & $\max\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Availablity} & $\prod\limits_{i=1}^n q(s_i)$   & $\prod\limits_{i=1}^n q(s_i)$   & $q(s)^k$   &  $\min\limits_{i=1}^n q(s_i)$ \\
\midrule
    \small{Throughput} & $\min\limits_{i=1}^n q(s_i)$   & $\min\limits_{i=1}^n q(s_i)$  & $q(s)$  & $\min\limits_{i=1}^n q(s_i)$ \\
    \bottomrule
    \end{tabular}%
\end{document} 
Related Question