# Split one label into many and append with a, b, c, etc

I am making one table into two (or more) and would like them to have the same label number for these two tables, but append them with an "a" or "b" to differentiate them. Also, I would like to be able to refer to them in the text by just the number, not as number.a and number.b. And I would like to retain LaTeX's assume table numbering.

For example, a table that LaTeX would later number as 8 is too big to fit on one page, so I split it up manually and want it to be automatically labeled 8a and 8b and referred to as 8 in the text. Does this exist? I am sure that I'm searching the wrong keywords, again.

The back story is that I create tables with scripts in R. I looked for a widetable package here yesterday and there are some good solutions, but not for the scripts I already have (although I'd like to later add them). Plus it sounds like a good skill to have. Thanks!

-

The ccaption package allows for "continuation captions". So to implement what you want, you could do the following (adapted from the ccaption documentation.)

# Update

Since you wanted the first table to have a letter suffix as well, I've changed the code to allow two commands: \splittablecaption and \splittablecaption*. This also removes the need to manually reset the subtable caption counter. Use the starred version for the first in the series, and the unstarred version for any subsequent ones.

\documentclass{article}
\usepackage{ccaption}
\newcounter{splittab}
\renewcommand{\thesplittab}{\alph{splittab}}
\makeatletter
\newcommand{\splittablecaption}{\@ifstar\splittablecaptionstar\splittablecaptionplain}
\makeatother
\newcommand{\splittablecaptionplain}[1]{\stepcounter{splittab}\captiondelim{\thesplittab: }\contcaption{#1}}
\newcommand{\splittablecaptionstar}[1]{\setcounter{splittab}{0}\stepcounter{splittab}\captiondelim{\thesplittab: }\caption{#1}}

% Usage: for a split table, use \splittablecaption*{} for the initial caption
% and \splittablecaption{} for the subsequent captions
% There is no need to reset the counters manually, as this is done inside the
% starred version of the \splittablecaption command.

\begin{document}

\begin{table} \centering \splittablecaption*{A multi-part table} \label{tab:m}
\begin{tabular}{lc} \hline
just a single line & 1 \\ \end{tabular} \end{table}
\begin{table} \centering \splittablecaption{Continued} \begin{tabular}{lc} \hline
just a single line & 2 \\ \end{tabular} \end{table}
\begin{table} \centering \splittablecaption{Concluded} \begin{tabular}{lc} \hline
just a single line & 3 \\ \end{tabular} \end{table}

\begin{table} \centering \splittablecaption*{A multi-part table} \label{tab:m}
\begin{tabular}{lc} \hline
just a single line & 1 \\ \end{tabular} \end{table}
\begin{table} \centering \splittablecaption{Continued} \begin{tabular}{lc} \hline
just a single line & 2 \\ \end{tabular} \end{table}
\begin{table} \centering \splittablecaption{Concluded} \begin{tabular}{lc} \hline
just a single line & 3 \\ \end{tabular} \end{table}

\end{document}

-
Alan FTW, again. Is there a way I can make the tables 1a, 1b, 1c instead of 1, 1a, 1b? In my tinkering I can't figure it out. Thanks! –  Richard Herron Jan 26 '11 at 19:50
@Richard I've changed the code to reflect this; it's actually nicer now. –  Alan Munn Jan 26 '11 at 20:21
I don't understand what's happened to your code blocks. I just went to edit your answer to put them in but the preview showed the code properly as code. That's bizarre. –  Andrew Stacey Jan 26 '11 at 21:19
@Alan -- Perfect! Thanks so much! I always forget that latex is also a programming language. –  Richard Herron Jan 26 '11 at 21:20
@Andrew no it won't become CW unless I edit it more than 10 times, or more than 5 different users edit it. –  Alan Munn Jan 26 '11 at 21:43

You can use the subcaption package in the following way, this package comes now shipped with the caption package, and has similar options.

\begin{table}
\subcaptionbox{\label{t1a} Caption for table a}%
{\begin{tabular}<spec>
<things here>
\end{tabular}}
\subcaptionbox{\label{t1b} Caption for table b}%
{\begin{tabular}<spec>
<things here>
\end{tabular}}
\subcaptionbox{\label{t1c} Caption for table c}%
{\begin{tabular}<spec>
<things here>
\end{tabular}}
\caption{\label{t} Caption for all tables
\end{table}


In this way, you can reference each table separately, or just the bunch of them with the label t.

-
I don't think this will work for Richard's purposes: his problem is that the subtables span multiple pages. The subfigure package is designed for multiple small figures or tables within a single float. –  Alan Munn Jan 26 '11 at 19:23
@Alan You are right. I forgot about the multiple pages part. –  fabikw Jan 26 '11 at 19:52