I have a document with a few sections, I'm new to LaTeX so I'm just using the article class. I want the figure numbers to restart in each section. I did this with \setcounter{figure}{0} at the start of each section, and I figure this is somehow related to (causing) my problem but I just can't figure out a solution.
The problem is when I click on a hyper-link in a figure reference to, say, Figure 1 in Section 2, it will take you back to the first figure one (back in Section 1 in this case), even if the reference specifies the correct figure by name/label.
I'm using XeLaTeX and the multicols environment so I've included that in my MWE but I don't think they are related to the problem. I'm also using a custom \Figure so that the figure fits in the column nicely.
Here is the MWE:
\documentclass[10pt, letterpaper]{article}
\usepackage{geometry}
\geometry{letterpaper, hmargin=1.5in, vmargin=1in, marginparsep=7pt, marginparwidth=.6in}
\usepackage{multicol}
\usepackage[small,bf,hypcap=false]{caption}
\usepackage{graphicx}
\usepackage[unicode, bookmarks, colorlinks, breaklinks]{hyperref}
\newenvironment{Figure}
{\par\medskip\noindent\minipage{\linewidth}}
{\endminipage\par\medskip}
\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}
\newpage
\setcounter{figure}{0}
\begin{multicols}{2}[\section*{section2}]
(Figure~\ref{fig:fig2}
\begin{Figure}
\centering
\includegraphics[width=\textwidth]{apple.jpg}
\captionof{figure}{caption}
\label{fig:fig2}
\end{Figure}
\end{multicols}
\end{document}
Here is a compiled PDF for your convenience: http://dl.dropbox.com/u/3730003/mwe6.pdf
To easily witness the problem, go to the 2nd page and click on the hyperlink in the reference to the figure, it will take you back to the first page.
I've been trying to use:
\renewcommand*{\theHfigure}{\arabic{section}.\arabic{figure}}
after the start of each section and this works if I use section{} instead of section*{} but with 'section*' the 'section' number stays at 0 with \arabic{section} and \thesection.
Note: I'm not completely sure what hypcap=false does but I was getting errors from the caption package with the default hypcap=true so I switched it to false but it doesn't seem to change anything.
\phantomsectionbefore your\section*{...}commands? I think this may increment the necessary counters without extra effort. – qubyte Feb 27 '12 at 06:16