[Tex/LaTex] Hypcap not working with custom figure environment

captionscross-referencingfloatshyperrefmulticol

I'm trying to use caption with hypcap=true so that cross-reference hyperlinks will go to the figure instead of the figure caption. However, I'm using a multicol environment with a custom figure environment so that the floats place well in the two-column document.

Here is a MWE:

\documentclass[10pt, letterpaper]{article} 
\usepackage{multicol}
\usepackage[small,bf,hypcap=true]{caption}
\usepackage[demo]{graphicx}
\newenvironment{Figure}
  {\par\medskip\noindent\minipage{\linewidth}}
  {\endminipage\par\medskip}
\usepackage[unicode, bookmarks, colorlinks, breaklinks]{hyperref} 
\usepackage[all]{hypcap} %I don't know if this line is needed

\begin{document}
\begin{multicols}{2}[\section{section1}]
Figure~\ref{fig:fig1}
\begin{Figure}
\centering
\includegraphics[width=\textwidth]{apple.jpg}
\captionof{figure}{caption}
\label{fig:fig1}
\end{Figure}
\end{multicols}
\end{document}

I'm using XeLaTeX but I don't think that changes anything.

Best Answer

You should use float package to use H placement specifier:

\documentclass{article} 
\usepackage{multicol}
\usepackage[small,bf,hypcap=true]{caption}
\usepackage[demo]{graphicx}
\usepackage{float}
\usepackage[unicode]{hyperref}

\begin{document}
\begin{multicols}{2}[\section{section1}]
Figure~\ref{fig:fig1}
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{apple.jpg}
\caption{caption}
\label{fig:fig1}
\end{figure}
\end{multicols}
\end{document}
Related Question