# Longtable is not centered

I have this very wide long table. Even though I have included {c}, the table does not appear centered. This is the code:

\documentclass[12pt]{article}
\begin{document}
\begin{longtable}[c]{lcccccccc}
\label{my-label}\\
\toprule
\multicolumn{1}{l}{\textbf{Descriptive Statistic}} & \multicolumn{1}{c}{\textbf{$rtb_t$}} & \multicolumn{1}{c}{\textbf{$xIG_t$}} & \multicolumn{1}{c}{\textbf{$xHY_t$}} & \multicolumn{1}{c}{\textbf{$xEM_t$}} & \multicolumn{1}{c}{\textbf{$xConv_t$}}& \multicolumn{1}{c}{\textbf{$y_t$}}& \multicolumn{1}{c}{\textbf{$DefRate_t$}}& \multicolumn{1}{c}{\textbf{$spr_t$}}\\
%
%
\toprule
~~Mean  &  0.1658  &   0.0378  &   0.0442  &   0.0502   &  0.0524  &   0.4233  &   0.4996   &  0.2521 \\
~~Standard Deviation & 0.0459  &   0.0699  &   0.0928 &    0.0810   &  0.1250  &   0.0439  &   0.0909   &  0.0351 \\
~~Variance & 0.0021  &   0.0049  &   0.0086 &    0.0066  &   0.0156  &   0.0019  &   0.0083  &   0.0012\\
~~Skewness & 0.1963  &  -0.9932  &  -1.6310  &  -4.7227 &   -1.1165  &   0.1730 &    1.2201   &  2.8841\\
~~Kurtosis & 2.9890 &    8.4808  &  14.6628  &  50.1189  &   8.5597  &   2.0001  &   3.7574  &  13.6014 \\
~~Sharpe Ratio &  -  &   0.5404  &   0.4762  &   0.6192  &   0.4191  &   -   &  - &   -\\
\bottomrule
\caption{Sample Statistics: Bond Model}
\end{longtable}
\end{document}


This is the result

I would like to center it, but I am not able. Thanks for your help.

• your table is to wide. it can't be centered on such a way. you have two options: (i) make table narrower (ii) locally increase text width. i would give a try tor the first option. btw: do you really need longtable? from mwe seems that tabular* or tabularx would be better choise. – Zarko Jul 30 '18 at 22:35
• Have you considered transposing the table, so that it has 6 data columns instead of 8? Incidentally, why are you using a longtable environment? – Mico Jul 30 '18 at 22:35
• @Mico I would not like to transpose the table. I am using longtable because it is the only environment I know, if with other environment it would fit in one page I would consider them. – madrac Jul 30 '18 at 22:37
• and please, extend your code sniped to complete small document \beginning with \documentclass{...} and ending with \end{document}. – Zarko Jul 30 '18 at 22:40
• your mwe is not complete. missed are packages used in your table and defining page layout ... – Zarko Jul 30 '18 at 22:55

Playing with the fontsize and the value of \tabcolsep is enough. In addition, I used the S column type, for the alignment of the numeric cells on the decimal dot (non numeric cells are centred if you enclose their content between braces), and I moved the caption above the table, which is the typographic tradition for tables, especially with tables that can extend over several pages.:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{longtable, booktabs}
\usepackage{siunitx}

\begin{document}

{\footnotesize\setlength{\tabcolsep}{3pt}
\sisetup{table-format=2.4}
\begin{longtable}{l*{8}{S}}
\caption{Sample Statistics: Bond Model}
\label{my-label}\\
\toprule
\textbf{Descriptive Statistic} &{$rtb_t$} & {$xIG_t$} & {$xHY_t$} & {$xEM_t$} & {$xConv_t$} & {$y_t$}& {$DefRate_t$} & {$spr_t$}\\
%
%
\toprule
Mean & 0.1658 & 0.0378 & 0.0442 & 0.0502 & 0.0524 & 0.4233 & 0.4996 & 0.2521 \\
Standard Deviation & 0.0459 & 0.0699 & 0.0928 & 0.0810 & 0.1250 & 0.0439 & 0.0909 & 0.0351 \\
Variance & 0.0021 & 0.0049 & 0.0086 & 0.0066 & 0.0156 & 0.0019 & 0.0083 & 0.0012\\
Skewness & 0.1963 & -0.9932 & -1.6310 & -4.7227 & -1.1165 & 0.1730 & 1.2201 & 2.8841\\
Kurtosis & 2.9890 & 8.4808 & 14.6628 & 50.1189 & 8.5597 & 2.0001 & 3.7574 & 13.6014 \\
Sharpe Ratio &{–} & 0.5404 & 0.4762 & 0.6192 & 0.4191 & {–} & {–} & {–} \\
\bottomrule
\end{longtable}}

\end{document}


• Keep in mind that the OP has indicated that the main document font size is 12pt. – Mico Jul 30 '18 at 23:03
• @Mico: Nothing was specified initially. I'll update the code. Thanks for warning me! – Bernard Jul 30 '18 at 23:08
• @Bernard many thanks for your code, works very good! Could you please tell me how to put notes on the bottom of the table? If I had \begin{tablenotes} it will crash with the caption that I have at the bottom. – madrac Jul 30 '18 at 23:28
• For a long table, you have to use the threeparttablex package. Check the syntax in the documentation, as it is slightly different from threeparttable. Roughly, you define a TableNotes environment at the beginning, then use \InsertTableNotes at the point where you want them (usually at the end, but not necessarily). – Bernard Jul 30 '18 at 23:39

I suggest you drop the longtable enviroment and, instead, use a tabular* environment with the overall width set to \textwidth. I would also make an effort to align all numbers on their decimal markers, and I would typeset the variable names using math italics rather than pure math mode. Oh, and I would also lose the "Descriptive Statistics" header in the (1,1) cell since it (a) takes up a lot of space and (b) is redundant, given the information contained in the caption of the table. And, to eliminate any hint of baroque appearance, I would not indent the items in the left-hand column.

\documentclass[12pt]{article}
\usepackage{booktabs,siunitx}
\usepackage{geometry} % set page and text block parameters suitably
\newcommand\vn[1]{\mathit{#1}} % how to display variable names
\newcolumntype{T}[1]{S[table-format=#1]} % for alignment on decimal markers
\begin{document}

\begin{table}[ht!]
\small % for a 10% linear reduction in font size
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l T{1.4} *{4}{T{-1.4}} *{3}{T{2.4}} }
\label{my-label}\\
\toprule
& {$\vn{rtb}_t$}     & {$\vn{xIG}_t$}
& {$\vn{xHY}_t$}     & {$\vn{xEM}_t$}
& {$\vn{xConv}_t$}   & {$\vn{y}_t$}
& {$\vn{DefRate}_t$} & {$\vn{spr}_t$}\\
\midrule
Mean  &  0.1658  &   0.0378  &   0.0442  &   0.0502   &  0.0524  &   0.4233  &   0.4996   &  0.2521 \\
Std.\ Dev. & 0.0459  &   0.0699  &   0.0928 &    0.0810   &  0.1250  &   0.0439  &   0.0909   &  0.0351 \\
Variance & 0.0021  &   0.0049  &   0.0086 &    0.0066  &   0.0156  &   0.0019  &   0.0083  &   0.0012\\
Skewness & 0.1963  &  -0.9932  &  -1.6310  &  -4.7227 &   -1.1165  &   0.1730 &    1.2201   &  2.8841\\
Kurtosis & 2.9890 &    8.4808  &  14.6628  &  50.1189  &   8.5597  &   2.0001  &   3.7574  &  13.6014 \\
Sharpe Ratio &  {--}  &   0.5404  &   0.4762  &   0.6192  &   0.4191  &   {--}   &  {--} &   {--} \\
\bottomrule
\end{tabular*}
\caption{Sample Statistics: Bond Model}
\end{table}
\end{document}


an example how you can make your table narrowed:

(red lines indicate page layout)

\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage{booktabs, makecell, longtable}
\usepackage{siunitx}

\begin{document}
{\setlength\tabcolsep{3pt}
\small
\begin{longtable}{@{}l
S[table-format=1.4]
*{4}{S[table-format=2.4]}
*{2}{S[table-format=1.4]}
S[table-format=2.4]
@{}}
\toprule
& {$rtb_t$}   & {$xIG_t$} & {$xHY_t$}     & {$xEM_t$}
& {$xConv_t$} & {$y_t$}   & {$DefRate_t$} & {$spr_t$}   \\
%
%
\toprule
Mean        &  0.1658 &   0.0378  &   0.0442 &   0.0502 &  0.0524  &   0.4233 & 0.4996 &  0.2521 \\
Standard Deviation
& 0.0459  &   0.0699  &   0.0928 &   0.0810 &  0.1250  &   0.0439 & 0.0909 &  0.0351 \\
Variance    & 0.0021  &   0.0049  &   0.0086 &   0.0066 &  0.0156  &   0.0019 & 0.0083 &  0.0012 \\
Skewness    & 0.1963  &  -0.9932  &  -1.6310 &  -4.7227 & -1.1165  &   0.1730 & 1.2201 &  2.8841 \\
Kurtosis    & 2.9890  &   8.4808  &  14.6628 &  50.1189 &  8.5597  &   2.0001 & 3.7574 & 13.6014 \\
Sharpe Ratio & { - }  &   0.5404  &   0.4762 &   0.6192 &  0.4191  &   {-}    &  {-}   &   {-}   \\
\bottomrule
\caption{Sample Statistics: Bond Model}
\label{my-label}\\
\end{longtable}
}
\end{document}

• Don't forget that the OP's code shows that the main document font size is 12pt. – Mico Jul 30 '18 at 23:04
• @Mico, in time of my writing of table, this was not known. with 12 pt situation is worse ... – Zarko Jul 30 '18 at 23:05
• Indeed, after the OP volunteered the 12pt font size spec, I decided to eliminate the redundant "Descriptive Statistics" from the (1,1) cell, to avoid having to go down to \footnotesize or even (gasp) \scriptsize. – Mico Jul 30 '18 at 23:07
• @Mico, i managed to use \small` font size, however, page layout is still unknown :-(. – Zarko Jul 30 '18 at 23:09