I need to write the contents of a macro \number in an index.
I use multiple indexes with the index package. When I consult the adx file, \number is not interpreted and remains \number. Is it possible to have the contents of the macro \number in the index rather than its name ?
THANKS
Fabrice
LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and Acronyms ⇒ The contents of a macro in an index
- Stefan Kottwitz
- Site Admin
- Posts: 10232
- Joined: Mon Mar 10, 2008 9:44 pm
The contents of a macro in an index
Hi Fabrice,
welcome to the forum!
When I use a macro within an \index command, it is interpreted and its contents are printed in the index. What are you doing, exactly? Perhaps post a minimal working example that shows the issue.
Stefan
welcome to the forum!
When I use a macro within an \index command, it is interpreted and its contents are printed in the index. What are you doing, exactly? Perhaps post a minimal working example that shows the issue.
Stefan
LaTeX.org admin
-
- Posts: 4
- Joined: Sat Jul 13, 2024 10:19 am
The contents of a macro in an index
Yes, this is definitely a misuse on my part. I want to use the idx file to retrieve the page number in a python script. However in the idx file, the macro newcommand \foo is coded \foo and not its content. I understand that it is not possible for the idx file to include the content of my macro rather than its name.
THANKS
THANKS
-
- Posts: 4
- Joined: Sat Jul 13, 2024 10:19 am
The contents of a macro in an index
An example :
\newcommand{\foo}{bar}
\index{\foo}
In my idx file :
\indexentry{\foo}{56}
I would have liked to read \indexentry{bar}{56}
\newcommand{\foo}{bar}
\index{\foo}
In my idx file :
\indexentry{\foo}{56}
I would have liked to read \indexentry{bar}{56}
-
- Posts: 4
- Joined: Sat Jul 13, 2024 10:19 am
The contents of a macro in an index
I found a way to do this :
\newcommand{\foo}[1]
{
\newcommand{\fooo}{\index{#1}}
\fooo
}
\foo{YES}
This way I force the expansion of the command. This allows me to use a variable #1 in my index and retrieve its value in the idx file
\newcommand{\foo}[1]
{
\newcommand{\fooo}{\index{#1}}
\fooo
}
\foo{YES}
This way I force the expansion of the command. This allows me to use a variable #1 in my index and retrieve its value in the idx file
Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”
Who is online
Users browsing this forum: No registered users and 5 guests