Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
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: mathematics.nsetzer.com/latex/latex_for_loop.html. –  peter Apr 30 '11 at 20:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.