2

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.

ctable-koma-float-bug

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}
0
1

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

5
  • Thanks for the formatting suggestion. I clarified my question. I want all things centered here.
    – Tobias
    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.
    – Keks Dose
    Jul 30 '14 at 10:35
  • Well, I am making a class and do not want to restrict my users too much.
    – Tobias
    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.
    – Tobias
    Jul 31 '14 at 8:23
  • Note: I accept this as this post first indicated a non-user-fixable bug.
    – Tobias
    Aug 1 '14 at 15:42
2

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}

enter image description here

3
  • 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?
    – Tobias
    Jul 30 '14 at 21:35
  • @Tobias Sorry, no; I've never considered ctable among my preferred packages.
    – egreg
    Jul 30 '14 at 21:54
  • Me no longer, I think...
    – Tobias
    Jul 31 '14 at 18:07
2

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:

enter image description here

1
  • 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.
    – Tobias
    Jul 30 '14 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.