3

I am trying to mark places in my document automatically (for later bookmarking). I defined a counter nops and my marking macro should be like this: \newcommand{\nop}{\addtocounter{nops}{1}\hypertarget{nop\value{nops}}{}}, but it seems that this is not the correct way to do it, since a bookmark like \bookmark[dest=nop3]{third occurrence} always just brings me to the title page.

I assume this is a more general problem like 'how to use commands where text is expected' but I don't know enough about latex to properly classify it. Someone more knowledgeable may change the title and tags (seems I can't create any meaningful tags like 'counter value hypertarget name' or 'dynamic bookmarks' for this anyhow).

peter
  • 2,895

1 Answers1

4

With \value{nops}, you get the internal representation of the counter (\c@nops) instead of its actual value which you can get e.g. with \arabic{nops} as an arabic number. So your definition must be

\newcommand{\nop}{\addtocounter{nops}{1}\hypertarget{nop\arabic{nops}}{}}

to make your bookmarks work.

diabonas
  • 25,784
  • Thanks, it works. That was easy. So when would I use \value? – peter Apr 30 '11 at 20:46
  • 1
    I found it out while preparing and thereby obsoleting my next question: http://mathematics.nsetzer.com/latex/latex_for_loop.html. – peter Apr 30 '11 at 20:59