I created a small example:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage[pdfstartview=FitH]{hyperref}
\usepackage{bookmark}
\begin{document}
one line
\newcounter{test}
\[\text{\stepcounter{test}\bookmark[dest=whatever]{my equation}one equation}\]
counter value: \arabic{test}.
\end{document}
It creates 4 bookmarks but increases the counter only by 1. How is that (even logically) possible? Either this equation environment somehow executes the code 4 times (maybe first measuring the contents or whatever), then the counter should be increased by four. Or it only executes once, then there should only be one bookmark.
How do I get it to display only one bookmark? (moving it out of the equation is not an option since this happens inside a macro which at the same time marks the equation as target.)
update:
alright, egregs \tbookmark command fixed my minimal example. turns out it was too minimal. here is another one which went back to not working:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage[pdfstartview=FitH]{hyperref}
\usepackage[atend]{bookmark}
\makeatletter\newcommand{\tbookmark}[2][]{\iffirstchoice@\bookmark[#1]{#2}\fi}\makeatother
\newcounter{nops}
\newcommand{\nop}{\stepcounter{nops}\raisebox{\ht\strutbox}{\hypertarget{nop\arabic{nops}}{}}\begingroup\edef\x{\endgroup\noexpand\BookmarkAtEnd{\noexpand\tbookmark[dest=nop\arabic{nops}]{page \arabic{nops}}}}\x}
\begin{document}
one line
\[\text{\nop one equation}\]
counter value: \arabic{nops}.
\end{document}

\mathchoicehas four arguments corresponding to display, text, script and script-script style. When TeX encounters it it constructs all four and then inserts the appropriate one. So it could be a case of this primitive being used somewhere. – jfbu May 1 '11 at 17:37