LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and Acronyms ⇒ apply arbitrary command to index term? Topic is solved

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Meta002
Posts: 22
Joined: Sat Jul 11, 2015 2:15 pm

apply arbitrary command to index term?

This is what I want in the ".ind" file generated by MakeIndex:

\begin{theindex}   \item \TBFN{α}, 35   \indexspace   \item \TBFN{β}, 6   \indexspaceetc.\end{theindex}

I need to do this because the unicode alpha and beta characters I'm using aren't in the font used to generate the index. I understand how to use \index[ } to apply an arbitrary command to the page number; I need a similar facility for the index term. Is this possible, or do I have to keep patching the ".ind" file by hand?

Tags:

Johannes_B
Site Moderator
Posts: 3639
Joined: Thu Nov 01, 2012 4:08 pm
Never really had to deal with indices, maybe that is why i don't understand the problem. What has the font to do with generating the index?

The code that generates the index file would be of much much more help here, i.e. a minimal working example.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Meta002
Posts: 22
Joined: Sat Jul 11, 2015 2:15 pm
My description of the problem was poor. What I meant to say was that when \printindex typesets the information in the ".ind" file, the font used (the normal font) doesn't contain the two desired characters. This forces me to "patch" the ".ind" file and specify the correct font with my command \TBFN{ }. The patched ".ind" works perfectly, it's just a bit inelegant to have to do the patching. It's something I could forget before sending the PDF to the printer, which would be embarrassing.

cgnieder
Site Moderator
Posts: 1985
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:
it is not at all clear how you generate the index. However, the usual way of adding formatting to index entry is the \index{sort@entry}. So for a bold word: \index{word@\textbf{word}}. This could be automated by defining semantic macros which create the index entry “on the fly”.

\documentclass{scrartcl}\usepackage{imakeidx}\makeindex\begin{document} A\index{A@\textit{A}} $x^2$\index{x**2@$x^2$} word\index{word} \printindex \end{document}
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

Meta002
Posts: 22
Joined: Sat Jul 11, 2015 2:15 pm
In my case:

\index{α@\TBFN{α}}\index{β@\TBFN{β}}

Here is the output on the Index page:
α, 35
β, 6

Thanks for the tip! One less thing to forget!