我有一个 ctable,它的宽度大于 textwidth,我想让它在页面上居中。我尝试了以下解决方案:这里但它们似乎都不适用于 ctable。以下是我迄今为止尝试过的
\documentclass[11pt,a4paper]{article}
\usepackage[top=50mm,bottom=25mm,left=20mm,right=15mm]{geometry}
\usepackage{ctable}
\begin{document}
%\centerline{
%\makebox[\textwidth][c]{
\noindent\ctable[]{llll}{}{
\toprule
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
\bottomrule
}
%}
\centerline{
\noindent\begin{tabular}{llll}
\toprule
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
\bottomrule
\end{tabular}}
\end{document}
当我删除第一个表中的一个注释时,我收到一个错误“不在外部模式中”,而第二个表看起来像预期的那样。
我怎样才能将第一个表格置于中央?
非常感谢。
答案1
文档解释了如何doinside=\hspace*{some negative length}
解决这个问题:
\documentclass[11pt,a4paper]{article}
\usepackage[top=50mm, bottom=25mm, left=20mm, right=15mm, showframe]{geometry}
\usepackage{ctable}
\usepackage{changepage}
\begin{document}
\ctable[doinside = \hspace*{-7mm}]{llll}{}{
\toprule
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
\bottomrule
}
\centerline{
\noindent\begin{tabular}{llll}
\toprule
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
long, long, long, long text & long, long, long, long text & long, long, long, long text & long, long, long, long text \\
\bottomrule
\end{tabular}}
\end{document}