I've just read questions:
- Changing the subfigure caption by removing brackets & font of the subcaption
- Adding parentheses around subfig references
- How to put two images next to each other with a) and b) labels?
- subcaption: how to redefine default separator between figure and subfigure number in \ref's?
But i still haven't found answer.
Minimal example:
\documentclass{article}
\usepackage{caption}
\usepackage{subfig}
\usepackage{hyperref}
\begin{document}
\begin{figure}
\centering
\subfloat[subfigure A]{\rule{100pt}{50pt}
\label{fig:subfig-a}
}
\subfloat[subfigure B]{\rule{100pt}{50pt}
\label{fig:subfig-b}
}
\subfloat[subfigure C]{\rule{100pt}{50pt}
\label{fig:subfig-c}
}
\caption{Subfigures:}
\label{fig:figures}
\end{figure}
See Figures~\ref{fig:subfig-a}, \ref{fig:subfig-b} and~\ref{fig:subfig-c}.
\end{document}
Output looks like:
What i need:
- Subcaptions should be
a)
,b)
,c)
without caption text instead of(a)
,(b)
and(c)
with caption text. - Refs to subfigures should be
1,\,a
instead1a
. - Figure caption should consist of prefix (
Fig.~1.
), separation space, general caption (Subfigures:
) and sub-captions of subfigures (for example,(a) --- subfigure A; (b) --- subfigure B; (c) --- subfigure C
).
What i tried:
Set caption
\captionsetup[figure]{labelsep=period,justification=centering,singlelinecheck=off}
Set ref format
\makeatletter
\def\thesubfigure{\textit{\alph{subfigure}}}
\providecommand\thefigsubsep{,\,}
\def\p@subfigure{\@nameuse{thefigure}\thefigsubsep}
\makeatother
So i've got:
\documentclass{article}
\usepackage{caption}
\usepackage{subfig}
\usepackage{hyperref}
\captionsetup[figure]{labelsep=period,justification=centering,singlelinecheck=off}
\makeatletter
\def\thesubfigure{\textit{\alph{subfigure}}}
\providecommand\thefigsubsep{,\,}
\def\p@subfigure{\@nameuse{thefigure}\thefigsubsep}
\makeatother
\begin{document}
\begin{figure}
\centering
\subfloat[subfigure A]{\rule{100pt}{50pt}
\label{fig:subfig-a}
}
\subfloat[subfigure B]{\rule{100pt}{50pt}
\label{fig:subfig-b}
}
\subfloat[subfigure C]{\rule{100pt}{50pt}
\label{fig:subfig-c}
}
\caption{Subfigures:}
\label{fig:figures}
\end{figure}
See Figures~\ref{fig:subfig-a}, \ref{fig:subfig-b} and~\ref{fig:subfig-c}.
\end{document}
It looks like that:
It is still needed to correct format of sub-captions and main caption.
Also, why there are different spaces between subfigures?
Best Answer
I don't think using three different formats for the numbering of subfigures is good. Anyway, here it is:
The
\makexcaption
command has also an optional argument for text going before the list of subcaptions, sowould produce
Beware of unprotected end-of-lines in the arguments of
\subfloat
, that are the cause of your spurious spaces.