Hopefully the last question I would ask about the extended figure caption macro. In the last version Here, hyperref do not affect \addefcline or \efcline, leaving me the task of having to define an hypertarget on the figure every time I use the \extcaption function.
In short, how could I make an hypertarget that point at \thefigure to make the process automatic ? Also, is there some sort of ifhyperref package (to check whether hyperref is loaded) ?
Here is the MWE
\documentclass[a4paper,10pt]{report}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{caption}
% Redefinition of \addcontentsline
\long\def\addefcline#1#2#3{%
\addtocontents{#1}{\efcline{#2}{#3}{\thepage}}}
% Redefinition of \contentsline
\makeatletter
\long\def\efcline#1{\csname l@#1\endcsname}
\makeatother
% Extended figure caption
\newcommand{\extcaption}[1]{% Write to .efc file
\addefcline{efc}{extfig}{{%
\bfseries \protect\hyperlink{fig:\thefigure}{Figure \thefigure, page~\thepage:}} %
\unexpanded{\unexpanded{#1}}%
}%
}
\makeatletter
\newcommand{\printextcaptions}{\@starttoc{efc}}% Read .efc file
\newcommand{\l@extfig}[2]{\noindent #1 \vspace{\parskip} \par}% How each .efc entry is handled
\makeatother
\usepackage[linktoc=all]{hyperref}
\begin{document}
\chapter{A chapter}
\section{A section}
\lipsum[1]
\begin{figure}
\includegraphics{example-image-a.pdf}
\caption{Picture of a big A}\hypertarget{fig:\thefigure}{}
\extcaption{\lipsum[1-2]}
\end{figure}
\begin{figure}
\includegraphics{example-image-b.pdf}
\caption{Picture of a big B}\hypertarget{fig:\thefigure}{}
\extcaption{The reasons why B is awful
\begin{itemize}
\item "B" like Bad
\item "B" like Banana
\end{itemize}
}
\end{figure}
\section{Extended figure captions}
\printextcaptions
\end{document}
\AtBeginDocument\\@ifpackageloaded{hyperref}{}{}does the trick indeed. However, hypcap requires you to either set the anchor manually, or automatically but making sure all figures have captions ... isn't there a way to link aimply to \figure ? I asked a similar question previously to link at a \thesection http://tex.stackexchange.com/questions/270141/make-an-hyperref-link-to-current-chapter-section – HcN Nov 23 '15 at 12:02