I know that tex.sx isn't the forum for bug-reporting, but I have a bit of a problem and I'm looking for a technical workaround. The following MWE produces odd labels:
\documentclass{article}
\usepackage{subcaption}
\usepackage{tabularx}
\begin{document}
\begin{figure*}
\begin{subfigure}{0.3\textwidth}
Figure 1a
\caption{Fig1a}
\label{fig:1a}
\end{subfigure}
\hfill
\begin{subfigure}{0.5\textwidth}
\begin{tabularx}{0.5\textwidth}{r}
Figure 1b
\end{tabularx}
\caption{Fig1b}
\label{fig:1b}
\end{subfigure}
\caption{Fig1}
\label{fig:1}
\end{figure*}
\begin{figure}
Figure 2
\caption{Fig2 caption}
\label{fig:2}
\end{figure}
Figures \ref{fig:1a}, \ref{fig:1b}, and \ref{fig:1} should be 1a, 1b
and 1; Figure \ref{fig:2} should be 2.
\end{document}
Specifically, the last line of text reads, "Figures 1a, 1b, and 2 should be 1a, 1b and 1; Figure 3 should be 2." (I know that the example doesn't use any of tabularx's features; merely the use of the tabularx environment is enough to throw off the labels.) If I move the \caption{Fig1}\label{fig:1} above the subfigures, then I get the right numbering, but of course the caption is now in the wrong position.
According to \listfiles, I'm using
article.cls 2007/10/19 v1.4h
size10.clo 2007/10/19 v1.4h
subcaption.sty 2011/10/30 v1.1c
caption.sty 2011/11/10 v3.2e
caption3.sty 2011/11/01 v1.4a
keyval.sty 1999/03/16 v1.13
tabularx.sty 1999/01/07 v2.07
array.sty 2008/09/09 v2.4c
So my question is, what is tabularx doing that is not properly respecting the label counter, and how could I have deduced that myself?
tabularxtotabular*then everything seems to work the way you want – cmhughes Dec 16 '11 at 19:10subcaptionpackage (I can't explain yet). I will take a closer look at it tomorrow, and try to offer a fix ASAP. – Axel Sommerfeldt Dec 16 '11 at 19:16tabularx.sty, where, according to the documentation, all values of counters are saved globally while, as I understand,subcaptionstepsfigureonly locally inside asubfigureenvironment. – egreg Dec 16 '11 at 20:26