[Tex/LaTex] Centering Table with Column Width in Two-column layout

horizontal alignmenttables

I have the following table which I want to put in the center of the two-column
manuscript. But it failed although I already put the asterisk in the \begin{table*} command.

\begin{table*}
\noindent\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}*{7}{r}@{}}
  \toprule
  & $z_{6}$ & $z_{8}$ & $z_{9}$ & $z_{11}$ & $z_{13}$ & $z_{14}$ \\
  \midrule
  fileA & 0.00 & 0.00 & 0.00 & 0.08 & 0.79 & 0.08  \\
  fileB & 0.01 & 0.00 & 0.13 & 0.00 & 0.84 & 0.00  \\
  fileC & 0.00 & 0.39 & 0.02 & 0.49 & 0.00 & 0.00  \\
  fileD & 0.75 & 0.08 & 0.00 & 0.00 & 0.00 & 0.00  \\
  \bottomrule                             
\end{tabular*}
\end{table*}

What's the right way to do it?

Best Answer

The full width of the text area is \textwidth not \columnwidth so as shown in the first example below you could specify that to tabular* personally I think that makes the table look rather spaced out and it is better to set it to its natural width using tabular and then centre the result, as shown in the second table.

enter image description here

\documentclass[twocolumn]{article}

\usepackage{booktabs}

\def\a{One two three four. }
\def\b{Red Yellow Green Blue. }
\def\c{\a\a\b\b\par\b\a\b\a\b\b\a\par}

\begin{document}
\c\c\c\c\c\c\c\c\c\c\c\c\c\c\c
\begin{table*}
\centering
\begin{tabular*}{\textwidth}{@{\extracolsep{\stretch{1}}}*{7}{r}@{}}
  \toprule
  & $z_{6}$ & $z_{8}$ & $z_{9}$ & $z_{11}$ & $z_{13}$ & $z_{14}$ \\
  \midrule
  fileA & 0.00 & 0.00 & 0.00 & 0.08 & 0.79 & 0.08  \\
  fileB & 0.01 & 0.00 & 0.13 & 0.00 & 0.84 & 0.00  \\
  fileC & 0.00 & 0.39 & 0.02 & 0.49 & 0.00 & 0.00  \\
  fileD & 0.75 & 0.08 & 0.00 & 0.00 & 0.00 & 0.00  \\
  \bottomrule                             
\end{tabular*}
\caption{tabular*}
\end{table*}
\begin{table*}
\centering
\begin{tabular}{*{7}{r}}
  \toprule
  & $z_{6}$ & $z_{8}$ & $z_{9}$ & $z_{11}$ & $z_{13}$ & $z_{14}$ \\
  \midrule
  fileA & 0.00 & 0.00 & 0.00 & 0.08 & 0.79 & 0.08  \\
  fileB & 0.01 & 0.00 & 0.13 & 0.00 & 0.84 & 0.00  \\
  fileC & 0.00 & 0.39 & 0.02 & 0.49 & 0.00 & 0.00  \\
  fileD & 0.75 & 0.08 & 0.00 & 0.00 & 0.00 & 0.00  \\
  \bottomrule                             
\end{tabular}
\caption{tabular}
\end{table*}

\c\c\c\c\c\c\c\c\c\c\c\c\c\c\c\c


\end{document}
Related Question