使用 \makebox 将宽超表格居中

使用 \makebox 将宽超表格居中

我正在尝试使用\makebox来居中一个宽\supertabular表,但如果该表跨越多页,LaTeX 会给出! Missing \endgroup inserted。关于如何居中宽表,您有什么想法supertable吗?

下面是一个示例,如果您删除一行以使表格适合一页,则效果很好:

\documentclass{article}

\usepackage{supertabular}

\begin{document}

\tablehead{
\hline \hline
1 & 2 & 3 & 4 & 5 \\ \hline
}

\tabletail{
\hline \hline
}

\noindent\makebox[\textwidth]{
\begin{supertabular}{ c c c c c c}
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
\end{supertabular}
}

\end{document}

此外,的标题supertable似乎有问题,包括\tablecaption的结果! Missing \endgroup inserted

\documentclass{article}

\usepackage{supertabular}

\begin{document}

\tablehead{
\hline \hline
1 & 2 & 3 & 4 & 5 \\ \hline
}

\tabletail{
\hline \hline
}

 \tablecaption{example table}

\noindent\makebox[\textwidth]{
\begin{supertabular}{ c c c c c c}
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
\end{supertabular}
}


\end{document}

答案1

您不想使用盒子,因为根据定义,它不会跨页。

通常情况下,您可以只使用\centering ,但首先您需要使文本宽度比内容更宽,这样居中才能起作用(对于任何居中,而不仅仅是表格,您都需要这样做)outdent这里的环境只是一个副本,quote但减少而不​​是增加边距,并添加\centering

在此处输入图片描述

\documentclass{article}

\usepackage{supertabular}

\newenvironment{outdent}
{\begin{list}{}{\leftmargin-2cm\rightmargin\leftmargin}\centering\item\relax}
{\end{list}\ignorespacesafterend}

\begin{document}

\tablehead{
\hline \hline
1 & 2 & 3 & 4 & 5 \\ \hline
}

\tabletail{
\hline \hline
}


\noindent X \dotfill X

\begin{outdent}

\noindent X \dotfill X


\begin{supertabular}{ c c c c c c }
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
AAAAAAAAAA & BBBBBBBBBB & DDDDDDDDDDD & EEEEEEEEEE & FFFFFFFFFF \\
\end{supertabular}
\end{outdent}

\end{document}

相关内容