There are other similar questions, all with different answers, but I could not find one which achieves what I want. In the table below, the spacing between the numbers is too wide. How can I shrink it a bit?
\newcommand{\testmode}[2] {
\begin{tabular}{c}
\textbf{#1} \\ \textbf{d=#2}
\end{tabular}
}
\begin{table}[ht]
\begin{tabular}{l | c c c | c c c |}
\cline{2-7}
& \multicolumn{3}{c|}{\textbf{Single}} & \multicolumn{3}{c|}{\textbf{Double}} \\
\cline{2-7}
& \testmode{Scalar}{1} & \testmode{SSE-4}{4} & \testmode{AVX-2}{8} & \testmode{Scalar}{1} & \testmode{SSE-4}{2} & \testmode{AVX-2}{4} \\
\hline
\multicolumn{1}{|c|}{\textbf{Eytzinger} } & 209.86 & 370.18 & 411.25 & 180.85 & 245.37 & 262.61 \\
\multicolumn{1}{|c|}{\textbf{Classic Offset} } & 213.28 & 363.35 & 476.10 & 209.04 & 247.02 & 208.63 \\
\hline
\end{tabular}
\caption{Throughput in millions of searches per second with vector $X$ of size 15}
\label{tab:results0}
\end{table}
Best Answer
In your example you have doubled the column separation using a
tabular
inside atabular
. Note: LaTeX adds a distance of\tabcolsep
before and after each column. In your case you have such a distance before and after the column of the inner tabular of\testmode
and before and after the column of the outer tabular. To avoid this, you should add@{}
before the first column of the inner tabular and after the last column of the inner tabular:To explain some more: By default LaTeX adds
\hskip\tabcolsep
before it starts a column and after it has finished a column. So you have the distance\tabcolsep
before the first and after the last column and2\tabcolsep
between two columns. If you use@{…}
the code of the argument of@
is added instead of the distance. So@{}
just removes the distance.Additional note: I would recommend to avoid vertical rules in tables (see the manual of package
booktabs
) and to use packagesiunitx
for number columns. And I would not center the elements of the first table row but left-align them. And becaused=…
in the table head is something like math, you should set it in math mode. In this case I also would not make it bold (using, e.g.,\boldmath
), because font attributes in math have mostly a semantic (e.g, bold is often used for vectors or sets).