2

I'm working on a paper and the figures are quite complex. For this reason I'm making the figures as a single image in GIMP so I can arrange and place them as I like. In this single image I still manually label the parts of the figure with e.g. A and B and I would like to refer to them using \cref or \autoref. My current solution is to make a figure with mutliple subfigures but setting all the widths expect one to 0 so it only prints a single image for the figure. These 0 width subfigures do have labels which allows me to refer to them in the body of the text with\cref.

My question is: is there a more elegant way to be able to use \autoref or \cref to reference these label than just have a bunch of 0 width subfigures in my figure? Is there maybe a similar command to \phantomsubcaption to have a phantom subfigure to attach a label to?

Below I have attached my current "ugly" solution

    \begin{figure}[h]
    \centering
    \begin{subfigure}[b]{0\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/DBS_figure_d.png}
        \phantomsubcaption
        \label{fig:test-sub-1}
    \end{subfigure}

    \begin{subfigure}[b]{1\textwidth}
        \centering
        \includegraphics[width=\textwidth]{images/DBS_figure_d.png}
        \phantomsubcaption
        \label{fig:test-sub-2}
    \end{subfigure}

    \caption{blablablablabla}
    \label{fig:test}
\end{figure}
3
  • Welcome to tex.sx. Aug 15, 2021 at 15:32
  • Without more detail, I'd suggest setting the images on their own, rather than playing around with GIMP and then also in TeX to align the captions. That would be a more elegant way.
    – Werner
    Aug 15, 2021 at 16:07
  • This is like labeling specific areas of a "big figure"?
    – juanuni
    Aug 15, 2021 at 17:28

1 Answer 1

1

Since all the links go to the top of the figure, it doesn't matter where they go. They do need to go inside a group so as to not affect the figure caption.

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

\begin{document}
\begin{figure}[ht]
    \centering
    \includegraphics[width=\textwidth]{example-image}
    {\phantomsubcaption\label{fig:test-sub-1}%
     \phantomsubcaption\label{fig:test-sub-2}}%
    \caption{blablablablabla}
    \label{fig:test}
\end{figure}

\ref{fig:test-sub-1}\quad\subref{fig:test-sub-1}\par
\ref{fig:test-sub-2}\quad\subref{fig:test-sub-2}\par
\ref{fig:test}
\end{document}
1
  • Yes this worked for me and is exactly what I was looking for, thanks!
    – vicsnor
    Aug 16, 2021 at 6:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .