I created an index in which some entries have subentries: for those kind of entries I created \ati macro, while for entries without subentries I use another macro.

In those entries created by \ati macro I want top-level entry to be bold. I was able to get what I want without a macro with "Entry":

Index entry with bold formatting

However I am unable to achieve the same with the macro without changing number of arguments. I want this macro to have only two arguments, in that order, because I use it in existing document.

I think the way to achieve this is to somehow process text before and after first exclamation mark (!) in first argument and then somehow incorporate that into macro definition without changing amount of arguments. But I have no idea how to go about that.

(In case it is important to solution, I use texindy as index processor.)


\def \ati#1#2{#2\index{#1}} % "Add to index" macro

There are many ways to write a document. You could use a \ati{Markup!LaTeX@\LaTeX}{\LaTeX}, \ati{Markup!Markdown}{Markdown} or even \ati{Markup!HTML}{HTML}. If you do write your document by hand, do not use \ati{Markup!XML}{XML}, because you are going to go mad.


\ati{Markup!LaTeX@\LaTeX}{\LaTeX} is obviously the best to produce high-quality PDF file, but you do not have to type it by hand. You can use \ati{Markup!Markdown}{Markdown} instead and then convert it to both \ati{Markup!HTML}{HTML} and \ati{Markup!LaTeX@\LaTeX}{\LaTeX}, as well as many other formats.

Now comes interesting stuff. When you write a technical book in \ati{Markup!LaTeX@\LaTeX}{\LaTeX}, you can quite easily create an \sindex{Index creation}index. When you do, you have quite a few choices when it comes to packages you use and \ati{Index processor}{index processors} that will sort your .idx file into .ind file that gets included in your document at the time of next compilation.


One of those index processors is \ati{Index processor!MakeIndex}{MakeIndex}, but there are also few other alternatives. I personally prefer to use \ati{Index processor!xindy}{xindy} through command line program called texindy.


Now, I want to make each top-level entry like ``Index processor'' and ``Markup'' bold, only for those entries which do have sub-entries (this is what \\ati macro is for). It would be awesome if I could use same macro even for entries which do not have subentries and still get bold top-level entries only for those entries with subentries, but it is not must-have.

So what I want to produce looks like this:



\index{Entry@\textbf{Entry}!another entry}{another entry}

\index{Entry@\textbf{Entry}!another entry}{another entry}

\index{Entry@\textbf{Entry}!yet another entry}{yet another entry}

but I want to achieve it inside ``ati'' macro.



Is this at all possible?

Your Answer

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

Browse other questions tagged or ask your own question.