0

I have a figure with some subfloats. The figure es something like that:

enter image description here

I have not each subfloat separately, I have a single picture.

For linking the picture with the reference in text I used hyperref:

\documentclass{article}
\usepackage{subfig}
\usepackage{hyperref}
\usepackage{graphicx}

\begin{document}

Figures \ref{Fig1a} and \ref{Fig1b} are in Figure \ref{Fig1}

\begin{figure}[htb]
\centering
\subfloat{
\includegraphics{example-image}
\label{Fig1a}
}
\subfloat{\label{Fig1b}}
\caption{Image description:
\textbf{(a)}~figure 1a and 
\textbf{(b)}~figure 1b
}
\label{Fig1}
\end{figure}
\end{document}

When I click on Fig1a and Fig1 in the .pdf document inmediatelly I am conduced to the figure, but when I click on Fig1b I'm conduced to the caption. How can I click on Fig1b and get conduced to the image and not to the caption?

3
1

The problem is how to get the second \subfloat into vmode, since that only happens at the end of a line. Then I thought, a minipage effectively starts a new page (in vmode).

Of course, putting a \subfloat inside a minipage is sort of redundant, since it basically is a minipage.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{hyperref}

\begin{document}

Figures \ref{Fig1a} and \ref{Fig1b} are in Figure \ref{Fig1}

\begin{figure}[htb]
\centering
\subfloat{
  \includegraphics[width={\dimexpr 0.5\textwidth-0.5\columnsep}]{example-image-a}
  \label{Fig1a}
}\hfil
\begin{minipage}[b]{\dimexpr 0.5\textwidth-0.5\columnsep}
  \subfloat{
    \includegraphics[width=\textwidth]{example-image-b}
    \label{Fig1b}
  }
\end{minipage}
\caption{Image description:
\textbf{(a)}~figure 1a and 
\textbf{(b)}~figure 1b
}
\label{Fig1}
\end{figure}
\end{document}

This solution uses minipages only. It still uses some definitions from the subfig package.

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{hyperref}

\makeatletter
\newcommand{\stepsubfigure}{%
  \advance\c@figure by 1 %local
  \refstepcounter{subfigure}%
}
\makeatother

\begin{document}

Figures \ref{Fig1a} and \ref{Fig1b} are in Figure \ref{Fig1}

\begin{figure}[htb]
\begin{minipage}[b]{\dimexpr 0.5\textwidth-0.5\columnsep}
  \stepsubfigure
  \includegraphics[width=\textwidth]{example-image-a}
  \label{Fig1a}
\end{minipage}\hfill
\begin{minipage}[b]{\dimexpr 0.5\textwidth-0.5\columnsep}
  \stepsubfigure
  \includegraphics[width=\textwidth]{example-image-b}
  \label{Fig1b}
\end{minipage}
\caption{Image description:
\textbf{(a)}~figure 1a and 
\textbf{(b)}~figure 1b
}
\label{Fig1} 
\end{figure}
\end{document}
2
  • it works, but duplicated th image. Supose that the image already has the image a and the image b Jul 12 '17 at 17:18
  • I added the image to the second \subfloat so that it would actually have some height. Jul 13 '17 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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