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've used subfloat to include subfigures, with their relevant labels but with empty captions. what I'm going to do is to reference these figures with \subref in the main caption of the figure. But what I get is only ?? signs in the caption [main caption]. I can't figure out what's the problem. this is what I have:

\begin{figure}
\centering
\subfloat[][]
{
\includegraphics[scale=0.55]{signal}
\label{signal_model}
}
\subfloat[][]
{
\includegraphics[scale=0.55]{amplitude}
\label{amplitude_mod}
}
\caption{phase noise variability: \subref{signal model} some text \subref{amplitude_mod} some other text}
\end{figure}
share|improve this question
1  
You need a subcaption nevertheless, even if empty, so that the subfigure is at least labelled. –  JLDiaz Jul 8 '12 at 16:53
1  
can you turn your snippet into a complete MWE? –  cmhughes Jul 8 '12 at 17:13
1  
Actually I want to have labeled subfigures, i.e. to have (a) (b) (c) etc. below each subfigure without sub-captions. but I want to cite or refer them in the main caption of the figure (I thought it's possible with '\subref') –  pasha Jul 8 '12 at 17:24
    
I got the answer, but I think something missing with subcaption package: "The subcaption package was updated to version 1.1. It got a new option for selecting a format used by \subref, and a new command called \phantomsubcaption for referencing a sub-figure without caption. Furthermore the subcaption package documentation was enhanced regarding references." –  pasha Jul 8 '12 at 17:49
    
If you are really using the subcaption package (and not the subfig one) please use \subcaptionbox instead of \subfloat and put the \label inside the caption text, not inside the sub-figure body. –  Axel Sommerfeldt Jul 9 '12 at 6:45
add comment

1 Answer

up vote 6 down vote accepted

You need to \protect the \subref command in the caption:

\caption{Phase noise variability: \protect\subref{signal_model} some text 
  \protect\subref{amplitude_mod} some other text}

MWE:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}

\begin{figure}
\centering

\subfloat[][]{\includegraphics[scale=0.55]{example-image-a}\label{signal_model}}
\subfloat[][]{\includegraphics[scale=0.55]{example-image-b}\label{amplitude_mod}}

\caption{Phase noise variability: \protect\subref{signal_model} some text 
  \protect\subref{amplitude_mod} some other text}

\end{figure}
\end{document}

enter image description here

share|improve this answer
    
+1 and BIG thanks for this .. I was struggling with this (my documentclass prohibits use of caption, and therefore subcaption, where for some reason \subref does not need \protect) –  user1207217 Mar 14 '13 at 16:53
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.