8

I have a latex document with a table that contains two subtables. When I reference the entire table it the numbering starts at 1, but when I reference one of the individual subtables the numbering starts with 0. Here is an example of my setup:

% In my preamble
\usepackage[tight,footnotesize]{subfigure}

% In my document section
\section{Section}
\subsection{Sub Section}

% My Table
\begin{table}[ht]
  \centering
  \subtable[Sub Table 1]
  {
    \label{tbl:sub-table-1}
    \centering
    \begin{tabular}{ l c }
      \textbf{A} & \textbf{B} \\
      1 & 2 \\
      2 & 3 \\
    \end{tabular}
  }
  \subtable[Sub Table 2]
  {
    \label{tbl:sub-table-2}
    \centering
    \begin{tabular}{ l c }
      \textbf{A} & \textbf{B} \\
      1 & 2 \\
      2 & 3 \\
    \end{tabular}
  }
  \caption{Sub Tables}
  \label{tbl:table-1}
\end{table}

This it my sub table \ref{tbl:sub-table-1}. % Comes out 0(a) instead of 1(a)
This is my table \ref{tbl:table-1}. % Comes out to 1 as you expect
  • 1
    Table captions are normally on top of the table, not below like figure captions. Move the \caption before the \subtables and look if it changes the numbering. – Martin Scharrer May 8 '11 at 22:23
  • ...otherwise take a look at the subfigure documentation, there is an option for sub-captions below the tables. (Something like "subfigcap", can't remember the name.) Once you have found and used it, the numbering should be correct. – user2574 May 9 '11 at 5:53
7

subfigure is an obsolete package and shouldn't be used anymore. You can use the subcaption package instead:

\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{subcaption}

\captionsetup[subtable]{font=footnotesize}

\begin{document}

\section{Section}
\subsection{Sub Section}

\begin{table}[ht]
  \begin{subtable}{.5\textwidth}
  \centering
  \subcaption{Subtable 1}
  \begin{tabular}{ l c }
    \textbf{A} & \textbf{B} \\
    1 & 2 \\
    2 & 3 \\
  \end{tabular}
  \label{tbl:sub-table-1}
  \end{subtable}  
  \begin{subtable}{.5\textwidth}
  \centering
  \subcaption{Subtable 2}
  \begin{tabular}{ l c }
    \textbf{A} & \textbf{B} \\
    1 & 2 \\
    2 & 3 \\
  \end{tabular}
  \label{tbl:sub-table-2}
  \end{subtable}  
  \caption{Sub Tables}
  \label{tbl:table-1}
\end{table}

This it my subtable~\ref{tbl:sub-table-1}.
This is my table~\ref{tbl:table-1}.

\end{document}

EDIT: I added the \captionsetup command (to change the font size for the subtable captions).

  • Nice. I didn't know about this package. The interface is much cleaner than the subfigure package. – Alan Munn May 8 '11 at 22:42
  • Ok I will give this a try I had not hear of this package either. When/if it works I will accept your answer. – Joe May 8 '11 at 22:48
  • Ok that worked, but I couldn't get the two to work together so I had to go change a lot of other subfigure's in my document. Does anyone happen to know how to center the caption text? – Joe May 9 '11 at 0:34
  • @Joe: the caption is centered by default if it fits in one line. Are you getting something different? – Gonzalo Medina May 9 '11 at 0:37
  • Yeah, it flowed over onto two lines but I was able to add a \centering to the caption and that got it centered. – Joe May 9 '11 at 4:11

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.