8

I'm getting a to-me strange behavior when using scrartcl and subcaption. In particular, numbering is doubled for each table with the default option captions=tableheading. Here's an image (code at the end) with captions=tablesignature, notice how the counter only increase by one if the caption is below the table (I'm not suggesting any causality here): KOMA-Script, subcation and captions=tablesignature

Here's the output when I switch to captions=tableheading: KOMA-Script, subcation and captions=tableheading

I looked through the manuals of KOMA-Script, caption and subcaption but I didn't find anything that would suggest this behavior. Is it a feature? It's appreciate any hint on why this occur.

Here's the source

% bug(?), default setting for captions
\documentclass[captions=tablesignature]{scrartcl} %% same with scrreprt
% \documentclass[captions=tableheading]{scrartcl} % no bug
\usepackage{subcaption}
\setkomafont{caption}{\LARGE}
\begin{document}
\begin{table}
\caption{table one\label{tab:ind}}
\begin{subtable}[t]{.45\linewidth}
\caption{expenses}
\centering
\begin{tabular}{llr}
\hline
& Konto & \textsc{dkk}\\
\hline
& gnus & 3000\\
\hline
\textsc{(i)} & gnash & 146000\\
\hline
\end{tabular}
\end{subtable}
\qquad
\begin{subtable}[t]{.45\linewidth}
\caption{income}
\centering
\begin{tabular}{llr}
\hline
& Konto & \textsc{dkk}\\
\hline
& gnog & 100000\\
\hline
\textsc{(ii)} & gnus & 100000\\
\hline
\end{tabular}
\end{subtable}
\end{table}

\begin{table}
%% \caption{table two\label{tab:ind2}}
\begin{subtable}[t]{.45\linewidth}
\caption{expenses}
\centering
\begin{tabular}{llr}
\hline
& Konto & \textsc{dkk}\\
\hline
& gnus & 3000\\
\hline
\textsc{(i)} & gnash & 146000\\
\hline
\end{tabular}
\end{subtable}
\qquad
\begin{subtable}[t]{.45\linewidth}
\caption{income}
\centering
\begin{tabular}{llr}
\hline
& Konto & \textsc{dkk}\\
\hline
& gnog & 100000\\
\hline
\textsc{(ii)} & gnus & 100000\\
\hline
\end{tabular}
\end{subtable}
%% could also use \captionbelow
\caption{table two\label{tab:ind2}}
\end{table}

\begin{table}
\caption{table three}
\begin{subtable}[t]{.45\linewidth}
\caption{expenses}
\centering
\begin{tabular}{llr}
\hline
& Konto & \textsc{dkk}\\
\hline
& gnog & 370000\\
\hline
\textsc{(iii)} & gug & 552000\\
\hline
\end{tabular}
\end{subtable}
\qquad
\begin{subtable}[t]{.45\linewidth}
\caption{income\label{tab:ind3}}
\begin{tabular}{llr}
\hline
& Konto & \textsc{dkk}\\
\hline
& gmag & 100000\\
& glog & 218000\\
\hline
\textsc{(iv)} & gnus & 318000\\
\hline
\end{tabular}
\end{subtable}
\end{table}
\end{document}
  • I am not able to reproduce the error on either settings. which version are you using? – ArTourter May 22 '13 at 10:32
  • I use the latest version from TeX Live 2012. For caption cat-version: 3.3 (2013-02-03) and for KOMA-Script cat-version: 3.11b. Now that you point it out there is a newer version of caption on CTAN which I haven't tried since TeX Live 2012 froze and TeX Live 2013 isn't released. IS that the version you're using? – Rasmus May 22 '13 at 10:54
  • 1
    I can reproduce the wrong counting with MiKTeX 2.9 (3.1415926-2.4-1.40.13), scrartcl.cls (2012/07/29 v3.11b), caption.sty (2013/04/14 v3.3-73) and subcaption.sty (2013/02/03 v1.1-62). – Mensch May 22 '13 at 11:30
  • Perhaps you found a bug in one of the three packages. Would you mind to report it to komascript.de ? You can report in English. – Keks Dose May 22 '13 at 16:51
8

It's not a bug, the behavior is IMHO correct. Since a table can contain more than one \caption, the caption package uses hints like captions=tablesignature to determine where it has to increase the table counter.

So when you use code like

\documentclass[captions=tablesignature]{scrartcl}
...
\begin{table}
% Table 1:
\caption{table one\label{tab:ind}}
% Table 2:
\begin{subtable}[t]{.45\linewidth}
\caption{expenses}
...
\end{subtable}
\qquad
\begin{subtable}[t]{.45\linewidth}
\caption{income}
...
\end{subtable}
\end{table}

the caption package sees two tables here: The one titled "table one" which ends directly after the \caption (and has no content, but the caption package does not know this!), since captions=tablesignature is specified. Afterwards a second table (without caption) is following. The table counter will be incremented for the second table because of the sub-tables. (A \ref to the first sub-table will therefore lead to "2a".)

If you really want to have a top caption even if captions=tablesignature is set, you have to give the caption package a hint about that, for example by using \captionabove instead of \caption:

\documentclass[captions=tablesignature]{scrartcl}
...
\begin{table}
% Table 1:
\captionabove{table one\label{tab:ind}}
\begin{subtable}[t]{.45\linewidth}
\caption{expenses}
...
\end{subtable}
\qquad
\begin{subtable}[t]{.45\linewidth}
\caption{income}
...
\end{subtable}
\end{table}

(A \ref to the first sub-table will lead to "1a" here, since the caption package knows that the content follows the \caption since \captionabove is used.)

But why the output is as intended when using the article class instead? This is not really true, if you use the article class and load the caption package with option tableposition=b, you will get the same behavior. My fault, I will add a section about the relationship of the position option with the figure and table counter in the next version of the documentation.

And why is there "no bug" if captions=tableheading is used instead? Well, this seems to be a real bug to me since "Table 2: table two" should be "Table 3: table two" here, I need to examine this...

  • Thanks for the explanation. Note though, that captions=tablesignature is the default so I wasn't really trying to cheat it. I was just trying to a subtable configuration a la subfigure (in general I prefer subcaption). So would you advice a different approach to setting up a one-table-two-subtabulars kind of thing? – Rasmus May 22 '13 at 22:57
  • @Rasmus The stuff about "cheating" should be fun, so no, of course you did not try to cheat. (My humor does not seem to be compatible, so I just removed that in my answer.) It's not clear to me what the remaining problem is. Setting captions=tableheading and putting \caption at the top of the table should not only help about the countering but also should fix the spacing between \caption and content (since KOMA-Script uses this setting for using the correct spacing here). – Axel Sommerfeldt May 23 '13 at 8:15

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.