0

I want to center my table in the middle of a two-column document in Latex. I have tried the {table*} and "\centering" command and it works, but not completely. It left aligns the table instead of centering it across the two columns. Here is my code. I would appreciate any tips on how to center this table properly.

\begin{table*}
\centering
\caption{Monte Carlo Simulation Results vs. Historical Food Distributions}
\label{table:DistributionComparison}
\begin{tabular}{@{}llllcll@{}}
\toprule
\multicolumn{2}{l}{Simulation} & \multicolumn{2}{l}{Historical} & Difference between means &        &                  \\ \midrule
$M_1$            & $(SD_1)$           & $M_2$             & $(SD_2)$            & $M_1$ - $M_2$ {[}95\% CI{]}    & $t(460)$  & $p$                \\ \midrule
146,797          & (3,786)          & 122,468           & (27,411)           & 24,330 {[}21,080, 27,578{]}    & 14.7132  & \textless{}0.001 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item Note. $ N=462$. CI = Confidence Interval; $n_1 = 450$. $n_2 = 12$. 
\end{tablenotes}
\end{table*}
4
  • 1
    Please post a complete document (a minimal working example) that demonstrates the problem. Don't make us guess what packages and document class you're using. When I test your code in the standard article class with the twocolumn option, the table is centered between the columns, so there must be more in your actual document that's relevant.
    – frabjous
    Commented Sep 24, 2022 at 0:02
  • I am using the \documentclass[a4paper,fleqn]{cas-dc} and the \usepackage{booktabs,caption}, \usepackage{multicol}, and \usepackage[flushleft]{threeparttable}
    – Ben Morrow
    Commented Sep 24, 2022 at 0:08
  • Don't put code in the comments. Edit the question and add the code to the code block, making it compiliable as is.
    – frabjous
    Commented Sep 24, 2022 at 0:10
  • 1
    But isn't the problem just the natural result of the flushleft option to threeparttable?
    – frabjous
    Commented Sep 24, 2022 at 0:16

2 Answers 2

1

You haven't provided the full code to compile and test so I am guessing the annotation are moved left because table itself should be centred.

First, the table* environment creates space of the full width but your table is is not that wide. I never used tablesnotes this way and I guess because it is not a part of the table, it is moved to the left margin with a small indentation as tablesnotes create a list.

If you want annotation to be aligned with the table, remove tablesnotes and either insert one more row below \bottomrule with all cells merged

 \multicolumn{7}{@{}l}{\small Note. ...}

or apply threeparttable as in the example below, which I would recommend

enter image description here

\documentclass[twocolumn]{article}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{kantlipsum}

\begin{document}
\kant[1-4]

\begin{table*}
  \centering
  \begin{threeparttable}
    \caption{Monte Carlo Simulation Results vs. Historical Food Distributions}
    \label{table:DistributionComparison}
    \begin{tabular}{@{}llllcll@{}}
      \toprule
      \multicolumn{2}{c}{Simulation}
      & \multicolumn{2}{c}{Historical}
      & Difference between means
      & & \\
      \midrule
      $M_1$   & $(SD_1)$ & $M_2$   & $(SD_2)$ & $M_1$ - $M_2$ {[}95\% CI{]} & $t(460)$ & $p$ \\
      \midrule
      146,797 & (3,786)  & 122,468 & (27,411) & 24,330 {[}21,080, 27,578{]} & 14.7132  & $<0.001$ \\
      \bottomrule
    \end{tabular}
    {\small Note. $ N=462$. CI = Confidence Interval; $n_1 = 450$. $n_2 = 12$.}
  \end{threeparttable}
\end{table*}

\kant[2-5]
\end{document}
1
  • Thanks! The threeparttable worked perfectly.
    – Ben Morrow
    Commented Sep 24, 2022 at 2:54
0

Like this?

enter image description here

With taltblr table, which is tabularray equivalent for threeparttable and use of the stfloat package, you can get table centered at the top or at the bottom of the page (if it is inserted in the first column and after this point is enough space for table):

\documentclass[twocolumn]{article}
\usepackage{stfloats}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{lipsum}

\begin{document}
\lipsum[1-2]

\begin{table*}[b]
  \centering
    \begin{talltblr}[
caption = {Monte Carlo Simulation Results vs. Historical Food Distributions},
  label = {table:DistributionComparison},
note{} = {Note: $ N=462$, CI = Confidence Interval, $n_1 = 450$, $n_2 = 12$.}
                    ]{colspec = {@{} *{7}{Q[c, mode=math]} @{}},
                      row{1}  = {c, mode=text}
                      }
    \toprule
\SetCell[c=2]{c}   Simulation 
    &   &   \SetCell[c=2]{c}   Historical 
            &   &   Difference between means
                    &   &   \\
    \cmidrule[r]{1-2}
    \cmidrule[lr]{3-4}
    \cmidrule[lr]{5-5}
M_1     & (SD_1)    & M_2       & (SD_2)    & M_1 - M_2\ [95\,\% CI]    & t(460)    & p \\
    \midrule
146,797 & (3,786)   & 122,468   & (27,411)  & 24,330\ [21,080, 27,578]  & 14.7132   & <0.001 \\
146,797 & (3,786)   & 122,468   & (27,411)  & 24,330\ [21,080, 27,578]  & 14.7132   & <0.001 \\
      \bottomrule
    \end{talltblr}
\end{table*}

\lipsum[3-6]
\end{document}

You must log in to answer this question.

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