# Referencing equation counter value in custom float caption

I have used the float package to create an equation float, eqfloat, so I can add captions to equations. Within the eqfloat I used the equation environment to typeset the math.

I want to keep the right hand arabic numbering within parentheses that is added by the equation environment but I also would like the eqfloat caption below the equation to use the same number as the equation environment.

The following code achieves this by making the eqfloat use the same counter as the equation environment and then manually adjusting the equation numbering within each eqfloat.

Is there a better way to make the eqfloat caption reference the current value of the equation environment counter?

Is it possible to prevent the custom float environment from increasing the counter and only to reference the current value of the equation counter?

\documentclass[a4paper]{article}

\usepackage[margin=25pt, labelfont=bf]{caption}
\usepackage{amsmath, amsfonts, pifont, float, color, url}
\usepackage[pdftex, plainpages=false, pdfpagelabels, bookmarks=true]{hyperref}

\newfloat{eqfloat}{h}{eqflts}
\floatname{eqfloat}{Equation}
\makeatletter
\let\c@eqfloat\c@equation
\makeatother

\begin{document}
...
\begin{eqfloat}
$$E = mc^2$$
\caption{Equation caption here.}
\label{eq:example}
\end{eqfloat}

\end{document}

-
Welcome to TeX.sx! –  Peter Jansson Feb 6 '13 at 13:34

Package aliascnt can be used for aliasing the counter. It also takes care for the other companion macros of a counter (e.g.\the<counter> or \theH<counter> for hyperref). Therefore the following example uses the class book for a more complicate counter. \newaliascnt is called before \newfloat, because then \newfloat detects the new "counter" and does not assign a counter register.

The line \addtocounter{equation}{-1} can be automated by adding it to \caption inside environment eqfloat.

\documentclass[a4paper]{book}

\usepackage[margin=25pt, labelfont=bf]{caption}
\usepackage{amsmath, amsfonts, pifont, float, color, url}
\usepackage[pdftex, plainpages=false, pdfpagelabels,
bookmarks=true]{hyperref}

\usepackage{aliascnt}
\newaliascnt{eqfloat}{equation}
\newfloat{eqfloat}{h}{eqflts}
\floatname{eqfloat}{Equation}

\newcommand*{\ORGeqfloat}{}
\let\ORGeqfloat\eqfloat
\def\eqfloat{%
\let\ORIGINALcaption\caption
\def\caption{%
\ORIGINALcaption
}%
\ORGeqfloat
}

\begin{document}
\chapter{Test}
\begin{eqfloat}
$$E = mc^2$$
\caption{Equation caption here.}
\label{eq:example}
\end{eqfloat}

See \ref{eq:example}.
\end{document}


-
Thanks, this does exactly what I wanted –  KeithJ108 Feb 8 '13 at 12:56