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

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

apply arbitrary command to index term?

Postby Meta002 » Mon Sep 14, 2015 5:02 am

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

  1. \begin{theindex}
  2. \item \TBFN{α}, 35
  3. \indexspace
  4. \item \TBFN{β}, 6
  5. \indexspace
  6. etc.
  7. \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?


User avatar
Site Moderator
Posts: 3639
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Sep 14, 2015 7:35 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.

Posts: 22
Joined: Sat Jul 11, 2015 2:15 pm

Postby Meta002 » Mon Sep 14, 2015 9:16 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.

User avatar
Site Moderator
Posts: 1985
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany

Postby cgnieder » Tue Sep 15, 2015 9:23 pm

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”.

  1. \documentclass{scrartcl}
  2. \usepackage{imakeidx}
  3. \makeindex
  4. \begin{document}
  6. A\index{A@\textit{A}} $x^2$\index{x**2@$x^2$} word\index{word}
  8. \printindex
  10. \end{document}
chemmacros · chemformula · leadsheets · xsim

Posts: 22
Joined: Sat Jul 11, 2015 2:15 pm

Postby Meta002 » Tue Sep 15, 2015 11:27 pm

In my case:

  1. \index{α@\TBFN{α}}
  2. \index{β@\TBFN{β}}

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

Thanks for the tip! One less thing to forget! :D

Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”

Who is online

Users browsing this forum: No registered users and 1 guest