# Is it possible to jump to the image with href while not using captions?

I am using various figures throughout my documents without captions. In order to reference them I use the command \refstepcounter{figure} before labelling them with \label{fig:label}. However, when I do this so and click on the figure reference Latex goes below the figure as if there was a caption. However, there is no caption and the command \capstart from the hypcap package does not work either. What can I do to work around this problem?

The MWE is below:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc} % I write in UTF8
\usepackage[T1]{fontenc} % 256 glyphs are sufficient for our purposes
\usepackage[demo]{graphicx}
\usepackage[hypcap=true]{caption}
\usepackage[list=true]{subcaption} % Provides subfigures with captions and lists them in ToC
\usepackage{hyperref} % Options configured later
\usepackage{hypcap} % For anchorage
\usepackage{float} % For additional position specifiers etc.
\usepackage{lipsum}

\begin{document}
\section{Introduction}
\lipsum[6-7]
\lipsum[8-10]
\begin{figure}[H]\capstart
\includegraphics[width=\textwidth,height=10cm]{try}
\refstepcounter{figure} \label{fig:try}
\end{figure}
\end{document}

• Can you provide a base template that replicates this issue of yours? – Werner Aug 3 '18 at 22:29
• @Werner I provided a MWE to illustrate the issue. It generates two pages of output. – Vesnog Aug 3 '18 at 22:47
• @Vesnog your code might be much, but your Minimal Working Example doesn't seem very minimal. – Skillmon Aug 3 '18 at 22:55
• @Skillmon I shortened my MWE. – Vesnog Aug 3 '18 at 23:05
• @Vesnog: Why not use \hypertarget and \hyperlink since there's no caption or numbering of the floats? Here's an example. – Werner Aug 4 '18 at 4:31

First of all if you load the hypcap package, the hyperref-caption feature of the caption package will be switched off since in this case the caption package assumes that you would like to use the features/commands of the hypcap package rather than using the hyperref-caption feature of the caption package.

Now to a possible solution: Similar to the \phantom... commands offered by the hyperref package the caption package offers \phantomcaption:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc} % I write in UTF8
\usepackage[T1]{fontenc} % 256 glyphs are sufficient for our purposes
\usepackage[demo]{graphicx}
\usepackage[hypcap=true]{caption}
\usepackage[list=true]{subcaption} % Provides subfigures with captions and lists them in ToC
\usepackage{hyperref} % Options configured later
\usepackage{float} % For additional position specifiers etc.
\usepackage{lipsum}

\begin{document}
\section{Introduction}
\lipsum[6-7]
\lipsum[8-10]
\begin{figure}[H]
\includegraphics[width=\textwidth,height=10cm]{try}
\phantomcaption \label{fig:try}
\end{figure}
\end{document}


\phantomcaption increases the figure counter (but only if \ContinuedFloat isn't used), takes care of the hyper-link and hyper-target, and so on, but does not typeset a caption itself.

As an alternative one could also use \captionlistentry which does the same as \phantomcaption but places an entry into the List of Figures:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc} % I write in UTF8
\usepackage[T1]{fontenc} % 256 glyphs are sufficient for our purposes
\usepackage[demo]{graphicx}
\usepackage[hypcap=true]{caption}
\usepackage[list=true]{subcaption} % Provides subfigures with captions and lists them in ToC
\usepackage{hyperref} % Options configured later
\usepackage{float} % For additional position specifiers etc.
\usepackage{lipsum}

\begin{document}
\listoffigures
\section{Introduction}
\lipsum[6-7]
\lipsum[8-10]
\begin{figure}[H]
\includegraphics[width=\textwidth,height=10cm]{try}
\captionlistentry{Whatever} \label{fig:try}
\end{figure}
\end{document}


I must confess that I'm not sure how these solutions behave if the hypcap package will be loaded additionally, so I recommend dropping it if you would like to use these features offered by the caption package.

However, both solution increment the figure counter and \ref will give you a reference to the figure counter. If this is not what you want, I recommend using \hypertarget and \hyperlink instead, just as Werner has suggested.

• Thanks for the answer it seems to leave a little bit of empty space just after the float but does what I intend to do. But moving it before the \includegraphics command resolved this issue. What does \phantomcaption to that \refstepcounter{figure} does not? – Vesnog Aug 4 '18 at 12:24
• @Vesnog It connects the reference with the hyperref anchor the caption package has placed at the beginning of the figure. (Regarding the extra space: This should not happen, I will take a look at it...) – Axel Sommerfeldt Aug 4 '18 at 15:13