nag l2tabu caption/label checking versus \subcaptionbox

The nag package used with the l2tabu option complains when \label is used in a float without following a \caption. Unfortunately, it does not understand that the first argument of \subcaptionbox from the subcaption package is a caption. It therefore complains here when it should not:

\RequirePackage[l2tabu]{nag}
\documentclass{article}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\subcaptionbox{Subfigure caption\label{example}}{subfigure content}
\caption{Main figure caption}
\end{figure}
\end{document}


Sample output:

Package nag Warning: \label in float, but not after \caption on input line 7.


(Warning repeats four times.)

Any suggestions on how I can teach nag that \subcaptionbox creates a caption, and therefore that \label should be allowed here?

-
What about just ignoring the nag? :-) –  Mico Dec 14 '11 at 20:32
Unfortunately my coauthors tend to ignore all nags, including important ones, unless I put nag in abort mode. And if I do that, then ignoring these nags is no longer an option. –  Ben Liblit Dec 14 '11 at 23:38

One could use this very dirty hack to satisfy the nag package:

\RequirePackage[l2tabu]{nag}
\documentclass{article}
\usepackage{subcaption}

\makeatletter
\let\subcaptionboxORI\subcaptionbox
\renewcommand\subcaptionbox{%
\csname nag@hascaptiontrue\endcsname
\subcaptionboxORI}
\makeatother

\begin{document}
\begin{figure}
\subcaptionbox{Subfigure caption\label{example}}{subfigure content}
\caption{Main figure caption}
\end{figure}
\end{document}


Unfortunately this has an unwanted side-effect: The internal flag of the nag package will now be set by \subcaptionbox*, which does not create a reference for \label, too. This is wrong.

So a better solution is updating to version 3.3 of the caption package. This version is available now and it contains an adaption to the nag package.

-
I'll have to doublecheck, I vaguely recall defining \nag@captionprovider and \nag@labelprovider for that purpose. But you're correct, it won't distinguish the starred form. –  Ulrich Schwarz Dec 14 '11 at 22:04
@Ulrich: As soon as I have a solution I would like to send it to you for revision before uploading it to CTAN, is this ok? Furthermore I would like to solve the issue mentioned in section 4.1 of the nag doc. –  Axel Sommerfeldt Dec 15 '11 at 8:18
Sure. (He said, without checking what the problem of section 4.1 was :D ) –  Ulrich Schwarz Dec 15 '11 at 14:31
Since I'm just about fixing another bug (see tex.stackexchange.com/questions/38523/… ) the nag adaption will take some more time. Please hold the line... –  Axel Sommerfeldt Dec 19 '11 at 14:50
I'm deeply sorry for the long delay but finally v3.3 of the caption package which fixes this is available now. (Will edit my answer right now...) –  Axel Sommerfeldt Jan 9 '13 at 21:03