# How to Universally Remove the Comma from Each Index Entry

This question extends the one recently posed in How to Selectively Remove the Comma in an Index Entry

In the above post, it was answered that by inserting \newcommand\textbfnocomma[2]{\textbf{#1}} into the preamble, an index entry comma can be removed with the command \textbfnocomma.

I am presently working on producing an index of quotations where the said comma seems to be a little out of place; and so, I would like to see what the index looks like with all such commas removed.

Consider the code,

\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage
\makeindex
\usepackage{idxlayout}
\usepackage{xcolor}

%\newcommand\textbfnocomma[2]{\textbf{#1}}
\begin{document}
\large

\idxlayout{columns=1}
\printindex
\end{document}


which produces the Index:

QUESTION: Is it possible, and if so, how may I easily remove the comma from all index entries without resorting to removing them all individually with the preamble command described above? No textindy please.

Thank you.

• @David Carlisle In the "Selectively Remove" post alluded to above? Jan 13 at 20:10
• er this I guess tex.stackexchange.com/a/622091/1090 Jan 13 at 20:33
• @David Carlisle Still confused as to what you mean; however, I see that your updated answer in that post relates to the question I asked here. Thanks for pointing it out to me. Jan 13 at 21:13

You need to adjust the delim_1 field of makeindex, since the page numbers you list is at level 1. From makeindex.hlp:

 delim_0          ", "
Delimiter to be inserted between  a
level  0  key  and  its  first page
number (default: comma followed  by
a blank).

delim_1          ", "
Delimiter to be inserted between  a
level  1  key  and  its  first page
number (default: comma followed  by
a blank).

delim_2          ", "
Delimiter to be inserted between  a
level  2  key  and  its  first page
number (default: comma followed  by
a blank).

delim_n          ", "
Delimiter to  be  inserted  between
two  page  numbers for the same key
in any level (default:  comma  fol-
lowed by a blank).

delim_r          "--"
Delimiter to  be  inserted  between
the   starting   and   ending  page
numbers of a range.

delim_t          ""
Delimiter to be inserted at the end
of a page list.  This delimiter has
no effect on entries which have  no
associated page list.



In short, include/change the following in your preamble:

\begin{filecontents*}[overwrite]{\jobname.ist}
delim_1 " "
\end{filecontents*}

\makeindex[options=-s \jobname.ist]


The above code writes a file \jobname.ist - a makeindex style file - and changes the default value of delim_1 to " " - a regular space (from ", "). Then, to use this newly-created style file, pass the option -s \jobname.ist to your call to \makeindex. If you have page numbers at multiple levels, just add delim_0, delim_2, ... to the .ist.

\documentclass{book}

\begin{filecontents*}[overwrite]{\jobname.ist}
delim_1 " "
\end{filecontents*}

\usepackage{imakeidx}
\let\cleardoublepage\clearpage
\makeindex[options=-s \jobname.ist]
\usepackage{idxlayout}
\usepackage{xcolor}

\begin{document}
\large

Some words.

• Many thanks for posting this answer; however, when I run it as is, I get errors. It seems that my TexStudio does not recognize \begin{document} nor begin{filecontents}. However, when I run it without [overwrite]---it seems to work fine. Is [overwrite] needed here? Jan 13 at 20:17
• @mlchristians: Your distribution is probably out-of-date. The filecontents functionality (from the filecontents package) was absorbed into the LaTeX kernel (Oct 2020), with some minor changes. Some mutually-exclusive options to try: (1) Add \usepackage{filecontents} and remove the [overwrite] option. (2) Put delim_1 " " inside a separate .ist file, but keep \makeindex[options=-s \jobname.ist] in your file. (3) Update your distribution and try again.