1

What I'd like to do is that, every time I reference an acronym, it should be rendered with an \index{} using the same value as either the acronym's short or long form.

M(not)WE:

\documentclass{article}

\usepackage{acronym}
\usepackage{makeidx}

\makeindex

\begin{document}

    \begin{acronym}
        \acro{SE}{StackExchange}
        \acro{TDD}{Test-Driven-Development}
    \end{acronym}

    lorem ipsum \ac{SE} dolor met \ac{TDD}

    % should list "SE" and "TDD", or "StackExchange" and "Test-Driven-Development", or both
    \printindex
\end{document}

I tried adding an \index{} inside the \acro commands (as in \acro{TDD}{\index{TDD}Test-Driven-Development}, but that does not work.

One workaround would be using a custom command as below, but I would like to think that there's a better solution (which also works for acronym usage other than just the regular \ac).

\newcommand{\SE}{\index{SE}\ac{SE}\xspace}

Any solutions are appreciated, although those that don't require switching to a different "acronyming" or indexing package would be preferable.

Note: This question is indeed nearly identical, but it still requires overwriting each variant of \ac (\acs, \acl, \acf etc.) separately. I'm hoping there's a shorter solution, but that might be too optimistic.

PixelMaster
  • 255
  • 1
  • 10
  • This does indeed target a nearly identical topic - however, it still requires overwriting each variant of \ac (i.e. \ac, \acs, \acl, \acf etc.) separately. As a computer scientist, I detest duplication, so I'm still hoping for a shorter solution. But thank you regardless :) – PixelMaster Feb 28 '18 at 15:49
  • I know you said you'd rather not switch package, but if no one provides a neat solution with acronym are you prepared to accept a solution with a different package? – Nicola Talbot Feb 28 '18 at 18:53
  • sure, the other solution is just preferable, not exclusive. – PixelMaster Feb 28 '18 at 18:59
  • Sorry, I was too late. The question's been closed. The dup doesn't mention anything about allowing a different package. – Nicola Talbot Feb 28 '18 at 19:17

0 Answers0