TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have defined a custom environment (using the tocloft package, thanx to Juan) that looks like:

\newcommand{\listscriptname}{List of Scripts}
  { \vspace{3mm}\hspace{3mm}
    \textbf{Script~\thescript #1:code/#2.groovy}}

which I use like:


And refer to it with:


But instead of the script environment number, I get the number of the section.

What am I doing wrong (I did try several variations...)?

share|improve this question
up vote 8 down vote accepted

Move \refstepcounter out of the \colorbox:

    \textbf{Script~\thescript foo#1bar:code/#2.groovy}}
share|improve this answer
Of course... yes, makes sense... in retrospect at least... :) Thanx! – Egon Willighagen Oct 9 '10 at 15:37

Your Answer


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.