12

I would like to create a .ist style file to change the layout of my Index. I am using book, hyperref and imakeidx. But I am at lost when it comes to creating the .ist file.

Basically, I would like to have the Index with bold alphabets before a new group of words begin. Something like this:

Index

A
angry
apple

B
ball
beer

My Codes:

\documentclass[11pt,a5paper,twoside]{extbook}
\usepackage{imakeidx}
\usepackage[colorlinks=true]{hyperref}
\makeindex[program=makeindex,columns=2,intoc=true]

\begin{document}  
\tableofcontents
\chapter{This is the First Chapter}  

She was angry \index{angry}  that she wasn't given an apple\index{apple}.  
He drank some beer \index{beer} and then played ball \index{ball}.  

\printindex

\end{document}
egreg
  • 1,121,712
pyro
  • 155
  • How do you want the index to look? Would be helpful if you could produce a brief code sample with one or two index entries so that answers could adapt that. – Aubrey Blumsohn May 17 '15 at 08:49
  • I have just added an example and a brief code. I know I needed to create a .ist file to change the index style but I don't know how to. TQ. – pyro May 17 '15 at 14:20

1 Answers1

16

Create a pyro.ist file in the same directory as your main file with the following contents:

heading_prefix "\n\\noindent\\textbf{"
heading_suffix "}\\par\\nopagebreak\n"
headings_flag 1

and change the call to \makeindex to

\makeindex[program=makeindex,options=-s pyro,columns=2,intoc=true]

That's all. Your .ind file will look like

\begin{theindex}

\noindent\textbf{A}\par\nopagebreak

  \item angry, \hyperpage{3}
  \item apple, \hyperpage{3}

  \indexspace

\noindent\textbf{B}\par\nopagebreak

  \item ball, \hyperpage{3}
  \item beer, \hyperpage{3}

\end{theindex}

enter image description here

egreg
  • 1,121,712
  • 1
    When you said "Create a pyro.ist file...", how do I actually do that? Do I write those codes in a latex editor and save it as .ist? But I couldn't find that option in the editor I'm using. Sorry, this is probably a very simple thing to do but at this moment, I am really stumped.. – pyro May 17 '15 at 15:09
  • @pyro Yes, any text editor will do and should be able to save a file with whatever name you specify. – egreg May 17 '15 at 15:10
  • Still can't get the output. Don't think I am doing the .ist correctly. I am still unable to save a file with a file format extension .ist. I am using Texmaker. When I save the file as pyro.ist, it became pyro.ist.tex. – pyro May 17 '15 at 15:22
  • @pyro Rename it from the file manager window (the Finder on Mac OS X, whatever it's called on Windows). – egreg May 17 '15 at 15:22
  • Ok....that finally did it! After many days of frustrations....Thanks! Feel like an idiot now... :) – pyro May 17 '15 at 15:32
  • @egreg Is there a manual explaining how to properly create an .ist file? It is not clear to me how to build it, what options I have in each case. What I have seen is based on examples, but I can't find any didactic explanation about it. – Aradnix Dec 27 '23 at 20:17
  • 1
    @Aradnix texdoc ind (or the LaTeX Companion, of course). – egreg Dec 27 '23 at 20:39