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.

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 write documents that rely heavily on the 'enumerate' environment. I'd like to turn any particular item from within that environment into a variable that I can use elsewhere. The idea is to ensure consistency with long headers I have to repeat later.

Ideally, the string store method wouldn't check for special characters like @ or _.
Better still if I could use numbers for the string name.


    (piles of content)  

    \item\label{itm:01} \def\AA{Heading text.} \rAA\


(piles of content)


This throws an 'undefined' error. It's possible to define the command outside an environment and use it within one, but with extended lists and multiple headers, repeatedly going elsewhere to find out what section I'm in slows my workflow.

Am I overlooking a simple way (or even not-so-simple way) of doing this?

share|improve this question
\gdef instead of \def? With the usual caveat that this doesn't check for already defined commands. – egreg Aug 8 '14 at 19:57

An environment forms a group, so a \def inside it will not survive the end of the envvironment. What you need is \gdef, but your \AA is a perfect example of something that shouldn't be done, as \AA is a font related command (it produces Å).

You can define your own check, using \@ifdefinable to check for availability of the command and \gdef to globally define the command, so transcending the group structure.


Complete example:




\item\label{itm:01} \definestring\rAA{Heading text.} \rAA

Now we use \rAA


enter image description here

share|improve this answer
This worked perfectly. You saved a great deal of work, thank you. – user60435 Aug 8 '14 at 21:35

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.