# \label does not work

am looking help for two things. (1) I would like to write the text as 'In Fig. (1) and in Fig. (2a)', for which the TEX is written as follows:

Shown in Fig. (\ref{fig:main}) and shown in Fig. (\ref{fig:2})'

\begin{figure*}[t]
\centering
\label{fig:main} \caption{main}

\subfloat[ 1]{\label{fig:1}\includegraphics[width=3.5cm]{11}}
\subfloat[ 2]{\label{fig:2}\includegraphics[width=4.1cm]{22}}
\subfloat[ 3]{\label{fig:3}\includegraphics[width=4.1cm]{33}}
\subfloat[ 4]{\label{fig:4}\includegraphics[width=4.1cm]{44}}

\subfloat[ 5]{\label{fig:5}\includegraphics[width=4.1cm]{55}}
\subfloat[ 6]{\label{fig:6}\includegraphics[width=4.1cm]{66}}
\subfloat[ 7]{\label{fig:7}\includegraphics[width=4.1cm]{77}}
\subfloat[ 8]{\label{fig:8}\includegraphics[width=4.1cm]{88}}

\end{figure*}


But the output does not link to Fig. (2a).

(2) Also, with this code the captions are above the image, how can we move them below the image, something like this:

    11      22      33      44
(a) 1   (b) 2   (c) 3   (d) 4
Fig. (1) main


where, 11, 22, ...so on are the images.

Packages used:

\usepackage{caption}
\usepackage{subcaption}


Any solution? Or Any other way of working on it, where labels for individual images can also be referred? Thank you.

• In floats \label must always be after \caption. Feb 9 '14 at 4:42
• Could you please elaborate, I tried that but does not work. Deleting .log file too does not help.
– dbs
Feb 9 '14 at 4:45
• You're using the syntax for the package subfig, while you load subcaption. Feb 9 '14 at 10:12

Inside floats, always place \label after \caption (in the figure you had them the other way round). Since you are using \ref{fig:2} which has the string used to label the second subfigure, you are hyperlinking to the second subfigure, not to the first one; to hyperlink the first subfigure you need \ref{fig:1} (by the way, try to pick more describtive strings for your references).

Use

\captionsetup[subfloat]{position=bottom}


to have the subcaptions below the subfigures.

I added some \hfills to give some spacing between the subfigures:

\documentclass[twocolumn]{article}
\usepackage{subfig}
\usepackage[demo]{graphicx}
\usepackage{hyperref}

\captionsetup[subfloat]{position=bottom}

\begin{document}
Shown in Fig.~(\ref{fig:main}) and shown in Fig.~\ref{fig:2}
\begin{figure*}[t]
\centering
\caption{main}\label{fig:main}
\subfloat[ 1]{\label{fig:1}\includegraphics[width=3.5cm]{11}}\hfill
\subfloat[ 2\label{fig:2}]{\includegraphics[width=4.1cm]{22}}\hfill
\subfloat[ 3]{\label{fig:3}\includegraphics[width=4.1cm]{33}}\hfill
\subfloat[ 4]{\label{fig:4}\includegraphics[width=4.1cm]{44}}

\subfloat[ 5]{\label{fig:5}\includegraphics[width=4.1cm]{55}}\hfill
\subfloat[ 6]{\label{fig:6}\includegraphics[width=4.1cm]{66}}\hfill
\subfloat[ 7]{\label{fig:7}\includegraphics[width=4.1cm]{77}}\hfill
\subfloat[ 8]{\label{fig:8}\includegraphics[width=4.1cm]{88}}

\end{figure*}

\end{document}

• I would even say inside the caption's argument (\caption{\label{…}main}). Feb 9 '14 at 10:08