I have the following table in my document, and it seems to be OK except that the topmost columns' text is not centered. I can't figure out why not. I could manually adjust the multicolumn m
sizes to get there, but that does not seem like the right solution.
I have a similar table in my document and the centering works fine. This is all within a 2 column IEEE-type document. I thought maybe my table was too wide and something weird was happening – but making the table less wide does not solve the problem (although it does make the text off center in different ways). My entire table is centered on the page; I tried taking that out and leaving it left justified and that had no effect.
The TeX that generates this table is:
\begin{table*}
\centering
\caption{Results on Xilinx Virtex 5 Devices}
\label{tab:XilinxResults}
\begin{tabular}{|m{3cm}|m{1.50cm}|m{1.50cm}|m{1.30cm}|m{1.30cm}|m{1.30cm}|m{1.30cm}|m{1.30cm}|m{1.30cm}|}
\cline{2-9}
\multicolumn{1}{>{\centering}m{3.0cm}|}{ } & % blank box
\multicolumn{2}{>{\centering}m{3.0cm}|}{\bfseries Clock Frequency (MHz)} &
\multicolumn{2}{>{\centering}m{2.6cm}|}{\bfseries Throughput (Mbit/s)} &
\multicolumn{2}{>{\centering}m{2.6cm}|}{\bfseries Area (CLB Slices)} &
\multicolumn{2}{>{\centering}m{2.6cm}|}{\bfseries Throughput / Area} \tabularnewline \hline
\multicolumn{1}{|>{\centering}m{3cm}|}{\bfseries Architecture} &
\multicolumn{1}{>{\centering}m{1.50cm}|}{\bfseries 512-bit} &
\multicolumn{1}{>{\centering}m{1.50cm}|}{\bfseries 256-bit} &
\multicolumn{1}{>{\centering}m{1.30cm}|}{\bfseries 512-bit} &
\multicolumn{1}{>{\centering}m{1.30cm}|}{\bfseries 256-bit} &
\multicolumn{1}{>{\centering}m{1.30cm}|}{\bfseries 512-bit} &
\multicolumn{1}{>{\centering}m{1.30cm}|}{\bfseries 256-bit} &
\multicolumn{1}{>{\centering}m{1.30cm}|}{\bfseries 512-bit} &
\multicolumn{1}{>{\centering}m{1.30cm}|}{\bfseries 256-bit}
\tabularnewline\hline\hline
\bfseries BMW x1 &
\raggedleft 4.89 & \raggedleft 8.14 & \raggedleft 5004 & \raggedleft 4168 &
\raggedleft 12039 & \raggedleft 6164 & \raggedleft 0.42 & \raggedleft 0.68 \tabularnewline \hline
\bfseries BMW x1-PPL18 &
\raggedleft 46.51 & \raggedleft 70.97 & \raggedleft 47628 & \raggedleft 36335 &
\raggedleft 24564 & \raggedleft 11610 & \raggedleft 1.84 & \raggedleft 2.96 \tabularnewline \hline
\bfseries BMW /32(h) &
\raggedleft 44.27 & \raggedleft 69.41 & \raggedleft 1416 & \raggedleft 1110 &
\raggedleft 4001 & \raggedleft 2211 & \raggedleft 0.35 & \raggedleft 0.50 \tabularnewline \hline
\bfseries CubeHash x1 &
\raggedleft 152.70 & \raggedleft 151.93 & \raggedleft 2443 & \raggedleft 2430 &
\raggedleft 745 & \raggedleft 672 & \raggedleft 3.28 & \raggedleft 3.62 \tabularnewline \hline
\bfseries CubeHash x1-PAR5 &
\raggedleft 151.26 & \raggedleft 151.56 & \raggedleft 12101 & \raggedleft 12125 &
\raggedleft 3742 & \raggedleft 3490 & \raggedleft 3.23 & \raggedleft 3.47 \tabularnewline \hline
\bfseries CubeHash x1-PAR17 &
\raggedleft N/A & \raggedleft 150.49 & \raggedleft N/A & \raggedleft 40933 &
\raggedleft N/A & \raggedleft 11360 & \raggedleft N/A & \raggedleft 1.91 \tabularnewline \hline
\bfseries CubeHash x1-PAR33 &
\raggedleft 150.65 & \raggedleft N/A & \raggedleft 79542 & \raggedleft N/A &
\raggedleft 24570 & \raggedleft N/A & \raggedleft 3.24 & \raggedleft N/A \tabularnewline \hline
\bfseries CubeHash /2(h) &
\raggedleft 173.52 & \raggedleft 184.71 & \raggedleft 1388 & \raggedleft 1477 &
\raggedleft 733 & \raggedleft 624 & \raggedleft 1.89 & \raggedleft 2.37 \tabularnewline \hline
\end{tabular}
\end{table*}
Best Answer
When using
\multicolumn{1}
, you don't need to respecify the column width viam{<len>}
, since it requires a cumbersome interface when trying to centre the column entry. Rather just use\multicolumn{1}{c}{...}
.Here is an updated version of your code snippet:
Hopefully this improves some of the formatting and readability of code. Some improvements include:
*{<num>}{<col spec>}
which repeats<col spec>
a total of<num>
times;\raggedleft
at the "column specification" level to avoid cluttering thetabular
contents with\raggedleft
;\arraybackslash
within>{<stuff>}
in the column specifier, which restores the traditional use of\\
as\tabularnewline
;\stackcell[<col spec>]{<stuff>}
which adds a stackabletabular
within a cell (although you may not need/require this).Finally, as a recommendation for professional-looking tables, consider using the
booktabs
package. The horizontal alignment/structure of a table lends itself to avoid using vertical rules, something promoted by/when usingbooktabs
.(
geometry
was loaded inlandscape
mode to make the table fit on the page when compiling the MWE.)