4

Hyperref is not linking to the correct location of the figure. Using the hypcap package didn't help. I keep getting the error :" you have forgotten to use \caption" ..

The document class is available at this link:

Below is the MWE:

\documentclass[12pt,letterpaper,doublespaced,ETD,proposal]{thesis}
\bibfiles{refs,strings}
\usepackage{graphicx, subfig}
\usepackage{hyperref}

%Needed to Generate the figures page
\figurespagetrue


\begin{document}
\contents %Generates the figures list.

\begin{figure}[htb]

  \centering
  \centerline{\includegraphics[width=6cm]{graphics.png}}

\caption{fig1}
 \label{fig1}
\end{figure}
\end{document}

Thanks a lot.

  • 1
    Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Heiko Oberdiek Sep 3 '13 at 8:48
  • Try to make the example without non-standard classes ([thesis][1].cls) and packages (insfig.sty). Otherwise the non-standard files are needed to reproduce the problem. – Heiko Oberdiek Sep 3 '13 at 9:55
  • Hope it looks better now. I don't have the dtx file generating the class. – Hasan Sep 3 '13 at 10:19
  • @hasan: heiko asked for a version of your source without the non-standard thesis.cls -- how do we debug your code without access to all of the files you use? – wasteofspace Sep 3 '13 at 10:28
  • I get no error and a correct link (albeit at the foot of the caption), without hypcap. – egreg Sep 3 '13 at 10:39
4

The class you're using already tries being hyperref savvy: here's some code from it

312    \if@hyperrefused%
313       \typeout{This should not be output.}
314       \hypersetup{%
315          plainpages=true,
316          breaklinks=true,% not default in dvips mode, so we must specify
317          hypertexnames=false,%not ideal, but needed when pagenums duplicate (`i' vs. `1')
318          pageanchor=true,
319          colorlinks=true,
320          linkcolor={blue},
321          citecolor={green},
322          urlcolor={red},
323          pagecolor={cyan},
324          anchorcolor={black}
325       }
326       %\ifHy@nesting
327       \long\def\@caption#1[#2]#3{%
328          \hyper@makecurrent{\@captype}%
329          \par\addcontentsline{\csname ext@#1\endcsname}{#1}{%
330             \protect\numberline{\csname fnum@#1\endcsname}{\ignorespaces #2}}%
331          \begingroup
332             \@parboxrestore
333             \if@minipage
334                \@setminipage
335             \fi
336             \normalsize
337             \@makecaption{\csname fnum@#1\endcsname}{%
338                \ignorespaces
339                \ifHy@nesting
340                   \hyper@@anchor{\@currentHref}{#3}%
341                \else
342                   \Hy@raisedlink{\hyper@@anchor{\@currentHref}{\relax}}#3%
343                \fi
344             }%
345             \par
346          \endgroup
347       }
348       %\else
349       %\fi
350       \let\Hy@float@caption\@caption
351       \@ifpackageloaded{float}{%
352          \def\Hy@float@caption{%
353             \hyper@makecurrent{\@captype}%
354             \float@caption
355          }
356          \let\HyOrg@float@makebox\float@makebox
357          \renewcommand{\float@makebox}[1]{%
358             \HyOrg@float@makebox{%
359                #1\relax
360                \hyper@@anchor{\@currentHref}{\relax}%
361             }% \HyOrg@float@makebox
362          }% \renewcommand
363       }{}%
364    \else

This code is executed when hyperref is loaded; so hypcap can't do its patching (which should not be needed anyway) or, better, it already finds some conflicting code.

If the result is not what's expected, this must be considered a bug in the class.

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.