# Package hypcap Error: You have forgotten to use \caption

I get the following error:

 <use myfile.jpg>
Package hyperref Info: bookmark level for unknown myfig defaults to 0 on input
! Package hypcap Error: You have forgotten to use \caption.


for the following document (see definition of myfig)

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{float}
\usepackage{hyperref}
\usepackage{hypcap}

\begin{document}

\floatstyle{ruled}
\newfloat{myfig}{thp}{lop}
\floatname{myfig}{Text}
\hypcapredef{myfig}
\begin{myfig} \capstart
\includegraphics[scale=.5]{myfile}
\caption{myBook}
\end{myfig}

\end{document}


the final .dvi and .pdf output are ok, but I need to avoid any error to edit by lyx. I have seen a few posts on similar issues, but I am not sure how to fix things with my example. thks

-
Welcome to TeX.sx! I'm afraid hypcap is incompatible with float –  egreg Mar 5 '13 at 14:51
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Aug 18 '13 at 20:25

You can use package caption. It also implements the function of hypcap, thus you do not need \hypcapredef and \capstart:

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{float}
\usepackage{hyperref}
\usepackage{caption}

\begin{document}

\ref{fig:myfig}

\floatstyle{ruled}
\newfloat{myfig}{thp}{lop}
\floatname{myfig}{Text}

\begin{myfig}
\includegraphics[scale=.5]{myfile}
\caption{myBook}\label{fig:myfig}
\end{myfig}

\end{document}

-
yes, it seems it works. thanks so much. m. –  mario Mar 5 '13 at 19:59
sorry for late accept –  mario Jan 4 at 10:38