The Texbook says:

The \write command is somewhht special, because its token list is first read without expansion; expansion occurs later, when the tokens are actually
being written to a file.


As \index writes to a file, this may be the problem!

I'll see if I can do any tricks with
\def\trick#1XXXX
where XXXX is delimiters to try and the name it out of the original text, as #1 macros seem to make it through fine...

Sam

Sam Liddicott wrote:
I'm trying to extend the indexing of newfangle literate code chunks.

I'm: \usepackage{index}

so that I can have multiple indexes; but the \index{} command seems to
literally interpret the first parameter, so that
\index{\chunkname}
indexes "\chunkname" instead of the name.

I've tried all kinds of use of \expandafter and other tricks with
secondary macros, like this:

\def\ch...@index#1{%
  \...@index[chunks]{#1}%
}%
\def\Chunk#1{%
  \lstset{title={\newfanglecaption},name=#1}%
  \global\edef\...@chunkname{\lst@intname}%
  \expandafter\ch...@index{\lst@chunkname}%
}%

But even then I get the literal text "\...@chunkname" as the indexed item.

The only thing that "nearly" works is if I pass #1 within \Chunk, but
then I get other text too, which I want to chop off.

Any clues on how to make the index package take an expression?

Sam

Reply via email to