# makeindex style

I am using a template from, "The Legrand Orange Book" (name of tex file is main.tex) and the author has a very nice template that looks like:

However, after using "Make Index" from WinEdt, my index comes out all plain and no color like that above. He mentioned in his template to run:

makeindex main.idx -s StyleInd.ist


from the command line. How can I implement this index template in my document. In the folder that he has available, he already has the .idx and ind file. But whenever I run WinEdt's "Make Index", it gets over written to look like:

How can I make the index in WinEdt to look like the first image above?

• I do not know how to properly set-up WinEdt to achive your goal but a simple solution would be that you open a command window in your working directory and explicitly type makeindex main.idx -s StyleInd.ist together with a couple of LateX or PdflateX compilations and it will work. – pluton Jun 8 '15 at 0:55

## 2 Answers

I found a version of the style fileMyStyle.ist here:

delim_0 "\\dotfill\ "
delim_1 "\\dotfill\ "
headings_flag 1
heading_prefix "\\vspace*{0.5cm}\\nopagebreak\n\\tikz\\node at (0pt,0pt) [rounded corners=5pt,draw=ocre,fill=ocre!10,line width=1pt,inner sep=5pt]{\\parbox{\\linewidth-2\\fboxsep-2\\fboxrule-2pt}{\\centering\\large\\sffamily\\bfseries\\textcolor{black}{" heading_suffix "}}};\\vspace*{0.2cm}\\nopagebreak\n"


It uses commands from other packages and the color ocre. The following example uses package imakeidx for the index generation, because the question is labeled with the tag of the same name.

Full example:

\documentclass{article}

% Setup for MyStyle.ist
\usepackage{calc}
\usepackage{xcolor}
\definecolor{ocre}{HTML}{F16723}
\usepackage{tikz}

\usepackage{imakeidx}
\makeindex[options=-s MyStyle.ist]

\begin{document}

% Some empty pages for generating the index entries
\setcounter{page}{6}\index{Citation}\null\newpage
\index{Definitions}\null\newpage
\index{Examples!Equation and Text}\index{Corollaries}\null\newpage
\index{Examples!Paragraph of Text}\null\newpage

% Index
\begingroup
% \fbox* settings to fix the code in MyStyle.ist
\setlength{\fboxsep}{5pt}%
\setlength{\fboxrule}{0pt}%
\printindex
\endgroup

\end{document}


# Variation

If the style file for makeindex is specific for a project, then the style file can be saved with the name of the TeX file, but with extension mst (\jobname.mst). If makeindex automatically loads such a file without the need to specify the style file via option (see above: -s MyStyle.ist).

The environment filecontents can be used to put the contents of the style file in the TeX file. The file is written, if it does not exist, but not updated. If package filecontents is loaded, the the file is always written, even if it exists.

Instead of complicate TeX code, I would use markup commands, which can be defined in the TeX file.

Full example with some changes to the style code:

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.mst}
delim_0 "\\IndexDotfill "
delim_1 "\\IndexDotfill "
headings_flag 1
heading_prefix "  \\IndexHeading{"
heading_suffix "}\n"
\end{filecontents*}

\documentclass{article}

% Setup for MyStyle.ist
\usepackage{xcolor}
\definecolor{ocre}{HTML}{F16723}
\usepackage{tikz}

\newcommand*{\IndexDotfill}{%
\nobreak\dotfill\ \nobreak
}
\renewcommand*{\indexspace}{%
\par
\vspace{25pt plus 6pt minus 4pt}%
}
\newcommand*{\IndexHeading}[1]{%
\tikz\node[
rounded corners=5pt,
draw=ocre,
fill=ocre!10,
line width=1pt,
inner sep=5pt,
align=center,
font=\sffamily\bfseries\large,
minimum width=\linewidth-\pgflinewidth,
] {#1};%
\nopagebreak
\par
\vspace{2mm}%
}

\usepackage{imakeidx}
\makeindex

\begin{document}

% Some empty pages for generating the index entries
\setcounter{page}{6}\index{Citation}\null\newpage
\index{Definitions}\null\newpage
\index{Examples!Equation and Text}\index{Corollaries}\null\newpage
\index{Examples!Paragraph of Text}\null\newpage

% Index
\printindex

\end{document}


Just to let you know how to add additional options on the fly to the command line of makeindex in WinEdt.

Open the Execution Modes dialog (Options menu) and select the option 'Enter Extra Switches on Spot' for MakeIndex application

At compiling time you will be prompted for inserting extra options and type -s StyleInd.ist

If instead you want to add it permanently, type -s StyleInd.ist in the field 'Switches'