横向表格不会位于页面的中心

横向表格不会位于页面的中心

我阅读了所有关于这个问题和答案,但它们只会让我更加困惑。我希望我的表格位于横向页面的中央,但它总是在左侧对齐。有没有办法让它出现在中间?我将文档序言中的包和命令包括在内,以防它们引起冲突。最小示例:

\documentclass{amsart}
\usepackage{relsize, fullpage, url, amsmath, amssymb, graphicx}
\usepackage{lscape, afterpage}
\setlength{\parindent}{0cm}

\begin{document}
Some text

\afterpage{

\begin{landscape}
\begin{table}[h] %[!h]
\centering
\begin{tabular}{l|cccccccccccccccccccccc}
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
\end{tabular}
\caption{I want this table to be in the middle of the page, above the 2. It would also be nice if there was more vertical space before this caption.}
\end{table}
\end{landscape}

}

\end{document}

答案1

\vfill在环境中添加一对landscape。我添加了threeparttable,以便表格标题不会比表格宽太多,并在表格和标题之间留出更多间距:

\documentclass{amsart}
\usepackage{relsize, fullpage, url, amsmath, amssymb, graphicx, array}
\usepackage{lscape, afterpage}
\setlength{\parindent}{0cm}
\usepackage{threeparttable}

\begin{document}
Some text

\afterpage{

\begin{landscape}
\mbox{}\vfill
\begin{table}[!h]
\begin{threeparttable}
\begin{tabular}{l|*{22}{c}}
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
& 0& 1 &2& 3&4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20 &21\\
\end{tabular}
\vskip 2ex
\caption{I want this table to be in the middle of the page, above the 2. It would also be nice if there was more vertical space before this caption.}
\end{threeparttable}
\end{table}
\vfill
\end{landscape}
}

\end{document} 

在此处输入图片描述

相关内容