# Two labels in one caption possible?

In a lot of journals it is common to have single digit figure numbers and denote parts in the figures as (a), (b), and so on. I wanted to use a similar style. After reading the documentation to the caption package and the cleveref package I did not find anything similar. I do not want to break up the picture in two parts and use subfigure with two captions but keep it all in one.

Is there an easy way to realize this? My example looks as follows without the correct references:

\documentclass{scrbook}

\usepackage{caption}
\usepackage{cleveref}

\begin{document}

\begin{figure}
\centering
a \rule{10pt}{10pt} \hspace{1cm} b \rule{15pt}{15pt}
\caption{Common text here. \label{part_a}\textbf{(a)} Description of a. \label{part_b}\textbf{(b)} Description of b. }
\end{figure}

This should read fig. 0.1a and fig. 0.1b but it is only \cref{part_a} and \cref{part_b}.

\end{document}


This gives this output:

-
I would really not recommend this. Not only you need to introduce two labels hence referring to words instead of pictures and artificial a and b characters in the picture , but also you would encounter many difficulties when dealing with the publication office. It's quite easy to use subcaption (not subfigure which is obsolete now) package, is there any particular reason why you don't want to use it? –  percusse Jul 22 '12 at 14:19
@percusse: Science, Nature, Physical Review Letters use this style, so I do not think it is so uncommon for scientific journals. Subcaptions take up a lot of space compared to just writing a single caption. I agree that the a and b characters are artificial but they also appear with a subcaption, just not in the picture itself. –  Alexander Jul 22 '12 at 14:43
I've made up an answer without the extra captions. –  percusse Jul 22 '12 at 15:10

A small addition to Mico's answer with \phantomcaption option:

\documentclass{article}
\usepackage{mwe}            %For dummy images
\usepackage{subcaption}
\usepackage{cleveref}
\crefdefaultlabelformat{\thesection.#2#1#3}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.4\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{example-image-a}
\phantomcaption
\label{part_a}
\end{subfigure}
\hspace{1cm}
\begin{subfigure}{0.4\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{example-image-b}
\phantomcaption
\label{part_b}
\end{subfigure}
\caption{Common caption here \textbf{(a)} On left \textbf{(b)} On right} \label{fig-overall}
\end{figure}

This should read fig.\ 0.1a and fig.\ 0.1b, and indeed it now reads \cref{part_a} and \cref{part_b}.
\end{document}


-
Note that scrbook doesn't need the \crefdefaultlabelformat command. I've forgot and used the standard article class. –  percusse Jul 22 '12 at 15:12
That is very nice and exactly what I had in mind, thank you very much. –  Alexander Jul 22 '12 at 15:29

A good way to proceed, I believe, is to use the subcaption package and its subfigure environment. That way, you can assign labels to each subfigure (as well as, of course, to the entire figure).

Note that you need to assign a width to each subfigure environment. This could either be an absolute length, such as 3cm, or a fraction of a document variable such as \textwidth, as I've chosen to do in the MWE below. If you two subfigures and want to maximize their possible size, you could give them both a width of ca 0.48\textwidth, and use the command \hspace{\fill} to spread them apart. (You shouldn't use 0.5\textwidth as there's some "overhead" whitespace.)

\documentclass{scrbook}
\usepackage{caption,subcaption}
\usepackage{cleveref}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.3\textwidth}
\centering
a \rule{10pt}{10pt}
\caption{Description of a.} \label{part_a}
\end{subfigure}
\hspace{1cm}
\begin{subfigure}{0.4\textwidth}
\centering
b \rule{15pt}{15pt}
\caption{Description of b. } \label{part_b}
\end{subfigure}
\caption{Common caption here} \label{fig-overall}
\end{figure}

This should read fig.\ 0.1a and fig.\ 0.1b, and indeed it now reads
\cref{part_a} and \cref{part_b}.

\end{document}


-
I wanted to avoid the two extra captions as this takes up extra space and looks strange if the descriptions differ significantly in length. Is this also possible with the subcaption package? –  Alexander Jul 22 '12 at 14:47