2

I use begain{center} and end{center} here,but why the table is not in the middle?The following is my Latex code.

\documentclass{article}
\usepackage{float}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \begin{center}
  \large
    \begin{tabular}{ccccccccccc}

    \toprule
    Variable & (1)   &       & (2)   &       & (3)   &       & (4)   &       & (5)   &  \\
    \midrule
    \_cons & -0.2503  & ***   & -0.2499  & ***   & -0.2473  & ***   & -0.2459  & ***   & -0.2499  & *** \\
          & (7.71) &       & (8.00) &       & (7.69) &       & (8.01) &       & (7.79) &  \\
    X2Y   & 0.0106  & ***   &       &       &       &       &       &       &       &  \\
          & (3.13) &       &       &       &       &       &       &       &       &  \\
    sign.2Y &       &       & -0.0062  & ***   &       &       &       &       &       &  \\
          &       &       & (2.88) &       &       &       &       &       &       &  \\
    Positive2 &       &       &       &       & 0.0098  & ***   &       &       & 0.0052  &  \\
          &       &       &       &       & (2.66) &       &       &       & (1.27) &  \\
    Negative2 &       &       &       &       &       &       & 0.0393  & ***   & 0.0337  & *** \\
          &       &       &       &       &       &       & (3.36) &       & (3.14) &  \\
    PGR   & 0.0045  &       & 0.0037  &       & 0.0047  &       & 0.0026  &       & 0.0033  &  \\
          & (0.82) &       & (0.67) &       & (0.89) &       & (0.47) &       & (0.60) &  \\
    LTA   & 0.0161  & ***   & 0.0163  & ***   & 0.0159  & ***   & 0.0160  & ***   & 0.0162  & *** \\
          & (7.98) &       & (8.19) &       & (7.98) &       & (8.24) &       & (8.06) &  \\
          &       &       &       &       &       &       &       &       &       &  \\
    R\^2  & 0.6984  &       & 0.7021  &       & 0.6955  &       & 0.7003  &       & 0.7014  &  \\
    Firm Effect & Yes   &       & Yes   &       & Yes   &       & Yes   &       & Yes   &  \\
    Cluster year & Yes   &       & Yes   &       & Yes   &       & Yes   &       & Yes   &  \\
    No. of observation & 282   &       & 282   &       & 282   &       & 282   &       & 282   &  \\
    \midrule
          &       &       &       &       &       &       &       &       &       &  \\
    \midrule
    Variable & (1)   &       & (2)   &       & (3)   &       & (4)   &       & (5)   &  \\
    \midrule
    \_cons & -0.2526  & ***   & -0.2499 & ***   & -0.2502 & ***   & -0.2445 & ***   & -0.2512 & *** \\
          & (7.67) &       & (8.00) &       & (7.64) &       & (7.97) &       & (7.71) &  \\
    X3Y   & 0.01  & ***   &       &       &       &       &       &       &       &  \\
          & (3.28) &       &       &       &       &       &       &       &       &  \\
    sign.3Y &       &       & -0.0062 & ***   &       &       &       &       &       &  \\
          &       &       & (2.88) &       &       &       &       &       &       &  \\
    Positive3 &       &       &       &       & 0.0096 & ***   &       &       & 0.0061 &  \\
          &       &       &       &       & (2.87) &       &       &       & (1.49) &  \\
    Negative3 &       &       &       &       &       &       & 0.0388 & ***   & 0.0314 & *** \\
          &       &       &       &       &       &       & (3.32) &       & (2.75) &  \\
    PGR   & 0.0045 &       & 0.0037 &       & 0.0047 &       & 0.0028 &       & 0.0036 &  \\
          & (0.83) &       & (0.67) &       & (0.89) &       & (0.51) &       & (0.66) &  \\
    LTA   & 0.0162 & ***   & 0.0163 & ***   & 0.016 & ***   & 0.0159 & ***   & 0.0162 & *** \\
          & (7.94) &       & (8.19) &       & (7.93) &       & (8.19) &       & (7.99) &  \\
          &       &       &       &       &       &       &       &       &       &  \\
    R\^2  & 0.6985 &       & 0.7021 &       & 0.6962 &       & 0.6988 &       & 0.7007 &  \\
    Firm Effect & Yes   &       & Yes   &       & Yes   &       & Yes   &       & Yes   &  \\
    Cluster year & Yes   &       & Yes   &       & Yes   &       & Yes   &       & Yes   &  \\
    No. of observation & 282   &       & 282   &       & 282   &       & 282   &       & 282   &  \\
    \bottomrule
    \end{tabular}%
    \end{center}
  \label{tab:addlabel}%
\end{table}%

\end{document}

6
  • This isn't the problem, but without a \caption, the \label won't work correctly.
    – Teepeemm
    Jun 23, 2020 at 1:56
  • @Teepeemm, after using \caption,the table is still not in the middle.I need an elegant table,so I want to know how to move my table to the left
    – XUN ZHANG
    Jun 23, 2020 at 2:03
  • @Teepeemm I know the answer now.I need to use\hskip-4.0cm . Thanks!
    – XUN ZHANG
    Jun 23, 2020 at 2:09
  • 1
    Your table currently is a lot wider than the textwidth resulting in it overflowing into the right margin only. Instead of adding something like \hskipI'd usggest making the table narrower in order to get it to fit into the margins proberly.
    – leandriis
    Jun 23, 2020 at 5:46
  • 1
    I would reduce the font size to normalsize by removing \large. In order to save some more space, I'd abbreviate "observarions". Is there a special reason why the asterisks are in a separate column from the numbers? If not, I would put the asterisks in the same column as the number they correspond to. If you then also use tabular* and @{\extracolsep{\fill} your table should fit into the textwidth. If you want to improve the alignment of the numbers, take a look at the S type column from siunitx.
    – leandriis
    Jun 23, 2020 at 5:51

1 Answer 1

1
  • In such of tables are usual used S column type for columns 2 -- 6.
  • Since table is quite wide, it is sensible to left calculation of separation between columns in the table to macro \extracolsep
  • It is not very clear what is means of the *** in separate columns. In such tables are usual add to numbers to denote their confidence intervals.
\documentclass{article}
\usepackage{booktabs, threeparttable}
\usepackage{siunitx}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}[htbp]
\sisetup{table-space-text-pre={(},
         table-align-text-pre=false,
         table-space-text-post={$^{***}$},
         table-align-text-post=false,
         input-open-uncertainty = ,
         input-close-uncertainty = ,
         table-format=-1.4
         }
\setlength\tabcolsep{0pt}
   \begin{threeparttable}
\caption{my table ...}
\label{tab:addlabel}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l *{5}{S} }
    \toprule
Variable    & {(1)} & {(2)} & {(3)} & {(4)} & {(5)}    \\
    \midrule
\_cons      & -0.2503\tnote{***}    & -0.2499\tnote{***}    & -0.2473\tnote{***}
            & -0.2459\tnote{***}    & -0.2499\tnote{***}        \\
            & (7.71)                & (8.00)                & (7.69) 
            & (8.01)                & (7.79)                    \\
X2Y         & 0.0106\tnote{***}     &   &   &   &               \\
            & (3.13)                &   &   &   &               \\
sign.2Y     &                       & -0.0062\tnote{***}    &   &   &   \\
            &                       & (2.88)                &   &   &   \\
Positive2   &                       &                       & 0.0098\tnote{***}
            &                       & 0.0052                    \\
            &                       &                       & (2.66) 
            &                       & (1.27)                    \\
Negative2   &                       &                       &      
            & 0.0393\tnote{***}     & 0.0337\tnote{***}         \\
            &                       &                       &        
            & (3.36)                & (3.14)                    \\
PGR         & 0.0045                & 0.0037                & 0.0047 
            & 0.0026                & 0.0033                    \\
            & (0.82)                & (0.67)                & (0.89) 
            & (0.47)                & (0.60)                   \\
LTA         &  0.0161\tnote{***}    & 0.0163\tnote{***}     & 0.0159\tnote{***}   
            &  0.0160\tnote{***}    & 0.0162\tnote{***}         \\
            & (7.98)                & (8.19)                & (7.98)
            & (8.24)                & (8.06)                    \\
    \addlinespace
R\^2        & 0.6984                & 0.7021                & 0.6955  
            & 0.7003                & 0.7014                    \\
Firm Effect & {Yes}                 & {Yes}                 & {Yes}  
            & {Yes}                 & {Yes}                     \\
Cluster year& {Yes}                 & {Yes}                 & {Yes}
            & {Yes}                 & {Yes}                     \\
No. of observation 
            & {282}                 & {282}                 & {282}       
            & {282}                 & {282}                 \\
    \midrule
    \midrule
Variable    & {(1)} & {(2)} & {(3)} & {(4)} & {(5)}    \\
    \midrule
\_cons      & -0.2526\tnote{***}    & -0.2499\tnote{***}    & -0.2502\tnote{***}   
            & -0.2445\tnote{***}    & -0.2512\tnote{***}    \\
            & (7.67)                & (8.00)                & (7.64)
            & (7.97)                & (7.71)                \\
X3Y         & 0.01\tnote{***}       &   &   &   &           \\
            & (3.28)                &   &   &   &           \\
sign.3Y     &                       & -0.0062\tnote{***}    &  
            &                       &           \\
            &                       & (2.88)    &   &   &   \\
Positive3   &                       &                   & 0.0096\tnote{***}   
            &                       & 0.0061                \\
            &                       &                   & (2.87) 
            &                       & (1.49)                \\
Negative3   &                       &                   &       
            & 0.0388\tnote{***}     & 0.0314\tnote{***}     \\
            &                       &                   &       
            & (3.32)                & (2.75)                \\
PGR         & 0.0045                & 0.0037            & 0.0047 
            & 0.0028                & 0.0036                \\
            & (0.83)                & (0.67)            & (0.89) 
            & (0.51)                & (0.66)                \\
LTA         & 0.0162\tnote{***}     & 0.0163\tnote{***} & 0.016\tnote{***}   
            & 0.0159\tnote{***}     & 0.0162\tnote{***}     \\
            & (7.94)                & (8.19)            & (7.93) 
            & (8.19)                & (7.99)                \\
    \addlinespace
R\^2        & 0.6985                & 0.7021            & 0.6962 
            & 0.6988                & 0.7007                \\
Firm Effect & {Yes}                 & {Yes}                 & {Yes}
            & {Yes}                 & {Yes}                     \\
Cluster year& {Yes}                 & {Yes}                 & {Yes}
            & {Yes}                 & {Yes}                     \\
No. of observation
            & {282}                 & {282}                 & {282}
            & {282}                 & {282}                 \\
    \bottomrule
\end{tabular*}
    \begin{tablenotes}[flushleft, para]\footnotesize
\item[*]    text
\item[**]   text
\item[***]  text
    \end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}

enter image description here

(red lines shows page layout)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.