2

I have a table with item list inside multicolumns which are not behaving as expected (vertically and horizontally centered):

\newcolumntype{C}{>{\centering\arraybackslash} m{2.3cm}}
\begin{table}
\caption{Some caption}
\label{tab:tab1}
\centering%
\begin{minipage}{\textwidth}
    \begin{tabular*}{\textwidth}{|C|C|C|C|>{\centering\arraybackslash}m{3cm}|}
        \hline
        \ & \textbf{Hellman} & \textbf{Rainbow Table} & \textbf{Proposed Method} & \textbf{Proposed Method with Compression}\\
        \hline
        Input Range & $2^{37}$ & $2^{37}$ & $2^{37}$ & $2^{37}$ \\ \hline
        Size & $1.4$ GB & $1.4$ GB & $1.4$ GB & $1.4$ GB \\ \hline
        Hash Operations & $90.3$ M & $7.4$ M & $4$ B & $3.5$ B \\ \hline
Advantages &
\multicolumn{2}{>{\centering\arraybackslash}m{4.9cm}|}{
    \begin{itemize}
        \item Few hash operations
    \end{itemize}
} &
\multicolumn{2}{>{\centering\arraybackslash}m{5.4cm}|}{
    \begin{itemize}
        \item Little disk access
        \item Disk access is serial
        \item Success is guaranteed
        \item Easily parallelizable
    \end{itemize}
} \\
\hline
    \end{tabular*}
\end{minipage}
\end{table}

Which results in:

results

As you can see only the third row (Hash Operations) seem to be precisely centered. The main problem, though, is the last line. The item lists are far from centered in any direction. How can I fix this?

I also don't know why the right side border is not correctly placed but I can manage to get an acceptable result playing with the cell's width (not shown in the image).

0

2 Answers 2

2

If I simplify your code (remove minipage, instead tabular* use just tabular) and left aesthetic point of view aside, then I obtain:

enter image description here

The code is now:

\documentclass[12pt]{article}
\usepackage{lmodern,caption}
\usepackage{array}
\usepackage{siunitx}

\newcolumntype{C}[1]{>{\centering\arraybackslash} m{#1}}


\begin{document}
    \begin{table}
    \centering%
\caption{Some caption}
    \label{tab:tab1}
    \begin{tabular}{|*{4}{C{2.3cm}|}C{3.1cm}|}
        \hline
        \ & \textbf{Hellman} & \textbf{Rainbow Table} & \textbf{Proposed Method} & \textbf{Proposed Method with Compression}\\
        \hline
        Input Range & $2^{37}$ & $2^{37}$ & $2^{37}$ & $2^{37}$ \\ \hline
        Size & $1.4$ GB & $1.4$ GB & $1.4$ GB & $1.4$ GB \\ \hline
        Hash Operations & $90.3$ M & $7.4$ M & $4$ B & $3.5$ B \\ \hline
Advantages &
\multicolumn{2}{C{4.9cm}|}{
    \begin{itemize}
        \item Few hash operations
    \end{itemize}
} &
\multicolumn{2}{C{5.4cm}|}{
    \begin{itemize}
        \item Little disk access
        \item Disk access is serial
        \item Success is guaranteed
        \item Easily parallelizable
    \end{itemize}
} \\
\hline
    \end{tabular}
\end{table}
\end{document}

With this your table is:

enter image description here Edit: Some aesthetic improvement:

  • in preamble add \setlength{\extrarowheight}{3pt}. This will give more space inabove and below text in table rows
    • for more compact itemize list replace \begin{itemize} with \begin{itemize}\firmlist and in preamlbe add definition for it:

\newcommand{\firmlist}{%
  \setlength{\itemsep}{0.5\itemsep}
  \setlength{\parskip}{0.2\parskip}%0.5
  \setlength{\listparindent}{3ex}%2em
                        }
3
  • Worked fine using only your code. However, the multicolumn keep behaving just as it does on my image if I add the .sty required by the conference (svn.cercomp.ufg.br/pub/infraweb-wticifes/sbc-template.sty). I have tried to extract font information from this .sty so I would just generate the table and use it as an image but no luck... Jun 28, 2015 at 21:44
  • I look in sbc-template ... and see that I haven't installed required packages (as caption2, which is, as far as I know, considered obsolete, etc), consequently I'm not familiar with them. I try to keep my MikTeX installation as small as possible (my PC is very old and has limited memory size).
    – Zarko
    Jun 28, 2015 at 21:54
  • One way, to overcome limitation of sbc-template is generating table in separate document, for example with help of standalone package and import table as pdf or png file.
    – Zarko
    Jun 28, 2015 at 21:58
1

This may be a visual artefact from a regular list's way of indenting itself. Perhaps creating your own tabularitemize that doesn't use much list formatting suits your needs better:

enter image description here

\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{array,varwidth,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash} m{2.3cm}}

\newenvironment{tabularitemize}
  {\par\addvspace{\topsep}%
   \renewcommand{\item}{\par\addvspace{\itemsep}%
     \textbullet\hspace{\labelsep}\ignorespaces}%
   \begin{varwidth}{\linewidth}}
  {\par\strut\end{varwidth}}

\begin{document}

\noindent
\begin{tabular*}{\textwidth}{|C|C|C|C|>{\centering\arraybackslash}m{3cm}|}
  \hline
  & \textbf{Hellman} & \textbf{Rainbow Table} & \textbf{Proposed Method} & \textbf{Proposed Method with Compression} \\
  \hline
  Input Range & $2^{37}$ & $2^{37}$ & $2^{37}$ & $2^{37}$ \\ \hline
  Size & $1.4$ GB & $1.4$ GB & $1.4$ GB & $1.4$ GB \\ \hline
  Hash Operations & $90.3$ M & $7.4$ M & $4$ B & $3.5$ B \\ \hline
  Advantages &
  \multicolumn{2}{>{\centering\arraybackslash}m{4.9cm}|}{
    \begin{itemize}
      \item Few hash operations
    \end{itemize}
  } &
  \multicolumn{2}{>{\centering\arraybackslash}m{5.4cm}|}{
    \begin{itemize}
      \item Little disk access
      \item Disk access is serial
      \item Success is guaranteed
      \item Easily parallelizable
    \end{itemize}
  } \\
  \hline
  Input Range & $2^{37}$ & $2^{37}$ & $2^{37}$ & $2^{37}$ \\ \hline
  Size & $1.4$ GB & $1.4$ GB & $1.4$ GB & $1.4$ GB \\ \hline
  Hash Operations & $90.3$ M & $7.4$ M & $4$ B & $3.5$ B \\ \hline
  Advantages &
  \multicolumn{2}{>{\centering\arraybackslash}m{4.9cm}|}{
    \begin{tabularitemize}
      \item Few hash operations
    \end{tabularitemize}
  } &
  \multicolumn{2}{>{\centering\arraybackslash}m{5.4cm}|}{
    \begin{tabularitemize}
      \item Little disk access
      \item Disk access is serial
      \item Success is guaranteed
      \item Easily parallelizable
    \end{tabularitemize}
  } \\
  \hline
\end{tabular*}

\bigskip

\noindent
\begin{tabular*}{\textwidth}{*{5}{C}}
  \toprule
  & \textbf{Hellman} & \textbf{Rainbow Table} & \textbf{Proposed Method} & \textbf{Proposed Method with Compression} \\
  \midrule
  Input Range & $2^{37}$ & $2^{37}$ & $2^{37}$ & $2^{37}$ \\
  \addlinespace[.5ex]
  Size & $1.4$ GB & $1.4$ GB & $1.4$ GB & $1.4$ GB \\
  \addlinespace[.5ex]
  Hash Operations & $90.3$ M & $7.4$ M & $4$ B & $3.5$ B \\
  \addlinespace[.5ex]
  Advantages &
  \multicolumn{2}{>{\centering\arraybackslash}m{4.9cm}}{
    \begin{itemize}
      \item Few hash operations
    \end{itemize}
  } &
  \multicolumn{2}{>{\centering\arraybackslash}m{5.4cm}}{
    \begin{tabularitemize}
      \item Little disk access
      \item Disk access is serial
      \item Success is guaranteed
      \item Easily parallelizable
    \end{tabularitemize}
  } \\
  \bottomrule
\end{tabularx*}

\end{document}

The lists are placed inside a varwidth environment to optimize the horizontal width they take up if that is shorter than the given horizontal width.

booktabs is purely for aesthetic value.

You must log in to answer this question.

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