# Avoiding non-centered caption on ctable with float

I try to put my floats under the control of KOMA-Script using \restylefloat and KOMA's komaabove and komabelow. This works, but gives undesired side effects with ctable. The tables are centered but their captions are flush left.

How can I correct this?

Edit: I want both the caption and the table to be centered.

MWE:

\documentclass{scrartcl}
\usepackage{float}
\usepackage{ctable}
\floatstyle{komaabove}
\restylefloat{table}
\begin{document}
\ctable[table,caption={Test test test test testtest test test testtest},
label=tbl:things]%
{>{}p{.4\linewidth}@{}c}{}{%
\FL Part           & done
\ML Title          & yes
\NN Intro          & yes
\NN Solution       & yes
\NN Implementation & yes
\NN Evaluation     & no
\NN Related Work   & no
\NN Conclusion     & yes
\LL
}
\end{document}


Edit2: I found this is not KOMA-Script specific, this non-KOMA MWE exihibits similar behavior

\documentclass{article}
\usepackage{float}
\usepackage{ctable}
\floatstyle{ruled}
\restylefloat{table}
\begin{document}
\ctable[table,caption={Test test test test testtest test test testtest},
label=tbl:things]%
{>{}p{.4\linewidth}@{}c}{}{%
\FL Part           & done
\ML Title          & yes
\NN Intro          & yes
\NN Solution       & yes
\NN Implementation & yes
\NN Evaluation     & no
\NN Related Work   & no
\NN Conclusion     & yes
\LL
}
\end{document}


Please insert code using the brackets symbol, otherwise we can't copy it properly.

If you wish to align caption and table, just add "left":

\documentclass{scrartcl}
\usepackage{float}
\usepackage{ctable}
\floatstyle{komaabove}
\restylefloat{table}
\begin{document}
\ctable[table,caption={Test test test test testtest test test
testtest}, label=tbl:things, left]%
{>{}p{.4\linewidth}@{}c}{} {%
\FL Part & done
\ML Title & yes
\NN Intro  & yes
\NN Solution & yes
\NN Implementation & yes
\NN Evaluation & no
\NN Related Work & no
\NN Conclusion & yes
\LL
}
\end{document}


EDIT

I guess there is a bug somewhere, but whether it is in ctable or somewhere in KOMAscript, who knows? Due to this, you can't get the table and the caption centered.

Maybe -- and if you really are convinced to need ctable -- you ask the maintainer of KOMAscript: www.komascript.de

• Thanks for the formatting suggestion. I clarified my question. I want all things centered here. Jul 30 '14 at 10:14
• Then you are in trouble. But this isn't worth the time and effort, simply swap ctable against a tabular environment and go ahead. Jul 30 '14 at 10:35
• Well, I am making a class and do not want to restrict my users too much. Jul 30 '14 at 10:57
• Asking the KOMA maintainer turned up that it is not a KOMA problem at all. It seems to be a float/ctable bug. Jul 31 '14 at 8:23
• Note: I accept this as this post first indicated a non-user-fixable bug. Aug 1 '14 at 15:42

With threeparttable and booktabs it works flawlessly

\documentclass{scrartcl}
\usepackage{threeparttable,booktabs,array}

\begin{document}

\begin{table}
\centering

\begin{threeparttable}
\caption{Test test test test testtest test test testtest}
\label{tbl:things}
\begin{tabular}{p{.4\linewidth}@{}c}
\toprule
Part           & done \\
\midrule
Title          & yes \\
Intro          & yes \\
Solution       & yes \\
Implementation & yes \\
Evaluation     & no  \\
Related Work   & no  \\
Conclusion     & yes \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}

\end{document}


• This is good to know! Since I write a wrapper class, I however have to care for the case when it is actually a ctable. Any idea? Jul 30 '14 at 21:35
• @Tobias Sorry, no; I've never considered ctable among my preferred packages. Jul 30 '14 at 21:54
• Me no longer, I think... Jul 31 '14 at 18:07

I get the desired result if I use the KOMA-option captions=tableheading and remove both \floatstyle{komaabove} and \restylefloat{table} and also \usepackage{float}.

\documentclass[captions=tableheading]{scrartcl}
\usepackage{ctable}

\begin{document}
\ctable[
table,
caption={Test test test test testtest test test testtest},
label=tbl:things
]{>{}p{.4\linewidth}@{}c}{} {%
\FL Part & done
\ML Title & yes
\NN Intro  & yes
\NN Solution & yes
\NN Implementation & yes
\NN Evaluation & no
\NN Related Work & no
\NN Conclusion & yes
\LL
}
\end{document}


Result:

• Yes, this is correct. I meant question however specifically for when I use \restylefloat. The reason is that (since I write a class) I want my users to be able to use normal tables as well as ctables, and, in both cases, the caption end up above the table, regardless of whether the \caption is (in the code) given before or after the tabular. Jul 30 '14 at 11:25