Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the IEEEtran class, and I need to use the subfig package with the caption=false option. However, when I use the package like this

\documentclass{article}
% Remove the caption=false and this work as intended
\usepackage[font=footnotesize,caption=false]{subfig}

\begin{document}

\begin{table}
\caption{My tables}
\centering
\begin{tabular}{cc}
\subfloat[\label{tab:1}]{%
\begin{tabular}{lc}
\hline\noalign{\smallskip}
a & b\\
\hline\noalign{\smallskip}
foo & bar\\\hline\noalign{\smallskip}
\end{tabular}%
}&%
\subfloat[]{%
\begin{tabular}{lc}
\hline\noalign{\smallskip}
a & b\\
\hline\noalign{\smallskip}
foo & bar\\\hline\noalign{\smallskip}
\end{tabular}%
\label{tab:2}
}%subfloat
\end{tabular}
\end{table}

Testing a reference to \ref{tab:1} and \ref{tab:2}.        
\end{document}

I obtain the reference to 2a and 2b instead of 1a and 1b. However, if I remove the caption=false everything works fine. But, I'm require to use that part, so the IEEEtran class can put the correct formatting to the captions.

What solution do I have? I tried to move the \label around, as you can see in both cases, but both have the same result. Am I missing something here?

share|improve this question
    
The problem is that if I add caption (that is the same as removing the caption=false--I think) removes the special format that the IEEEtran uses. Note that I didn't put IEEEtran in the document class, but if you use it you will see the difference. –  adn Jun 13 '12 at 5:31
    
Well, it keeps the roman number style. However, IEEEtran normally uses text all caps, but when using caption explicitly the words are normal (not capitalized). –  adn Jun 13 '12 at 6:07
add comment

1 Answer 1

up vote 2 down vote accepted

A dirty trick is to load the caption package before the document class. That way the subfig package is happy, and the document class settings that format captions overwrite those of the caption package.

\RequirePackage{caption}
\let\abovecaptionskip\relax
\let\belowcaptionskip\relax
\documentclass{IEEEtran}
\usepackage{subfig}
\begin{document}
\begin{table}
\caption{My tables}
\label{table1}
\centering
\begin{tabular}{cc}
\subfloat[]{%
\begin{tabular}{lc}
\hline\noalign{\smallskip}
a & b\\
\hline\noalign{\smallskip}
foo & bar\\\hline\noalign{\smallskip}
\end{tabular}%
\label{tab:1}
}&%
\subfloat[]{%
\begin{tabular}{lc}
\hline\noalign{\smallskip}
a & b\\
\hline\noalign{\smallskip}
foo & bar\\\hline\noalign{\smallskip}
\end{tabular}%
\label{tab:2}
}%subfloat
\end{tabular}
\end{table}
Testing a reference to \ref{tab:1} and \ref{tab:2}.        
\end{document}
share|improve this answer
    
Dirty or not, that did the work. Is not advised to do this kind of loading before? or there is any drawback of doing it? –  adn Jun 14 '12 at 1:04
1  
In general, loading a package before the document class is not supported, and there can be side effects, but I don't think there are any in this case. –  Ian Thompson Jun 15 '12 at 10:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.