桌子不肯居中

桌子不肯居中

无论我尝试什么包和格式,我的表都无法居中。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{multirow}
\usepackage{booktabs}

\title{xxxxx}
\author{xxxxxxxx }
\date{July 2019}
\begin{document}
\maketitle

\begin{center}
{
\scalebox{.79}{{
\centering
\begin{tabular}{| ccccccccc |}
\toprule
Metric Date & Metric Values &  Metric Rank & VIX Date &  VIX Values &  VIX Rank & metric rank & vix rank & timedelta \\
\midrule
  2017-06-20 & 0.3217 &  1 &  2018-02-05 & 37.32 &   1 &  10 & 1 &  0 days \\
  2016-12-19 & 0.3194 &  2 &  2018-12-24 & 36.07 &  2  & 10 & 6 &    1 days \\
  2017-09-18 & 0.3193 &  3 &  2018-02-08 & 33.46 &  3  &  9 &   9 &  1 days \\
  2016-12-27 & 0.2993 & 4 &  2018-12-26 &  30.41 &  4  & 10 & 3 &  3 days \\
  2017-06-05 & 0.2874 & 5 &  2018-12-27 & 30.41 & 5 &  10 & 8 & 4 days \\
  2017-05-23 & 0.2708 & 6 &  2018-02-06 & 29.98 & 6 &  9 & 2 & 5 days \\
  2017-08-25 & 0.2461 & 7 &  2018-12-28 & 29.96 & 7 &  9 & 4 & 7 days \\
  2017-08-24 & 0.2398 & 8 &  2018-02-09 & 29.06 & 8 &  9 & 5 & 8 days \\
  2018-12-19 & 0.2391 & 9 &  2018-12-20 & 28.38 & 9 &  9 & 7 & 9 days \\
  2018-02-05 & 0.2317 & 10 & 2016-02-11 & 28.14 & 10 & 3 & 1 & 140 days \\
\bottomrule
\end{tabular}}
}}\end{center}

\end{document}

答案1

缩放表格应该是最后的手段。.79缩放系数只是一个大胆的(也是错误的)猜测,它留下了一个过大的对象,当然它不居中,并且突出在右边距。

首先修复浪费大量空间的长标题;然后压缩列间空间;使用起来很方便tabular*,将计算留给 TeX 来完成。

我留下了(注释掉)\small。尝试一下,看看表格是否看起来更好。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{multirow}
\usepackage{booktabs}

\title{xxxxx}
\author{xxxxxxxx }
\date{July 2019}
\begin{document}
\maketitle

\begin{center}
%\small
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ccccccccc@{}}
\toprule
\multicolumn{3}{c}{Metric} & \multicolumn{3}{c}{VIX} & \multicolumn{2}{c}{rank} & timedelta \\
\cmidrule{1-3} \cmidrule{4-6} \cmidrule{7-8}
Date & Values &  Rank & Date & Values & Rank & metric & vix\\
\midrule
2017-06-20 & 0.3217 &  1 & 2018-02-05 & 37.32 &  1 & 10 & 1 &   0 days \\
2016-12-19 & 0.3194 &  2 & 2018-12-24 & 36.07 &  2 & 10 & 6 &   1 days \\
2017-09-18 & 0.3193 &  3 & 2018-02-08 & 33.46 &  3 &  9 & 9 &   1 days \\
2016-12-27 & 0.2993 &  4 & 2018-12-26 & 30.41 &  4 & 10 & 3 &   3 days \\
2017-06-05 & 0.2874 &  5 & 2018-12-27 & 30.41 &  5 & 10 & 8 &   4 days \\
2017-05-23 & 0.2708 &  6 & 2018-02-06 & 29.98 &  6 &  9 & 2 &   5 days \\
2017-08-25 & 0.2461 &  7 & 2018-12-28 & 29.96 &  7 &  9 & 4 &   7 days \\
2017-08-24 & 0.2398 &  8 & 2018-02-09 & 29.06 &  8 &  9 & 5 &   8 days \\
2018-12-19 & 0.2391 &  9 & 2018-12-20 & 28.38 &  9 &  9 & 7 &   9 days \\
2018-02-05 & 0.2317 & 10 & 2016-02-11 & 28.14 & 10 &  3 & 1 & 140 days \\
\bottomrule
\end{tabular*}

\end{center}

\end{document}

在此处输入图片描述

需要进一步减少列宽:删除重复信息总是好的。感谢 Fran 的建议。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{multirow}
\usepackage{booktabs}

\title{xxxxx}
\author{xxxxxxxx }
\date{July 2019}
\begin{document}
\maketitle

\begin{center}
%\small
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ccccccccc@{}}
\toprule
\multicolumn{3}{@{}c}{Metric} & \multicolumn{3}{c}{VIX} & \multicolumn{2}{c}{rank} &
\smash{\begin{tabular}[t]{c} time $\delta$ \\ (days) \end{tabular}} \\
\cmidrule{1-3} \cmidrule{4-6} \cmidrule{7-8}
Date & Values &  Rank & Date & Values & Rank & metric & vix\\
\midrule
2017-06-20 & 0.3217 &  1 & 2018-02-05 & 37.32 &  1 & 10 & 1 &   0 \\
2016-12-19 & 0.3194 &  2 & 2018-12-24 & 36.07 &  2 & 10 & 6 &   1 \\
2017-09-18 & 0.3193 &  3 & 2018-02-08 & 33.46 &  3 &  9 & 9 &   1 \\
2016-12-27 & 0.2993 &  4 & 2018-12-26 & 30.41 &  4 & 10 & 3 &   3 \\
2017-06-05 & 0.2874 &  5 & 2018-12-27 & 30.41 &  5 & 10 & 8 &   4 \\
2017-05-23 & 0.2708 &  6 & 2018-02-06 & 29.98 &  6 &  9 & 2 &   5 \\
2017-08-25 & 0.2461 &  7 & 2018-12-28 & 29.96 &  7 &  9 & 4 &   7 \\
2017-08-24 & 0.2398 &  8 & 2018-02-09 & 29.06 &  8 &  9 & 5 &   8 \\
2018-12-19 & 0.2391 &  9 & 2018-12-20 & 28.38 &  9 &  9 & 7 &   9 \\
2018-02-05 & 0.2317 & 10 & 2016-02-11 & 28.14 & 10 &  3 & 1 & 140 \\
\bottomrule
\end{tabular*}

\end{center}

\end{document}

在此处输入图片描述

相关内容