I am trying to accomplish something like in this question and this question.

I have several authors contributing solutions to problems that are numbered using an externally imposed scheme, which I handle via the description environment. I wrap each author's name in \index{} and need the printed index to display the problem number as it appears in the external scheme. Right now I'm using the report document class, but could be persuaded to change.

I picked up a way to capture the external numbering using a modified \ref{} command from here, but have not been able to get the index to display other than just the counter value.

For example:


\item[#1] \refstepcounter{desccount}\label{#1}

\descitem{1B.1} by \index{Smith}
\descitem{1B.3} by \index{Jones}
\descitem{1C.1} by \index{Smith}
\descitem{1E.11} by \index{Burton}



I would like the resulting index of the document to be

Burton   1E.11  
Jones    1B.3  
Smith    1B.1, 1C.1

with hyperref filling in the hyperlinks appropriately. The closest I've come is to use the memoir document class and include a \renewcommand{\index}[1]{\specialindex{\jobname}{desccount}{#1}} but this simply returns the value of desccount and not the external numbering scheme. In the example given, the output I would get is

Burton    4  
Jones     2  
Smith     1, 3

which is not quite what I want. How can I have the index return the argument of \descitem instead of the page number or the value of desccount?

  • This seems more like a glossary, than an index. I'd look into the glossaries package. – egreg Feb 4 '15 at 20:37
  • @egreg, you may be right, but I'm not sure how to do this using the glossaries package either. I tried using the xindy option with \GlsAddXdyLocation{descref} but still only got the results of desccount and not the external numbering system. Do you have any specific feedback on what to do with the glossaries package in this case? – Brian Feb 5 '15 at 16:25
  • @Brian: If you're still interested in a solution, see my possible answer – user31729 Dec 30 '15 at 18:37

Here's a possible solution with glossaries and writing 'arbitrary' text labels to the .aux file which are used in turn to provide problem number using \getrefnumber (package refcount)

The underlying desccount counter was used to provided the relevant entries for the new glossary provider.

There might be better setups for \descitem, but this was given by the O.P. I changed it a little bit to \descitem[provider name]{Number}.

I kept the old \descitem macro on purpose, but commented it!




% Here is the 'original' \descitem command. 

  \item[\protect\hypertarget{#2}{#2}]\refstepcounter{desccount}\writetextlabel{#2} by \gls{#1}%

\newglossary[prl]{provider}{pri}{pro}{Providers of solutions}[desccount]
  description={Smith has provided some of solutions},

  description={Jones has provided other solutions},

  description={Burton was a lazy guy}


\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\renewcommand{\glsnumberformat}[1]{\protect\hyperlink{\getrefnumber{description::##1}}{\getrefnumber{description::##1}}}% Change to use the textlabel
\renewcommand*{\glossaryheader}{%  Change the table header
  \bfseries Author & \bfseries Description & \bfseries Solutions provided \\
\renewcommand*{\glossentry}[2]{%  Change the displayed items
  \glstarget{##1}{\glossentryname{##1}} %
  & \glossentrydesc{##1}% Description
  & \space ##2  \tabularnewline






enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.