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}
\begin{equation}
E = mc^2
\end{equation}
\addtocounter{equation}{-1}
\caption{Equation caption here.}
\label{eq:example}
\end{eqfloat}
\end{document}
Best Answer
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>
forhyperref
). Therefore the following example uses the classbook
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 environmenteqfloat
.