1

I have a ctable which is wider than textwidth and I would like to center it on the page. I tried the solutions from here but none of them seems to work for a ctable. Here is what I tried so far

\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}

As soon as I remove one of the comments in the first table I get an error "not in outer par mode" whereas the second table looks like expected.

How can I center also the first table?

Many thanks.

1 Answers1

1

The documentation explains you have the doinside=\hspace*{some negative length} to solve this problem:

\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} 

enter image description here

Bernard
  • 271,350