Page LayoutHow to customize the index ?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to customize the index ?

Post by Cham »

I would like to customize a bit the index by ading the alphabetical letters, in bold, for the whole index. Currently, I can only do the default index which is pretty dull.

Here's a MWE as a start :

Code: Select all

\documentclass[12pt,letterpaper]{article}
\usepackage[pdfpagelabels,hyperindex=false]{hyperref}
\usepackage{makeidx}
\usepackage{robustindex}
\makeindex

\begin{document}
Bla bla bla word\index{Word} bla bla bla something\index{Something}
\newpage
Bla bla bla joy\index{Joy}

\printindex
\end{document}
Any idea how to customize the index ?

I tried the imakeidx and idxlayout packages but I really don't understand how to use them. :oops:

Take note that I need the robustindex package, since I'm having several pages offset with many index links, without that package. The robustindex solves this issue.
Last edited by Cham on Wed Dec 26, 2012 10:30 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to customize the index ?

Post by Cham »

When I load the imakeidx package, I can add some basic styles using an ist file, but I'm unable to have clickable links in the index (hyperref not recognized ?), and I'm having troubles with non-English characters (é, è, etc and then the index contains a "Symbols" list) :

Code: Select all

\usepackage[unicode,colorlinks,plainpages=false,hyperindex=true,pdfpagelabels]{hyperref}
%\usepackage{makeidx}
\usepackage[makeindex]{imakeidx}
%\usepackage{robustindex}
\makeindex[options= -s index_style.ist]
where the index_style.ist document has the following code :

Code: Select all

headings_flag 1
heading_prefix "\\textbf\{\\huge "
heading_suffix "\}"
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to customize the index ?

Post by Cham »

Hmmm, I can now make the idxlayout package to work. It appears to be nicer than imakeidx, since it's working with the robustindex and the hyperref packages.

However, I'm yet unable to add the huge bold alphabetical letters to the index.

EDIT : How am I supposed to call makeindex with parameters (ist file) ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to customize the index ?

Post by Cham »

So, is there a way to use a ist file (or a mst file) from within LaTeX ? How can we apply index styling to the \printindex command, from the tex file itself ?

Or how can we change the default index style ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to customize the index ?

Post by Cham »

Apparently, the imakeidx package can do everything I want for my index, so I may switch to it. However, how can I tell it to use small fonts for all the index entries ?

EDIT : Okay, I've found it. So here's my index generation code, to be placed BEFORE the hyperref package :

Code: Select all

\usepackage{imakeidx}
\indexsetup{othercode=\small}
\makeindex[program=makeindex,columns=2,intoc=true,options={-s index_style.ist}]
and my index_style.ist file contains this code :

Code: Select all

headings_flag 1
heading_prefix "{\\large\\sffamily\\bfseries "
heading_suffix "}\\nopagebreak\n"
delim_0 " \\dotfill "
delim_1 " \\dotfill "
delim_2 " \\dotfill "
The output looks like this :
index.jpg
index.jpg (96.22 KiB) Viewed 28325 times
bartzmc
Posts: 10
Joined: Thu Apr 06, 2017 9:15 pm

How to customize the index ?

Post by bartzmc »

I have a few longer indexes and they are line breaking with indent. How can I modify your script to get rid of this indents?
Image
bartzmc
Posts: 10
Joined: Thu Apr 06, 2017 9:15 pm

How to customize the index ?

Post by bartzmc »

I put this in preambule and it works.

Code: Select all

\makeatletter
\def\@idxitem{\par\hangindent 0pt}
\makeatother
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to customize the index ?

Post by Stefan Kottwitz »

Good to know!
Btw. there's an international TeX meeting in Poland, end of April.

Stefan
LaTeX.org admin
mamoun
Posts: 14
Joined: Thu Oct 03, 2019 10:12 pm

How to customize the index ?

Post by mamoun »

hello <
i did two files :
the first one : \documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[makeindex]{imakeidx}

\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[pdftex, bookmarksnumbered, pagebackref, colorlinks=true, citecolor=red, linkcolor=red, urlcolor=Black,bookmarksopen]{hyperref}

\indexsetup{othercode=\small}

\makeindex[options= -s index_style.ist]

\begin{document}

\section{Introduction}
In this example several keywords\index{keywords} will be used
which are important and deserve to appear in the Index\index{Index}.

Terms like generate\index{generate} and some\index{others} will also
show up. Terms in the index can also be nested \index{Index!nested}

\printindex
\end{document}

and in the second one :
headings_flag 1
heading_prefix "{\\large\\sffamily\\bfseries "
heading_suffix "}\\nopagebreak\n"
delim_0 " \\dotfill "
delim_1 " \\dotfill "
delim_2 " \\dotfill "


but the result not as you < without dots < as
used , 2
not as , used ...........................................2
Post Reply