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}
2
  • 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. Commented May 17, 2015 at 8: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
    Commented May 17, 2015 at 14:20

1 Answer 1

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

7
  • 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
    Commented May 17, 2015 at 15:09
  • @pyro Yes, any text editor will do and should be able to save a file with whatever name you specify.
    – egreg
    Commented May 17, 2015 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
    Commented May 17, 2015 at 15:22
  • @pyro Rename it from the file manager window (the Finder on Mac OS X, whatever it's called on Windows).
    – egreg
    Commented May 17, 2015 at 15:22
  • 1
    @Aradnix texdoc ind (or the LaTeX Companion, of course).
    – egreg
    Commented Dec 27, 2023 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .