# [texhax] how to write href into an indexentry

Fehd, Ronald J. (CDC/CCHIS/NCHM) rjf2 at cdc.gov
Tue Aug 8 17:39:40 CEST 2006

> > when what I want is this:
> > \item Fehd, Ronald
> > \subitem macro tools
> >
\href{http://www2.sas.com/proceedings/sugi30/004-30.pdf}{sugi30-004}},
> > \hyperpage{2}
> >
> > I am primarily a LaTeX user
> > and have no problem understanding the issues of writing LaTeX macros
> >
> > I am willing to settle for something simple like:
> >
> > \newcommand{\writeurl}[2]{
> > \href{http://www2.sas.com/proceedings/sugi30/#1}{#2}}
> >
> > Q: what are the issues of macro resolution to get the pdf-name and
> > text written into the index file?

did I remember to mention that I am using package index (see also:
camel)
and writing to several indexes: author, company, keyword,
and default

as usual, when stuck, talking/writing the issues down,
and then going back to (re)read the manual more carefully
-- The LaTeX Companion, 2e, pg 681 --
"The argument of \index is never expanded ..."
got me to understand my issues
which were: hoping that I could get TeX to expand the tokens
before writing the indexentry to file

I played around with expandafter and edef
but did not succeed.

so this is what I have working this morning:

\newcommand{\writeurl}[2]{\href{http://www2.sas.com/proceedings/sugi30/#
1}{#2}}

\index{word1 \writeurl{001-30.pdf}{sugi31.001}

this is way much more copying&pasting than I wanted in my .tex document
but I do have my protype working with the above hard-coded references.

thanx to John Culleton
for providing some off-line commentary on this q:
> see the file samplepdf.tex in the pdftex distro.
which is mentioned in this doc:

http://sites.huji.ac.il/tex/live.pdf

> Another option is to use the pdf bookmark facility.
> This is in effect another form of index

Ron Fehd  CDC