MakeIndex, Nomenclature, Glossaries and Acronymsapply arbitrary command to index term?

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

apply arbitrary command to index term?

Post by Meta002 »

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

Code: Select all

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: apply arbitrary command to index term?

Post by Johannes_B »

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

Re: apply arbitrary command to index term?

Post by Meta002 »

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
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

apply arbitrary command to index term?

Post by cgnieder »

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

Code: Select all

\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}
site moderator & package author
Meta002
Posts: 22
Joined: Sat Jul 11, 2015 2:15 pm

apply arbitrary command to index term?

Post by Meta002 »

In my case:

Code: Select all

\index{α@\TBFN{α}}
\index{β@\TBFN{β}}
Here is the output on the Index page:
α, 35
β, 6

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